mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
parent
f2bcf4c272
commit
2e74e3c951
|
@ -13,6 +13,7 @@ import { URL } from 'url';
|
|||
class GitHubGistProfileContentHandler implements vscode.ProfileContentHandler {
|
||||
|
||||
readonly name = vscode.l10n.t('GitHub');
|
||||
readonly description = vscode.l10n.t('gist');
|
||||
|
||||
private _octokit: Promise<Octokit> | undefined;
|
||||
private getOctokit(): Promise<Octokit> {
|
||||
|
|
|
@ -26,9 +26,10 @@ export class MainThreadProfileContentHandlers extends Disposable implements Main
|
|||
this.proxy = context.getProxy(ExtHostContext.ExtHostProfileContentHandlers);
|
||||
}
|
||||
|
||||
async $registerProfileContentHandler(id: string, name: string, extensionId: string): Promise<void> {
|
||||
async $registerProfileContentHandler(id: string, name: string, description: string | undefined, extensionId: string): Promise<void> {
|
||||
this.registeredHandlers.set(id, this.userDataProfileImportExportService.registerProfileContentHandler(id, {
|
||||
name,
|
||||
description,
|
||||
extensionId,
|
||||
saveProfile: async (name: string, content: string, token: CancellationToken) => {
|
||||
const result = await this.proxy.$saveProfile(id, name, content, token);
|
||||
|
|
|
@ -1087,7 +1087,7 @@ export interface ExtHostUriOpenersShape {
|
|||
}
|
||||
|
||||
export interface MainThreadProfileContentHandlersShape {
|
||||
$registerProfileContentHandler(id: string, name: string, extensionId: string): Promise<void>;
|
||||
$registerProfileContentHandler(id: string, name: string, description: string | undefined, extensionId: string): Promise<void>;
|
||||
$unregisterProfileContentHandler(id: string): Promise<void>;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ export class ExtHostProfileContentHandlers implements ExtHostProfileContentHandl
|
|||
}
|
||||
|
||||
this.handlers.set(id, handler);
|
||||
this.proxy.$registerProfileContentHandler(id, handler.name, extension.identifier.value);
|
||||
this.proxy.$registerProfileContentHandler(id, handler.name, handler.description, extension.identifier.value);
|
||||
|
||||
return toDisposable(() => {
|
||||
this.handlers.delete(id);
|
||||
|
|
|
@ -410,25 +410,11 @@ export class UserDataProfileImportExportService extends Disposable implements IU
|
|||
if (this.profileContentHandlers.size === 1) {
|
||||
return this.profileContentHandlers.values().next().value;
|
||||
}
|
||||
const linkHandlers: { id: string; label: string }[] = [];
|
||||
const fileHandlers: { id: string; label: string }[] = [];
|
||||
for (const [id, profileContentHandler] of this.profileContentHandlers) {
|
||||
if (profileContentHandler.extensionId) {
|
||||
linkHandlers.push({ id, label: profileContentHandler.name });
|
||||
} else {
|
||||
fileHandlers.push({ id, label: profileContentHandler.name });
|
||||
}
|
||||
}
|
||||
const options: QuickPickItem[] = [];
|
||||
if (linkHandlers.length) {
|
||||
options.push({ label: localize('link', "link"), type: 'separator' });
|
||||
options.push(...linkHandlers);
|
||||
for (const [id, profileContentHandler] of this.profileContentHandlers) {
|
||||
options.push({ id, label: profileContentHandler.name, description: profileContentHandler.description });
|
||||
}
|
||||
if (fileHandlers.length) {
|
||||
options.push({ label: localize('file', "file"), type: 'separator' });
|
||||
options.push(...fileHandlers);
|
||||
}
|
||||
const result = await this.quickInputService.pick(options,
|
||||
const result = await this.quickInputService.pick(options.reverse(),
|
||||
{
|
||||
title: localize('select profile content handler', "Export '{0}' profile as...", name),
|
||||
hideInput: true
|
||||
|
@ -599,6 +585,7 @@ export class UserDataProfileImportExportService extends Disposable implements IU
|
|||
class FileUserDataProfileContentHandler implements IUserDataProfileContentHandler {
|
||||
|
||||
readonly name = localize('local', "Local");
|
||||
readonly description = localize('file', "file");
|
||||
|
||||
constructor(
|
||||
@IFileDialogService private readonly fileDialogService: IFileDialogService,
|
||||
|
|
|
@ -112,6 +112,7 @@ export interface ISaveProfileResult {
|
|||
|
||||
export interface IUserDataProfileContentHandler {
|
||||
readonly name: string;
|
||||
readonly description?: string;
|
||||
readonly extensionId?: string;
|
||||
saveProfile(name: string, content: string, token: CancellationToken): Promise<ISaveProfileResult | null>;
|
||||
readProfile(idOrUri: string | URI, token: CancellationToken): Promise<string | null>;
|
||||
|
|
|
@ -7,6 +7,7 @@ declare module 'vscode' {
|
|||
|
||||
export interface ProfileContentHandler {
|
||||
readonly name: string;
|
||||
readonly description?: string;
|
||||
saveProfile(name: string, content: string, token: CancellationToken): Thenable<{ readonly id: string; readonly link: Uri } | null>;
|
||||
readProfile(idOrUri: string | Uri, token: CancellationToken): Thenable<string | null>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue