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