Skip to content

Commit a9e4eb1

Browse files
authored
Merge pull request #85 from zuoyuanh/1.1
Add warning message on auto update being turned off
2 parents 1e94173 + 0707135 commit a9e4eb1

File tree

3 files changed

+94
-6
lines changed

3 files changed

+94
-6
lines changed

patched-vscode/extensions/sagemaker-extension/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
"contributes": {
2828
"configuration": {
2929
"type": "object",
30-
"title": "Sagemaker Extension",
31-
"properties": {}
30+
"title": "SageMaker Extension",
31+
"properties": {
32+
"sagemaker-extension.notification.extensionAutoUpdateDisabled": {
33+
"type": "boolean",
34+
"default": true,
35+
"markdownDescription": "Show notification if extension auto-update is disabled"
36+
}
37+
}
3238
},
3339
"commands": [
3440
]

patched-vscode/extensions/sagemaker-extension/src/extension.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import * as console from "console";
1818

1919
const PARSE_SAGEMAKER_COOKIE_COMMAND = 'sagemaker.parseCookies';
2020

21+
// Command to enable auto-update for extensions
22+
// Please ensure backwards compatibility when pulling in new Code OSS version
23+
const ENABLE_AUTO_UPDATE_COMMAND = 'workbench.extensions.action.enableAutoUpdate';
24+
2125
function showWarningDialog() {
2226
vscode.commands.executeCommand(PARSE_SAGEMAKER_COOKIE_COMMAND).then(response => {
2327

@@ -121,6 +125,37 @@ function updateStatusItemWithMetadata(context: vscode.ExtensionContext) {
121125
});
122126
}
123127

128+
// Render warning message regarding auto upgrade disabled
129+
function renderExtensionAutoUpdateDisabledNotification() {
130+
// Get current extension auto disabled config
131+
const autoUpdateEnabled = vscode.workspace.getConfiguration('extensions').get('autoUpdate');
132+
133+
// Check if customer has choose to disable this notification
134+
const extensionConfig = vscode.workspace.getConfiguration('sagemaker-extension');
135+
const showNotificationEnabled = extensionConfig.get('notification.extensionAutoUpdateDisabled', true);
136+
137+
// Only show notification, if auto update is disabled, and customer hasn't opt-out the notification
138+
if (showNotificationEnabled && autoUpdateEnabled == false) {
139+
const enableAutoUpdate = 'Enable extension auto-update';
140+
const doNotShowAgain = 'Do not show again';
141+
vscode.window.showInformationMessage(
142+
'Extension auto-update is disabled. This can be changed in Code Editor settings.',
143+
enableAutoUpdate,
144+
doNotShowAgain,
145+
).then(response => {
146+
if (response === enableAutoUpdate) {
147+
vscode.commands.executeCommand(ENABLE_AUTO_UPDATE_COMMAND)
148+
} else if (response == doNotShowAgain) {
149+
extensionConfig.update(
150+
'notification.extensionAutoUpdateDisabled',
151+
false,
152+
vscode.ConfigurationTarget.Global
153+
);
154+
}
155+
})
156+
}
157+
}
158+
124159
export function activate(context: vscode.ExtensionContext) {
125160

126161
// TODO: log activation of extension
@@ -134,4 +169,7 @@ export function activate(context: vscode.ExtensionContext) {
134169
initialize(sagemakerCookie);
135170
updateStatusItemWithMetadata(context);
136171
});
172+
173+
// render warning message regarding auto upgrade disabled
174+
renderExtensionAutoUpdateDisabledNotification();
137175
}

patches/sagemaker-extension.diff

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension
22
===================================================================
33
--- /dev/null
44
+++ sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension.ts
5-
@@ -0,0 +1,137 @@
5+
@@ -0,0 +1,175 @@
66
+import * as vscode from 'vscode';
77
+import * as fs from 'fs';
88
+import { SessionWarning } from "./sessionWarning";
@@ -23,6 +23,10 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension
2323
+
2424
+const PARSE_SAGEMAKER_COOKIE_COMMAND = 'sagemaker.parseCookies';
2525
+
26+
+// Command to enable auto-update for extensions
27+
+// Please ensure backwards compatibility when pulling in new Code OSS version
28+
+const ENABLE_AUTO_UPDATE_COMMAND = 'workbench.extensions.action.enableAutoUpdate';
29+
+
2630
+function showWarningDialog() {
2731
+ vscode.commands.executeCommand(PARSE_SAGEMAKER_COOKIE_COMMAND).then(response => {
2832
+
@@ -126,6 +130,37 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension
126130
+ });
127131
+}
128132
+
133+
+// Render warning message regarding auto upgrade disabled
134+
+function renderExtensionAutoUpdateDisabledNotification() {
135+
+ // Get current extension auto disabled config
136+
+ const autoUpdateEnabled = vscode.workspace.getConfiguration('extensions').get('autoUpdate');
137+
+
138+
+ // Check if customer has choose to disable this notification
139+
+ const extensionConfig = vscode.workspace.getConfiguration('sagemaker-extension');
140+
+ const showNotificationEnabled = extensionConfig.get('notification.extensionAutoUpdateDisabled', true);
141+
+
142+
+ // Only show notification, if auto update is disabled, and customer hasn't opt-out the notification
143+
+ if (showNotificationEnabled && autoUpdateEnabled == false) {
144+
+ const enableAutoUpdate = 'Enable extension auto-update';
145+
+ const doNotShowAgain = 'Do not show again';
146+
+ vscode.window.showInformationMessage(
147+
+ 'Extension auto-update is disabled. This can be changed in Code Editor settings.',
148+
+ enableAutoUpdate,
149+
+ doNotShowAgain,
150+
+ ).then(response => {
151+
+ if (response === enableAutoUpdate) {
152+
+ vscode.commands.executeCommand(ENABLE_AUTO_UPDATE_COMMAND)
153+
+ } else if (response == doNotShowAgain) {
154+
+ extensionConfig.update(
155+
+ 'notification.extensionAutoUpdateDisabled',
156+
+ false,
157+
+ vscode.ConfigurationTarget.Global
158+
+ );
159+
+ }
160+
+ })
161+
+ }
162+
+}
163+
+
129164
+export function activate(context: vscode.ExtensionContext) {
130165
+
131166
+ // TODO: log activation of extension
@@ -139,6 +174,9 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension
139174
+ initialize(sagemakerCookie);
140175
+ updateStatusItemWithMetadata(context);
141176
+ });
177+
+
178+
+ // render warning message regarding auto upgrade disabled
179+
+ renderExtensionAutoUpdateDisabledNotification();
142180
+}
143181
Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/sessionWarning.ts
144182
===================================================================
@@ -211,7 +249,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/package.json
211249
===================================================================
212250
--- /dev/null
213251
+++ sagemaker-code-editor/vscode/extensions/sagemaker-extension/package.json
214-
@@ -0,0 +1,46 @@
252+
@@ -0,0 +1,52 @@
215253
+{
216254
+ "name": "sagemaker-extension",
217255
+ "displayName": "Sagemaker Extension",
@@ -241,8 +279,14 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/package.json
241279
+ "contributes": {
242280
+ "configuration": {
243281
+ "type": "object",
244-
+ "title": "Sagemaker Extension",
245-
+ "properties": {}
282+
+ "title": "SageMaker Extension",
283+
+ "properties": {
284+
+ "sagemaker-extension.notification.extensionAutoUpdateDisabled": {
285+
+ "type": "boolean",
286+
+ "default": true,
287+
+ "markdownDescription": "Show notification if extension auto-update is disabled"
288+
+ }
289+
+ }
246290
+ },
247291
+ "commands": [
248292
+ ]

0 commit comments

Comments
 (0)