@@ -11,13 +11,13 @@ import { pageableToCollection } from '../../shared/utilities/collectionUtils'
1111import { CloudWatchLogs } from 'aws-sdk'
1212import { isValidResponse , StepEstimator } from '../../shared/wizards/wizard'
1313import { isNonNullable } from '../../shared/utilities/tsUtils'
14+ import {
15+ startLiveTailHelpUrl ,
16+ startLiveTailLogStreamNamesHelpUrl ,
17+ startLiveTailLogStreamPrefixHelpUrl ,
18+ } from '../../shared/constants'
1419
15- export enum LogStreamFilterType {
16- MENU = 'menu' ,
17- PREFIX = 'prefix' ,
18- SPECIFIC = 'specific' ,
19- ALL = 'all' ,
20- }
20+ export type LogStreamFilterType = 'menu' | 'prefix' | 'specific' | 'all'
2121
2222export interface LogStreamFilterResponse {
2323 readonly filter ?: string
@@ -26,7 +26,7 @@ export interface LogStreamFilterResponse {
2626
2727export class LogStreamFilterSubmenu extends Prompter < LogStreamFilterResponse > {
2828 private logStreamPrefixRegEx = / ^ [ ^ : * ] * $ /
29- private currentState : LogStreamFilterType = LogStreamFilterType . MENU
29+ private currentState : LogStreamFilterType = 'menu'
3030 private steps ?: [ current : number , total : number ]
3131 private region : string
3232 private logGroupArn : string
@@ -39,7 +39,7 @@ export class LogStreamFilterSubmenu extends Prompter<LogStreamFilterResponse> {
3939 }
4040
4141 public createMenuPrompter ( ) {
42- const helpUri = 'https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartLiveTail.html'
42+ const helpUri = startLiveTailHelpUrl
4343 const prompter = createQuickPick ( this . menuOptions , {
4444 title : 'Select LogStream filter type' ,
4545 buttons : createCommonButtons ( helpUri ) ,
@@ -52,24 +52,23 @@ export class LogStreamFilterSubmenu extends Prompter<LogStreamFilterResponse> {
5252 options . push ( {
5353 label : 'All' ,
5454 detail : 'Include log events from all LogStreams in the selected LogGroup' ,
55- data : LogStreamFilterType . ALL ,
55+ data : 'all' ,
5656 } )
5757 options . push ( {
5858 label : 'Specific' ,
5959 detail : 'Include log events from only a specific LogStream' ,
60- data : LogStreamFilterType . SPECIFIC ,
60+ data : 'specific' ,
6161 } )
6262 options . push ( {
6363 label : 'Prefix' ,
6464 detail : 'Include log events from LogStreams that begin with a provided prefix' ,
65- data : LogStreamFilterType . PREFIX ,
65+ data : 'prefix' ,
6666 } )
6767 return options
6868 }
6969
7070 public createLogStreamPrefixBox ( ) : InputBoxPrompter {
71- const helpUri =
72- 'https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartLiveTail.html#CWL-StartLiveTail-request-logStreamNamePrefixes'
71+ const helpUri = startLiveTailLogStreamPrefixHelpUrl
7372 return createInputBox ( {
7473 title : 'Enter LogStream prefix' ,
7574 placeholder : 'logStream prefix (case sensitive; empty matches all)' ,
@@ -90,8 +89,7 @@ export class LogStreamFilterSubmenu extends Prompter<LogStreamFilterResponse> {
9089 }
9190
9291 public createLogStreamSelector ( ) : QuickPickPrompter < string > {
93- const helpUri =
94- 'https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartLiveTail.html#CWL-StartLiveTail-request-logStreamNames'
92+ const helpUri = startLiveTailLogStreamNamesHelpUrl
9593 const client = new DefaultCloudWatchLogsClient ( this . region )
9694 const request : CloudWatchLogs . DescribeLogStreamsRequest = {
9795 logGroupIdentifier : this . logGroupArn ,
@@ -118,37 +116,37 @@ export class LogStreamFilterSubmenu extends Prompter<LogStreamFilterResponse> {
118116 protected async promptUser ( ) : Promise < PromptResult < LogStreamFilterResponse > > {
119117 while ( true ) {
120118 switch ( this . currentState ) {
121- case LogStreamFilterType . MENU : {
119+ case 'menu' : {
122120 const prompter = this . createMenuPrompter ( )
123121 this . steps && prompter . setSteps ( this . steps [ 0 ] , this . steps [ 1 ] )
124122
125123 const resp = await prompter . prompt ( )
126- if ( resp === LogStreamFilterType . PREFIX ) {
127- this . switchState ( LogStreamFilterType . PREFIX )
128- } else if ( resp === LogStreamFilterType . SPECIFIC ) {
129- this . switchState ( LogStreamFilterType . SPECIFIC )
130- } else if ( resp === LogStreamFilterType . ALL ) {
124+ if ( resp === 'prefix' ) {
125+ this . switchState ( 'prefix' )
126+ } else if ( resp === 'specific' ) {
127+ this . switchState ( 'specific' )
128+ } else if ( resp === 'all' ) {
131129 return { filter : undefined , type : resp }
132130 } else {
133131 return undefined
134132 }
135133
136134 break
137135 }
138- case LogStreamFilterType . PREFIX : {
136+ case 'prefix' : {
139137 const resp = await this . createLogStreamPrefixBox ( ) . prompt ( )
140138 if ( isValidResponse ( resp ) ) {
141- return { filter : resp , type : LogStreamFilterType . PREFIX }
139+ return { filter : resp , type : 'prefix' }
142140 }
143- this . switchState ( LogStreamFilterType . MENU )
141+ this . switchState ( 'menu' )
144142 break
145143 }
146- case LogStreamFilterType . SPECIFIC : {
144+ case 'specific' : {
147145 const resp = await this . createLogStreamSelector ( ) . prompt ( )
148146 if ( isValidResponse ( resp ) ) {
149- return { filter : resp , type : LogStreamFilterType . SPECIFIC }
147+ return { filter : resp , type : 'specific' }
150148 }
151- this . switchState ( LogStreamFilterType . MENU )
149+ this . switchState ( 'menu' )
152150 break
153151 }
154152 }
0 commit comments