Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doNotAskAgain button for Sign In and Select Organization windows #560

Merged
merged 7 commits into from
Feb 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/schema-association-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ async function autoDetectSchema(
workspaceFolder: vscode.WorkspaceFolder): Promise<vscode.Uri | undefined> {
const azureAccountApi = await getAzureAccountExtensionApi();

const doNotAskAgainSignIn = context.globalState.get<boolean>('doNotAskAgainSignIn');
logger.log(`doNotAskAgainSignIn status: ${doNotAskAgainSignIn}`);

// We could care less about the subscriptions; all we need are the sessions.
// However, there's no waitForSessions API, and waitForLogin returns before
// the underlying account information is guaranteed to finish loading.
// The next-best option is then waitForSubscriptions which, by definition,
// can't return until the sessions are also available.
// This only returns false if there is no login.
if (!(await azureAccountApi.waitForSubscriptions())) {
if (!(await azureAccountApi.waitForSubscriptions()) && !doNotAskAgainSignIn) {
winstliu marked this conversation as resolved.
Show resolved Hide resolved
logger.log(`Waiting for login`, 'SchemaDetection');

try {
Expand All @@ -117,7 +120,7 @@ async function autoDetectSchema(

// Don't await this message so that we can return the fallback schema instead of blocking.
// We'll detect the login in extension.ts and then re-request the schema.
void vscode.window.showInformationMessage(Messages.signInForEnhancedIntelliSense, Messages.signInLabel)
void vscode.window.showInformationMessage(Messages.signInForEnhancedIntelliSense, Messages.signInLabel, Messages.doNotAskAgain)
.then(async action => {
if (action === Messages.signInLabel) {
await vscode.window.withProgress({
Expand All @@ -126,6 +129,8 @@ async function autoDetectSchema(
}, async () => {
await vscode.commands.executeCommand("azure-account.login");
});
} else if (action === Messages.doNotAskAgain) {
await context.globalState.update('doNotAskAgainSignIn', true);
}
});

Expand Down Expand Up @@ -177,6 +182,13 @@ async function autoDetectSchema(
} else {
logger.log(`${workspaceFolder.name} has no remote URL or is not an Azure repo`, 'SchemaDetection');

const doNotAskAgainSelectOrg = context.globalState.get<boolean>('doNotAskAgainSelectOrg');
logger.log(`doNotAskAgainSelectOrg status: ${doNotAskAgainSelectOrg}`);
winstliu marked this conversation as resolved.
Show resolved Hide resolved

if (doNotAskAgainSelectOrg) {
return;
}

const azurePipelinesDetails = context.workspaceState.get<{
[folder: string]: { organization: string; tenant: string; }
}>('azurePipelinesDetails');
Expand All @@ -199,7 +211,7 @@ async function autoDetectSchema(
// We'll detect when they choose the organization in extension.ts and then re-request the schema.
void vscode.window.showInformationMessage(
format(Messages.selectOrganizationForEnhancedIntelliSense, workspaceFolder.name),
Messages.selectOrganizationLabel)
Messages.selectOrganizationLabel, Messages.doNotAskAgain)
.then(async action => {
if (action === Messages.selectOrganizationLabel) {
// Lazily construct list of organizations so that we can immediately show the quick pick,
Expand Down Expand Up @@ -237,6 +249,8 @@ async function autoDetectSchema(
});

selectOrganizationEvent.fire(workspaceFolder);
} else if (action === Messages.doNotAskAgain) {
await context.globalState.update('doNotAskAgainSelectOrg', true);
}
});
return undefined;
Expand Down