@@ -4,7 +4,7 @@ import { customElement, property, state } from 'lit/decorators.js';
44import { classMap } from 'lit/directives/class-map.js' ;
55import { when } from 'lit/directives/when.js' ;
66import type { Commands } from '../../../../../constants.commands' ;
7- import type { LaunchpadItem } from '../../../../../plus/launchpad/launchpadProvider ' ;
7+ import type { LaunchpadCommandArgs } from '../../../../../plus/launchpad/launchpad ' ;
88import {
99 actionGroupMap ,
1010 launchpadCategoryToGroupMap ,
@@ -422,10 +422,7 @@ export abstract class GlBranchCardBase extends GlElement {
422422 }
423423
424424 get cardIndicator ( ) {
425- if ( this . launchpadItem && this . pr ?. state === 'opened' ) {
426- return getLaunchpadItemGrouping ( this . launchpadItem . category ) ?? 'base' ;
427- }
428- return 'base' ;
425+ return getLaunchpadItemGrouping ( getLaunchpadItemGroup ( this . pr , this . launchpadItem ) ) ?? 'base' ;
429426 }
430427
431428 get branchCardIndicator ( ) {
@@ -715,22 +712,17 @@ export abstract class GlBranchCardBase extends GlElement {
715712 return nothing ;
716713 }
717714
718- let indicator : GlCard [ 'indicator' ] ;
719- if ( this . branch . opened ) {
720- if ( this . launchpadItem && this . pr ?. state === 'opened' ) {
721- indicator = getLaunchpadItemGrouping ( this . launchpadItem . category ) ?? 'base' ;
722- } else {
723- indicator = 'base' ;
724- }
725- }
715+ const indicator : GlCard [ 'indicator' ] = this . branch . opened
716+ ? getLaunchpadItemGrouping ( getLaunchpadItemGroup ( this . pr , this . launchpadItem ) ) ?? 'base'
717+ : undefined ;
726718
727719 const actions = this . renderPrActions ( ) ;
728720 return html `
729721 < gl-work-item ?expanded =${ this . expanded } ?nested =${ ! this . branch . opened } .indicator=${ indicator } >
730722 < div class ="branch-item__section ">
731723 < p class ="branch-item__grouping ">
732724 < span class ="branch-item__icon ">
733- < pr-icon state =${ this . pr . state } pr-id =${ this . pr . id } > </ pr-icon >
725+ < pr-icon ?draft = ${ this . pr . draft } state =${ this . pr . state } pr-id=${ this . pr . id } > </ pr-icon >
734726 </ span >
735727 < a href =${ this . pr . url } class ="branch-item__name branch-item__name--secondary"
736728 > ${ this . pr . title } </ a
@@ -745,47 +737,43 @@ export abstract class GlBranchCardBase extends GlElement {
745737 }
746738
747739 protected renderLaunchpadItem ( ) {
748- if ( this . launchpadItem == null || this . pr ?. state !== 'opened' ) return nothing ;
740+ if ( this . launchpadItem == null ) return nothing ;
749741
750- const group = launchpadCategoryToGroupMap . get ( this . launchpadItem . category ) ;
751- if ( group == null || group === 'other' || group === 'draft' || group === 'current-branch' ) {
752- return nothing ;
753- }
742+ const group = getLaunchpadItemGroup ( this . pr , this . launchpadItem ) ;
743+ if ( group == null ) return nothing ;
754744
755745 const groupLabel = launchpadGroupLabelMap . get ( group ) ;
756746 const groupIcon = launchpadGroupIconMap . get ( group ) ;
757747
758748 if ( groupLabel == null || groupIcon == null ) return nothing ;
759749 const groupIconString = groupIcon . match ( / \$ \( ( .* ?) \) / ) ! [ 1 ] . replace ( 'gitlens' , 'gl' ) ;
760750
761- // <a
762- // href=${createCommandLink<Omit<LaunchpadCommandArgs, 'command'>>('gitlens.showLaunchpad', {
763- // source: 'home',
764- // state: {
765- // item: { ...this.launchpadItem.item, group: group },
766- // },
767- // } satisfies Omit<LaunchpadCommandArgs, 'command'>) }
768- // class="launchpad__grouping"
769- // >
770-
771751 const tooltip = interpolate ( actionGroupMap . get ( this . launchpadItem . category ) ! [ 1 ] , {
772752 author : this . launchpadItem . author ?. username ?? 'unknown' ,
773753 createdDateRelative : fromNow ( new Date ( this . launchpadItem . createdDate ) ) ,
774754 } ) ;
775755
776756 return html `< div class ="branch-item__section branch-item__section--details " slot ="context ">
777- < p class ="launchpad-grouping-- ${ getLaunchpadItemGrouping ( this . launchpadItem . category ) } ">
757+ < p class ="launchpad-grouping-- ${ getLaunchpadItemGrouping ( group ) } ">
778758 < gl-tooltip content ="${ tooltip } ">
779- < code-icon icon ="${ groupIconString } "> </ code-icon
780- > < span class ="branch-item__category "> ${ groupLabel . toUpperCase ( ) } </ span >
759+ < a
760+ href =${ createCommandLink < Omit < LaunchpadCommandArgs , 'command' > > ( 'gitlens.showLaunchpad' , {
761+ source : 'home' ,
762+ state : {
763+ id : { uuid : this . launchpadItem . uuid , group : group } ,
764+ } ,
765+ } satisfies Omit < LaunchpadCommandArgs , 'command' > ) }
766+ class ="launchpad__grouping"
767+ >
768+ < code-icon icon ="${ groupIconString } "> </ code-icon
769+ > < span class ="branch-item__category "> ${ groupLabel . toUpperCase ( ) } </ span > </ a
770+ >
781771 </ gl-tooltip >
782772 </ p >
783773 </ div >
784774 ${ groupIconString
785775 ? html `< span
786- class ="branch-item__summary launchpad-grouping-- ${ getLaunchpadItemGrouping (
787- this . launchpadItem . category ,
788- ) } "
776+ class ="branch-item__summary launchpad-grouping-- ${ getLaunchpadItemGrouping ( group ) } "
789777 slot ="summary "
790778 > < gl-tooltip placement ="bottom " content ="${ groupLabel } "
791779 > < code-icon icon ="${ groupIconString } "> </ code-icon > </ gl-tooltip
@@ -1031,9 +1019,22 @@ export class GlWorkUnit extends LitElement {
10311019 }
10321020}
10331021
1034- function getLaunchpadItemGrouping ( category : LaunchpadItem [ 'actionableCategory' ] ) {
1035- const group = launchpadCategoryToGroupMap . get ( category ) ;
1022+ function getLaunchpadItemGroup (
1023+ pr : Awaited < GetOverviewBranch [ 'pr' ] > ,
1024+ launchpadItem : Awaited < NonNullable < Awaited < GetOverviewBranch [ 'pr' ] > > [ 'launchpad' ] > ,
1025+ ) {
1026+ if ( launchpadItem == null || pr ?. state !== 'opened' ) return undefined ;
1027+ if ( pr . draft && launchpadItem . category === 'unassigned-reviewers' ) return undefined ;
1028+
1029+ const group = launchpadCategoryToGroupMap . get ( launchpadItem . category ) ;
1030+ if ( group == null || group === 'other' || group === 'draft' || group === 'current-branch' ) {
1031+ return undefined ;
1032+ }
1033+
1034+ return group ;
1035+ }
10361036
1037+ function getLaunchpadItemGrouping ( group : ReturnType < typeof getLaunchpadItemGroup > ) {
10371038 switch ( group ) {
10381039 case 'mergeable' :
10391040 return 'mergeable' ;
0 commit comments