[MM-48079] Dont show server login when GPO has preconfigured servers (#2346)
* Show onboarding server screen only when teams.length is 0 * Add tests * Add more tests * Fix issue where callback would not re-evaluate variables
This commit is contained in:
@@ -101,7 +101,8 @@
|
|||||||
"__CAN_UPGRADE__": false,
|
"__CAN_UPGRADE__": false,
|
||||||
"__IS_NIGHTLY_BUILD__": false,
|
"__IS_NIGHTLY_BUILD__": false,
|
||||||
"__IS_MAC_APP_STORE__": false,
|
"__IS_MAC_APP_STORE__": false,
|
||||||
"__DISABLE_GPU__": false
|
"__DISABLE_GPU__": false,
|
||||||
|
"__SKIP_ONBOARDING_SCREENS__": false
|
||||||
},
|
},
|
||||||
"setupFiles": [
|
"setupFiles": [
|
||||||
"./src/jestSetup.js"
|
"./src/jestSetup.js"
|
||||||
|
@@ -25,4 +25,3 @@ jest.mock('electron-log', () => ({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@@ -60,9 +60,7 @@ export function handleConfigUpdate(newConfig: CombinedConfig) {
|
|||||||
didCheckForAddServerModal = true;
|
didCheckForAddServerModal = true;
|
||||||
updateServerInfos(newConfig.teams);
|
updateServerInfos(newConfig.teams);
|
||||||
WindowManager.initializeCurrentServerName();
|
WindowManager.initializeCurrentServerName();
|
||||||
if (newConfig.teams.length === 0) {
|
handleMainWindowIsShown();
|
||||||
handleMainWindowIsShown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info('Log level set to:', newConfig.logLevel);
|
log.info('Log level set to:', newConfig.logLevel);
|
||||||
|
@@ -406,9 +406,7 @@ function initializeAfterAppReady() {
|
|||||||
|
|
||||||
// only check for non-Windows, as with Windows we have to wait for GPO teams
|
// only check for non-Windows, as with Windows we have to wait for GPO teams
|
||||||
if (process.platform !== 'win32' || typeof Config.registryConfigData !== 'undefined') {
|
if (process.platform !== 'win32' || typeof Config.registryConfigData !== 'undefined') {
|
||||||
if (Config.teams.length === 0) {
|
handleMainWindowIsShown();
|
||||||
handleMainWindowIsShown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,8 @@ import {
|
|||||||
handleEditServerModal,
|
handleEditServerModal,
|
||||||
handleRemoveServerModal,
|
handleRemoveServerModal,
|
||||||
handleWelcomeScreenModal,
|
handleWelcomeScreenModal,
|
||||||
|
handleMainWindowIsShown,
|
||||||
|
handleShowOnboardingScreens,
|
||||||
} from './intercom';
|
} from './intercom';
|
||||||
|
|
||||||
jest.mock('common/config', () => ({
|
jest.mock('common/config', () => ({
|
||||||
@@ -257,4 +259,33 @@ describe('main/app/intercom', () => {
|
|||||||
expect(ModalManager.addModal).toHaveBeenCalledWith('welcomeScreen', '/some/index.html', '/some/preload.js', [], {}, true);
|
expect(ModalManager.addModal).toHaveBeenCalledWith('welcomeScreen', '/some/index.html', '/some/preload.js', [], {}, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('handleMainWindowIsShown', () => {
|
||||||
|
it('MM-48079 should not show onboarding screen or server screen if GPO server is pre-configured', () => {
|
||||||
|
getLocalURLString.mockReturnValue('/some/index.html');
|
||||||
|
getLocalPreload.mockReturnValue('/some/preload.js');
|
||||||
|
WindowManager.getMainWindow.mockReturnValue({
|
||||||
|
isVisible: () => true,
|
||||||
|
});
|
||||||
|
|
||||||
|
Config.set.mockImplementation((name, value) => {
|
||||||
|
Config[name] = value;
|
||||||
|
});
|
||||||
|
Config.teams = JSON.parse(JSON.stringify([{
|
||||||
|
name: 'test-team',
|
||||||
|
order: 0,
|
||||||
|
url: 'https://someurl.here',
|
||||||
|
}]));
|
||||||
|
|
||||||
|
handleMainWindowIsShown();
|
||||||
|
expect(ModalManager.addModal).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('handleShowOnboardingScreens', () => {
|
||||||
|
it('MM-48079 should not show onboarding screen or server screen if GPO server is pre-configured', () => {
|
||||||
|
handleShowOnboardingScreens(false, false, true);
|
||||||
|
expect(ModalManager.addModal).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -85,31 +85,38 @@ export function handleOpenTab(event: IpcMainEvent, serverName: string, tabName:
|
|||||||
Config.set('teams', teams);
|
Config.set('teams', teams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function handleShowOnboardingScreens(showWelcomeScreen: boolean, showNewServerModal: boolean, mainWindowIsVisible: boolean) {
|
||||||
|
log.debug('Intercom.handleShowOnboardingScreens', {showWelcomeScreen, showNewServerModal, mainWindowIsVisible});
|
||||||
|
if (showWelcomeScreen) {
|
||||||
|
handleWelcomeScreenModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (showNewServerModal) {
|
||||||
|
handleNewServerModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function handleMainWindowIsShown() {
|
export function handleMainWindowIsShown() {
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const showWelcomeScreen = !(Boolean(__SKIP_ONBOARDING_SCREENS__) || Config.teams.length);
|
const showWelcomeScreen = () => !(Boolean(__SKIP_ONBOARDING_SCREENS__) || Config.teams.length);
|
||||||
|
const showNewServerModal = () => Config.teams.length === 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 2 lines above need to be functions, otherwise the mainWindow.once() callback from previous
|
||||||
|
* calls of this function will notification re-evaluate the booleans passed to "handleShowOnboardingScreens".
|
||||||
|
*/
|
||||||
|
|
||||||
const mainWindow = WindowManager.getMainWindow();
|
const mainWindow = WindowManager.getMainWindow();
|
||||||
|
|
||||||
if (mainWindow) {
|
log.debug('intercom.handleMainWindowIsShown', {configTeams: Config.teams, showWelcomeScreen, showNewServerModal, mainWindow: Boolean(mainWindow)});
|
||||||
if (mainWindow.isVisible()) {
|
if (mainWindow?.isVisible()) {
|
||||||
if (showWelcomeScreen) {
|
handleShowOnboardingScreens(showWelcomeScreen(), showNewServerModal(), true);
|
||||||
handleWelcomeScreenModal();
|
} else {
|
||||||
} else {
|
mainWindow?.once('show', () => {
|
||||||
handleNewServerModal();
|
handleShowOnboardingScreens(showWelcomeScreen(), showNewServerModal(), false);
|
||||||
}
|
});
|
||||||
} else {
|
|
||||||
mainWindow.once('show', () => {
|
|
||||||
if (showWelcomeScreen) {
|
|
||||||
log.debug('Intercom.handleMainWindowIsShown.show.welcomeScreenModal');
|
|
||||||
handleWelcomeScreenModal();
|
|
||||||
} else {
|
|
||||||
log.debug('Intercom.handleMainWindowIsShown.show.newServerModal');
|
|
||||||
handleNewServerModal();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -118,7 +118,6 @@ export type CombinedConfig = ConfigV3 & BuildConfig & {
|
|||||||
registryTeams: Team[];
|
registryTeams: Team[];
|
||||||
appName: string;
|
appName: string;
|
||||||
useNativeWindow: boolean;
|
useNativeWindow: boolean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LocalConfiguration = Config & {
|
export type LocalConfiguration = Config & {
|
||||||
|
Reference in New Issue
Block a user