[MM-36428][MM-36434][MM-36435] Keyboard navigation and menu updates for new tab/dropdown layout (#1695)

* [MM-36428][MM-36434][MM-36435] Keyboard navigation and menu updates for new tab/dropdown layout

* Shortcuts for Windows/Linux

* Update config.yml

* Fixed up the shortcuts

* Fixed the new server modal popping up where there are GPO teams only
This commit is contained in:
Devin Binnie
2021-08-16 09:17:45 -04:00
committed by GitHub
parent 52becc3467
commit a79e7aeb4c
9 changed files with 139 additions and 19 deletions

View File

@@ -7,7 +7,7 @@ import fs from 'fs';
import path from 'path';
import electron, {BrowserWindow, IpcMainEvent, IpcMainInvokeEvent, Rectangle} from 'electron';
import electron, {BrowserWindow, globalShortcut, IpcMainEvent, IpcMainInvokeEvent, Rectangle} from 'electron';
import isDev from 'electron-is-dev';
import installExtension, {REACT_DEVELOPER_TOOLS} from 'electron-devtools-installer';
import log from 'electron-log';
@@ -39,6 +39,8 @@ import {
SWITCH_TAB,
SHOW_EDIT_SERVER_MODAL,
SHOW_REMOVE_SERVER_MODAL,
UPDATE_SHORTCUT_MENU,
OPEN_TEAMS_DROPDOWN,
} from 'common/communication';
import Config from 'common/config';
import {getDefaultTeamWithTabsFromTeam} from 'common/tabs/TabView';
@@ -96,6 +98,7 @@ let appVersion = null;
let config: Config;
let authManager: AuthManager;
let certificateManager: CertificateManager;
let didCheckForAddServerModal = false;
/**
* Main entry point for the application, ensures that everything initializes in the proper order
@@ -233,6 +236,7 @@ function initializeInterCommunicationEventListeners() {
ipcMain.on(NOTIFY_MENTION, handleMentionNotification);
ipcMain.handle('get-app-version', handleAppVersion);
ipcMain.on('update-menu', handleUpdateMenuEvent);
ipcMain.on(UPDATE_SHORTCUT_MENU, handleUpdateShortcutMenuEvent);
ipcMain.on(FOCUS_BROWSERVIEW, WindowManager.focusBrowserView);
if (process.platform !== 'darwin') {
@@ -301,6 +305,14 @@ function handleConfigSynchronize() {
WindowManager.sendToRenderer(RELOAD_CONFIGURATION);
}
if (process.platform === 'win32' && !didCheckForAddServerModal && typeof config.registryConfigData !== 'undefined') {
didCheckForAddServerModal = true;
if (config.teams.length === 0) {
handleNewServerModal();
}
}
ipcMain.emit('update-menu', true, config);
ipcMain.emit(EMIT_CONFIGURATION, true, config.data);
}
@@ -646,8 +658,11 @@ function initializeAfterAppReady() {
WindowManager.showMainWindow(deeplinkingURL);
if (config.teams.length === 0) {
WindowManager.showSettingsWindow();
// 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) {
handleNewServerModal();
}
}
criticalErrorHandler.setMainWindow(WindowManager.getMainWindow()!);
@@ -722,6 +737,10 @@ function initializeAfterAppReady() {
// is the requesting url trusted?
callback(urlUtils.isTrustedURL(requestingURL, config.teams));
});
globalShortcut.register(`${process.platform === 'darwin' ? 'Cmd+Ctrl' : 'Ctrl+Shift'}+S`, () => {
ipcMain.emit(OPEN_TEAMS_DROPDOWN);
});
}
//
@@ -761,6 +780,10 @@ function handleUpdateMenuEvent(event: IpcMainEvent, menuConfig: Config) {
}
}
function handleUpdateShortcutMenuEvent(event: IpcMainEvent) {
handleUpdateMenuEvent(event, config);
}
async function handleSelectDownload(event: IpcMainInvokeEvent, startFrom: string) {
const message = 'Specify the folder where files will download';
const result = await dialog.showOpenDialog({defaultPath: startFrom || config.downloadLocation,