From 179eacb582df039a49fae51b7c5e1e7c2b64cc52 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Fri, 21 Oct 2022 09:14:02 -0400 Subject: [PATCH] [MM-47778] Remove Sign into another Server menu item when no servers exist (#2301) --- src/main/menus/app.test.js | 21 +++++++++++++++++++++ src/main/menus/app.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/menus/app.test.js b/src/main/menus/app.test.js index ede26aea..9b280385 100644 --- a/src/main/menus/app.test.js +++ b/src/main/menus/app.test.js @@ -213,6 +213,27 @@ describe('main/menus/app', () => { expect(signInOption).not.toBe(undefined); }); + it('should not show `Sign in to Another Server` if no teams are configured', () => { + localizeMessage.mockImplementation((id) => { + switch (id) { + case 'main.menus.app.file': + return '&File'; + case 'main.menus.app.file.signInToAnotherServer': + return 'Sign in to Another Server'; + default: + return ''; + } + }); + const modifiedConfig = { + ...config, + teams: [], + }; + const menu = createTemplate(modifiedConfig); + const fileMenu = menu.find((item) => item.label === '&AppName' || item.label === '&File'); + const signInOption = fileMenu.submenu.find((item) => item.label === 'Sign in to Another Server'); + expect(signInOption).not.toBe(undefined); + }); + it('should show the first 9 servers (using order) in the Window menu', () => { localizeMessage.mockImplementation((id) => { if (id === 'main.menus.app.window') { diff --git a/src/main/menus/app.ts b/src/main/menus/app.ts index 68aa4537..dea85b46 100644 --- a/src/main/menus/app.ts +++ b/src/main/menus/app.ts @@ -45,7 +45,7 @@ export function createTemplate(config: Config, updateManager: UpdateManager) { }, }); - if (config.data?.enableServerManagement === true) { + if (config.data?.enableServerManagement === true && config.data?.teams.length > 0) { platformAppMenu.push({ label: localizeMessage('main.menus.app.file.signInToAnotherServer', 'Sign in to Another Server'), click() {