[MM-56795] Improve help options in the Help menu (#3216)
* [MM-56795] Improve help options in the Help menu * Fix i18n * Remove extra separator
This commit is contained in:
@@ -36,18 +36,13 @@ import {doubleSecToMs, getPercentage, isStringWithLength, readFilenameFromConten
|
||||
import ViewManager from 'main/views/viewManager';
|
||||
import MainWindow from 'main/windows/mainWindow';
|
||||
|
||||
import type {DownloadedItem, DownloadItemDoneEventState, DownloadedItems, DownloadItemState, DownloadItemUpdatedEventState} from 'types/downloads';
|
||||
import {type DownloadedItem, type DownloadItemDoneEventState, type DownloadedItems, type DownloadItemState, type DownloadItemUpdatedEventState, DownloadItemTypeEnum} from 'types/downloads';
|
||||
|
||||
import appVersionManager from './AppVersionManager';
|
||||
import {downloadsJson} from './constants';
|
||||
|
||||
const log = new Logger('DownloadsManager');
|
||||
|
||||
export enum DownloadItemTypeEnum {
|
||||
FILE = 'file',
|
||||
UPDATE = 'update',
|
||||
}
|
||||
|
||||
export class DownloadsManager extends JsonFileManager<DownloadedItems> {
|
||||
autoCloseTimeout: NodeJS.Timeout | null;
|
||||
open: boolean;
|
||||
|
@@ -68,6 +68,7 @@ jest.mock('common/servers/serverManager', () => ({
|
||||
hasServers: jest.fn(),
|
||||
getOrderedServers: jest.fn(),
|
||||
getOrderedTabsForServer: jest.fn(),
|
||||
getRemoteInfo: jest.fn(),
|
||||
}));
|
||||
jest.mock('app/serverViewState', () => ({
|
||||
switchServer: jest.fn(),
|
||||
@@ -302,6 +303,7 @@ describe('main/menus/app', () => {
|
||||
}
|
||||
return id;
|
||||
});
|
||||
ServerManager.hasServers.mockReturnValue(true);
|
||||
ServerViewState.getCurrentServer.mockImplementation(() => ({id: servers[0].id}));
|
||||
|
||||
const modifiedViews = [...Array(15).keys()].map((key) => ({
|
||||
|
@@ -10,6 +10,7 @@ import log from 'electron-log';
|
||||
import ServerViewState from 'app/serverViewState';
|
||||
import {OPEN_SERVERS_DROPDOWN, SHOW_NEW_SERVER_MODAL} from 'common/communication';
|
||||
import type {Config} from 'common/config';
|
||||
import {DEFAULT_EE_REPORT_PROBLEM_LINK, DEFAULT_TE_REPORT_PROBLEM_LINK} from 'common/constants';
|
||||
import ServerManager from 'common/servers/serverManager';
|
||||
import {t} from 'common/utils/util';
|
||||
import {getViewDisplayName} from 'common/views/View';
|
||||
@@ -312,6 +313,7 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
|
||||
});
|
||||
|
||||
const servers = ServerManager.getOrderedServers();
|
||||
const currentServer = ServerManager.hasServers() ? ServerViewState.getCurrentServer() : undefined;
|
||||
const windowMenu = {
|
||||
id: 'window',
|
||||
label: localizeMessage('main.menus.app.window', '&Window'),
|
||||
@@ -347,7 +349,7 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
|
||||
ServerViewState.switchServer(server.id);
|
||||
},
|
||||
});
|
||||
if (ServerViewState.getCurrentServer().id === server.id) {
|
||||
if (currentServer?.id === server.id) {
|
||||
ServerManager.getOrderedTabsForServer(server.id).slice(0, 9).forEach((view, i) => {
|
||||
items.push({
|
||||
label: ` ${localizeMessage(`common.views.${view.type}`, getViewDisplayName(view.type as ViewType))}`,
|
||||
@@ -380,6 +382,8 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
|
||||
],
|
||||
};
|
||||
template.push(windowMenu);
|
||||
|
||||
const currentRemoteInfo = currentServer ? ServerManager.getRemoteInfo(currentServer.id) : undefined;
|
||||
const submenu = [];
|
||||
if (updateManager && config.canUpgrade) {
|
||||
if (updateManager.versionDownloaded) {
|
||||
@@ -404,17 +408,29 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
if (config.helpLink) {
|
||||
submenu.push({
|
||||
label: localizeMessage('main.menus.app.help.learnMore', 'Learn More...'),
|
||||
click() {
|
||||
shell.openExternal(config.helpLink!);
|
||||
},
|
||||
});
|
||||
submenu.push(separatorItem);
|
||||
}
|
||||
|
||||
const helpLink = currentRemoteInfo?.helpLink ?? config.helpLink;
|
||||
if (helpLink) {
|
||||
submenu.push({
|
||||
label: localizeMessage('main.menus.app.help.userGuide', 'User guide'),
|
||||
click() {
|
||||
shell.openExternal(helpLink);
|
||||
},
|
||||
});
|
||||
}
|
||||
const academyLink = config.academyLink;
|
||||
if (academyLink) {
|
||||
submenu.push({
|
||||
label: localizeMessage('main.menus.app.help.academy', 'Mattermost Academy'),
|
||||
click() {
|
||||
shell.openExternal(academyLink);
|
||||
},
|
||||
});
|
||||
}
|
||||
submenu.push(separatorItem);
|
||||
|
||||
submenu.push({
|
||||
id: 'Show logs',
|
||||
label: localizeMessage('main.menus.app.help.ShowLogs', 'Show logs'),
|
||||
@@ -430,6 +446,27 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
|
||||
Diagnostics.run();
|
||||
},
|
||||
});
|
||||
|
||||
let reportProblemLink = currentRemoteInfo?.reportProblemLink;
|
||||
if (!reportProblemLink) {
|
||||
switch (currentRemoteInfo?.licenseSku) {
|
||||
case 'enterprise':
|
||||
case 'professional':
|
||||
reportProblemLink = DEFAULT_EE_REPORT_PROBLEM_LINK;
|
||||
break;
|
||||
default:
|
||||
reportProblemLink = DEFAULT_TE_REPORT_PROBLEM_LINK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (reportProblemLink) {
|
||||
submenu.push({
|
||||
label: localizeMessage('main.menus.app.help.reportProblem', 'Report a problem'),
|
||||
click() {
|
||||
shell.openExternal(reportProblemLink!);
|
||||
},
|
||||
});
|
||||
}
|
||||
submenu.push(separatorItem);
|
||||
|
||||
const version = localizeMessage('main.menus.app.help.versionString', 'Version {version}{commit}', {
|
||||
|
@@ -32,6 +32,10 @@ export class ServerInfo {
|
||||
this.onGetPlugins,
|
||||
parseURL(`${this.server.url}/api/v4/plugins/webapp`),
|
||||
);
|
||||
await this.getRemoteInfo<{SkuShortName: string}>(
|
||||
this.onGetLicense,
|
||||
parseURL(`${this.server.url}/api/v4/license/client?format=old`),
|
||||
);
|
||||
|
||||
return this.remoteInfo;
|
||||
};
|
||||
@@ -66,10 +70,17 @@ export class ServerInfo {
|
||||
this.remoteInfo.siteURL = data.SiteURL;
|
||||
this.remoteInfo.siteName = data.SiteName;
|
||||
this.remoteInfo.hasFocalboard = this.remoteInfo.hasFocalboard || data.BuildBoards === 'true';
|
||||
this.remoteInfo.helpLink = data.HelpLink;
|
||||
this.remoteInfo.reportProblemLink = data.ReportAProblemLink;
|
||||
};
|
||||
|
||||
private onGetLicense = (data: {SkuShortName: string}) => {
|
||||
this.remoteInfo.licenseSku = data.SkuShortName;
|
||||
};
|
||||
|
||||
private onGetPlugins = (data: Array<{id: string; version: string}>) => {
|
||||
this.remoteInfo.hasFocalboard = this.remoteInfo.hasFocalboard || data.some((plugin) => plugin.id === 'focalboard');
|
||||
this.remoteInfo.hasPlaybooks = data.some((plugin) => plugin.id === 'playbooks');
|
||||
this.remoteInfo.hasUserSurvey = data.some((plugin) => plugin.id === 'com.mattermost.nps');
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user