import { AzureWizardPromptStep , IAzureQuickPickItem } from 'vscode-azureextensionui' ; import { localize } from '../localize' ; import { createQuickPickFromJsons , getGitHubJsonResponse , gitHubOrgData } from './connectToGitHub' ; import { IConnectToGitHubWizardContext } from './IConnectToGitHubWizardContext' ; export class GitHubOrgListStep extends AzureWizardPromptStep < IConnectToGitHubWizardContext > { public async prompt ( context ) { const placeHolder = localize ( 'chooseOrg' , 'Choose organization.' ) ; context . orgData = ( await context . ui . showQuickPick ( this . getOrganizations ( context ) , { placeHolder } ) ) . data ; } public shouldPrompt ( context ) { return ! context . orgData ; } private async getOrganizations ( context ) { const [ userData ] = await getGitHubJsonResponse ( context , 'https://api.github.com/user' ) ; let quickPickItems = createQuickPickFromJsons ( userData , 'login' ) ; const [ orgData ] = await getGitHubJsonResponse ( context , 'https://api.github.com/user/orgs' ) ; quickPickItems = quickPickItems . concat ( createQuickPickFromJsons ( orgData , 'login' ) ) ; return quickPickItems ; } }