Refactor requireWorkspaceTrust to requestWorkspaceTrust
This commit is contained in:
parent
be5170cc19
commit
648ea3d1e0
12 changed files with 18 additions and 18 deletions
|
@ -39,7 +39,7 @@ export class TypeScriptVersionManager extends Disposable {
|
|||
}
|
||||
} else {
|
||||
setImmediate(() => {
|
||||
vscode.workspace.requireWorkspaceTrust({ modal: false })
|
||||
vscode.workspace.requestWorkspaceTrust({ modal: false })
|
||||
.then(trustState => {
|
||||
if (trustState === vscode.WorkspaceTrustState.Trusted && this.versionProvider.localVersion) {
|
||||
this.updateActiveVersion(this.versionProvider.localVersion);
|
||||
|
@ -120,7 +120,7 @@ export class TypeScriptVersionManager extends Disposable {
|
|||
description: version.displayName,
|
||||
detail: version.pathLabel,
|
||||
run: async () => {
|
||||
const trustState = await vscode.workspace.requireWorkspaceTrust();
|
||||
const trustState = await vscode.workspace.requestWorkspaceTrust();
|
||||
if (trustState === vscode.WorkspaceTrustState.Trusted) {
|
||||
await this.workspaceState.update(useWorkspaceTsdkStorageKey, true);
|
||||
const tsConfig = vscode.workspace.getConfiguration('typescript');
|
||||
|
|
|
@ -84,7 +84,7 @@ export interface IWorkspaceTrustService {
|
|||
onDidChangeTrustState: WorkspaceTrustChangeEvent;
|
||||
getWorkspaceTrustState(): WorkspaceTrustState;
|
||||
isWorkspaceTrustEnabled(): boolean;
|
||||
requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
||||
requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
||||
}
|
||||
|
||||
export interface IWorkspaceTrustUriInfo {
|
||||
|
|
2
src/vs/vscode.proposed.d.ts
vendored
2
src/vs/vscode.proposed.d.ts
vendored
|
@ -2836,7 +2836,7 @@ declare module 'vscode' {
|
|||
* @param options Optional object describing the properties of the
|
||||
* workspace trust request
|
||||
*/
|
||||
export function requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<WorkspaceTrustState>;
|
||||
export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<WorkspaceTrustState>;
|
||||
|
||||
/**
|
||||
* Event that fires when the trust state of the current workspace changes
|
||||
|
|
|
@ -208,8 +208,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
|
|||
|
||||
// --- trust ---
|
||||
|
||||
$requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||
return this._workspaceTrustService.requireWorkspaceTrust(options);
|
||||
$requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||
return this._workspaceTrustService.requestWorkspaceTrust(options);
|
||||
}
|
||||
|
||||
private getWorkspaceTrustState(): WorkspaceTrustState {
|
||||
|
|
|
@ -912,9 +912,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
|||
checkProposedApiEnabled(extension);
|
||||
return extHostWorkspace.trustState;
|
||||
},
|
||||
requireWorkspaceTrust: (options?: vscode.WorkspaceTrustRequestOptions) => {
|
||||
requestWorkspaceTrust: (options?: vscode.WorkspaceTrustRequestOptions) => {
|
||||
checkProposedApiEnabled(extension);
|
||||
return extHostWorkspace.requireWorkspaceTrust(options);
|
||||
return extHostWorkspace.requestWorkspaceTrust(options);
|
||||
},
|
||||
onDidChangeWorkspaceTrustState: (listener, thisArgs?, disposables?) => {
|
||||
return extHostWorkspace.onDidChangeWorkspaceTrustState(listener, thisArgs, disposables);
|
||||
|
|
|
@ -927,7 +927,7 @@ export interface MainThreadWorkspaceShape extends IDisposable {
|
|||
$saveAll(includeUntitled?: boolean): Promise<boolean>;
|
||||
$updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string; }[]): Promise<void>;
|
||||
$resolveProxy(url: string): Promise<string | undefined>;
|
||||
$requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
||||
$requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState>;
|
||||
}
|
||||
|
||||
export interface IFileChangeDto {
|
||||
|
|
|
@ -563,8 +563,8 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
|
|||
return this._workspaceTrustState;
|
||||
}
|
||||
|
||||
requireWorkspaceTrust(options?: vscode.WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||
return this._proxy.$requireWorkspaceTrust(options);
|
||||
requestWorkspaceTrust(options?: vscode.WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||
return this._proxy.$requestWorkspaceTrust(options);
|
||||
}
|
||||
|
||||
$onDidChangeWorkspaceTrustState(state: WorkspaceTrustStateChangeEvent): void {
|
||||
|
|
|
@ -116,7 +116,7 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
|
|||
|
||||
public static async promptForPermission(taskService: ITaskService, storageService: IStorageService, notificationService: INotificationService, workspaceTrustService: IWorkspaceTrustService,
|
||||
openerService: IOpenerService, workspaceTaskResult: Map<string, WorkspaceFolderTaskResult>) {
|
||||
const isWorkspaceTrusted = await workspaceTrustService.requireWorkspaceTrust({ modal: false }) === WorkspaceTrustState.Trusted;
|
||||
const isWorkspaceTrusted = await workspaceTrustService.requestWorkspaceTrust({ modal: false }) === WorkspaceTrustState.Trusted;
|
||||
if (!isWorkspaceTrusted) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
|
|||
// TODO: Confirm that this is the right lifecycle phase
|
||||
this.lifecycleService.when(LifecyclePhase.Eventually).then(() => {
|
||||
if (this.extensionsDisabledByTrustRequirement.length > 0) {
|
||||
this.workspaceTrustService.requireWorkspaceTrust({ modal: false });
|
||||
this.workspaceTrustService.requestWorkspaceTrust({ modal: false });
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -169,7 +169,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
|
|||
|
||||
const result = await Promises.settled(extensions.map(e => {
|
||||
if (this._isDisabledByTrustRequirement(e)) {
|
||||
return this.workspaceTrustService.requireWorkspaceTrust()
|
||||
return this.workspaceTrustService.requestWorkspaceTrust()
|
||||
.then(trustState => {
|
||||
if (trustState === WorkspaceTrustState.Trusted) {
|
||||
return this._setEnablement(e, newState);
|
||||
|
@ -442,7 +442,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
|
|||
|
||||
private _onDidInstallExtension({ local, error }: DidInstallExtensionEvent): void {
|
||||
if (local && !error && this._isDisabledByTrustRequirement(local)) {
|
||||
this.workspaceTrustService.requireWorkspaceTrust({ modal: false });
|
||||
this.workspaceTrustService.requestWorkspaceTrust({ modal: false });
|
||||
this._onEnablementChanged.fire([local]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
|
|||
protected async checkForWorkspaceTrust(manifest: IExtensionManifest): Promise<void> {
|
||||
if (getExtensionWorkspaceTrustRequirement(manifest) === 'onStart') {
|
||||
try {
|
||||
await this.workspaceTrustService.requireWorkspaceTrust({
|
||||
await this.workspaceTrustService.requestWorkspaceTrust({
|
||||
modal: true,
|
||||
message: localize('extensionInstallWorkspaceTrustMessage', "Enabling this extension requires a trusted workspace."),
|
||||
buttons: [
|
||||
|
|
|
@ -436,7 +436,7 @@ export class WorkspaceTrustService extends Disposable implements IWorkspaceTrust
|
|||
return this.configurationService.getValue<boolean>(WORKSPACE_TRUST_ENABLED) ?? false;
|
||||
}
|
||||
|
||||
async requireWorkspaceTrust(options: WorkspaceTrustRequestOptions = { modal: true }): Promise<WorkspaceTrustState> {
|
||||
async requestWorkspaceTrust(options: WorkspaceTrustRequestOptions = { modal: true }): Promise<WorkspaceTrustState> {
|
||||
// Trusted workspace
|
||||
if (this.currentTrustState === WorkspaceTrustState.Trusted) {
|
||||
return this.currentTrustState;
|
||||
|
|
|
@ -22,7 +22,7 @@ export class TestWorkspaceTrustService implements IWorkspaceTrustService {
|
|||
return true;
|
||||
}
|
||||
|
||||
requireWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||
requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Promise<WorkspaceTrustState> {
|
||||
return Promise.resolve(WorkspaceTrustState.Trusted);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue