From ca3411426ab95bb9382f09d6ecf85c87858b89fc Mon Sep 17 00:00:00 2001 From: Grzegorz Zdunek Date: Mon, 19 Jun 2023 15:03:42 +0200 Subject: [PATCH] Connect: Update Electron to 25.1 and TypeScript to 5.1 (#27837) * Update Electron to 25.1, TypeScript to 5.1 * Use the same focusing mechanism on all platforms * Use `role: about` in the app menu as Linux supports it * Bump Electron to 25.1.1 --- package.json | 2 +- web/packages/teleterm/package.json | 2 +- .../teleterm/src/mainProcess/mainProcess.ts | 8 ++----- .../src/mainProcess/windowsManager.ts | 21 +++++++++---------- yarn.lock | 16 +++++++------- 5 files changed, 22 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 222edb8e4e9..f9c900c551b 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "x-default-browser": "^0.5.2" }, "devDependencies": { - "typescript": "^5.0.4" + "typescript": "^5.1.3" }, "workspaces": { "packages": [ diff --git a/web/packages/teleterm/package.json b/web/packages/teleterm/package.json index be7178b955c..e4c267b22eb 100644 --- a/web/packages/teleterm/package.json +++ b/web/packages/teleterm/package.json @@ -40,7 +40,7 @@ "@types/node-forge": "^1.0.4", "clean-webpack-plugin": "4.0.0", "cross-env": "5.0.5", - "electron": "24.3.0", + "electron": "25.1.1", "electron-notarize": "^1.2.1", "eslint-import-resolver-webpack": "0.13.2", "eslint-loader": "3.0.3", diff --git a/web/packages/teleterm/src/mainProcess/mainProcess.ts b/web/packages/teleterm/src/mainProcess/mainProcess.ts index df922b2e717..edfbef8cbb6 100644 --- a/web/packages/teleterm/src/mainProcess/mainProcess.ts +++ b/web/packages/teleterm/src/mainProcess/mainProcess.ts @@ -337,10 +337,7 @@ export default class MainProcess { role: 'help', submenu: [ { label: 'Learn More', click: openDocsUrl }, - { - label: 'About Teleport Connect', - click: app.showAboutPanel, - }, + { role: 'about' }, ], }, ]; @@ -350,8 +347,7 @@ export default class MainProcess { } private updateAboutPanelIfNeeded(): void { - // There is no about menu for Linux. See https://github.com/electron/electron/issues/18918 - // On Windows default menu does not show copyrights. + // On Windows and Linux default menu does not show copyrights. if ( this.settings.platform === 'linux' || this.settings.platform === 'win32' diff --git a/web/packages/teleterm/src/mainProcess/windowsManager.ts b/web/packages/teleterm/src/mainProcess/windowsManager.ts index bc3de2c3f20..2244f085297 100644 --- a/web/packages/teleterm/src/mainProcess/windowsManager.ts +++ b/web/packages/teleterm/src/mainProcess/windowsManager.ts @@ -147,12 +147,12 @@ export class WindowsManager { return; } - // What follows is a special focus handler for windows. - // - // On Windows, app.focus() doesn't work as expected so instead we call win.focus(). - // If the window is minimized, win.focus() will bring it to the front and give it focus. - // If the window is not minimized but simply covered by other another window, win.focus() will + // On Windows, app.focus() doesn't work the same as on the other platforms. + // If the window is minimized, app.focus() will bring it to the front and give it focus. + // If the window is not minimized but simply covered by other another window, app.focus() will // flash the icon of Connect in the task bar. + // To make things even more complicated, the app behaves like that only when it is packaged. + // When it is in dev mode, it seems to work correctly (it is brought to the front every time). // // Ideally, we'd like the not minimized window to receive focus too. We considered two // workarounds to bring focus to a window that's not minimized: @@ -171,21 +171,20 @@ export class WindowsManager { // // https://github.com/electron/electron/issues/2867#issuecomment-1080573240 // - // I don't understand why calling win.focus() on a minimized window gives it focus in the + // I don't understand why calling app.focus() on a minimized window gives it focus in the // first place. In theory it shouldn't work, see the links below: // // https://stackoverflow.com/a/72620653/742872 // https://devblogs.microsoft.com/oldnewthing/20090220-00/?p=19083 // https://github.com/electron/electron/issues/2867#issuecomment-142480964 // https://github.com/electron/electron/issues/2867#issuecomment-142511956 - if (this.settings.platform === 'win32') { - this.window.focus(); - return; - } app.dock?.bounce('informational'); + // app.focus() alone doesn't un-minimize the window if the window is minimized. - this.window.show(); + if (this.window.isMinimized()) { + this.window.restore(); + } app.focus({ steal: true }); } diff --git a/yarn.lock b/yarn.lock index dc79ddf639d..4464cfcaba9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6884,10 +6884,10 @@ electron-to-chromium@^1.4.284: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.304.tgz#d6eb7fea4073aacc471cf117df08b4b4978dc6ad" integrity sha512-6c8M+ojPgDIXN2NyfGn8oHASXYnayj+gSEnGeLMKb9zjsySeVB/j7KkNAAG9yDcv8gNlhvFg5REa1N/kQU6pgA== -electron@24.3.0: - version "24.3.0" - resolved "https://registry.yarnpkg.com/electron/-/electron-24.3.0.tgz#d1ef519b0d6d86cc4992519b49821372cb957fe6" - integrity sha512-M7PpfpOzGdLeZPr2xhxXuvJeoXPEHMH40Rtv8BCGleRPolwna9BepAGc0H0F+Uz5kGKOv3xcm99fTurvXUH0nw== +electron@25.1.1: + version "25.1.1" + resolved "https://registry.yarnpkg.com/electron/-/electron-25.1.1.tgz#b7aaf0d66a56fbbbad987c13cee108642f63bd50" + integrity sha512-WvFUfVsJn6YiP35UxdibYVjU2LceastyMm4SVp2bmb4XvKEvItAIiwxgm7tPC5Syl1243aRCvQLqr84sZ71pyQ== dependencies: "@electron/get" "^2.0.0" "@types/node" "^18.11.18" @@ -14885,10 +14885,10 @@ typescript@^4.0.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== -typescript@^5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== +typescript@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.3.tgz#8d84219244a6b40b6fb2b33cc1c062f715b9e826" + integrity sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw== uglify-js@^3.1.4: version "3.14.3"