Skip to content
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
21 changes: 14 additions & 7 deletions src/commands/logStream/RevisionListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ import { localize } from "../../utils/localize";
import { IStreamLogsContext } from "./IStreamLogsContext";

export class RevisionListStep extends AzureWizardPromptStep<IStreamLogsContext> {
private revisions: Revision[] | undefined;

public async prompt(context: IStreamLogsContext): Promise<void> {
const placeHolder: string = localize('selectRevision', 'Select a revision');
context.revision = (await context.ui.showQuickPick(this.getPicks(context), { placeHolder })).data;
context.revision = (await context.ui.showQuickPick(await this.getPicks(context), { placeHolder })).data;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally you don't want to await this.getPicks in showQuickPick. showQuickPick is designed to handle promises so that it will show a loading bar while the promise resolves. If you await it, there'll be a small gap where the quickpick UI doesn't show up while it's loading the picks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops accidently added that ahaha.

}

public async configureBeforePrompt(context: IStreamLogsContext): Promise<void> {
const picks = await this.getPicks(context);
if (context.containerApp.revisionsMode === 'Multiple' && picks.length === 1) {
context.revision = picks[0].data;
} else if (context.containerApp.revisionsMode === 'Single') {
if (context.containerApp.revisionsMode === 'Single') {
const client: ContainerAppsAPIClient = await createContainerAppsAPIClient([context, createSubscriptionContext(context.subscription)]);
const revisionData = await client.containerAppsRevisions.getRevision(context.resourceGroupName, context.containerApp.name, nonNullProp(context.containerApp, 'latestRevisionName'));
context.revision = revisionData;
} else {
const picks = await this.getPicks(context);
if (picks.length === 1) {
context.revision = picks[0].data;
}
}
}

Expand All @@ -34,8 +38,11 @@ export class RevisionListStep extends AzureWizardPromptStep<IStreamLogsContext>

private async getPicks(context: IStreamLogsContext): Promise<IAzureQuickPickItem<Revision>[]> {
const client: ContainerAppsAPIClient = await createContainerAppsAPIClient([context, createSubscriptionContext(context.subscription)]);
const revisions = (await uiUtils.listAllIterator(client.containerAppsRevisions.listRevisions(context.resourceGroupName, context.containerApp.name)));
return revisions.map(r => {
if (!this.revisions) {
this.revisions = (await uiUtils.listAllIterator(client.containerAppsRevisions.listRevisions(context.resourceGroupName, context.containerApp.name)));
}

return this.revisions.map(r => {
const date = r.createdTime;
return { label: nonNullProp(r, 'name'), description: dayjs(date).fromNow(), data: r };
});
Expand Down