Skip to content

Commit

Permalink
Use data instead of description for editScmType (#124)
Browse files Browse the repository at this point in the history
Also suppress persistence for editScmType

Since they're unlikely to change to the 'current source' again
  • Loading branch information
ejizba authored Mar 22, 2018
1 parent 9613127 commit 61269b3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions appservice/src/editScmType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { SiteConfigResource } from 'azure-arm-website/lib/models';
import * as vscode from 'vscode';
import { IAzureNode, IAzureUserInput, UserCancelledError } from 'vscode-azureextensionui';
import { IAzureNode, IAzureQuickPickItem, IAzureQuickPickOptions, IAzureUserInput, UserCancelledError } from 'vscode-azureextensionui';
import { connectToGitHub } from './connectToGitHub';
import { localize } from './localize';
import { ScmType } from './ScmType';
Expand All @@ -31,24 +31,27 @@ export async function editScmType(client: SiteClient, node: IAzureNode, outputCh
}

async function showScmPrompt(ui: IAzureUserInput, currentScmType: string): Promise<string> {
const placeHolder: string = localize('scmPrompt', 'Select a new source.');
const currentSource: string = localize('currentSource', '(Current source)');
const scmQuickPicks: vscode.QuickPickItem[] = [];
const scmQuickPicks: IAzureQuickPickItem<string | undefined>[] = [];
// generate quickPicks to not include current type
for (const scmQuickPick of Object.keys(ScmType)) {
if (scmQuickPick === currentScmType) {
for (const scmType of Object.keys(ScmType)) {
if (scmType === currentScmType) {
// put the current source at the top of the list
scmQuickPicks.unshift({ label: scmQuickPick, description: currentSource });
scmQuickPicks.unshift({ label: scmType, description: currentSource, data: undefined });
} else {
scmQuickPicks.push({ label: scmQuickPick, description: '' });
scmQuickPicks.push({ label: scmType, description: '', data: scmType });
}
}

const quickPick: vscode.QuickPickItem = await ui.showQuickPick(scmQuickPicks, { placeHolder: placeHolder });
if (quickPick.description === currentSource) {
const options: IAzureQuickPickOptions = {
placeHolder: localize('scmPrompt', 'Select a new source.'),
suppressPersistence: true
};
const newScmType: string | undefined = (await ui.showQuickPick(scmQuickPicks, options)).data;
if (newScmType === undefined) {
// if the user clicks the current source, treat it as a cancel
throw new UserCancelledError();
} else {
return quickPick.label;
return newScmType;
}
}

0 comments on commit 61269b3

Please sign in to comment.