@codingame/monaco-vscode-policy-service-override 40.1.0 → 41.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-policy-service-override",
3
- "version": "40.1.0",
3
+ "version": "41.0.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - policy service-override",
6
6
  "keywords": [],
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "40.1.0"
18
+ "@codingame/monaco-vscode-api": "41.0.0"
19
19
  },
20
20
  "main": "index.js",
21
21
  "module": "index.js",
@@ -6,6 +6,7 @@ import { IDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/
6
6
  import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
7
7
  import { INotificationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service";
8
8
  import { IOpenerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service";
9
+ import { IManagedSettingsService } from "@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/copilotManagedSettings.service";
9
10
  import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
10
11
  import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
11
12
  import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
@@ -29,18 +30,23 @@ export declare class AccountPolicyGateContribution extends Disposable implements
29
30
  private readonly productService;
30
31
  private readonly storageService;
31
32
  private readonly telemetryService;
33
+ private readonly managedSettingsService;
32
34
  static readonly ID = "workbench.contrib.accountPolicyGate";
33
35
  private readonly contextKey;
34
36
  private lastInfo;
35
37
  private readonly notificationHandle;
38
+ /** The key and support URL of the notification in `notificationHandle`. */
39
+ private shownNotification;
36
40
  private readonly managedSettingsPendingNotificationHandle;
37
41
  private managedSettingsDialogVisibleKey;
38
42
  private managedSettingsDialogDismissedKey;
39
43
  private dismissedKey;
40
44
  private initialised;
41
- constructor(gateService: IAccountPolicyGateService, contextKeyService: IContextKeyService, chatEntitlementService: IChatEntitlementService, defaultAccountService: IDefaultAccountService, logService: ILogService, notificationService: INotificationService, dialogService: IDialogService, commandService: ICommandService, openerService: IOpenerService, productService: IProductService, storageService: IStorageService, telemetryService: ITelemetryService);
45
+ constructor(gateService: IAccountPolicyGateService, contextKeyService: IContextKeyService, chatEntitlementService: IChatEntitlementService, defaultAccountService: IDefaultAccountService, logService: ILogService, notificationService: INotificationService, dialogService: IDialogService, commandService: ICommandService, openerService: IOpenerService, productService: IProductService, storageService: IStorageService, telemetryService: ITelemetryService, managedSettingsService: IManagedSettingsService);
42
46
  private apply;
43
47
  private maybeShowNotification;
48
+ /** Shows the open notification again when the organization's support URL changes under it. */
49
+ private refreshNotificationSupportUrl;
44
50
  private isGateRestricted;
45
51
  private updatePolicyGateState;
46
52
  private updateManagedSettingsCompatibilityState;
@@ -13,6 +13,8 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/noti
13
13
  import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
14
14
  import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
15
15
  import { ManagedSettingsFreshnessFailure, ManagedSettingsFreshnessState } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/managedSettingsFreshness';
16
+ import { getManagedSupportUrl } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/copilotManagedSettings';
17
+ import { IManagedSettingsService } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/copilotManagedSettings.service';
16
18
  import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
17
19
  import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
18
20
  import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
@@ -21,6 +23,7 @@ import { DEFAULT_ACCOUNT_SIGN_IN_COMMAND } from '@codingame/monaco-vscode-api/vs
21
23
  import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service';
22
24
  import { ChatAccountPolicyGateActiveContext, AccountPolicyGateState, AccountPolicyGateUnsatisfiedReason } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/policies/common/accountPolicyService';
23
25
  import { IAccountPolicyGateService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/policies/common/accountPolicyService.service';
26
+ import { openOrganizationSupport, getOrganizationSupportActionLabel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/policies/common/organizationSupport';
24
27
  import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
25
28
 
26
29
  const NOTIFICATION_DISMISSED_KEY = "accountPolicy.gateNotificationDismissed";
@@ -43,7 +46,8 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
43
46
  openerService,
44
47
  productService,
45
48
  storageService,
46
- telemetryService
49
+ telemetryService,
50
+ managedSettingsService
47
51
  ) {
48
52
  super();
49
53
  this.gateService = gateService;
@@ -57,6 +61,7 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
57
61
  this.productService = productService;
58
62
  this.storageService = storageService;
59
63
  this.telemetryService = telemetryService;
64
+ this.managedSettingsService = managedSettingsService;
60
65
  this.notificationHandle = this._register(( new MutableDisposable()));
61
66
  this.managedSettingsPendingNotificationHandle = this._register(( new MutableDisposable()));
62
67
  this.initialised = false;
@@ -71,6 +76,9 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
71
76
  this._register(
72
77
  this.defaultAccountService.onDidChangeManagedSettingsCompatibilityError(() => this.updateManagedSettingsCompatibilityState())
73
78
  );
79
+ this._register(
80
+ this.managedSettingsService.onDidChangeManagedSettings(() => this.refreshNotificationSupportUrl())
81
+ );
74
82
  this._register(disposableTimeout(() => {
75
83
  if (!this.initialised) {
76
84
  this.initialised = true;
@@ -144,35 +152,39 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
144
152
  let message;
145
153
  if (accountName && hasConcreteOrgs) {
146
154
  message = ( localize(
147
- 27736,
155
+ 29411,
148
156
  "Your administrator restricts AI features to GitHub accounts in the following organizations: {0}. The account \"{1}\" is not a member of any of these.",
149
157
  orgList,
150
158
  accountName
151
159
  ));
152
160
  } else if (accountName) {
153
161
  message = ( localize(
154
- 27737,
162
+ 29412,
155
163
  "Your administrator restricts AI features to specific GitHub accounts. The account \"{0}\" does not qualify.",
156
164
  accountName
157
165
  ));
158
166
  } else if (hasConcreteOrgs) {
159
167
  message = ( localize(
160
- 27738,
168
+ 29413,
161
169
  "Your administrator restricts AI features to GitHub accounts in the following organizations: {0}.",
162
170
  orgList
163
171
  ));
164
172
  } else {
165
173
  message = ( localize(
166
- 27739,
174
+ 29414,
167
175
  "Your administrator restricts AI features to specific GitHub accounts."
168
176
  ));
169
177
  }
170
178
  const handleDisposables = ( new DisposableStore());
179
+ const supportUrl = getManagedSupportUrl(this.managedSettingsService);
171
180
  const handle = this.notificationService.prompt(Severity.Warning, message, [{
172
- label: ( localize(27740, "Sign In")),
181
+ label: ( localize(29415, "Sign In")),
173
182
  run: () => this.commandService.executeCommand(DEFAULT_ACCOUNT_SIGN_IN_COMMAND)
174
- }, {
175
- label: ( localize(27741, "Learn More")),
183
+ }, ...(supportUrl ? [{
184
+ label: getOrganizationSupportActionLabel(),
185
+ run: () => openOrganizationSupport(this.openerService, supportUrl)
186
+ }] : []), {
187
+ label: ( localize(29416, "Learn More")),
176
188
  run: () => this.openerService.open(( URI.parse("https://code.visualstudio.com/docs/enterprise/overview")))
177
189
  }], {
178
190
  sticky: true
@@ -185,6 +197,18 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
185
197
  dispose: () => handle.close()
186
198
  });
187
199
  this.notificationHandle.value = handleDisposables;
200
+ this.shownNotification = {
201
+ key: notificationKey,
202
+ supportUrl
203
+ };
204
+ }
205
+ refreshNotificationSupportUrl() {
206
+ const shown = this.shownNotification;
207
+ if (!this.notificationHandle.value || !shown || getManagedSupportUrl(this.managedSettingsService) === shown.supportUrl) {
208
+ return;
209
+ }
210
+ this.notificationHandle.clear();
211
+ this.maybeShowNotification(this.lastInfo, shown.key);
188
212
  }
189
213
  isGateRestricted(info) {
190
214
  return info.state === AccountPolicyGateState.Restricted && info.reason !== AccountPolicyGateUnsatisfiedReason.PolicyNotResolved;
@@ -209,7 +233,7 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
209
233
  this.managedSettingsPendingNotificationHandle.value = store;
210
234
  store.add(disposableTimeout(() => {
211
235
  const handle = this.notificationService.prompt(Severity.Info, ( localize(
212
- 27742,
236
+ 29417,
213
237
  "{0} is resolving your organization's policy. AI features will remain unavailable until this completes.",
214
238
  this.productService.nameShort
215
239
  )), [], {
@@ -256,37 +280,37 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
256
280
  switch (freshness.failure) {
257
281
  case ManagedSettingsFreshnessFailure.NoToken:
258
282
  return localize(
259
- 27743,
283
+ 29418,
260
284
  "AI features are unavailable because {0} must refresh your organization's managed settings. Sign in to continue.",
261
285
  this.productService.nameShort
262
286
  );
263
287
  case ManagedSettingsFreshnessFailure.NoUrl:
264
288
  return localize(
265
- 27744,
289
+ 29419,
266
290
  "AI features are unavailable because {0} cannot locate your organization's managed settings service. Contact your administrator.",
267
291
  this.productService.nameShort
268
292
  );
269
293
  case ManagedSettingsFreshnessFailure.RateLimited:
270
294
  return localize(
271
- 27745,
295
+ 29420,
272
296
  "AI features are temporarily unavailable because your organization's managed settings service is rate limiting requests. Try again later."
273
297
  );
274
298
  case ManagedSettingsFreshnessFailure.HttpError:
275
299
  return localize(
276
- 27746,
300
+ 29421,
277
301
  "AI features are unavailable because {0} could not refresh your organization's managed settings (HTTP {1}). Retry after checking your connection.",
278
302
  this.productService.nameShort,
279
303
  freshness.httpStatus
280
304
  );
281
305
  case ManagedSettingsFreshnessFailure.Malformed:
282
306
  return localize(
283
- 27747,
307
+ 29422,
284
308
  "AI features are unavailable because {0} received an invalid managed settings response. Retry or contact your administrator.",
285
309
  this.productService.nameShort
286
310
  );
287
311
  case ManagedSettingsFreshnessFailure.Network:
288
312
  return localize(
289
- 27748,
313
+ 29423,
290
314
  "Your organization requires {0} to refresh managed settings whenever it starts or reloads.\n\nAn error prevented the required policy from being retrieved, so AI features are unavailable. Retry, or contact your organization's administrator if the issue persists.",
291
315
  this.productService.nameShort
292
316
  );
@@ -296,12 +320,12 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
296
320
  const buttons = [];
297
321
  if (freshness.failure === ManagedSettingsFreshnessFailure.NoToken) {
298
322
  buttons.push({
299
- label: ( localize(27749, "Sign In")),
323
+ label: ( localize(29424, "Sign In")),
300
324
  run: () => this.commandService.executeCommand(DEFAULT_ACCOUNT_SIGN_IN_COMMAND)
301
325
  });
302
326
  } else if (freshness.failure !== ManagedSettingsFreshnessFailure.NoUrl) {
303
327
  buttons.push({
304
- label: ( localize(27750, "Retry")),
328
+ label: ( localize(29425, "Retry")),
305
329
  run: () => {
306
330
  void this.defaultAccountService.refresh({
307
331
  forceRefresh: true,
@@ -310,17 +334,17 @@ let AccountPolicyGateContribution = class AccountPolicyGateContribution extends
310
334
  }
311
335
  });
312
336
  }
313
- const title = freshness.failure === ManagedSettingsFreshnessFailure.Malformed ? ( localize(27751, "Invalid Managed Settings")) : ( localize(27752, "Managed Settings Unavailable"));
337
+ const title = freshness.failure === ManagedSettingsFreshnessFailure.Malformed ? ( localize(29426, "Invalid Managed Settings")) : ( localize(29427, "Managed Settings Unavailable"));
314
338
  return this.dialogService.prompt({
315
339
  type: Severity.Warning,
316
340
  title,
317
341
  message: this.getManagedSettingsBlockedMessage(freshness),
318
342
  custom: true,
319
343
  buttons,
320
- cancelButton: ( localize(27753, "Close"))
344
+ cancelButton: ( localize(29428, "Close"))
321
345
  });
322
346
  }
323
347
  };
324
- AccountPolicyGateContribution = ( __decorate([( __param(0, IAccountPolicyGateService)), ( __param(1, IContextKeyService)), ( __param(2, IChatEntitlementService)), ( __param(3, IDefaultAccountService)), ( __param(4, ILogService)), ( __param(5, INotificationService)), ( __param(6, IDialogService)), ( __param(7, ICommandService)), ( __param(8, IOpenerService)), ( __param(9, IProductService)), ( __param(10, IStorageService)), ( __param(11, ITelemetryService))], AccountPolicyGateContribution));
348
+ AccountPolicyGateContribution = ( __decorate([( __param(0, IAccountPolicyGateService)), ( __param(1, IContextKeyService)), ( __param(2, IChatEntitlementService)), ( __param(3, IDefaultAccountService)), ( __param(4, ILogService)), ( __param(5, INotificationService)), ( __param(6, IDialogService)), ( __param(7, ICommandService)), ( __param(8, IOpenerService)), ( __param(9, IProductService)), ( __param(10, IStorageService)), ( __param(11, ITelemetryService)), ( __param(12, IManagedSettingsService))], AccountPolicyGateContribution));
325
349
 
326
350
  export { AccountPolicyGateContribution };
@@ -69,7 +69,7 @@ let ManagedSettingsUpdateContribution = class ManagedSettingsUpdateContribution
69
69
  bannerService.show({
70
70
  id: ManagedSettingsUpdateContribution_1.ID,
71
71
  icon: Codicon.info,
72
- message: info.updateStatus ? ( localize(27754, "{0} {1}", info.message, info.updateStatus)) : info.message,
72
+ message: info.updateStatus ? ( localize(29429, "{0} {1}", info.message, info.updateStatus)) : info.message,
73
73
  ariaLabel: [info.title, info.message, info.detail, info.updateStatus].filter(Boolean).join(" "),
74
74
  actions: info.action ? [info.action] : [],
75
75
  priority: -1,
@@ -108,20 +108,20 @@ AccessibleViewRegistry.register({
108
108
  info.detail,
109
109
  info.updateStatus,
110
110
  isSessionsWindow ? ( localize(
111
- 27755,
111
+ 29430,
112
112
  "The Agents window is blocked by your organization's minimum-version requirement. The overlay explains the required update."
113
- )) : ( localize(27756, "Chat is read-only while this requirement is active.")),
113
+ )) : ( localize(29431, "Chat is read-only while this requirement is active.")),
114
114
  ( localize(
115
- 27757,
115
+ 29432,
116
116
  "Use Tab or Shift+Tab to move between available actions, then press Enter or Space to activate one."
117
117
  )),
118
- info.action ? ( localize(27758, "The available update action is {0}.", info.action.label)) : undefined,
118
+ info.action ? ( localize(29433, "The available update action is {0}.", info.action.label)) : undefined,
119
119
  isSessionsWindow ? ( localize(
120
- 27759,
120
+ 29434,
121
121
  "Use Tab or Shift+Tab to reach Open Editor Window, then press Enter or Space. This opens a new editor window."
122
122
  )) : undefined,
123
123
  !isSessionsWindow ? ( localize(
124
- 27760,
124
+ 29435,
125
125
  "The window banner is also available with the Focus Banner command. In the banner, use the arrow keys to reach its actions. Closing the banner does not dismiss the explanation in Chat or change your organization's requirement."
126
126
  )) : undefined
127
127
  ].filter(Boolean).join("\n"), () => {