diff --git a/src/app/app-menu.ts b/src/app/app-menu.ts index 61c9dd13..c8f44d1e 100644 --- a/src/app/app-menu.ts +++ b/src/app/app-menu.ts @@ -619,7 +619,6 @@ export class AppMenu { (windowHandler.url && windowHandler.url.startsWith('https://corporate.symphony.com')) || false; - return { label: i18n.t('Help')(), role: 'help', @@ -715,23 +714,23 @@ export class AppMenu { id: C2_CHANNELS_MENU_ID, submenu: [ { - click: (_item) => - windowHandler.switchClient(ClientSwitchType.CLIENT_2_0), + click: (_item) => this.switchTo(Channels.Stable), visible: isCorp, type: 'checkbox', - checked: windowHandler.url?.startsWith(CORP_URL + '/client-bff'), + checked: + windowHandler.url?.startsWith(CORP_URL) && + !windowHandler.url?.includes('daily'), id: `${Target.C2}-${Channels.Stable}`, label: i18n.t('Stable')(), accelerator: 'CmdorCtrl+1', }, { - click: (_item) => - windowHandler.switchClient(ClientSwitchType.CLIENT_2_0_DAILY), + click: (_item) => this.switchTo(Channels.Daily), visible: isCorp, type: 'checkbox', - checked: windowHandler.url?.startsWith( - CORP_URL + '/bff-daily/daily', - ), + checked: + windowHandler.url?.startsWith(CORP_URL) && + windowHandler.url.includes('daily'), id: `${Target.C2}-${Channels.Daily}`, label: i18n.t('Daily')(), accelerator: 'CmdorCtrl+2', @@ -910,4 +909,31 @@ export class AppMenu { }); autoUpdate.checkUpdates(AutoUpdateTrigger.MANUAL); } + + /** + * Allow user to switch C2 from stable to daily + * @param channel Targeted C2 channel + */ + private switchTo(channel: Channels) { + const isBFFServedContent = + windowHandler.url && windowHandler.url.includes('bff'); + let clientSwitchType; + switch (channel) { + case Channels.Daily: + clientSwitchType = isBFFServedContent + ? ClientSwitchType.CLIENT_2_0_DAILY + : ClientSwitchType.STARTPAGE_CLIENT_2_0_DAILY; + break; + case Channels.Stable: + clientSwitchType = isBFFServedContent + ? ClientSwitchType.CLIENT_2_0 + : ClientSwitchType.STARTPAGE_CLIENT_2_0; + break; + default: + break; + } + if (clientSwitchType) { + windowHandler.switchClient(clientSwitchType); + } + } } diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index ede24e1d..eed280ad 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -79,6 +79,8 @@ const windowSize: string | null = getCommandLineArgs( export enum ClientSwitchType { CLIENT_2_0 = 'CLIENT_2_0', CLIENT_2_0_DAILY = 'CLIENT_2_0_DAILY', + STARTPAGE_CLIENT_2_0 = 'START_PAGE_CLIENT_2_0', + STARTPAGE_CLIENT_2_0_DAILY = 'START_PAGE_CLIENT_2_0_DAILY', } export const DEFAULT_WELCOME_SCREEN_WIDTH: number = 542; @@ -411,10 +413,18 @@ export class WindowHandler { exportLogs(); }, SHORTCUT_KEY_THROTTLE); const switchToClient2 = throttle(() => { - windowHandler.switchClient(ClientSwitchType.CLIENT_2_0); + const clientSwitchType = + this.url && this.url.includes('bff') + ? ClientSwitchType.CLIENT_2_0 + : ClientSwitchType.STARTPAGE_CLIENT_2_0; + windowHandler.switchClient(clientSwitchType); }, SHORTCUT_KEY_THROTTLE); const switchToDaily = throttle(() => { - windowHandler.switchClient(ClientSwitchType.CLIENT_2_0_DAILY); + const clientSwitchType = + this.url && this.url.includes('bff') + ? ClientSwitchType.CLIENT_2_0_DAILY + : ClientSwitchType.STARTPAGE_CLIENT_2_0_DAILY; + windowHandler.switchClient(clientSwitchType); }, SHORTCUT_KEY_THROTTLE); this.mainWebContents.on('before-input-event', (event, input) => { if (input.control && input.shift && input.key.toLowerCase() === 'd') { @@ -2192,6 +2202,7 @@ export class WindowHandler { const csrfToken = await this.mainWebContents?.executeJavaScript( `localStorage.getItem('x-km-csrf-token')`, ); + switch (clientSwitch) { case ClientSwitchType.CLIENT_2_0: this.url = `https://${parsedUrl.hostname}/client-bff/index.html?x-km-csrf-token=${csrfToken}`; @@ -2199,6 +2210,12 @@ export class WindowHandler { case ClientSwitchType.CLIENT_2_0_DAILY: this.url = `https://${parsedUrl.hostname}/bff-daily/daily/index.html?x-km-csrf-token=${csrfToken}`; break; + case ClientSwitchType.STARTPAGE_CLIENT_2_0: + this.url = `https://${parsedUrl.hostname}/apps/client2`; + break; + case ClientSwitchType.STARTPAGE_CLIENT_2_0_DAILY: + this.url = `https://${parsedUrl.hostname}/apps/client2/daily`; + break; default: this.url = this.globalConfig.url + `?x-km-csrf-token=${csrfToken}`; } diff --git a/src/common/api-interface.ts b/src/common/api-interface.ts index dca9d88b..6e11d72b 100644 --- a/src/common/api-interface.ts +++ b/src/common/api-interface.ts @@ -288,7 +288,14 @@ export type NotificationActionCallback = ( export type ConfigUpdateType = 'restart' | 'reload'; export interface ICloud9Pipe { + /** + * Ability to write in C9 named pipe + */ write(data: Uint8Array): void; + + /** + * Ability to close named pipe + */ close(): void; }