mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-22 17:06:24 -06:00
SDA-4080 Adding support to startpage for C2 switch between stable and daily (#1711)
* SDA-4080 Adding support to startpage for C2 switch between stable and daily * Adding missing doc * Refactoring
This commit is contained in:
parent
27d5350d64
commit
18a0a0b892
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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}`;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user