@codingame/monaco-vscode-edit-sessions-service-override 25.1.2 → 26.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 +2 -2
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.js +521 -340
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsFileSystemProvider.js +20 -12
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsStorageService.js +192 -118
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsViews.js +91 -80
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.js +18 -18
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessionsLogService.js +8 -5
- package/vscode/src/vs/workbench/contrib/editSessions/common/workspaceStateSync.js +75 -35
- package/vscode/src/vs/workbench/services/workspaces/common/editSessionIdentityService.js +18 -11
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceIdentityService.js +13 -9
package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsFileSystemProvider.js
CHANGED
|
@@ -8,7 +8,9 @@ import { IEditSessionsStorageService } from '@codingame/monaco-vscode-api/vscode
|
|
|
8
8
|
import { NotSupportedError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
9
9
|
|
|
10
10
|
let EditSessionsFileSystemProvider = class EditSessionsFileSystemProvider {
|
|
11
|
-
static {
|
|
11
|
+
static {
|
|
12
|
+
this.SCHEMA = EDIT_SESSIONS_SCHEME;
|
|
13
|
+
}
|
|
12
14
|
constructor(editSessionsStorageService) {
|
|
13
15
|
this.editSessionsStorageService = editSessionsStorageService;
|
|
14
16
|
this.capabilities = FileSystemProviderCapabilities.Readonly + FileSystemProviderCapabilities.FileReadWrite;
|
|
@@ -20,13 +22,17 @@ let EditSessionsFileSystemProvider = class EditSessionsFileSystemProvider {
|
|
|
20
22
|
if (!match?.groups) {
|
|
21
23
|
throw FileSystemProviderErrorCode.FileNotFound;
|
|
22
24
|
}
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
+
const {
|
|
26
|
+
ref,
|
|
27
|
+
folderName,
|
|
28
|
+
filePath
|
|
29
|
+
} = match.groups;
|
|
30
|
+
const data = await this.editSessionsStorageService.read("editSessions", ref);
|
|
25
31
|
if (!data) {
|
|
26
32
|
throw FileSystemProviderErrorCode.FileNotFound;
|
|
27
33
|
}
|
|
28
34
|
const content = JSON.parse(data.content);
|
|
29
|
-
const change = content.folders.find(
|
|
35
|
+
const change = content.folders.find(f => f.name === folderName)?.workingChanges.find(change => change.relativeFilePath === filePath);
|
|
30
36
|
if (!change || change.type === ChangeType.Deletion) {
|
|
31
37
|
throw FileSystemProviderErrorCode.FileNotFound;
|
|
32
38
|
}
|
|
@@ -43,17 +49,19 @@ let EditSessionsFileSystemProvider = class EditSessionsFileSystemProvider {
|
|
|
43
49
|
size: content.byteLength
|
|
44
50
|
};
|
|
45
51
|
}
|
|
46
|
-
watch(resource, opts) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
async
|
|
50
|
-
async
|
|
52
|
+
watch(resource, opts) {
|
|
53
|
+
return Disposable.None;
|
|
54
|
+
}
|
|
55
|
+
async mkdir(resource) {}
|
|
56
|
+
async readdir(resource) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
async rename(from, to, opts) {}
|
|
60
|
+
async delete(resource, opts) {}
|
|
51
61
|
async writeFile() {
|
|
52
62
|
throw ( new NotSupportedError());
|
|
53
63
|
}
|
|
54
64
|
};
|
|
55
|
-
EditSessionsFileSystemProvider = ( __decorate([
|
|
56
|
-
( __param(0, IEditSessionsStorageService))
|
|
57
|
-
], EditSessionsFileSystemProvider));
|
|
65
|
+
EditSessionsFileSystemProvider = ( __decorate([( __param(0, IEditSessionsStorageService))], EditSessionsFileSystemProvider));
|
|
58
66
|
|
|
59
67
|
export { EditSessionsFileSystemProvider };
|
|
@@ -27,8 +27,12 @@ import { ISecretStorageService } from '@codingame/monaco-vscode-api/vscode/vs/pl
|
|
|
27
27
|
|
|
28
28
|
var EditSessionsWorkbenchService_1;
|
|
29
29
|
let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Disposable {
|
|
30
|
-
static {
|
|
31
|
-
|
|
30
|
+
static {
|
|
31
|
+
EditSessionsWorkbenchService_1 = this;
|
|
32
|
+
}
|
|
33
|
+
static {
|
|
34
|
+
this.CACHED_SESSION_STORAGE_KEY = "editSessionAccountPreference";
|
|
35
|
+
}
|
|
32
36
|
get isSignedIn() {
|
|
33
37
|
return this.existingSessionId !== undefined;
|
|
34
38
|
}
|
|
@@ -44,7 +48,19 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
44
48
|
get lastReadResources() {
|
|
45
49
|
return this._lastReadResources;
|
|
46
50
|
}
|
|
47
|
-
constructor(
|
|
51
|
+
constructor(
|
|
52
|
+
fileService,
|
|
53
|
+
storageService,
|
|
54
|
+
quickInputService,
|
|
55
|
+
authenticationService,
|
|
56
|
+
extensionService,
|
|
57
|
+
environmentService,
|
|
58
|
+
logService,
|
|
59
|
+
productService,
|
|
60
|
+
contextKeyService,
|
|
61
|
+
dialogService,
|
|
62
|
+
secretStorageService
|
|
63
|
+
) {
|
|
48
64
|
super();
|
|
49
65
|
this.fileService = fileService;
|
|
50
66
|
this.storageService = storageService;
|
|
@@ -63,74 +79,85 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
63
79
|
this._didSignOut = ( new Emitter());
|
|
64
80
|
this._lastWrittenResources = ( new Map());
|
|
65
81
|
this._lastReadResources = ( new Map());
|
|
66
|
-
this.serverConfiguration = this.productService[
|
|
67
|
-
this._register(
|
|
68
|
-
|
|
82
|
+
this.serverConfiguration = this.productService["editSessions.store"];
|
|
83
|
+
this._register(
|
|
84
|
+
this.authenticationService.onDidChangeSessions(e => this.onDidChangeSessions(e.event))
|
|
85
|
+
);
|
|
86
|
+
this._register(this.storageService.onDidChangeValue(
|
|
87
|
+
StorageScope.APPLICATION,
|
|
88
|
+
EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY,
|
|
89
|
+
this._store
|
|
90
|
+
)(() => this.onDidChangeStorage()));
|
|
69
91
|
this.registerSignInAction();
|
|
70
92
|
this.registerResetAuthenticationAction();
|
|
71
93
|
this.signedInContext = EDIT_SESSIONS_SIGNED_IN.bindTo(this.contextKeyService);
|
|
72
94
|
this.signedInContext.set(this.existingSessionId !== undefined);
|
|
73
95
|
}
|
|
74
96
|
async write(resource, content) {
|
|
75
|
-
await this.initialize(
|
|
97
|
+
await this.initialize("write", false);
|
|
76
98
|
if (!this.initialized) {
|
|
77
|
-
throw ( new Error(
|
|
99
|
+
throw ( new Error("Please sign in to store your edit session."));
|
|
78
100
|
}
|
|
79
|
-
if (typeof content !==
|
|
101
|
+
if (typeof content !== "string" && content.machine === undefined) {
|
|
80
102
|
content.machine = await this.getOrCreateCurrentMachineId();
|
|
81
103
|
}
|
|
82
|
-
content = typeof content ===
|
|
104
|
+
content = typeof content === "string" ? content : JSON.stringify(content);
|
|
83
105
|
const ref = await this.storeClient.writeResource(resource, content, null, undefined, createSyncHeaders(generateUuid()));
|
|
84
|
-
this._lastWrittenResources.set(resource, {
|
|
106
|
+
this._lastWrittenResources.set(resource, {
|
|
107
|
+
ref,
|
|
108
|
+
content
|
|
109
|
+
});
|
|
85
110
|
return ref;
|
|
86
111
|
}
|
|
87
112
|
async read(resource, ref) {
|
|
88
|
-
await this.initialize(
|
|
113
|
+
await this.initialize("read", false);
|
|
89
114
|
if (!this.initialized) {
|
|
90
|
-
throw ( new Error(
|
|
115
|
+
throw ( new Error("Please sign in to apply your latest edit session."));
|
|
91
116
|
}
|
|
92
117
|
let content;
|
|
93
118
|
const headers = createSyncHeaders(generateUuid());
|
|
94
119
|
try {
|
|
95
120
|
if (ref !== undefined) {
|
|
96
121
|
content = await this.storeClient?.resolveResourceContent(resource, ref, undefined, headers);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
122
|
+
} else {
|
|
99
123
|
const result = await this.storeClient?.readResource(resource, null, undefined, headers);
|
|
100
124
|
content = result?.content;
|
|
101
125
|
ref = result?.ref;
|
|
102
126
|
}
|
|
103
|
-
}
|
|
104
|
-
catch (ex) {
|
|
127
|
+
} catch (ex) {
|
|
105
128
|
this.logService.error(ex);
|
|
106
129
|
}
|
|
107
130
|
if (content !== undefined && content !== null && ref !== undefined) {
|
|
108
|
-
this._lastReadResources.set(resource, {
|
|
109
|
-
|
|
131
|
+
this._lastReadResources.set(resource, {
|
|
132
|
+
ref,
|
|
133
|
+
content
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
ref,
|
|
137
|
+
content
|
|
138
|
+
};
|
|
110
139
|
}
|
|
111
140
|
return undefined;
|
|
112
141
|
}
|
|
113
142
|
async delete(resource, ref) {
|
|
114
|
-
await this.initialize(
|
|
143
|
+
await this.initialize("write", false);
|
|
115
144
|
if (!this.initialized) {
|
|
116
145
|
throw ( new Error(`Unable to delete edit session with ref ${ref}.`));
|
|
117
146
|
}
|
|
118
147
|
try {
|
|
119
148
|
await this.storeClient?.deleteResource(resource, ref);
|
|
120
|
-
}
|
|
121
|
-
catch (ex) {
|
|
149
|
+
} catch (ex) {
|
|
122
150
|
this.logService.error(ex);
|
|
123
151
|
}
|
|
124
152
|
}
|
|
125
153
|
async list(resource) {
|
|
126
|
-
await this.initialize(
|
|
154
|
+
await this.initialize("read", false);
|
|
127
155
|
if (!this.initialized) {
|
|
128
156
|
throw ( new Error(`Unable to list edit sessions.`));
|
|
129
157
|
}
|
|
130
158
|
try {
|
|
131
159
|
return this.storeClient?.getAllResourceRefs(resource) ?? [];
|
|
132
|
-
}
|
|
133
|
-
catch (ex) {
|
|
160
|
+
} catch (ex) {
|
|
134
161
|
this.logService.error(ex);
|
|
135
162
|
}
|
|
136
163
|
return [];
|
|
@@ -150,14 +177,16 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
150
177
|
await this.extensionService.whenInstalledExtensionsRegistered();
|
|
151
178
|
if (!this.serverConfiguration?.url) {
|
|
152
179
|
throw ( new Error(
|
|
153
|
-
|
|
180
|
+
"Unable to initialize sessions sync as session sync preference is not configured in product.json."
|
|
154
181
|
));
|
|
155
182
|
}
|
|
156
183
|
if (this.storeClient === undefined) {
|
|
157
184
|
return false;
|
|
158
185
|
}
|
|
159
186
|
this._register(this.storeClient.onTokenFailed(() => {
|
|
160
|
-
this.logService.info(
|
|
187
|
+
this.logService.info(
|
|
188
|
+
"Clearing edit sessions authentication preference because of successive token failures."
|
|
189
|
+
);
|
|
161
190
|
this.clearAuthenticationPreference();
|
|
162
191
|
}));
|
|
163
192
|
if (this.machineClient === undefined) {
|
|
@@ -181,7 +210,7 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
181
210
|
return authenticationSession !== undefined;
|
|
182
211
|
}
|
|
183
212
|
async getMachineById(machineId) {
|
|
184
|
-
await this.initialize(
|
|
213
|
+
await this.initialize("read", false);
|
|
185
214
|
if (!this.cachedMachines) {
|
|
186
215
|
const machines = await this.machineClient.getMachines();
|
|
187
216
|
this.cachedMachines = machines.reduce((map, machine) => map.set(machine.id, machine.name), ( new Map()));
|
|
@@ -189,22 +218,29 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
189
218
|
return this.cachedMachines.get(machineId);
|
|
190
219
|
}
|
|
191
220
|
async getOrCreateCurrentMachineId() {
|
|
192
|
-
const currentMachineId = await this.machineClient.getMachines().then(
|
|
221
|
+
const currentMachineId = await this.machineClient.getMachines().then(machines => machines.find(m => m.isCurrent)?.id);
|
|
193
222
|
if (currentMachineId === undefined) {
|
|
194
223
|
await this.machineClient.addCurrentMachine();
|
|
195
|
-
return await this.machineClient.getMachines().then(
|
|
224
|
+
return await this.machineClient.getMachines().then(machines => machines.find(m => m.isCurrent).id);
|
|
196
225
|
}
|
|
197
226
|
return currentMachineId;
|
|
198
227
|
}
|
|
199
228
|
async getAuthenticationSession(reason, silent) {
|
|
200
229
|
if (this.existingSessionId) {
|
|
201
|
-
this.logService.info(
|
|
230
|
+
this.logService.info(
|
|
231
|
+
`Searching for existing authentication session with ID ${this.existingSessionId}`
|
|
232
|
+
);
|
|
202
233
|
const existingSession = await this.getExistingSession();
|
|
203
234
|
if (existingSession) {
|
|
204
|
-
this.logService.info(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
235
|
+
this.logService.info(
|
|
236
|
+
`Found existing authentication session with ID ${existingSession.session.id}`
|
|
237
|
+
);
|
|
238
|
+
return {
|
|
239
|
+
sessionId: existingSession.session.id,
|
|
240
|
+
token: existingSession.session.idToken ?? existingSession.session.accessToken,
|
|
241
|
+
providerId: existingSession.session.providerId
|
|
242
|
+
};
|
|
243
|
+
} else {
|
|
208
244
|
this._didSignOut.fire();
|
|
209
245
|
}
|
|
210
246
|
}
|
|
@@ -212,9 +248,15 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
212
248
|
this.logService.info(`Reusing user data sync enablement`);
|
|
213
249
|
const authenticationSessionInfo = await getCurrentAuthenticationSessionInfo(this.secretStorageService, this.productService);
|
|
214
250
|
if (authenticationSessionInfo !== undefined) {
|
|
215
|
-
this.logService.info(
|
|
251
|
+
this.logService.info(
|
|
252
|
+
`Using current authentication session with ID ${authenticationSessionInfo.id}`
|
|
253
|
+
);
|
|
216
254
|
this.existingSessionId = authenticationSessionInfo.id;
|
|
217
|
-
return {
|
|
255
|
+
return {
|
|
256
|
+
sessionId: authenticationSessionInfo.id,
|
|
257
|
+
token: authenticationSessionInfo.accessToken,
|
|
258
|
+
providerId: authenticationSessionInfo.providerId
|
|
259
|
+
};
|
|
218
260
|
}
|
|
219
261
|
}
|
|
220
262
|
if (silent) {
|
|
@@ -223,7 +265,11 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
223
265
|
const authenticationSession = await this.getAccountPreference(reason);
|
|
224
266
|
if (authenticationSession !== undefined) {
|
|
225
267
|
this.existingSessionId = authenticationSession.id;
|
|
226
|
-
return {
|
|
268
|
+
return {
|
|
269
|
+
sessionId: authenticationSession.id,
|
|
270
|
+
token: authenticationSession.idToken ?? authenticationSession.accessToken,
|
|
271
|
+
providerId: authenticationSession.providerId
|
|
272
|
+
};
|
|
227
273
|
}
|
|
228
274
|
return undefined;
|
|
229
275
|
}
|
|
@@ -232,19 +278,24 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
232
278
|
}
|
|
233
279
|
async getAccountPreference(reason) {
|
|
234
280
|
const disposables = ( new DisposableStore());
|
|
235
|
-
const quickpick = disposables.add(this.quickInputService.createQuickPick({
|
|
281
|
+
const quickpick = disposables.add(this.quickInputService.createQuickPick({
|
|
282
|
+
useSeparators: true
|
|
283
|
+
}));
|
|
236
284
|
quickpick.ok = false;
|
|
237
|
-
quickpick.placeholder = reason ===
|
|
285
|
+
quickpick.placeholder = reason === "read" ? ( localize(7545, "Select an account to restore your working changes from the cloud")) : ( localize(7546, "Select an account to store your working changes in the cloud"));
|
|
238
286
|
quickpick.ignoreFocusOut = true;
|
|
239
287
|
quickpick.items = await this.createQuickpickItems();
|
|
240
288
|
return ( new Promise((resolve, reject) => {
|
|
241
|
-
disposables.add(quickpick.onDidHide(
|
|
289
|
+
disposables.add(quickpick.onDidHide(e => {
|
|
242
290
|
reject(( new CancellationError()));
|
|
243
291
|
disposables.dispose();
|
|
244
292
|
}));
|
|
245
|
-
disposables.add(quickpick.onDidAccept(async
|
|
293
|
+
disposables.add(quickpick.onDidAccept(async e => {
|
|
246
294
|
const selection = quickpick.selectedItems[0];
|
|
247
|
-
const session =
|
|
295
|
+
const session = "provider" in selection ? {
|
|
296
|
+
...(await this.authenticationService.createSession(selection.provider.id, selection.provider.scopes)),
|
|
297
|
+
providerId: selection.provider.id
|
|
298
|
+
} : ("session" in selection ? selection.session : undefined);
|
|
248
299
|
resolve(session);
|
|
249
300
|
quickpick.hide();
|
|
250
301
|
}));
|
|
@@ -253,15 +304,24 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
253
304
|
}
|
|
254
305
|
async createQuickpickItems() {
|
|
255
306
|
const options = [];
|
|
256
|
-
options.push({
|
|
307
|
+
options.push({
|
|
308
|
+
type: "separator",
|
|
309
|
+
label: ( localize(7547, "Signed In"))
|
|
310
|
+
});
|
|
257
311
|
const sessions = await this.getAllSessions();
|
|
258
312
|
options.push(...sessions);
|
|
259
|
-
options.push({
|
|
313
|
+
options.push({
|
|
314
|
+
type: "separator",
|
|
315
|
+
label: ( localize(7548, "Others"))
|
|
316
|
+
});
|
|
260
317
|
for (const authenticationProvider of (await this.getAuthenticationProviders())) {
|
|
261
318
|
const signedInForProvider = ( sessions.some(account => account.session.providerId === authenticationProvider.id));
|
|
262
319
|
if (!signedInForProvider || this.authenticationService.getProvider(authenticationProvider.id).supportsMultipleAccounts) {
|
|
263
320
|
const providerName = this.authenticationService.getProvider(authenticationProvider.id).label;
|
|
264
|
-
options.push({
|
|
321
|
+
options.push({
|
|
322
|
+
label: ( localize(7549, "Sign in with {0}", providerName)),
|
|
323
|
+
provider: authenticationProvider
|
|
324
|
+
});
|
|
265
325
|
}
|
|
266
326
|
}
|
|
267
327
|
return options;
|
|
@@ -276,7 +336,10 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
276
336
|
const item = {
|
|
277
337
|
label: session.account.label,
|
|
278
338
|
description: this.authenticationService.getProvider(provider.id).label,
|
|
279
|
-
session: {
|
|
339
|
+
session: {
|
|
340
|
+
...session,
|
|
341
|
+
providerId: provider.id
|
|
342
|
+
}
|
|
280
343
|
};
|
|
281
344
|
accounts.set(item.session.account.id, item);
|
|
282
345
|
if (this.existingSessionId === session.id) {
|
|
@@ -292,38 +355,57 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
292
355
|
async getAuthenticationProviders() {
|
|
293
356
|
if (!this.serverConfiguration) {
|
|
294
357
|
throw ( new Error(
|
|
295
|
-
|
|
358
|
+
"Unable to get configured authentication providers as session sync preference is not configured in product.json."
|
|
296
359
|
));
|
|
297
360
|
}
|
|
298
361
|
const authenticationProviders = this.serverConfiguration.authenticationProviders;
|
|
299
362
|
const configuredAuthenticationProviders = ( Object.keys(authenticationProviders)).reduce((result, id) => {
|
|
300
|
-
result.push({
|
|
363
|
+
result.push({
|
|
364
|
+
id,
|
|
365
|
+
scopes: authenticationProviders[id].scopes
|
|
366
|
+
});
|
|
301
367
|
return result;
|
|
302
368
|
}, []);
|
|
303
369
|
const availableAuthenticationProviders = this.authenticationService.declaredProviders;
|
|
304
|
-
return configuredAuthenticationProviders.filter((
|
|
370
|
+
return configuredAuthenticationProviders.filter((
|
|
371
|
+
{
|
|
372
|
+
id
|
|
373
|
+
}
|
|
374
|
+
) => ( availableAuthenticationProviders.some(provider => provider.id === id)));
|
|
305
375
|
}
|
|
306
376
|
get existingSessionId() {
|
|
307
|
-
return this.storageService.get(
|
|
377
|
+
return this.storageService.get(
|
|
378
|
+
EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY,
|
|
379
|
+
StorageScope.APPLICATION
|
|
380
|
+
);
|
|
308
381
|
}
|
|
309
382
|
set existingSessionId(sessionId) {
|
|
310
383
|
this.logService.trace(`Saving authentication session preference for ID ${sessionId}.`);
|
|
311
384
|
if (sessionId === undefined) {
|
|
312
|
-
this.storageService.remove(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
385
|
+
this.storageService.remove(
|
|
386
|
+
EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY,
|
|
387
|
+
StorageScope.APPLICATION
|
|
388
|
+
);
|
|
389
|
+
} else {
|
|
390
|
+
this.storageService.store(
|
|
391
|
+
EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY,
|
|
392
|
+
sessionId,
|
|
393
|
+
StorageScope.APPLICATION,
|
|
394
|
+
StorageTarget.MACHINE
|
|
395
|
+
);
|
|
316
396
|
}
|
|
317
397
|
}
|
|
318
398
|
async getExistingSession() {
|
|
319
399
|
const accounts = await this.getAllSessions();
|
|
320
|
-
return accounts.find(
|
|
400
|
+
return accounts.find(account => account.session.id === this.existingSessionId);
|
|
321
401
|
}
|
|
322
402
|
async onDidChangeStorage() {
|
|
323
403
|
const newSessionId = this.existingSessionId;
|
|
324
404
|
const previousSessionId = this.authenticationInfo?.sessionId;
|
|
325
405
|
if (previousSessionId !== newSessionId) {
|
|
326
|
-
this.logService.trace(
|
|
406
|
+
this.logService.trace(
|
|
407
|
+
`Resetting authentication state because authentication session ID preference changed from ${previousSessionId} to ${newSessionId}.`
|
|
408
|
+
);
|
|
327
409
|
this.authenticationInfo = undefined;
|
|
328
410
|
this.initialized = false;
|
|
329
411
|
}
|
|
@@ -344,84 +426,76 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
344
426
|
return;
|
|
345
427
|
}
|
|
346
428
|
const that = this;
|
|
347
|
-
const id =
|
|
429
|
+
const id = "workbench.editSessions.actions.signIn";
|
|
348
430
|
const when = ( ContextKeyExpr.and(( ContextKeyExpr.equals(EDIT_SESSIONS_PENDING_KEY, false)), ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, false))));
|
|
349
|
-
this._register(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
{
|
|
431
|
+
this._register(
|
|
432
|
+
registerAction2(class ResetEditSessionAuthenticationAction extends Action2 {
|
|
433
|
+
constructor() {
|
|
434
|
+
super({
|
|
435
|
+
id,
|
|
436
|
+
title: ( localize(7550, "Turn on Cloud Changes...")),
|
|
437
|
+
category: EDIT_SESSION_SYNC_CATEGORY,
|
|
438
|
+
precondition: when,
|
|
439
|
+
menu: [{
|
|
440
|
+
id: MenuId.CommandPalette
|
|
441
|
+
}, {
|
|
360
442
|
id: MenuId.AccountsContext,
|
|
361
|
-
group:
|
|
362
|
-
when
|
|
443
|
+
group: "2_editSessions",
|
|
444
|
+
when
|
|
363
445
|
}]
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
async run() {
|
|
449
|
+
return await that.initialize("write", false);
|
|
450
|
+
}
|
|
451
|
+
})
|
|
452
|
+
);
|
|
370
453
|
this._register(( MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
371
|
-
group:
|
|
454
|
+
group: "2_editSessions",
|
|
372
455
|
command: {
|
|
373
456
|
id,
|
|
374
|
-
title: ( localize(
|
|
457
|
+
title: ( localize(7551, "Turn on Cloud Changes... (1)"))
|
|
375
458
|
},
|
|
376
459
|
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals(EDIT_SESSIONS_PENDING_KEY, true)), ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, false))))
|
|
377
460
|
})));
|
|
378
461
|
}
|
|
379
462
|
registerResetAuthenticationAction() {
|
|
380
463
|
const that = this;
|
|
381
|
-
this._register(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
{
|
|
464
|
+
this._register(
|
|
465
|
+
registerAction2(class ResetEditSessionAuthenticationAction extends Action2 {
|
|
466
|
+
constructor() {
|
|
467
|
+
super({
|
|
468
|
+
id: "workbench.editSessions.actions.resetAuth",
|
|
469
|
+
title: ( localize(7552, "Turn off Cloud Changes...")),
|
|
470
|
+
category: EDIT_SESSION_SYNC_CATEGORY,
|
|
471
|
+
precondition: ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, true)),
|
|
472
|
+
menu: [{
|
|
473
|
+
id: MenuId.CommandPalette
|
|
474
|
+
}, {
|
|
392
475
|
id: MenuId.AccountsContext,
|
|
393
|
-
group:
|
|
394
|
-
when: ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, true))
|
|
476
|
+
group: "2_editSessions",
|
|
477
|
+
when: ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, true))
|
|
395
478
|
}]
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
async run() {
|
|
482
|
+
const result = await that.dialogService.confirm({
|
|
483
|
+
message: ( localize(7553, "Do you want to disable storing working changes in the cloud?")),
|
|
484
|
+
checkbox: {
|
|
485
|
+
label: ( localize(7554, "Delete all stored data from the cloud."))
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
if (result.confirmed) {
|
|
489
|
+
if (result.checkboxChecked) {
|
|
490
|
+
that.storeClient?.deleteResource("editSessions", null);
|
|
491
|
+
}
|
|
492
|
+
that.clearAuthenticationPreference();
|
|
406
493
|
}
|
|
407
|
-
that.clearAuthenticationPreference();
|
|
408
494
|
}
|
|
409
|
-
}
|
|
410
|
-
|
|
495
|
+
})
|
|
496
|
+
);
|
|
411
497
|
}
|
|
412
498
|
};
|
|
413
|
-
EditSessionsWorkbenchService = EditSessionsWorkbenchService_1 = ( __decorate([
|
|
414
|
-
( __param(0, IFileService)),
|
|
415
|
-
( __param(1, IStorageService)),
|
|
416
|
-
( __param(2, IQuickInputService)),
|
|
417
|
-
( __param(3, IAuthenticationService)),
|
|
418
|
-
( __param(4, IExtensionService)),
|
|
419
|
-
( __param(5, IEnvironmentService)),
|
|
420
|
-
( __param(6, IEditSessionsLogService)),
|
|
421
|
-
( __param(7, IProductService)),
|
|
422
|
-
( __param(8, IContextKeyService)),
|
|
423
|
-
( __param(9, IDialogService)),
|
|
424
|
-
( __param(10, ISecretStorageService))
|
|
425
|
-
], EditSessionsWorkbenchService));
|
|
499
|
+
EditSessionsWorkbenchService = EditSessionsWorkbenchService_1 = ( __decorate([( __param(0, IFileService)), ( __param(1, IStorageService)), ( __param(2, IQuickInputService)), ( __param(3, IAuthenticationService)), ( __param(4, IExtensionService)), ( __param(5, IEnvironmentService)), ( __param(6, IEditSessionsLogService)), ( __param(7, IProductService)), ( __param(8, IContextKeyService)), ( __param(9, IDialogService)), ( __param(10, ISecretStorageService))], EditSessionsWorkbenchService));
|
|
426
500
|
|
|
427
501
|
export { EditSessionsWorkbenchService };
|