mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
Merge branch 'main' into bugfix/SDA-3377
This commit is contained in:
commit
636f39a48a
@ -93,6 +93,7 @@ exports[`windows title bar should render correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="title-bar-button"
|
className="title-bar-button"
|
||||||
|
disabled={false}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
onContextMenu={[Function]}
|
onContextMenu={[Function]}
|
||||||
onMouseDown={[Function]}
|
onMouseDown={[Function]}
|
||||||
@ -116,6 +117,7 @@ exports[`windows title bar should render correctly 1`] = `
|
|||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="title-bar-button"
|
className="title-bar-button"
|
||||||
|
disabled={false}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
onContextMenu={[Function]}
|
onContextMenu={[Function]}
|
||||||
onMouseDown={[Function]}
|
onMouseDown={[Function]}
|
||||||
|
@ -380,13 +380,10 @@ export class WindowHandler {
|
|||||||
this.mainWindow &&
|
this.mainWindow &&
|
||||||
windowExists(this.mainWindow)
|
windowExists(this.mainWindow)
|
||||||
) {
|
) {
|
||||||
this.mainWebContents = await loadBrowserViews(
|
this.mainWebContents = await loadBrowserViews(this.mainWindow);
|
||||||
this.mainWindow,
|
this.mainWebContents.loadURL(this.url, { userAgent });
|
||||||
this.url,
|
|
||||||
userAgent,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
await this.mainWindow.loadURL(this.url, { userAgent });
|
this.mainWindow.loadURL(this.url, { userAgent });
|
||||||
this.mainWebContents = this.mainWindow.webContents;
|
this.mainWebContents = this.mainWindow.webContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,6 +727,8 @@ export class WindowHandler {
|
|||||||
resource: i18n.loadedResources,
|
resource: i18n.loadedResources,
|
||||||
isMainWindow: true,
|
isMainWindow: true,
|
||||||
});
|
});
|
||||||
|
// disables action buttons in title bar
|
||||||
|
titleBarView.webContents.send('disable-action-button');
|
||||||
});
|
});
|
||||||
titleBarView.webContents.loadURL(titleBarWindowUrl);
|
titleBarView.webContents.loadURL(titleBarWindowUrl);
|
||||||
titleBarView.setBounds({
|
titleBarView.setBounds({
|
||||||
@ -770,6 +769,7 @@ export class WindowHandler {
|
|||||||
urlValid: !!userConfigUrl,
|
urlValid: !!userConfigUrl,
|
||||||
sso: ssoValue,
|
sso: ssoValue,
|
||||||
});
|
});
|
||||||
|
this.appMenu = new AppMenu();
|
||||||
this.addWindow(opts.winKey, this.welcomeScreenWindow);
|
this.addWindow(opts.winKey, this.welcomeScreenWindow);
|
||||||
this.mainWindow = this.welcomeScreenWindow as ICustomBrowserWindow;
|
this.mainWindow = this.welcomeScreenWindow as ICustomBrowserWindow;
|
||||||
});
|
});
|
||||||
@ -787,6 +787,13 @@ export class WindowHandler {
|
|||||||
return this.mainWindow;
|
return this.mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the welcome screen window
|
||||||
|
*/
|
||||||
|
public getWelcomeScreenWindow(): BrowserWindow | null {
|
||||||
|
return this.welcomeScreenWindow;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the main browser webContents
|
* Gets the main browser webContents
|
||||||
*/
|
*/
|
||||||
|
@ -368,13 +368,20 @@ export const updateLocale = async (locale: LocaleType): Promise<void> => {
|
|||||||
* Displays a popup menu
|
* Displays a popup menu
|
||||||
*/
|
*/
|
||||||
export const showPopupMenu = (opts: Electron.PopupOptions): void => {
|
export const showPopupMenu = (opts: Electron.PopupOptions): void => {
|
||||||
const mainWindow = windowHandler.getMainWindow();
|
const browserWindow =
|
||||||
if (mainWindow && windowExists(mainWindow) && isValidWindow(mainWindow)) {
|
windowHandler.getMainWindow() || windowHandler.getWelcomeScreenWindow();
|
||||||
|
if (
|
||||||
|
browserWindow &&
|
||||||
|
windowExists(browserWindow) &&
|
||||||
|
isValidWindow(browserWindow)
|
||||||
|
) {
|
||||||
const coordinates = windowHandler.isCustomTitleBar
|
const coordinates = windowHandler.isCustomTitleBar
|
||||||
? { x: 20, y: 15 }
|
? { x: 20, y: 15 }
|
||||||
: { x: 10, y: -20 };
|
: { x: 10, y: -20 };
|
||||||
const { x, y } = mainWindow.isFullScreen() ? { x: 0, y: 0 } : coordinates;
|
const { x, y } = browserWindow.isFullScreen()
|
||||||
const popupOpts = { window: mainWindow, x, y };
|
? { x: 0, y: 0 }
|
||||||
|
: coordinates;
|
||||||
|
const popupOpts = { window: browserWindow, x, y };
|
||||||
const appMenu = windowHandler.appMenu;
|
const appMenu = windowHandler.appMenu;
|
||||||
if (appMenu) {
|
if (appMenu) {
|
||||||
appMenu.popupMenu({ ...popupOpts, ...opts });
|
appMenu.popupMenu({ ...popupOpts, ...opts });
|
||||||
@ -1004,8 +1011,6 @@ export const monitorNetworkInterception = (url: string) => {
|
|||||||
|
|
||||||
export const loadBrowserViews = async (
|
export const loadBrowserViews = async (
|
||||||
mainWindow: BrowserWindow,
|
mainWindow: BrowserWindow,
|
||||||
url: string,
|
|
||||||
userAgent: string,
|
|
||||||
): Promise<WebContents> => {
|
): Promise<WebContents> => {
|
||||||
mainWindow.setMenuBarVisibility(false);
|
mainWindow.setMenuBarVisibility(false);
|
||||||
|
|
||||||
@ -1151,7 +1156,6 @@ export const loadBrowserViews = async (
|
|||||||
height: false,
|
height: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
await mainView.webContents.loadURL(url, { userAgent });
|
|
||||||
mainView.setBounds({
|
mainView.setBounds({
|
||||||
width: mainWindowBounds?.width || DEFAULT_WIDTH,
|
width: mainWindowBounds?.width || DEFAULT_WIDTH,
|
||||||
height: mainWindowBounds?.height || DEFAULT_HEIGHT,
|
height: mainWindowBounds?.height || DEFAULT_HEIGHT,
|
||||||
|
@ -8,6 +8,7 @@ interface IState {
|
|||||||
title: string;
|
title: string;
|
||||||
isMaximized: boolean;
|
isMaximized: boolean;
|
||||||
isFullScreen: boolean;
|
isFullScreen: boolean;
|
||||||
|
isDisabled: boolean;
|
||||||
}
|
}
|
||||||
const TITLE_BAR_NAMESPACE = 'TitleBar';
|
const TITLE_BAR_NAMESPACE = 'TitleBar';
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
title: document.title || 'Symphony',
|
title: document.title || 'Symphony',
|
||||||
isFullScreen: false,
|
isFullScreen: false,
|
||||||
isMaximized: false,
|
isMaximized: false,
|
||||||
|
isDisabled: false,
|
||||||
};
|
};
|
||||||
// Adds borders to the window
|
// Adds borders to the window
|
||||||
this.addWindowBorders();
|
this.addWindowBorders();
|
||||||
@ -44,6 +46,10 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
ipcRenderer.on('leave-full-screen', () =>
|
ipcRenderer.on('leave-full-screen', () =>
|
||||||
this.updateState({ isFullScreen: false }),
|
this.updateState({ isFullScreen: false }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ipcRenderer.once('disable-action-button', () => {
|
||||||
|
this.updateState({ isDisabled: true });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +86,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
* Renders the component
|
* Renders the component
|
||||||
*/
|
*/
|
||||||
public render(): JSX.Element | null {
|
public render(): JSX.Element | null {
|
||||||
const { title, isFullScreen } = this.state;
|
const { title, isFullScreen, isDisabled } = this.state;
|
||||||
const style = { display: isFullScreen ? 'none' : 'flex' };
|
const style = { display: isFullScreen ? 'none' : 'flex' };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -129,6 +135,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
onClick={this.eventHandlers.onMinimize}
|
onClick={this.eventHandlers.onMinimize}
|
||||||
onContextMenu={this.eventHandlers.onDisableContextMenu}
|
onContextMenu={this.eventHandlers.onDisableContextMenu}
|
||||||
onMouseDown={this.handleMouseDown}
|
onMouseDown={this.handleMouseDown}
|
||||||
|
disabled={isDisabled}
|
||||||
>
|
>
|
||||||
<svg x='0px' y='0px' viewBox='0 0 14 1'>
|
<svg x='0px' y='0px' viewBox='0 0 14 1'>
|
||||||
<rect fill='rgba(255, 255, 255, 0.9)' width='14' height='0.6' />
|
<rect fill='rgba(255, 255, 255, 0.9)' width='14' height='0.6' />
|
||||||
@ -163,7 +170,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
* Renders maximize or minimize buttons based on fullscreen state
|
* Renders maximize or minimize buttons based on fullscreen state
|
||||||
*/
|
*/
|
||||||
public renderMaximizeButtons(): JSX.Element {
|
public renderMaximizeButtons(): JSX.Element {
|
||||||
const { isMaximized } = this.state;
|
const { isMaximized, isDisabled } = this.state;
|
||||||
|
|
||||||
if (isMaximized) {
|
if (isMaximized) {
|
||||||
return (
|
return (
|
||||||
@ -173,6 +180,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
onClick={this.eventHandlers.onUnmaximize}
|
onClick={this.eventHandlers.onUnmaximize}
|
||||||
onContextMenu={this.eventHandlers.onDisableContextMenu}
|
onContextMenu={this.eventHandlers.onDisableContextMenu}
|
||||||
onMouseDown={this.handleMouseDown}
|
onMouseDown={this.handleMouseDown}
|
||||||
|
disabled={isDisabled}
|
||||||
>
|
>
|
||||||
<svg x='0px' y='0px' viewBox='0 0 14 10.2'>
|
<svg x='0px' y='0px' viewBox='0 0 14 10.2'>
|
||||||
<path
|
<path
|
||||||
@ -190,6 +198,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
onClick={this.eventHandlers.onMaximize}
|
onClick={this.eventHandlers.onMaximize}
|
||||||
onContextMenu={this.eventHandlers.onDisableContextMenu}
|
onContextMenu={this.eventHandlers.onDisableContextMenu}
|
||||||
onMouseDown={this.handleMouseDown}
|
onMouseDown={this.handleMouseDown}
|
||||||
|
disabled={isDisabled}
|
||||||
>
|
>
|
||||||
<svg x='0px' y='0px' viewBox='0 0 14 10.2'>
|
<svg x='0px' y='0px' viewBox='0 0 14 10.2'>
|
||||||
<path
|
<path
|
||||||
@ -214,6 +223,9 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
* Method that minimizes the browser window
|
* Method that minimizes the browser window
|
||||||
*/
|
*/
|
||||||
public minimize(): void {
|
public minimize(): void {
|
||||||
|
if (this.state.isDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ipcRenderer.send(apiName.symphonyApi, {
|
ipcRenderer.send(apiName.symphonyApi, {
|
||||||
cmd: apiCmds.minimizeMainWindow,
|
cmd: apiCmds.minimizeMainWindow,
|
||||||
});
|
});
|
||||||
@ -223,6 +235,9 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
* Method that maximize the browser window
|
* Method that maximize the browser window
|
||||||
*/
|
*/
|
||||||
public maximize(): void {
|
public maximize(): void {
|
||||||
|
if (this.state.isDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ipcRenderer.send(apiName.symphonyApi, {
|
ipcRenderer.send(apiName.symphonyApi, {
|
||||||
cmd: apiCmds.maximizeMainWindow,
|
cmd: apiCmds.maximizeMainWindow,
|
||||||
});
|
});
|
||||||
@ -233,6 +248,9 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
|||||||
* Method that unmaximize the browser window
|
* Method that unmaximize the browser window
|
||||||
*/
|
*/
|
||||||
public unmaximize(): void {
|
public unmaximize(): void {
|
||||||
|
if (this.state.isDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ipcRenderer.send(apiName.symphonyApi, {
|
ipcRenderer.send(apiName.symphonyApi, {
|
||||||
cmd: apiCmds.unmaximizeMainWindow,
|
cmd: apiCmds.unmaximizeMainWindow,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user