[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:
parent
5ab1eceade
commit
935cf3a0cc
|
@ -101,7 +101,8 @@
|
|||
"__CAN_UPGRADE__": false,
|
||||
"__IS_NIGHTLY_BUILD__": false,
|
||||
"__IS_MAC_APP_STORE__": false,
|
||||
"__DISABLE_GPU__": false
|
||||
"__DISABLE_GPU__": false,
|
||||
"__SKIP_ONBOARDING_SCREENS__": false
|
||||
},
|
||||
"setupFiles": [
|
||||
"./src/jestSetup.js"
|
||||
|
|
|
@ -25,4 +25,3 @@ jest.mock('electron-log', () => ({
|
|||
},
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
|
@ -60,9 +60,7 @@ export function handleConfigUpdate(newConfig: CombinedConfig) {
|
|||
didCheckForAddServerModal = true;
|
||||
updateServerInfos(newConfig.teams);
|
||||
WindowManager.initializeCurrentServerName();
|
||||
if (newConfig.teams.length === 0) {
|
||||
handleMainWindowIsShown();
|
||||
}
|
||||
handleMainWindowIsShown();
|
||||
}
|
||||
|
||||
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
|
||||
if (process.platform !== 'win32' || typeof Config.registryConfigData !== 'undefined') {
|
||||
if (Config.teams.length === 0) {
|
||||
handleMainWindowIsShown();
|
||||
}
|
||||
handleMainWindowIsShown();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import {
|
|||
handleEditServerModal,
|
||||
handleRemoveServerModal,
|
||||
handleWelcomeScreenModal,
|
||||
handleMainWindowIsShown,
|
||||
handleShowOnboardingScreens,
|
||||
} from './intercom';
|
||||
|
||||
jest.mock('common/config', () => ({
|
||||
|
@ -257,4 +259,33 @@ describe('main/app/intercom', () => {
|
|||
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);
|
||||
}
|
||||
|
||||
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() {
|
||||
// eslint-disable-next-line no-undef
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @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();
|
||||
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isVisible()) {
|
||||
if (showWelcomeScreen) {
|
||||
handleWelcomeScreenModal();
|
||||
} else {
|
||||
handleNewServerModal();
|
||||
}
|
||||
} else {
|
||||
mainWindow.once('show', () => {
|
||||
if (showWelcomeScreen) {
|
||||
log.debug('Intercom.handleMainWindowIsShown.show.welcomeScreenModal');
|
||||
handleWelcomeScreenModal();
|
||||
} else {
|
||||
log.debug('Intercom.handleMainWindowIsShown.show.newServerModal');
|
||||
handleNewServerModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
log.debug('intercom.handleMainWindowIsShown', {configTeams: Config.teams, showWelcomeScreen, showNewServerModal, mainWindow: Boolean(mainWindow)});
|
||||
if (mainWindow?.isVisible()) {
|
||||
handleShowOnboardingScreens(showWelcomeScreen(), showNewServerModal(), true);
|
||||
} else {
|
||||
mainWindow?.once('show', () => {
|
||||
handleShowOnboardingScreens(showWelcomeScreen(), showNewServerModal(), false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,6 @@ export type CombinedConfig = ConfigV3 & BuildConfig & {
|
|||
registryTeams: Team[];
|
||||
appName: string;
|
||||
useNativeWindow: boolean;
|
||||
|
||||
}
|
||||
|
||||
export type LocalConfiguration = Config & {
|
||||
|
|
Loading…
Reference in a new issue