From a084735ce5a785272f366e5e9ae3fbd42db7f7f9 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Fri, 17 May 2019 16:14:44 +0530 Subject: [PATCH] ELECTRON-771 (Fix custom title bar button titles & localization) (#651) * ELECTRON-771 - Fix custom title bar button titles * ELECTRON-771 - Update unit test cases --- spec/__snapshots__/windowsTitleBar.spec.ts.snap | 2 +- spec/windowsTitleBar.spec.ts | 6 +++--- src/locale/en-US.json | 3 ++- src/locale/en.json | 3 ++- src/locale/fr-FR.json | 3 ++- src/locale/fr.json | 3 ++- src/locale/ja-JP.json | 3 ++- src/locale/ja.json | 3 ++- src/renderer/components/windows-title-bar.tsx | 11 ++++++----- 9 files changed, 22 insertions(+), 15 deletions(-) diff --git a/spec/__snapshots__/windowsTitleBar.spec.ts.snap b/spec/__snapshots__/windowsTitleBar.spec.ts.snap index 3655c6ec..716753e4 100644 --- a/spec/__snapshots__/windowsTitleBar.spec.ts.snap +++ b/spec/__snapshots__/windowsTitleBar.spec.ts.snap @@ -85,7 +85,7 @@ exports[`windows title bar should render correctly 1`] = ` className="title-bar-button" onClick={[Function]} onMouseDown={[Function]} - title="unMaximize" + title="Maximize" > { describe('maximize functions', () => { it('should call `unmaximize` correctly when is not full screen', () => { - const titleLabel = 'Maximize'; + const titleLabel = 'Restore'; const unmaximizeFn = 'unmaximize'; const customSelector = `button.title-bar-button[title="${titleLabel}"]`; const wrapper = shallow(React.createElement(WindowsTitleBar)); @@ -160,7 +160,7 @@ describe('windows title bar', () => { it('should call `unmaximize` correctly when is full screen', () => { const windowSpyFn = 'setFullScreen'; - const titleLabel = 'Maximize'; + const titleLabel = 'Restore'; const customSelector = `button.title-bar-button[title="${titleLabel}"]`; const wrapper = shallow(React.createElement(WindowsTitleBar)); const instance: any = wrapper.instance(); @@ -175,7 +175,7 @@ describe('windows title bar', () => { }); it('should call maximize correctly when it is not in full screen', () => { - const titleLabel = 'unMaximize'; + const titleLabel = 'Maximize'; const maximizeFn = 'maximize'; const expectedState = { isMaximized: true }; const customSelector = `button.title-bar-button[title="${titleLabel}"]`; diff --git a/src/locale/en-US.json b/src/locale/en-US.json index 8e5d2438..c6c16b48 100644 --- a/src/locale/en-US.json +++ b/src/locale/en-US.json @@ -162,7 +162,8 @@ "Close": "Close", "Maximize": "Maximize", "Menu": "Menu", - "Minimize": "Minimize" + "Minimize": "Minimize", + "Restore": "Restore" }, "Title Bar Style": "Title Bar Style", "Toggle Full Screen": "Toggle Full Screen", diff --git a/src/locale/en.json b/src/locale/en.json index 8e5d2438..c6c16b48 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -162,7 +162,8 @@ "Close": "Close", "Maximize": "Maximize", "Menu": "Menu", - "Minimize": "Minimize" + "Minimize": "Minimize", + "Restore": "Restore" }, "Title Bar Style": "Title Bar Style", "Toggle Full Screen": "Toggle Full Screen", diff --git a/src/locale/fr-FR.json b/src/locale/fr-FR.json index 68a24256..f2889c66 100644 --- a/src/locale/fr-FR.json +++ b/src/locale/fr-FR.json @@ -162,7 +162,8 @@ "Close": "Fermer", "Maximize": "Maximiser", "Menu": "Menu", - "Minimize": "Minimiser" + "Minimize": "Minimiser", + "Restore": "Restaurer" }, "Title Bar Style": "Style de la barre de titre", "Toggle Full Screen": "Basculer plein écran", diff --git a/src/locale/fr.json b/src/locale/fr.json index 68a24256..f2889c66 100644 --- a/src/locale/fr.json +++ b/src/locale/fr.json @@ -162,7 +162,8 @@ "Close": "Fermer", "Maximize": "Maximiser", "Menu": "Menu", - "Minimize": "Minimiser" + "Minimize": "Minimiser", + "Restore": "Restaurer" }, "Title Bar Style": "Style de la barre de titre", "Toggle Full Screen": "Basculer plein écran", diff --git a/src/locale/ja-JP.json b/src/locale/ja-JP.json index 3750c447..5c8a2ae0 100644 --- a/src/locale/ja-JP.json +++ b/src/locale/ja-JP.json @@ -162,7 +162,8 @@ "Close": "閉じる", "Maximize": "最大化する", "Menu": "メニュー", - "Minimize": "最小化する" + "Minimize": "最小化する", + "Restore": "戻す" }, "Title Bar Style": "タイトルバーのスタイル", "Toggle Full Screen": "画面表示を切り替え", diff --git a/src/locale/ja.json b/src/locale/ja.json index 3750c447..5c8a2ae0 100644 --- a/src/locale/ja.json +++ b/src/locale/ja.json @@ -162,7 +162,8 @@ "Close": "閉じる", "Maximize": "最大化する", "Menu": "メニュー", - "Minimize": "最小化する" + "Minimize": "最小化する", + "Restore": "戻す" }, "Title Bar Style": "タイトルバーのスタイル", "Toggle Full Screen": "画面表示を切り替え", diff --git a/src/renderer/components/windows-title-bar.tsx b/src/renderer/components/windows-title-bar.tsx index acec1280..8e07e52c 100644 --- a/src/renderer/components/windows-title-bar.tsx +++ b/src/renderer/components/windows-title-bar.tsx @@ -9,6 +9,7 @@ interface IState { isFullScreen: boolean; titleBarHeight: string; } +const TITLE_BAR_NAMESPACE = 'TitleBar'; export default class WindowsTitleBar extends React.Component<{}, IState> { private readonly window: Electron.BrowserWindow; @@ -75,7 +76,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> { >