@codingame/monaco-vscode-edit-sessions-service-override 11.1.2 → 12.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/index.d.ts +2 -1
- package/index.js +21 -1
- package/package.json +21 -7
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.d.ts +96 -0
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.js +171 -173
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsFileSystemProvider.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsFileSystemProvider.js +4 -3
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsStorageService.d.ts +80 -0
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsStorageService.js +72 -78
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsViews.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsViews.js +58 -68
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.d.ts +52 -0
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.js +13 -12
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessionsLogService.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessionsLogService.js +7 -6
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessionsStorageClient.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessionsStorageClient.js +2 -1
- package/vscode/src/vs/workbench/contrib/editSessions/common/workspaceStateSync.d.ts +33 -0
- package/vscode/src/vs/workbench/contrib/editSessions/common/workspaceStateSync.js +10 -7
- package/vscode/src/vs/workbench/services/workspaces/common/editSessionIdentityService.d.ts +21 -0
- package/vscode/src/vs/workbench/services/workspaces/common/editSessionIdentityService.js +3 -1
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceIdentityService.d.ts +13 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceIdentityService.js +3 -1
- package/editSessions.js +0 -20
package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsFileSystemProvider.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IDisposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { Event } from "vscode/vscode/vs/base/common/event";
|
|
3
|
+
import { URI } from "vscode/vscode/vs/base/common/uri";
|
|
4
|
+
import { FileSystemProviderCapabilities, FileType, IFileDeleteOptions, IFileOverwriteOptions, IFileSystemProviderWithFileReadWriteCapability, IStat, IWatchOptions } from "vscode/vscode/vs/platform/files/common/files";
|
|
5
|
+
import { IEditSessionsStorageService } from "vscode/vscode/vs/workbench/contrib/editSessions/common/editSessions.service";
|
|
6
|
+
export declare class EditSessionsFileSystemProvider implements IFileSystemProviderWithFileReadWriteCapability {
|
|
7
|
+
private editSessionsStorageService;
|
|
8
|
+
static readonly SCHEMA = "vscode-edit-sessions";
|
|
9
|
+
constructor(editSessionsStorageService: IEditSessionsStorageService);
|
|
10
|
+
readonly capabilities: FileSystemProviderCapabilities;
|
|
11
|
+
readFile(resource: URI): Promise<Uint8Array>;
|
|
12
|
+
stat(resource: URI): Promise<IStat>;
|
|
13
|
+
readonly onDidChangeCapabilities: Event<any>;
|
|
14
|
+
readonly onDidChangeFile: Event<any>;
|
|
15
|
+
watch(resource: URI, opts: IWatchOptions): IDisposable;
|
|
16
|
+
mkdir(resource: URI): Promise<void>;
|
|
17
|
+
readdir(resource: URI): Promise<[
|
|
18
|
+
string,
|
|
19
|
+
FileType
|
|
20
|
+
][]>;
|
|
21
|
+
rename(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void>;
|
|
22
|
+
delete(resource: URI, opts: IFileDeleteOptions): Promise<void>;
|
|
23
|
+
writeFile(): Promise<void>;
|
|
24
|
+
}
|
package/vscode/src/vs/workbench/contrib/editSessions/browser/editSessionsFileSystemProvider.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
4
|
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
-
import { FileSystemProviderErrorCode, FileType, FilePermission } from 'vscode/vscode/vs/platform/files/common/files';
|
|
5
|
+
import { FileSystemProviderCapabilities, FileSystemProviderErrorCode, FileType, FilePermission } from 'vscode/vscode/vs/platform/files/common/files';
|
|
5
6
|
import { EDIT_SESSIONS_SCHEME, ChangeType, decodeEditSessionFileContent } from '../common/editSessions.js';
|
|
6
7
|
import { IEditSessionsStorageService } from 'vscode/vscode/vs/workbench/contrib/editSessions/common/editSessions.service';
|
|
7
8
|
import { NotSupportedError } from 'vscode/vscode/vs/base/common/errors';
|
|
@@ -10,7 +11,7 @@ let EditSessionsFileSystemProvider = class EditSessionsFileSystemProvider {
|
|
|
10
11
|
static { this.SCHEMA = EDIT_SESSIONS_SCHEME; }
|
|
11
12
|
constructor(editSessionsStorageService) {
|
|
12
13
|
this.editSessionsStorageService = editSessionsStorageService;
|
|
13
|
-
this.capabilities =
|
|
14
|
+
this.capabilities = FileSystemProviderCapabilities.Readonly + FileSystemProviderCapabilities.FileReadWrite;
|
|
14
15
|
this.onDidChangeCapabilities = Event.None;
|
|
15
16
|
this.onDidChangeFile = Event.None;
|
|
16
17
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IContextKeyService } from "vscode/vscode/vs/platform/contextkey/common/contextkey.service";
|
|
3
|
+
import { IEnvironmentService } from "vscode/vscode/vs/platform/environment/common/environment.service";
|
|
4
|
+
import { IFileService } from "vscode/vscode/vs/platform/files/common/files.service";
|
|
5
|
+
import { IProductService } from "vscode/vscode/vs/platform/product/common/productService.service";
|
|
6
|
+
import { IQuickInputService } from "vscode/vscode/vs/platform/quickinput/common/quickInput.service";
|
|
7
|
+
import { IStorageService } from "vscode/vscode/vs/platform/storage/common/storage.service";
|
|
8
|
+
import { IResourceRefHandle } from "vscode/vscode/vs/platform/userDataSync/common/userDataSync";
|
|
9
|
+
import { IAuthenticationService } from "vscode/vscode/vs/workbench/services/authentication/common/authentication.service";
|
|
10
|
+
import { IExtensionService } from "vscode/vscode/vs/workbench/services/extensions/common/extensions.service";
|
|
11
|
+
import { EditSession, SyncResource } from "../common/editSessions.js";
|
|
12
|
+
import { IEditSessionsLogService } from "vscode/vscode/vs/workbench/contrib/editSessions/common/editSessions.service";
|
|
13
|
+
import { IEditSessionsStorageService } from "vscode/vscode/vs/workbench/contrib/editSessions/common/editSessions.service";
|
|
14
|
+
import { IDialogService } from "vscode/vscode/vs/platform/dialogs/common/dialogs.service";
|
|
15
|
+
import { EditSessionsStoreClient } from "../common/editSessionsStorageClient.js";
|
|
16
|
+
import { ISecretStorageService } from "vscode/vscode/vs/platform/secrets/common/secrets.service";
|
|
17
|
+
export declare class EditSessionsWorkbenchService extends Disposable implements IEditSessionsStorageService {
|
|
18
|
+
private readonly fileService;
|
|
19
|
+
private readonly storageService;
|
|
20
|
+
private readonly quickInputService;
|
|
21
|
+
private readonly authenticationService;
|
|
22
|
+
private readonly extensionService;
|
|
23
|
+
private readonly environmentService;
|
|
24
|
+
private readonly logService;
|
|
25
|
+
private readonly productService;
|
|
26
|
+
private readonly contextKeyService;
|
|
27
|
+
private readonly dialogService;
|
|
28
|
+
private readonly secretStorageService;
|
|
29
|
+
_serviceBrand: undefined;
|
|
30
|
+
readonly SIZE_LIMIT: number;
|
|
31
|
+
private serverConfiguration;
|
|
32
|
+
private machineClient;
|
|
33
|
+
private authenticationInfo;
|
|
34
|
+
private static CACHED_SESSION_STORAGE_KEY;
|
|
35
|
+
private initialized;
|
|
36
|
+
private readonly signedInContext;
|
|
37
|
+
get isSignedIn(): boolean;
|
|
38
|
+
private _didSignIn;
|
|
39
|
+
get onDidSignIn(): import("vscode/vscode/vs/base/common/event").Event<void>;
|
|
40
|
+
private _didSignOut;
|
|
41
|
+
get onDidSignOut(): import("vscode/vscode/vs/base/common/event").Event<void>;
|
|
42
|
+
private _lastWrittenResources;
|
|
43
|
+
get lastWrittenResources(): Map<SyncResource, {
|
|
44
|
+
ref: string;
|
|
45
|
+
content: string;
|
|
46
|
+
}>;
|
|
47
|
+
private _lastReadResources;
|
|
48
|
+
get lastReadResources(): Map<SyncResource, {
|
|
49
|
+
ref: string;
|
|
50
|
+
content: string;
|
|
51
|
+
}>;
|
|
52
|
+
storeClient: EditSessionsStoreClient | undefined;
|
|
53
|
+
constructor(fileService: IFileService, storageService: IStorageService, quickInputService: IQuickInputService, authenticationService: IAuthenticationService, extensionService: IExtensionService, environmentService: IEnvironmentService, logService: IEditSessionsLogService, productService: IProductService, contextKeyService: IContextKeyService, dialogService: IDialogService, secretStorageService: ISecretStorageService);
|
|
54
|
+
write(resource: SyncResource, content: string | EditSession): Promise<string>;
|
|
55
|
+
read(resource: SyncResource, ref: string | undefined): Promise<{
|
|
56
|
+
ref: string;
|
|
57
|
+
content: string;
|
|
58
|
+
} | undefined>;
|
|
59
|
+
delete(resource: SyncResource, ref: string | null): Promise<void>;
|
|
60
|
+
list(resource: SyncResource): Promise<IResourceRefHandle[]>;
|
|
61
|
+
initialize(reason: "read" | "write", silent?: boolean): Promise<boolean>;
|
|
62
|
+
private doInitialize;
|
|
63
|
+
private cachedMachines;
|
|
64
|
+
getMachineById(machineId: string): Promise<string | undefined>;
|
|
65
|
+
private getOrCreateCurrentMachineId;
|
|
66
|
+
private getAuthenticationSession;
|
|
67
|
+
private shouldAttemptEditSessionInit;
|
|
68
|
+
private getAccountPreference;
|
|
69
|
+
private createQuickpickItems;
|
|
70
|
+
private getAllSessions;
|
|
71
|
+
private getAuthenticationProviders;
|
|
72
|
+
private get existingSessionId();
|
|
73
|
+
private set existingSessionId(value);
|
|
74
|
+
private getExistingSession;
|
|
75
|
+
private onDidChangeStorage;
|
|
76
|
+
private clearAuthenticationPreference;
|
|
77
|
+
private onDidChangeSessions;
|
|
78
|
+
private registerSignInAction;
|
|
79
|
+
private registerResetAuthenticationAction;
|
|
80
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
4
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
4
5
|
import { registerAction2, Action2, MenuId, MenuRegistry } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
@@ -8,6 +9,7 @@ import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/commo
|
|
|
8
9
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
9
10
|
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
|
|
10
11
|
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
12
|
+
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
11
13
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
12
14
|
import { createSyncHeaders } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
13
15
|
import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
@@ -16,9 +18,9 @@ import { EDIT_SESSIONS_SIGNED_IN, EDIT_SESSIONS_PENDING_KEY, EDIT_SESSIONS_SIGNE
|
|
|
16
18
|
import { IEditSessionsLogService } from 'vscode/vscode/vs/workbench/contrib/editSessions/common/editSessions.service';
|
|
17
19
|
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
18
20
|
import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
|
|
19
|
-
import { getCurrentAuthenticationSessionInfo } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationService';
|
|
21
|
+
import { getCurrentAuthenticationSessionInfo } from '@codingame/monaco-vscode-3607c442-ae7a-594b-b840-038378c24fef-common/vscode/vs/workbench/services/authentication/browser/authenticationService';
|
|
20
22
|
import { isWeb } from 'vscode/vscode/vs/base/common/platform';
|
|
21
|
-
import { UserDataSyncMachinesService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSyncMachines';
|
|
23
|
+
import { UserDataSyncMachinesService } from '@codingame/monaco-vscode-a2719803-af40-5ae9-a29f-8a2231c33056-common/vscode/vs/platform/userDataSync/common/userDataSyncMachines';
|
|
22
24
|
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
23
25
|
import { CancellationError } from 'vscode/vscode/vs/base/common/errors';
|
|
24
26
|
import { ISecretStorageService } from 'vscode/vscode/vs/platform/secrets/common/secrets.service';
|
|
@@ -58,12 +60,12 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
58
60
|
this.SIZE_LIMIT = Math.floor(1024 * 1024 * 1.9);
|
|
59
61
|
this.serverConfiguration = this.productService['editSessions.store'];
|
|
60
62
|
this.initialized = false;
|
|
61
|
-
this._didSignIn = (
|
|
62
|
-
this._didSignOut = (
|
|
63
|
-
this._lastWrittenResources = (
|
|
64
|
-
this._lastReadResources = (
|
|
63
|
+
this._didSignIn = ( new Emitter());
|
|
64
|
+
this._didSignOut = ( new Emitter());
|
|
65
|
+
this._lastWrittenResources = ( new Map());
|
|
66
|
+
this._lastReadResources = ( new Map());
|
|
65
67
|
this._register(this.authenticationService.onDidChangeSessions((e) => this.onDidChangeSessions(e.event)));
|
|
66
|
-
this._register(this.storageService.onDidChangeValue(
|
|
68
|
+
this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY, this._store)(() => this.onDidChangeStorage()));
|
|
67
69
|
this.registerSignInAction();
|
|
68
70
|
this.registerResetAuthenticationAction();
|
|
69
71
|
this.signedInContext = EDIT_SESSIONS_SIGNED_IN.bindTo(this.contextKeyService);
|
|
@@ -72,7 +74,7 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
72
74
|
async write(resource, content) {
|
|
73
75
|
await this.initialize('write', false);
|
|
74
76
|
if (!this.initialized) {
|
|
75
|
-
throw (
|
|
77
|
+
throw ( new Error('Please sign in to store your edit session.'));
|
|
76
78
|
}
|
|
77
79
|
if (typeof content !== 'string' && content.machine === undefined) {
|
|
78
80
|
content.machine = await this.getOrCreateCurrentMachineId();
|
|
@@ -85,7 +87,7 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
85
87
|
async read(resource, ref) {
|
|
86
88
|
await this.initialize('read', false);
|
|
87
89
|
if (!this.initialized) {
|
|
88
|
-
throw (
|
|
90
|
+
throw ( new Error('Please sign in to apply your latest edit session.'));
|
|
89
91
|
}
|
|
90
92
|
let content;
|
|
91
93
|
const headers = createSyncHeaders(generateUuid());
|
|
@@ -111,7 +113,7 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
111
113
|
async delete(resource, ref) {
|
|
112
114
|
await this.initialize('write', false);
|
|
113
115
|
if (!this.initialized) {
|
|
114
|
-
throw (
|
|
116
|
+
throw ( new Error(`Unable to delete edit session with ref ${ref}.`));
|
|
115
117
|
}
|
|
116
118
|
try {
|
|
117
119
|
await this.storeClient?.deleteResource(resource, ref);
|
|
@@ -123,7 +125,7 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
123
125
|
async list(resource) {
|
|
124
126
|
await this.initialize('read', false);
|
|
125
127
|
if (!this.initialized) {
|
|
126
|
-
throw (
|
|
128
|
+
throw ( new Error(`Unable to list edit sessions.`));
|
|
127
129
|
}
|
|
128
130
|
try {
|
|
129
131
|
return this.storeClient?.getAllResourceRefs(resource) ?? [];
|
|
@@ -147,9 +149,9 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
147
149
|
async doInitialize(reason, silent) {
|
|
148
150
|
await this.extensionService.whenInstalledExtensionsRegistered();
|
|
149
151
|
if (!this.serverConfiguration?.url) {
|
|
150
|
-
throw (
|
|
152
|
+
throw ( new Error(
|
|
151
153
|
'Unable to initialize sessions sync as session sync preference is not configured in product.json.'
|
|
152
|
-
))
|
|
154
|
+
));
|
|
153
155
|
}
|
|
154
156
|
if (this.storeClient === undefined) {
|
|
155
157
|
return false;
|
|
@@ -159,14 +161,14 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
159
161
|
this.clearAuthenticationPreference();
|
|
160
162
|
}));
|
|
161
163
|
if (this.machineClient === undefined) {
|
|
162
|
-
this.machineClient = (
|
|
164
|
+
this.machineClient = ( new UserDataSyncMachinesService(
|
|
163
165
|
this.environmentService,
|
|
164
166
|
this.fileService,
|
|
165
167
|
this.storageService,
|
|
166
168
|
this.storeClient,
|
|
167
169
|
this.logService,
|
|
168
170
|
this.productService
|
|
169
|
-
))
|
|
171
|
+
));
|
|
170
172
|
}
|
|
171
173
|
if (this.authenticationInfo !== undefined) {
|
|
172
174
|
return true;
|
|
@@ -182,7 +184,7 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
182
184
|
await this.initialize('read', false);
|
|
183
185
|
if (!this.cachedMachines) {
|
|
184
186
|
const machines = await this.machineClient.getMachines();
|
|
185
|
-
this.cachedMachines = machines.reduce((map, machine) => map.set(machine.id, machine.name), (
|
|
187
|
+
this.cachedMachines = machines.reduce((map, machine) => map.set(machine.id, machine.name), ( new Map()));
|
|
186
188
|
}
|
|
187
189
|
return this.cachedMachines.get(machineId);
|
|
188
190
|
}
|
|
@@ -226,49 +228,47 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
226
228
|
return undefined;
|
|
227
229
|
}
|
|
228
230
|
shouldAttemptEditSessionInit() {
|
|
229
|
-
return isWeb && this.storageService.isNew(
|
|
231
|
+
return isWeb && this.storageService.isNew(StorageScope.APPLICATION) && this.storageService.isNew(StorageScope.WORKSPACE);
|
|
230
232
|
}
|
|
231
233
|
async getAccountPreference(reason) {
|
|
232
|
-
const disposables = (
|
|
234
|
+
const disposables = ( new DisposableStore());
|
|
233
235
|
const quickpick = disposables.add(this.quickInputService.createQuickPick({ useSeparators: true }));
|
|
234
236
|
quickpick.ok = false;
|
|
235
|
-
quickpick.placeholder = reason === 'read' ? ( localize(
|
|
237
|
+
quickpick.placeholder = reason === 'read' ? ( localize(5691, "Select an account to restore your working changes from the cloud")) : ( localize(5692, "Select an account to store your working changes in the cloud"));
|
|
236
238
|
quickpick.ignoreFocusOut = true;
|
|
237
239
|
quickpick.items = await this.createQuickpickItems();
|
|
238
|
-
return (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}))
|
|
252
|
-
);
|
|
240
|
+
return ( new Promise((resolve, reject) => {
|
|
241
|
+
disposables.add(quickpick.onDidHide((e) => {
|
|
242
|
+
reject(( new CancellationError()));
|
|
243
|
+
disposables.dispose();
|
|
244
|
+
}));
|
|
245
|
+
disposables.add(quickpick.onDidAccept(async (e) => {
|
|
246
|
+
const selection = quickpick.selectedItems[0];
|
|
247
|
+
const session = 'provider' in selection ? { ...(await this.authenticationService.createSession(selection.provider.id, selection.provider.scopes)), providerId: selection.provider.id } : ('session' in selection ? selection.session : undefined);
|
|
248
|
+
resolve(session);
|
|
249
|
+
quickpick.hide();
|
|
250
|
+
}));
|
|
251
|
+
quickpick.show();
|
|
252
|
+
}));
|
|
253
253
|
}
|
|
254
254
|
async createQuickpickItems() {
|
|
255
255
|
const options = [];
|
|
256
|
-
options.push({ type: 'separator', label: ( localize(
|
|
256
|
+
options.push({ type: 'separator', label: ( localize(5693, "Signed In")) });
|
|
257
257
|
const sessions = await this.getAllSessions();
|
|
258
258
|
options.push(...sessions);
|
|
259
|
-
options.push({ type: 'separator', label: ( localize(
|
|
259
|
+
options.push({ type: 'separator', label: ( localize(5694, "Others")) });
|
|
260
260
|
for (const authenticationProvider of (await this.getAuthenticationProviders())) {
|
|
261
|
-
const signedInForProvider = (
|
|
261
|
+
const signedInForProvider = ( sessions.some(account => account.session.providerId === authenticationProvider.id));
|
|
262
262
|
if (!signedInForProvider || this.authenticationService.getProvider(authenticationProvider.id).supportsMultipleAccounts) {
|
|
263
263
|
const providerName = this.authenticationService.getProvider(authenticationProvider.id).label;
|
|
264
|
-
options.push({ label: ( localize(
|
|
264
|
+
options.push({ label: ( localize(5695, "Sign in with {0}", providerName)), provider: authenticationProvider });
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
return options;
|
|
268
268
|
}
|
|
269
269
|
async getAllSessions() {
|
|
270
270
|
const authenticationProviders = await this.getAuthenticationProviders();
|
|
271
|
-
const accounts = (
|
|
271
|
+
const accounts = ( new Map());
|
|
272
272
|
let currentSession;
|
|
273
273
|
for (const provider of authenticationProviders) {
|
|
274
274
|
const sessions = await this.authenticationService.getSessions(provider.id, provider.scopes);
|
|
@@ -287,32 +287,32 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
287
287
|
if (currentSession !== undefined) {
|
|
288
288
|
accounts.set(currentSession.session.account.id, currentSession);
|
|
289
289
|
}
|
|
290
|
-
return [...(
|
|
290
|
+
return [...( accounts.values())].sort((a, b) => a.label.localeCompare(b.label));
|
|
291
291
|
}
|
|
292
292
|
async getAuthenticationProviders() {
|
|
293
293
|
if (!this.serverConfiguration) {
|
|
294
|
-
throw (
|
|
294
|
+
throw ( new Error(
|
|
295
295
|
'Unable to get configured authentication providers as session sync preference is not configured in product.json.'
|
|
296
|
-
))
|
|
296
|
+
));
|
|
297
297
|
}
|
|
298
298
|
const authenticationProviders = this.serverConfiguration.authenticationProviders;
|
|
299
|
-
const configuredAuthenticationProviders = (
|
|
299
|
+
const configuredAuthenticationProviders = ( Object.keys(authenticationProviders)).reduce((result, id) => {
|
|
300
300
|
result.push({ id, scopes: authenticationProviders[id].scopes });
|
|
301
301
|
return result;
|
|
302
302
|
}, []);
|
|
303
303
|
const availableAuthenticationProviders = this.authenticationService.declaredProviders;
|
|
304
|
-
return configuredAuthenticationProviders.filter(({ id }) => (
|
|
304
|
+
return configuredAuthenticationProviders.filter(({ id }) => ( availableAuthenticationProviders.some(provider => provider.id === id)));
|
|
305
305
|
}
|
|
306
306
|
get existingSessionId() {
|
|
307
|
-
return this.storageService.get(EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY,
|
|
307
|
+
return this.storageService.get(EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY, StorageScope.APPLICATION);
|
|
308
308
|
}
|
|
309
309
|
set existingSessionId(sessionId) {
|
|
310
310
|
this.logService.trace(`Saving authentication session preference for ID ${sessionId}.`);
|
|
311
311
|
if (sessionId === undefined) {
|
|
312
|
-
this.storageService.remove(EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY,
|
|
312
|
+
this.storageService.remove(EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY, StorageScope.APPLICATION);
|
|
313
313
|
}
|
|
314
314
|
else {
|
|
315
|
-
this.storageService.store(EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY, sessionId,
|
|
315
|
+
this.storageService.store(EditSessionsWorkbenchService_1.CACHED_SESSION_STORAGE_KEY, sessionId, StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
async getExistingSession() {
|
|
@@ -342,15 +342,12 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
342
342
|
registerSignInAction() {
|
|
343
343
|
const that = this;
|
|
344
344
|
const id = 'workbench.editSessions.actions.signIn';
|
|
345
|
-
const when = (
|
|
346
|
-
(ContextKeyExpr.equals(EDIT_SESSIONS_PENDING_KEY, false)),
|
|
347
|
-
(ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, false))
|
|
348
|
-
)));
|
|
345
|
+
const when = ( ContextKeyExpr.and(( ContextKeyExpr.equals(EDIT_SESSIONS_PENDING_KEY, false)), ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, false))));
|
|
349
346
|
this._register(registerAction2(class ResetEditSessionAuthenticationAction extends Action2 {
|
|
350
347
|
constructor() {
|
|
351
348
|
super({
|
|
352
349
|
id,
|
|
353
|
-
title: ( localize(
|
|
350
|
+
title: ( localize(5696, 'Turn on Cloud Changes...')),
|
|
354
351
|
category: EDIT_SESSION_SYNC_CATEGORY,
|
|
355
352
|
precondition: when,
|
|
356
353
|
menu: [{
|
|
@@ -367,17 +364,14 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
367
364
|
return await that.initialize('write', false);
|
|
368
365
|
}
|
|
369
366
|
}));
|
|
370
|
-
this._register((
|
|
367
|
+
this._register(( MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
371
368
|
group: '2_editSessions',
|
|
372
369
|
command: {
|
|
373
370
|
id,
|
|
374
|
-
title: ( localize(
|
|
371
|
+
title: ( localize(5697, 'Turn on Cloud Changes... (1)')),
|
|
375
372
|
},
|
|
376
|
-
when: (
|
|
377
|
-
|
|
378
|
-
(ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, false))
|
|
379
|
-
)))
|
|
380
|
-
}))));
|
|
373
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals(EDIT_SESSIONS_PENDING_KEY, true)), ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, false))))
|
|
374
|
+
})));
|
|
381
375
|
}
|
|
382
376
|
registerResetAuthenticationAction() {
|
|
383
377
|
const that = this;
|
|
@@ -385,23 +379,23 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
385
379
|
constructor() {
|
|
386
380
|
super({
|
|
387
381
|
id: 'workbench.editSessions.actions.resetAuth',
|
|
388
|
-
title: ( localize(
|
|
382
|
+
title: ( localize(5698, 'Turn off Cloud Changes...')),
|
|
389
383
|
category: EDIT_SESSION_SYNC_CATEGORY,
|
|
390
|
-
precondition: (
|
|
384
|
+
precondition: ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, true)),
|
|
391
385
|
menu: [{
|
|
392
386
|
id: MenuId.CommandPalette,
|
|
393
387
|
},
|
|
394
388
|
{
|
|
395
389
|
id: MenuId.AccountsContext,
|
|
396
390
|
group: '2_editSessions',
|
|
397
|
-
when: (
|
|
391
|
+
when: ( ContextKeyExpr.equals(EDIT_SESSIONS_SIGNED_IN_KEY, true)),
|
|
398
392
|
}]
|
|
399
393
|
});
|
|
400
394
|
}
|
|
401
395
|
async run() {
|
|
402
396
|
const result = await that.dialogService.confirm({
|
|
403
|
-
message: ( localize(
|
|
404
|
-
checkbox: { label: ( localize(
|
|
397
|
+
message: ( localize(5699, 'Do you want to disable storing working changes in the cloud?')),
|
|
398
|
+
checkbox: { label: ( localize(5700, 'Delete all stored data from the cloud.')) }
|
|
405
399
|
});
|
|
406
400
|
if (result.confirmed) {
|
|
407
401
|
if (result.checkboxChecked) {
|
|
@@ -413,18 +407,18 @@ let EditSessionsWorkbenchService = class EditSessionsWorkbenchService extends Di
|
|
|
413
407
|
}));
|
|
414
408
|
}
|
|
415
409
|
};
|
|
416
|
-
EditSessionsWorkbenchService = EditSessionsWorkbenchService_1 = (
|
|
417
|
-
(
|
|
418
|
-
(
|
|
419
|
-
(
|
|
420
|
-
(
|
|
421
|
-
(
|
|
422
|
-
(
|
|
423
|
-
(
|
|
424
|
-
(
|
|
425
|
-
(
|
|
426
|
-
(
|
|
427
|
-
(
|
|
428
|
-
], EditSessionsWorkbenchService))
|
|
410
|
+
EditSessionsWorkbenchService = EditSessionsWorkbenchService_1 = ( __decorate([
|
|
411
|
+
( __param(0, IFileService)),
|
|
412
|
+
( __param(1, IStorageService)),
|
|
413
|
+
( __param(2, IQuickInputService)),
|
|
414
|
+
( __param(3, IAuthenticationService)),
|
|
415
|
+
( __param(4, IExtensionService)),
|
|
416
|
+
( __param(5, IEnvironmentService)),
|
|
417
|
+
( __param(6, IEditSessionsLogService)),
|
|
418
|
+
( __param(7, IProductService)),
|
|
419
|
+
( __param(8, IContextKeyService)),
|
|
420
|
+
( __param(9, IDialogService)),
|
|
421
|
+
( __param(10, ISecretStorageService))
|
|
422
|
+
], EditSessionsWorkbenchService));
|
|
429
423
|
|
|
430
424
|
export { EditSessionsWorkbenchService };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IInstantiationService } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
import { ViewContainer } from "vscode/vscode/vs/workbench/common/views";
|
|
4
|
+
export declare class EditSessionsDataViews extends Disposable {
|
|
5
|
+
private readonly instantiationService;
|
|
6
|
+
constructor(container: ViewContainer, instantiationService: IInstantiationService);
|
|
7
|
+
private registerViews;
|
|
8
|
+
}
|