-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRegistryRepositoriesListBaseStep.ts
More file actions
43 lines (36 loc) · 2.2 KB
/
RegistryRepositoriesListBaseStep.ts
File metadata and controls
43 lines (36 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep, type ConfirmationViewProperty } from "@microsoft/vscode-azext-utils";
import { type QuickPickItem } from "vscode";
import { loadMoreQp, noMatchingResourcesQp, type QuickPicksCache } from "../../../../constants";
import { localize } from "../../../../utils/localize";
import { type ContainerRegistryImageSourceContext } from "./ContainerRegistryImageSourceContext";
export abstract class RegistryRepositoriesListStepBase extends AzureWizardPromptStep<ContainerRegistryImageSourceContext> {
public async prompt(context: ContainerRegistryImageSourceContext): Promise<void> {
const picksCache: QuickPicksCache = { cache: [], next: null };
const placeHolder: string = localize('selectRepo', 'Select a repository');
let result: QuickPickItem | undefined;
do {
if (result === noMatchingResourcesQp) {
// Don't need to store any data since there's only one pick available
await context.ui.showQuickPick([noMatchingResourcesQp], { placeHolder });
} else {
result = await context.ui.showQuickPick(this.getPicks(context, picksCache), { placeHolder });
}
} while (result === noMatchingResourcesQp || result === loadMoreQp)
context.repositoryName = result.label;
}
public shouldPrompt(context: ContainerRegistryImageSourceContext): boolean {
return !context.repositoryName;
}
public confirmationViewProperty(context: ContainerRegistryImageSourceContext): ConfirmationViewProperty {
return {
name: localize('repository', 'Repository'),
value: context.repositoryName ?? '',
contextPropertyName: 'repositoryName'
}
}
public abstract getPicks(context: ContainerRegistryImageSourceContext, picksCache: QuickPicksCache | undefined): Promise<QuickPickItem[]>
}