ELECTRON-771 (Fix custom title bar button titles & localization) (#651)

* ELECTRON-771 - Fix custom title bar button titles

* ELECTRON-771 - Update unit test cases
This commit is contained in:
Kiran Niranjan 2019-05-17 16:14:44 +05:30 committed by Vishwas Shashidhar
parent 4a7fe58fba
commit a084735ce5
9 changed files with 22 additions and 15 deletions

View File

@ -85,7 +85,7 @@ exports[`windows title bar should render correctly 1`] = `
className="title-bar-button" className="title-bar-button"
onClick={[Function]} onClick={[Function]}
onMouseDown={[Function]} onMouseDown={[Function]}
title="unMaximize" title="Maximize"
> >
<svg <svg
viewBox="0 0 14 10.2" viewBox="0 0 14 10.2"

View File

@ -146,7 +146,7 @@ describe('windows title bar', () => {
describe('maximize functions', () => { describe('maximize functions', () => {
it('should call `unmaximize` correctly when is not full screen', () => { it('should call `unmaximize` correctly when is not full screen', () => {
const titleLabel = 'Maximize'; const titleLabel = 'Restore';
const unmaximizeFn = 'unmaximize'; const unmaximizeFn = 'unmaximize';
const customSelector = `button.title-bar-button[title="${titleLabel}"]`; const customSelector = `button.title-bar-button[title="${titleLabel}"]`;
const wrapper = shallow(React.createElement(WindowsTitleBar)); const wrapper = shallow(React.createElement(WindowsTitleBar));
@ -160,7 +160,7 @@ describe('windows title bar', () => {
it('should call `unmaximize` correctly when is full screen', () => { it('should call `unmaximize` correctly when is full screen', () => {
const windowSpyFn = 'setFullScreen'; const windowSpyFn = 'setFullScreen';
const titleLabel = 'Maximize'; const titleLabel = 'Restore';
const customSelector = `button.title-bar-button[title="${titleLabel}"]`; const customSelector = `button.title-bar-button[title="${titleLabel}"]`;
const wrapper = shallow(React.createElement(WindowsTitleBar)); const wrapper = shallow(React.createElement(WindowsTitleBar));
const instance: any = wrapper.instance(); 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', () => { it('should call maximize correctly when it is not in full screen', () => {
const titleLabel = 'unMaximize'; const titleLabel = 'Maximize';
const maximizeFn = 'maximize'; const maximizeFn = 'maximize';
const expectedState = { isMaximized: true }; const expectedState = { isMaximized: true };
const customSelector = `button.title-bar-button[title="${titleLabel}"]`; const customSelector = `button.title-bar-button[title="${titleLabel}"]`;

View File

@ -162,7 +162,8 @@
"Close": "Close", "Close": "Close",
"Maximize": "Maximize", "Maximize": "Maximize",
"Menu": "Menu", "Menu": "Menu",
"Minimize": "Minimize" "Minimize": "Minimize",
"Restore": "Restore"
}, },
"Title Bar Style": "Title Bar Style", "Title Bar Style": "Title Bar Style",
"Toggle Full Screen": "Toggle Full Screen", "Toggle Full Screen": "Toggle Full Screen",

View File

@ -162,7 +162,8 @@
"Close": "Close", "Close": "Close",
"Maximize": "Maximize", "Maximize": "Maximize",
"Menu": "Menu", "Menu": "Menu",
"Minimize": "Minimize" "Minimize": "Minimize",
"Restore": "Restore"
}, },
"Title Bar Style": "Title Bar Style", "Title Bar Style": "Title Bar Style",
"Toggle Full Screen": "Toggle Full Screen", "Toggle Full Screen": "Toggle Full Screen",

View File

@ -162,7 +162,8 @@
"Close": "Fermer", "Close": "Fermer",
"Maximize": "Maximiser", "Maximize": "Maximiser",
"Menu": "Menu", "Menu": "Menu",
"Minimize": "Minimiser" "Minimize": "Minimiser",
"Restore": "Restaurer"
}, },
"Title Bar Style": "Style de la barre de titre", "Title Bar Style": "Style de la barre de titre",
"Toggle Full Screen": "Basculer plein écran", "Toggle Full Screen": "Basculer plein écran",

View File

@ -162,7 +162,8 @@
"Close": "Fermer", "Close": "Fermer",
"Maximize": "Maximiser", "Maximize": "Maximiser",
"Menu": "Menu", "Menu": "Menu",
"Minimize": "Minimiser" "Minimize": "Minimiser",
"Restore": "Restaurer"
}, },
"Title Bar Style": "Style de la barre de titre", "Title Bar Style": "Style de la barre de titre",
"Toggle Full Screen": "Basculer plein écran", "Toggle Full Screen": "Basculer plein écran",

View File

@ -162,7 +162,8 @@
"Close": "閉じる", "Close": "閉じる",
"Maximize": "最大化する", "Maximize": "最大化する",
"Menu": "メニュー", "Menu": "メニュー",
"Minimize": "最小化する" "Minimize": "最小化する",
"Restore": "戻す"
}, },
"Title Bar Style": "タイトルバーのスタイル", "Title Bar Style": "タイトルバーのスタイル",
"Toggle Full Screen": "画面表示を切り替え", "Toggle Full Screen": "画面表示を切り替え",

View File

@ -162,7 +162,8 @@
"Close": "閉じる", "Close": "閉じる",
"Maximize": "最大化する", "Maximize": "最大化する",
"Menu": "メニュー", "Menu": "メニュー",
"Minimize": "最小化する" "Minimize": "最小化する",
"Restore": "戻す"
}, },
"Title Bar Style": "タイトルバーのスタイル", "Title Bar Style": "タイトルバーのスタイル",
"Toggle Full Screen": "画面表示を切り替え", "Toggle Full Screen": "画面表示を切り替え",

View File

@ -9,6 +9,7 @@ interface IState {
isFullScreen: boolean; isFullScreen: boolean;
titleBarHeight: string; titleBarHeight: string;
} }
const TITLE_BAR_NAMESPACE = 'TitleBar';
export default class WindowsTitleBar extends React.Component<{}, IState> { export default class WindowsTitleBar extends React.Component<{}, IState> {
private readonly window: Electron.BrowserWindow; private readonly window: Electron.BrowserWindow;
@ -75,7 +76,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
> >
<div className='title-bar-button-container'> <div className='title-bar-button-container'>
<button <button
title={i18n.t('Menu')()} title={i18n.t('Menu', TITLE_BAR_NAMESPACE)()}
className='hamburger-menu-button' className='hamburger-menu-button'
onClick={this.eventHandlers.onShowMenu} onClick={this.eventHandlers.onShowMenu}
onMouseDown={this.handleMouseDown} onMouseDown={this.handleMouseDown}
@ -94,7 +95,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
<div className='title-bar-button-container'> <div className='title-bar-button-container'>
<button <button
className='title-bar-button' className='title-bar-button'
title={i18n.t('Minimize')()} title={i18n.t('Minimize', TITLE_BAR_NAMESPACE)()}
onClick={this.eventHandlers.onMinimize} onClick={this.eventHandlers.onMinimize}
onMouseDown={this.handleMouseDown} onMouseDown={this.handleMouseDown}
> >
@ -109,7 +110,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
<div className='title-bar-button-container'> <div className='title-bar-button-container'>
<button <button
className='title-bar-button' className='title-bar-button'
title={i18n.t('Close')()} title={i18n.t('Close', TITLE_BAR_NAMESPACE)()}
onClick={this.eventHandlers.onClose} onClick={this.eventHandlers.onClose}
onMouseDown={this.handleMouseDown} onMouseDown={this.handleMouseDown}
> >
@ -136,7 +137,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
return ( return (
<button <button
className='title-bar-button' className='title-bar-button'
title={i18n.t('Maximize')()} title={i18n.t('Restore', TITLE_BAR_NAMESPACE)()}
onClick={this.eventHandlers.onUnmaximize} onClick={this.eventHandlers.onUnmaximize}
onMouseDown={this.handleMouseDown} onMouseDown={this.handleMouseDown}
> >
@ -152,7 +153,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
return ( return (
<button <button
className='title-bar-button' className='title-bar-button'
title={i18n.t('unMaximize')()} title={i18n.t('Maximize', TITLE_BAR_NAMESPACE)()}
onClick={this.eventHandlers.onMaximize} onClick={this.eventHandlers.onMaximize}
onMouseDown={this.handleMouseDown} onMouseDown={this.handleMouseDown}
> >