@@ -389,6 +389,22 @@ export class GlSearchInput extends GlElement {
389
389
this . searchHistoryPos = this . searchHistory . length - 1 ;
390
390
}
391
391
392
+ private padDate ( date : number ) {
393
+ let stringDate = date . toString ( ) ;
394
+ if ( stringDate . length < 2 ) {
395
+ stringDate = `0${ stringDate } ` ;
396
+ }
397
+ return stringDate ;
398
+ }
399
+
400
+ private handleInsertDateToken ( tokenPrefix : string ) {
401
+ const currentDate = new Date ( ) ;
402
+ const year = currentDate . getFullYear ( ) ;
403
+ const month = this . padDate ( currentDate . getMonth ( ) + 1 ) ;
404
+ const date = this . padDate ( currentDate . getDate ( ) ) ;
405
+ this . handleInsertToken ( `${ tokenPrefix } ${ year } -${ month } -${ date } ` ) ;
406
+ }
407
+
392
408
override render ( ) {
393
409
return html `< div class ="field ">
394
410
< div class ="controls controls__start ">
@@ -486,6 +502,33 @@ export class GlSearchInput extends GlElement {
486
502
Type < small > type:stash or is:stash</ small >
487
503
</ button >
488
504
</ menu-item >
505
+ < menu-item role ="none ">
506
+ < button
507
+ class ="menu-button "
508
+ type ="button "
509
+ @click ="${ ( ) => this . handleInsertDateToken ( 'date:' ) } "
510
+ >
511
+ Date < small > date:YYYY-MM-dd</ small >
512
+ </ button >
513
+ </ menu-item >
514
+ < menu-item role ="none ">
515
+ < button
516
+ class ="menu-button "
517
+ type ="button "
518
+ @click ="${ ( ) => this . handleInsertDateToken ( 'after:' ) } "
519
+ >
520
+ Date from < small > after:YYYY-MM-dd</ small >
521
+ </ button >
522
+ </ menu-item >
523
+ < menu-item role ="none ">
524
+ < button
525
+ class ="menu-button "
526
+ type ="button "
527
+ @click ="${ ( ) => this . handleInsertDateToken ( `before:` ) } "
528
+ >
529
+ Date to < small > before:YYYY-MM-dd</ small >
530
+ </ button >
531
+ </ menu-item >
489
532
</ div >
490
533
</ gl-popover >
491
534
</ div >
0 commit comments