-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathStreamListStep.ts
More file actions
36 lines (31 loc) · 1.71 KB
/
StreamListStep.ts
File metadata and controls
36 lines (31 loc) · 1.71 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullValue } from "@microsoft/vscode-azext-utils";
import { localize } from "../../utils/localize";
import { IStreamLogsContext } from "./IStreamLogsContext";
import { ILogStream, getActiveLogStreams } from "./logStreamRequest";
export class StreamListStep extends AzureWizardPromptStep<IStreamLogsContext> {
public async prompt(context: IStreamLogsContext): Promise<void> {
const placeHolder: string = localize('selectStream', 'Select a stream');
const picks: IAzureQuickPickItem<ILogStream | undefined>[] = this.getPicks(context);
if (picks.length > 1) {
picks.push({ label: localize('stopAll', 'Stop all Streams'), data: undefined });
}
context.logStreamToStop = (await context.ui.showQuickPick(picks, { placeHolder, enableGrouping: true, suppressPersistence: true })).data;
}
public shouldPrompt(context: IStreamLogsContext): boolean {
return !context.logStreamToStop;
}
private getPicks(context: IStreamLogsContext): IAzureQuickPickItem<ILogStream>[] {
const logStreams = getActiveLogStreams(context);
return Array.from(logStreams).map(l => {
return {
label: nonNullValue(l[1].data.container),
group: l[1].data.replica,
data: l[1] as ILogStream,
};
});
}
}