From 711ca555f624bfd5c86a1eabcf3b1a7b6fca9cbd Mon Sep 17 00:00:00 2001 From: Robo Date: Sat, 23 Mar 2024 14:35:50 +0900 Subject: [PATCH] chore: provide option to disable remote unsupported connection banner (#208392) --- .../browser/parts/banner/bannerPart.ts | 13 ++++--- .../remote/browser/remoteConnectionHealth.ts | 35 ++++++++++++------- .../services/banner/browser/bannerService.ts | 2 +- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/vs/workbench/browser/parts/banner/bannerPart.ts b/src/vs/workbench/browser/parts/banner/bannerPart.ts index 91c8e9902bb..dda7c882d5e 100644 --- a/src/vs/workbench/browser/parts/banner/bannerPart.ts +++ b/src/vs/workbench/browser/parts/banner/bannerPart.ts @@ -222,13 +222,12 @@ export class BannerPart extends Part implements IBannerService { } // Action - if (!item.disableCloseAction) { - const actionBarContainer = append(this.element, $('div.action-container')); - this.actionBar = this._register(new ActionBar(actionBarContainer)); - const closeAction = this._register(new Action('banner.close', 'Close Banner', ThemeIcon.asClassName(widgetClose), true, () => this.close(item))); - this.actionBar.push(closeAction, { icon: true, label: false }); - this.actionBar.setFocusable(false); - } + const actionBarContainer = append(this.element, $('div.action-container')); + this.actionBar = this._register(new ActionBar(actionBarContainer)); + const label = item.closeLabel ?? 'Close Banner'; + const closeAction = this._register(new Action('banner.close', label, ThemeIcon.asClassName(widgetClose), true, () => this.close(item))); + this.actionBar.push(closeAction, { icon: true, label: false }); + this.actionBar.setFocusable(false); this.setVisibility(true); this.item = item; diff --git a/src/vs/workbench/contrib/remote/browser/remoteConnectionHealth.ts b/src/vs/workbench/contrib/remote/browser/remoteConnectionHealth.ts index e75900e7fa7..a240229e784 100644 --- a/src/vs/workbench/contrib/remote/browser/remoteConnectionHealth.ts +++ b/src/vs/workbench/contrib/remote/browser/remoteConnectionHealth.ts @@ -21,6 +21,7 @@ import Severity from 'vs/base/common/severity'; const REMOTE_UNSUPPORTED_CONNECTION_CHOICE_KEY = 'remote.unsupportedConnectionChoice'; +const BANNER_REMOTE_UNSUPPORTED_CONNECTION_DISMISSED_KEY = 'workbench.banner.remote.unsupportedConnection.dismissed'; export class InitialRemoteConnectionHealthContribution implements IWorkbenchContribution { @@ -90,19 +91,27 @@ export class InitialRemoteConnectionHealthContribution implements IWorkbenchCont allowed = await this._confirmConnection(); } if (allowed) { - const actions = [ - { - label: localize('unsupportedGlibcBannerLearnMore', "Learn More"), - href: 'https://aka.ms/vscode-remote/faq/old-linux' - } - ]; - this.bannerService.show({ - id: 'unsupportedGlibcWarning.banner', - message: localize('unsupportedGlibcWarning.banner', "You are connected to an OS version that is unsupported by {0}.", this.productService.nameLong), - actions, - icon: Codicon.warning, - disableCloseAction: true - }); + const bannerDismissedVersion = this.storageService.get(`${BANNER_REMOTE_UNSUPPORTED_CONNECTION_DISMISSED_KEY}`, StorageScope.PROFILE) ?? ''; + // Ignore patch versions and dismiss the banner if the major and minor versions match. + const shouldShowBanner = bannerDismissedVersion.slice(0, bannerDismissedVersion.lastIndexOf('.')) !== this.productService.version.slice(0, this.productService.version.lastIndexOf('.')); + if (shouldShowBanner) { + const actions = [ + { + label: localize('unsupportedGlibcBannerLearnMore', "Learn More"), + href: 'https://aka.ms/vscode-remote/faq/old-linux' + } + ]; + this.bannerService.show({ + id: 'unsupportedGlibcWarning.banner', + message: localize('unsupportedGlibcWarning.banner', "You are connected to an OS version that is unsupported by {0}.", this.productService.nameLong), + actions, + icon: Codicon.warning, + closeLabel: `Do not show again in v${this.productService.version}`, + onClose: () => { + this.storageService.store(`${BANNER_REMOTE_UNSUPPORTED_CONNECTION_DISMISSED_KEY}`, this.productService.version, StorageScope.PROFILE, StorageTarget.MACHINE); + } + }); + } } else { this.hostService.openWindow({ forceReuseWindow: true, remoteAuthority: null }); return; diff --git a/src/vs/workbench/services/banner/browser/bannerService.ts b/src/vs/workbench/services/banner/browser/bannerService.ts index d8560ce135e..9c1ab0d4bdd 100644 --- a/src/vs/workbench/services/banner/browser/bannerService.ts +++ b/src/vs/workbench/services/banner/browser/bannerService.ts @@ -16,7 +16,7 @@ export interface IBannerItem { readonly actions?: ILinkDescriptor[]; readonly ariaLabel?: string; readonly onClose?: () => void; - readonly disableCloseAction?: boolean; + readonly closeLabel?: string; } export const IBannerService = createDecorator('bannerService');