MM-25003_Improve Onboarding screens for the desktop app - Intro Screen (#2220)

This commit is contained in:
Julian Mondragón
2022-08-16 12:33:03 -05:00
committed by GitHub
parent d4282d965e
commit faf2dae74b
50 changed files with 1815 additions and 42 deletions

View File

@@ -7,7 +7,7 @@ import {RELOAD_CONFIGURATION} from 'common/communication';
import Config from 'common/config';
import {handleConfigUpdate} from 'main/app/config';
import {addNewServerModalWhenMainWindowIsShown} from 'main/app/intercom';
import {handleMainWindowIsShown} from 'main/app/intercom';
import {setLoggingLevel} from 'main/app/utils';
import WindowManager from 'main/windows/windowManager';
@@ -32,7 +32,7 @@ jest.mock('main/app/utils', () => ({
setLoggingLevel: jest.fn(),
}));
jest.mock('main/app/intercom', () => ({
addNewServerModalWhenMainWindowIsShown: jest.fn(),
handleMainWindowIsShown: jest.fn(),
}));
jest.mock('main/AutoLauncher', () => ({
enable: jest.fn(),
@@ -98,7 +98,7 @@ describe('main/app/config', () => {
Config.registryConfigData = {};
handleConfigUpdate({teams: []});
expect(addNewServerModalWhenMainWindowIsShown).toHaveBeenCalled();
expect(handleMainWindowIsShown).toHaveBeenCalled();
Object.defineProperty(process, 'platform', {
value: originalPlatform,

View File

@@ -14,7 +14,7 @@ import {setUnreadBadgeSetting} from 'main/badge';
import {refreshTrayImages} from 'main/tray/tray';
import WindowManager from 'main/windows/windowManager';
import {addNewServerModalWhenMainWindowIsShown} from './intercom';
import {handleMainWindowIsShown} from './intercom';
import {handleUpdateMenuEvent, setLoggingLevel, updateServerInfos, updateSpellCheckerLocales} from './utils';
let didCheckForAddServerModal = false;
@@ -61,7 +61,7 @@ export function handleConfigUpdate(newConfig: CombinedConfig) {
updateServerInfos(newConfig.teams);
WindowManager.initializeCurrentServerName();
if (newConfig.teams.length === 0) {
addNewServerModalWhenMainWindowIsShown();
handleMainWindowIsShown();
}
}

View File

@@ -98,7 +98,7 @@ jest.mock('main/app/config', () => ({
handleConfigUpdate: jest.fn(),
}));
jest.mock('main/app/intercom', () => ({
addNewServerModalWhenMainWindowIsShown: jest.fn(),
handleMainWindowIsShown: jest.fn(),
}));
jest.mock('main/app/utils', () => ({
clearAppCache: jest.fn(),

View File

@@ -34,6 +34,7 @@ import {
START_UPGRADE,
START_DOWNLOAD,
PING_DOMAIN,
MAIN_WINDOW_SHOWN,
} from 'common/communication';
import Config from 'common/config';
import urlUtils from 'common/utils/url';
@@ -68,7 +69,7 @@ import {
} from './app';
import {handleConfigUpdate, handleDarkModeChange} from './config';
import {
addNewServerModalWhenMainWindowIsShown,
handleMainWindowIsShown,
handleAppVersion,
handleCloseTab,
handleEditServerModal,
@@ -247,6 +248,7 @@ function initializeInterCommunicationEventListeners() {
ipcMain.on(SHOW_NEW_SERVER_MODAL, handleNewServerModal);
ipcMain.on(SHOW_EDIT_SERVER_MODAL, handleEditServerModal);
ipcMain.on(SHOW_REMOVE_SERVER_MODAL, handleRemoveServerModal);
ipcMain.on(MAIN_WINDOW_SHOWN, handleMainWindowIsShown);
ipcMain.on(WINDOW_CLOSE, WindowManager.close);
ipcMain.on(WINDOW_MAXIMIZE, WindowManager.maximize);
ipcMain.on(WINDOW_MINIMIZE, WindowManager.minimize);
@@ -423,7 +425,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) {
addNewServerModalWhenMainWindowIsShown();
handleMainWindowIsShown();
}
}
}

View File

@@ -14,6 +14,7 @@ import {
handleNewServerModal,
handleEditServerModal,
handleRemoveServerModal,
handleWelcomeScreenModal,
} from './intercom';
jest.mock('common/config', () => ({
@@ -235,4 +236,24 @@ describe('main/app/intercom', () => {
}));
});
});
describe('handleWelcomeScreenModal', () => {
beforeEach(() => {
getLocalURLString.mockReturnValue('/some/index.html');
getLocalPreload.mockReturnValue('/some/preload.js');
WindowManager.getMainWindow.mockReturnValue({});
Config.set.mockImplementation((name, value) => {
Config[name] = value;
});
});
it('should show welcomeScreen modal', async () => {
const promise = Promise.resolve({});
ModalManager.addModal.mockReturnValue(promise);
handleWelcomeScreenModal();
expect(ModalManager.addModal).toHaveBeenCalledWith('welcomeScreen', '/some/index.html', '/some/preload.js', {}, {}, true);
});
});
});

View File

@@ -85,15 +85,26 @@ export function handleOpenTab(event: IpcMainEvent, serverName: string, tabName:
Config.set('teams', teams);
}
export function addNewServerModalWhenMainWindowIsShown() {
export function handleMainWindowIsShown() {
const showWelcomeScreen = !Config.teams.length;
const mainWindow = WindowManager.getMainWindow();
if (mainWindow) {
if (mainWindow.isVisible()) {
handleNewServerModal();
if (showWelcomeScreen) {
handleWelcomeScreenModal();
} else {
handleNewServerModal();
}
} else {
mainWindow.once('show', () => {
log.debug('Intercom.addNewServerModalWhenMainWindowIsShown.show');
handleNewServerModal();
if (showWelcomeScreen) {
log.debug('Intercom.handleMainWindowIsShown.show.welcomeScreenModal');
handleWelcomeScreenModal();
} else {
log.debug('Intercom.handleMainWindowIsShown.show.newServerModal');
handleNewServerModal();
}
});
}
}
@@ -213,6 +224,32 @@ export function handleRemoveServerModal(e: IpcMainEvent, name: string) {
}
}
export function handleWelcomeScreenModal() {
log.debug('Intercom.handleWelcomeScreenModal');
const html = getLocalURLString('welcomeScreen.html');
const modalPreload = getLocalPreload('modalPreload.js');
const mainWindow = WindowManager.getMainWindow();
if (!mainWindow) {
return;
}
const modalPromise = ModalManager.addModal('welcomeScreen', html, modalPreload, {}, mainWindow, true);
if (modalPromise) {
modalPromise.then(() => {
handleNewServerModal();
}).catch((e) => {
// e is undefined for user cancellation
if (e) {
log.error(`there was an error in the welcome screen modal: ${e}`);
}
});
} else {
log.warn('There is already a welcome screen modal');
}
}
export function handleMentionNotification(event: IpcMainEvent, title: string, body: string, channel: {id: string}, teamId: string, url: string, silent: boolean, data: MentionData) {
log.debug('Intercom.handleMentionNotification', {title, body, channel, teamId, url, silent, data});
displayMention(title, body, channel, teamId, url, silent, event.sender, data);