@codingame/monaco-vscode-policy-service-override 37.0.0 → 37.2.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/index.js +1 -0
- package/package.json +2 -2
- package/vscode/src/vs/workbench/services/policies/browser/accountPolicyGate.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/services/policies/browser/accountPolicyGate.contribution.js +5 -0
- package/vscode/src/vs/workbench/services/policies/browser/accountPolicyGateContribution.d.ts +55 -0
- package/vscode/src/vs/workbench/services/policies/browser/accountPolicyGateContribution.js +357 -0
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import '@codingame/monaco-vscode-api/vscode/vs/base/common/policy';
|
|
|
3
3
|
import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
4
|
import { AbstractPolicyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/policy';
|
|
5
5
|
import { IPolicyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/policy.service';
|
|
6
|
+
import './vscode/src/vs/workbench/services/policies/browser/accountPolicyGate.contribution.js';
|
|
6
7
|
|
|
7
8
|
class PolicyService extends AbstractPolicyService {
|
|
8
9
|
constructor(defaultPolicies) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-policy-service-override",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.2.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": "37.
|
|
18
|
+
"@codingame/monaco-vscode-api": "37.2.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
3
|
+
import { AccountPolicyGateContribution } from './accountPolicyGateContribution.js';
|
|
4
|
+
|
|
5
|
+
registerWorkbenchContribution2(AccountPolicyGateContribution.ID, AccountPolicyGateContribution, WorkbenchPhase.AfterRestored);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { ICommandService } from "@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service";
|
|
3
|
+
import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
|
|
4
|
+
import { IDefaultAccountService } from "@codingame/monaco-vscode-api/vscode/vs/platform/defaultAccount/common/defaultAccount.service";
|
|
5
|
+
import { IDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service";
|
|
6
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
7
|
+
import { INotificationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service";
|
|
8
|
+
import { IOpenerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service";
|
|
9
|
+
import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
|
|
10
|
+
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
|
11
|
+
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
12
|
+
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
13
|
+
import { IChatEntitlementService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service";
|
|
14
|
+
import { IAccountPolicyGateService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/policies/common/accountPolicyService.service";
|
|
15
|
+
/**
|
|
16
|
+
* UX/observability adapter for the Account Policy gate. Mirrors gate state into
|
|
17
|
+
* a context key, shows a sign-in notification when restricted, and emits telemetry.
|
|
18
|
+
* Does NOT re-evaluate the gate — `AccountPolicyService` owns that.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AccountPolicyGateContribution extends Disposable implements IWorkbenchContribution {
|
|
21
|
+
private readonly gateService;
|
|
22
|
+
private readonly chatEntitlementService;
|
|
23
|
+
private readonly defaultAccountService;
|
|
24
|
+
private readonly logService;
|
|
25
|
+
private readonly notificationService;
|
|
26
|
+
private readonly dialogService;
|
|
27
|
+
private readonly commandService;
|
|
28
|
+
private readonly openerService;
|
|
29
|
+
private readonly productService;
|
|
30
|
+
private readonly storageService;
|
|
31
|
+
private readonly telemetryService;
|
|
32
|
+
static readonly ID = "workbench.contrib.accountPolicyGate";
|
|
33
|
+
private readonly contextKey;
|
|
34
|
+
private lastInfo;
|
|
35
|
+
private readonly notificationHandle;
|
|
36
|
+
private readonly managedSettingsPendingNotificationHandle;
|
|
37
|
+
private managedSettingsDialogVisibleKey;
|
|
38
|
+
private managedSettingsDialogDismissedKey;
|
|
39
|
+
private dismissedKey;
|
|
40
|
+
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);
|
|
42
|
+
private apply;
|
|
43
|
+
private maybeShowNotification;
|
|
44
|
+
private isGateRestricted;
|
|
45
|
+
private updatePolicyGateState;
|
|
46
|
+
private updateManagedSettingsCompatibilityState;
|
|
47
|
+
private updateManagedSettingsPendingNotification;
|
|
48
|
+
private maybeShowManagedSettingsDialog;
|
|
49
|
+
private getManagedSettingsDialogKey;
|
|
50
|
+
private getBlockedManagedSettingsFreshness;
|
|
51
|
+
private showManagedSettingsDialog;
|
|
52
|
+
private getManagedSettingsBlockedMessage;
|
|
53
|
+
private showManagedSettingsBlockedDialog;
|
|
54
|
+
private showManagedSettingsCompatibilityDialog;
|
|
55
|
+
}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable, MutableDisposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { disposableTimeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
5
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
6
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
7
|
+
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
8
|
+
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
9
|
+
import { IDefaultAccountService } from '@codingame/monaco-vscode-api/vscode/vs/platform/defaultAccount/common/defaultAccount.service';
|
|
10
|
+
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
11
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
12
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
|
|
13
|
+
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
14
|
+
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
15
|
+
import { ManagedSettingsFreshnessFailure, ManagedSettingsFreshnessState } from '@codingame/monaco-vscode-api/vscode/vs/platform/policy/common/managedSettingsFreshness';
|
|
16
|
+
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
17
|
+
import { StorageScope } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
18
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
19
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
20
|
+
import { DEFAULT_ACCOUNT_SIGN_IN_COMMAND } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/accounts/browser/defaultAccount';
|
|
21
|
+
import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service';
|
|
22
|
+
import { ChatAccountPolicyGateActiveContext, AccountPolicyGateState, AccountPolicyGateUnsatisfiedReason } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/policies/common/accountPolicyService';
|
|
23
|
+
import { IAccountPolicyGateService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/policies/common/accountPolicyService.service';
|
|
24
|
+
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
25
|
+
|
|
26
|
+
const NOTIFICATION_DISMISSED_KEY = "accountPolicy.gateNotificationDismissed";
|
|
27
|
+
function isManagedSettingsBlockedDialogFreshness(freshness) {
|
|
28
|
+
return freshness.failure !== ManagedSettingsFreshnessFailure.UpdateRequired;
|
|
29
|
+
}
|
|
30
|
+
let AccountPolicyGateContribution = class AccountPolicyGateContribution extends Disposable {
|
|
31
|
+
static {
|
|
32
|
+
this.ID = "workbench.contrib.accountPolicyGate";
|
|
33
|
+
}
|
|
34
|
+
constructor(
|
|
35
|
+
gateService,
|
|
36
|
+
contextKeyService,
|
|
37
|
+
chatEntitlementService,
|
|
38
|
+
defaultAccountService,
|
|
39
|
+
logService,
|
|
40
|
+
notificationService,
|
|
41
|
+
dialogService,
|
|
42
|
+
commandService,
|
|
43
|
+
openerService,
|
|
44
|
+
productService,
|
|
45
|
+
storageService,
|
|
46
|
+
telemetryService
|
|
47
|
+
) {
|
|
48
|
+
super();
|
|
49
|
+
this.gateService = gateService;
|
|
50
|
+
this.chatEntitlementService = chatEntitlementService;
|
|
51
|
+
this.defaultAccountService = defaultAccountService;
|
|
52
|
+
this.logService = logService;
|
|
53
|
+
this.notificationService = notificationService;
|
|
54
|
+
this.dialogService = dialogService;
|
|
55
|
+
this.commandService = commandService;
|
|
56
|
+
this.openerService = openerService;
|
|
57
|
+
this.productService = productService;
|
|
58
|
+
this.storageService = storageService;
|
|
59
|
+
this.telemetryService = telemetryService;
|
|
60
|
+
this.notificationHandle = this._register(( new MutableDisposable()));
|
|
61
|
+
this.managedSettingsPendingNotificationHandle = this._register(( new MutableDisposable()));
|
|
62
|
+
this.initialised = false;
|
|
63
|
+
this.contextKey = ChatAccountPolicyGateActiveContext.bindTo(contextKeyService);
|
|
64
|
+
this.lastInfo = this.gateService.gateInfo;
|
|
65
|
+
this.updateManagedSettingsCompatibilityState();
|
|
66
|
+
this.apply(this.lastInfo, true, false);
|
|
67
|
+
this._register(this.gateService.onDidChangeGateInfo(info => {
|
|
68
|
+
this.initialised = true;
|
|
69
|
+
this.apply(info, false, true);
|
|
70
|
+
}));
|
|
71
|
+
this._register(
|
|
72
|
+
this.defaultAccountService.onDidChangeManagedSettingsCompatibilityError(() => this.updateManagedSettingsCompatibilityState())
|
|
73
|
+
);
|
|
74
|
+
this._register(disposableTimeout(() => {
|
|
75
|
+
if (!this.initialised) {
|
|
76
|
+
this.initialised = true;
|
|
77
|
+
this.apply(this.lastInfo, false, true);
|
|
78
|
+
}
|
|
79
|
+
}, 5000));
|
|
80
|
+
}
|
|
81
|
+
apply(info, forceTelemetry, showNotification) {
|
|
82
|
+
const stateChanged = forceTelemetry || info.state !== this.lastInfo.state || info.reason !== this.lastInfo.reason;
|
|
83
|
+
this.lastInfo = info;
|
|
84
|
+
const isRestricted = this.isGateRestricted(info);
|
|
85
|
+
this.updatePolicyGateState();
|
|
86
|
+
this.logService.info(
|
|
87
|
+
`[AccountPolicyGate] apply: state=${info.state}, reason=${info.reason}, isRestricted=${isRestricted}`
|
|
88
|
+
);
|
|
89
|
+
if (stateChanged) {
|
|
90
|
+
this.telemetryService.publicLog2("accountPolicy.gateState", {
|
|
91
|
+
gateActive: info.state !== AccountPolicyGateState.Inactive,
|
|
92
|
+
gateSatisfied: info.state === AccountPolicyGateState.Satisfied,
|
|
93
|
+
reasonNotSatisfied: info.reason
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (info.reason === AccountPolicyGateUnsatisfiedReason.ManagedSettingsRefresh) {
|
|
97
|
+
this.notificationHandle.clear();
|
|
98
|
+
this.dismissedKey = undefined;
|
|
99
|
+
this.updateManagedSettingsPendingNotification(info.managedSettingsFreshness);
|
|
100
|
+
if (showNotification) {
|
|
101
|
+
this.maybeShowManagedSettingsDialog();
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.managedSettingsPendingNotificationHandle.clear();
|
|
106
|
+
if (showNotification) {
|
|
107
|
+
this.maybeShowManagedSettingsDialog();
|
|
108
|
+
}
|
|
109
|
+
if (info.state !== AccountPolicyGateState.Restricted) {
|
|
110
|
+
this.notificationHandle.clear();
|
|
111
|
+
this.dismissedKey = undefined;
|
|
112
|
+
this.storageService.remove(NOTIFICATION_DISMISSED_KEY, StorageScope.APPLICATION);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!showNotification) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (info.reason === AccountPolicyGateUnsatisfiedReason.PolicyNotResolved) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const accountName = this.defaultAccountService.currentDefaultAccount?.accountName;
|
|
122
|
+
const notificationKey = `${info.reason ?? ""}:${accountName ?? ""}`;
|
|
123
|
+
if (this.dismissedKey !== undefined && this.dismissedKey !== notificationKey) {
|
|
124
|
+
this.notificationHandle.clear();
|
|
125
|
+
this.dismissedKey = undefined;
|
|
126
|
+
}
|
|
127
|
+
this.maybeShowNotification(info, notificationKey);
|
|
128
|
+
}
|
|
129
|
+
maybeShowNotification(info, notificationKey) {
|
|
130
|
+
if (this.notificationHandle.value) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (this.dismissedKey === notificationKey) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const persistedDismissed = this.storageService.get(NOTIFICATION_DISMISSED_KEY, StorageScope.APPLICATION);
|
|
137
|
+
if (persistedDismissed === notificationKey) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const accountName = this.defaultAccountService.currentDefaultAccount?.accountName;
|
|
141
|
+
const approvedOrgs = info.approvedOrganizations ?? [];
|
|
142
|
+
const hasConcreteOrgs = approvedOrgs.length > 0 && !approvedOrgs.includes("*");
|
|
143
|
+
const orgList = approvedOrgs.join(", ");
|
|
144
|
+
let message;
|
|
145
|
+
if (accountName && hasConcreteOrgs) {
|
|
146
|
+
message = ( localize(
|
|
147
|
+
19918,
|
|
148
|
+
"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
|
+
orgList,
|
|
150
|
+
accountName
|
|
151
|
+
));
|
|
152
|
+
} else if (accountName) {
|
|
153
|
+
message = ( localize(
|
|
154
|
+
19919,
|
|
155
|
+
"Your administrator restricts AI features to specific GitHub accounts. The account \"{0}\" does not qualify.",
|
|
156
|
+
accountName
|
|
157
|
+
));
|
|
158
|
+
} else if (hasConcreteOrgs) {
|
|
159
|
+
message = ( localize(
|
|
160
|
+
19920,
|
|
161
|
+
"Your administrator restricts AI features to GitHub accounts in the following organizations: {0}.",
|
|
162
|
+
orgList
|
|
163
|
+
));
|
|
164
|
+
} else {
|
|
165
|
+
message = ( localize(
|
|
166
|
+
19921,
|
|
167
|
+
"Your administrator restricts AI features to specific GitHub accounts."
|
|
168
|
+
));
|
|
169
|
+
}
|
|
170
|
+
const handleDisposables = ( new DisposableStore());
|
|
171
|
+
const handle = this.notificationService.prompt(Severity.Warning, message, [{
|
|
172
|
+
label: ( localize(19922, "Sign In")),
|
|
173
|
+
run: () => this.commandService.executeCommand(DEFAULT_ACCOUNT_SIGN_IN_COMMAND)
|
|
174
|
+
}, {
|
|
175
|
+
label: ( localize(19923, "Learn More")),
|
|
176
|
+
run: () => this.openerService.open(( URI.parse("https://code.visualstudio.com/docs/enterprise/overview")))
|
|
177
|
+
}], {
|
|
178
|
+
sticky: true
|
|
179
|
+
});
|
|
180
|
+
handleDisposables.add(handle.onDidClose(() => {
|
|
181
|
+
this.dismissedKey = notificationKey;
|
|
182
|
+
this.notificationHandle.clear();
|
|
183
|
+
}));
|
|
184
|
+
handleDisposables.add({
|
|
185
|
+
dispose: () => handle.close()
|
|
186
|
+
});
|
|
187
|
+
this.notificationHandle.value = handleDisposables;
|
|
188
|
+
}
|
|
189
|
+
isGateRestricted(info) {
|
|
190
|
+
return info.state === AccountPolicyGateState.Restricted && info.reason !== AccountPolicyGateUnsatisfiedReason.PolicyNotResolved;
|
|
191
|
+
}
|
|
192
|
+
updatePolicyGateState() {
|
|
193
|
+
const blocked = this.isGateRestricted(this.lastInfo) || this.defaultAccountService.managedSettingsCompatibilityError !== null;
|
|
194
|
+
this.contextKey.set(blocked);
|
|
195
|
+
this.chatEntitlementService.setForceHidden(blocked);
|
|
196
|
+
}
|
|
197
|
+
updateManagedSettingsCompatibilityState() {
|
|
198
|
+
this.updatePolicyGateState();
|
|
199
|
+
this.maybeShowManagedSettingsDialog();
|
|
200
|
+
}
|
|
201
|
+
updateManagedSettingsPendingNotification(freshness) {
|
|
202
|
+
if (freshness?.state !== ManagedSettingsFreshnessState.Pending) {
|
|
203
|
+
this.managedSettingsPendingNotificationHandle.clear();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (this.managedSettingsPendingNotificationHandle.value) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const store = ( new DisposableStore());
|
|
210
|
+
this.managedSettingsPendingNotificationHandle.value = store;
|
|
211
|
+
store.add(disposableTimeout(() => {
|
|
212
|
+
const handle = this.notificationService.prompt(Severity.Info, ( localize(
|
|
213
|
+
19924,
|
|
214
|
+
"{0} is resolving your organization's policy. AI features will remain unavailable until this completes.",
|
|
215
|
+
this.productService.nameShort
|
|
216
|
+
)), [], {
|
|
217
|
+
sticky: true
|
|
218
|
+
});
|
|
219
|
+
store.add(toDisposable(() => handle.close()));
|
|
220
|
+
}, 5000));
|
|
221
|
+
}
|
|
222
|
+
maybeShowManagedSettingsDialog() {
|
|
223
|
+
const key = this.getManagedSettingsDialogKey();
|
|
224
|
+
if (!key) {
|
|
225
|
+
const freshness = this.lastInfo.reason === AccountPolicyGateUnsatisfiedReason.ManagedSettingsRefresh ? this.lastInfo.managedSettingsFreshness : undefined;
|
|
226
|
+
if (!this.managedSettingsDialogVisibleKey && freshness?.state !== ManagedSettingsFreshnessState.Pending) {
|
|
227
|
+
this.managedSettingsDialogDismissedKey = undefined;
|
|
228
|
+
}
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (this.managedSettingsDialogVisibleKey || this.managedSettingsDialogDismissedKey === key) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
this.managedSettingsDialogVisibleKey = key;
|
|
235
|
+
void this.showManagedSettingsDialog().finally(() => {
|
|
236
|
+
this.managedSettingsDialogVisibleKey = undefined;
|
|
237
|
+
this.managedSettingsDialogDismissedKey = key;
|
|
238
|
+
this.maybeShowManagedSettingsDialog();
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
getManagedSettingsDialogKey() {
|
|
242
|
+
if (this.defaultAccountService.managedSettingsCompatibilityError) {
|
|
243
|
+
return ManagedSettingsFreshnessFailure.UpdateRequired;
|
|
244
|
+
}
|
|
245
|
+
const freshness = this.getBlockedManagedSettingsFreshness();
|
|
246
|
+
return freshness?.failure === ManagedSettingsFreshnessFailure.UpdateRequired ? undefined : freshness?.failure;
|
|
247
|
+
}
|
|
248
|
+
getBlockedManagedSettingsFreshness() {
|
|
249
|
+
const freshness = this.lastInfo.reason === AccountPolicyGateUnsatisfiedReason.ManagedSettingsRefresh ? this.lastInfo.managedSettingsFreshness : undefined;
|
|
250
|
+
return freshness?.state === ManagedSettingsFreshnessState.Blocked ? freshness : undefined;
|
|
251
|
+
}
|
|
252
|
+
showManagedSettingsDialog() {
|
|
253
|
+
const compatibilityError = this.defaultAccountService.managedSettingsCompatibilityError;
|
|
254
|
+
if (compatibilityError) {
|
|
255
|
+
return this.showManagedSettingsCompatibilityDialog(compatibilityError);
|
|
256
|
+
}
|
|
257
|
+
const freshness = this.getBlockedManagedSettingsFreshness();
|
|
258
|
+
return freshness && isManagedSettingsBlockedDialogFreshness(freshness) ? this.showManagedSettingsBlockedDialog(freshness) : Promise.resolve();
|
|
259
|
+
}
|
|
260
|
+
getManagedSettingsBlockedMessage(freshness) {
|
|
261
|
+
switch (freshness.failure) {
|
|
262
|
+
case ManagedSettingsFreshnessFailure.NoToken:
|
|
263
|
+
return localize(
|
|
264
|
+
19925,
|
|
265
|
+
"AI features are unavailable because {0} must refresh your organization's managed settings. Sign in to continue.",
|
|
266
|
+
this.productService.nameShort
|
|
267
|
+
);
|
|
268
|
+
case ManagedSettingsFreshnessFailure.NoUrl:
|
|
269
|
+
return localize(
|
|
270
|
+
19926,
|
|
271
|
+
"AI features are unavailable because {0} cannot locate your organization's managed settings service. Contact your administrator.",
|
|
272
|
+
this.productService.nameShort
|
|
273
|
+
);
|
|
274
|
+
case ManagedSettingsFreshnessFailure.RateLimited:
|
|
275
|
+
return localize(
|
|
276
|
+
19927,
|
|
277
|
+
"AI features are temporarily unavailable because your organization's managed settings service is rate limiting requests. Try again later."
|
|
278
|
+
);
|
|
279
|
+
case ManagedSettingsFreshnessFailure.HttpError:
|
|
280
|
+
return localize(
|
|
281
|
+
19928,
|
|
282
|
+
"AI features are unavailable because {0} could not refresh your organization's managed settings (HTTP {1}). Retry after checking your connection.",
|
|
283
|
+
this.productService.nameShort,
|
|
284
|
+
freshness.httpStatus
|
|
285
|
+
);
|
|
286
|
+
case ManagedSettingsFreshnessFailure.Malformed:
|
|
287
|
+
return localize(
|
|
288
|
+
19929,
|
|
289
|
+
"AI features are unavailable because {0} received an invalid managed settings response. Retry or contact your administrator.",
|
|
290
|
+
this.productService.nameShort
|
|
291
|
+
);
|
|
292
|
+
case ManagedSettingsFreshnessFailure.Network:
|
|
293
|
+
return localize(
|
|
294
|
+
19930,
|
|
295
|
+
"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.",
|
|
296
|
+
this.productService.nameShort
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
showManagedSettingsBlockedDialog(freshness) {
|
|
301
|
+
const buttons = [];
|
|
302
|
+
if (freshness.failure === ManagedSettingsFreshnessFailure.NoToken) {
|
|
303
|
+
buttons.push({
|
|
304
|
+
label: ( localize(19931, "Sign In")),
|
|
305
|
+
run: () => this.commandService.executeCommand(DEFAULT_ACCOUNT_SIGN_IN_COMMAND)
|
|
306
|
+
});
|
|
307
|
+
} else if (freshness.failure !== ManagedSettingsFreshnessFailure.NoUrl) {
|
|
308
|
+
buttons.push({
|
|
309
|
+
label: ( localize(19932, "Retry")),
|
|
310
|
+
run: () => {
|
|
311
|
+
void this.defaultAccountService.refresh({
|
|
312
|
+
forceRefresh: true,
|
|
313
|
+
retryManagedSettings: true
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
const title = freshness.failure === ManagedSettingsFreshnessFailure.Malformed ? ( localize(19933, "Invalid Managed Settings")) : ( localize(19934, "Managed Settings Unavailable"));
|
|
319
|
+
return this.dialogService.prompt({
|
|
320
|
+
type: Severity.Warning,
|
|
321
|
+
title,
|
|
322
|
+
message: this.getManagedSettingsBlockedMessage(freshness),
|
|
323
|
+
custom: true,
|
|
324
|
+
buttons,
|
|
325
|
+
cancelButton: ( localize(19935, "Close"))
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
showManagedSettingsCompatibilityDialog(error) {
|
|
329
|
+
const message = error.minimumClientVersion ? ( localize(
|
|
330
|
+
19936,
|
|
331
|
+
"Your version of {0} cannot enforce your organization's managed settings. Update {0} to version {1} or later to continue using AI features.",
|
|
332
|
+
this.productService.nameShort,
|
|
333
|
+
error.minimumClientVersion
|
|
334
|
+
)) : ( localize(
|
|
335
|
+
19937,
|
|
336
|
+
"Your version of {0} cannot enforce your organization's managed settings. Update {0} to continue using AI features.",
|
|
337
|
+
this.productService.nameShort
|
|
338
|
+
));
|
|
339
|
+
return this.dialogService.prompt({
|
|
340
|
+
type: Severity.Warning,
|
|
341
|
+
title: ( localize(19938, "Update Required")),
|
|
342
|
+
message,
|
|
343
|
+
custom: true,
|
|
344
|
+
buttons: [{
|
|
345
|
+
label: ( localize(19939, "Check for Updates")),
|
|
346
|
+
run: () => this.commandService.executeCommand("update.checkForUpdate")
|
|
347
|
+
}, {
|
|
348
|
+
label: ( localize(19940, "Learn More")),
|
|
349
|
+
run: () => this.openerService.open(( URI.parse("https://code.visualstudio.com/docs/enterprise/overview")))
|
|
350
|
+
}],
|
|
351
|
+
cancelButton: ( localize(19941, "Close"))
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
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));
|
|
356
|
+
|
|
357
|
+
export { AccountPolicyGateContribution };
|