
* Upgrade to ESLint v8 * Upgrade TypeScript, api-types, react-intl * Remove unnecessary dependencies * Update to React 17.0.2 * npm audit fixes, remove storybook * Lock some packages * Remove nan patch * Remove some deprecated dependencies * Fix lint/type/tests * Merge'd * Fix bad use of spawn * Fix notarize * Fix afterpack, switch to tsc es2020 * Fix api types * Use @mattermost/eslint-plugin
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
// Copyright (c) 2015-2016 Yuya Ochiai
|
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
'use strict';
|
|
|
|
import type {MenuItem, MenuItemConstructorOptions} from 'electron';
|
|
import {Menu} from 'electron';
|
|
|
|
import ServerViewState from 'app/serverViewState';
|
|
import ServerManager from 'common/servers/serverManager';
|
|
import {localizeMessage} from 'main/i18nManager';
|
|
import SettingsWindow from 'main/windows/settingsWindow';
|
|
|
|
export function createTemplate() {
|
|
const servers = ServerManager.getOrderedServers();
|
|
const template = [
|
|
...servers.slice(0, 9).map((server) => {
|
|
return {
|
|
label: server.name.length > 50 ? `${server.name.slice(0, 50)}...` : server.name,
|
|
click: () => {
|
|
ServerViewState.switchServer(server.id);
|
|
},
|
|
};
|
|
}), {
|
|
type: 'separator',
|
|
}, {
|
|
label: process.platform === 'darwin' ? localizeMessage('main.menus.tray.preferences', 'Preferences...') : localizeMessage('main.menus.tray.settings', 'Settings'),
|
|
click: () => {
|
|
SettingsWindow.show();
|
|
},
|
|
}, {
|
|
type: 'separator',
|
|
}, {
|
|
role: 'quit',
|
|
},
|
|
];
|
|
return template;
|
|
}
|
|
|
|
export function createMenu() {
|
|
// Electron is enforcing certain variables that it doesn't need
|
|
return Menu.buildFromTemplate(createTemplate() as Array<MenuItemConstructorOptions | MenuItem>);
|
|
}
|