Use checkbox option on auth dialog, fixes #91542

This commit is contained in:
Rachel Macfarlane
2020-02-26 09:50:49 -08:00
parent 02154d7ecf
commit bba707d60c

View File

@@ -75,48 +75,52 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
async $getSessionsPrompt(providerId: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean> {
const alwaysAllow = this.storageService.get(`${extensionId}-${providerId}`, StorageScope.GLOBAL);
if (alwaysAllow) {
return true;
return alwaysAllow === 'true';
}
const { choice } = await this.dialogService.show(
const { choice, checkboxChecked } = await this.dialogService.show(
Severity.Info,
nls.localize('confirmAuthenticationAccess', "The extension '{0}' is trying to access authentication information from {1}.", extensionName, providerName),
[nls.localize('cancel', "Cancel"), nls.localize('allow', "Allow"), nls.localize('alwaysAllow', "Always Allow"),],
{ cancelId: 0 }
[nls.localize('cancel', "Cancel"), nls.localize('allow', "Allow")],
{
cancelId: 0,
checkbox: {
label: nls.localize('neverAgain', "Don't Show Again")
}
}
);
switch (choice) {
case 1/** Allow */:
return true;
case 2 /** Always Allow */:
this.storageService.store(`${extensionId}-${providerId}`, 'true', StorageScope.GLOBAL);
return true;
default:
return false;
const allow = choice === 1;
if (checkboxChecked) {
this.storageService.store(`${extensionId}-${providerId}`, allow ? 'true' : 'false', StorageScope.GLOBAL);
}
return allow;
}
async $loginPrompt(providerId: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean> {
const alwaysAllow = this.storageService.get(`${extensionId}-${providerId}`, StorageScope.GLOBAL);
if (alwaysAllow) {
return true;
return alwaysAllow === 'true';
}
const { choice } = await this.dialogService.show(
const { choice, checkboxChecked } = await this.dialogService.show(
Severity.Info,
nls.localize('confirmLogin', "The extension '{0}' wants to sign in using {1}.", extensionName, providerName),
[nls.localize('cancel', "Cancel"), nls.localize('continue', "Continue"), nls.localize('neverAgain', "Don't Show Again")],
{ cancelId: 0 }
[nls.localize('cancel', "Cancel"), nls.localize('continue', "Continue")],
{
cancelId: 0,
checkbox: {
label: nls.localize('neverAgain', "Don't Show Again")
}
}
);
switch (choice) {
case 1/** Allow */:
return true;
case 2 /** Always Allow */:
this.storageService.store(`${extensionId}-${providerId}`, 'true', StorageScope.GLOBAL);
return true;
default:
return false;
const allow = choice === 1;
if (checkboxChecked) {
this.storageService.store(`${extensionId}-${providerId}`, allow ? 'true' : 'false', StorageScope.GLOBAL);
}
return allow;
}
}