@@ -370,6 +370,89 @@ export class LaunchpadCommand extends QuickCommand<State> {
370370 { picked, selectTopItem } : { picked ?: string ; selectTopItem ?: boolean } ,
371371 ) : StepResultGenerator < GroupedLaunchpadItem | ConnectMoreIntegrationsItem > {
372372 const hasDisconnectedIntegrations = [ ...context . connectedIntegrations . values ( ) ] . some ( c => ! c ) ;
373+
374+ const buildGroupHeading = (
375+ ui : LaunchpadGroup ,
376+ groupLength : number ,
377+ ) : [ DirectiveQuickPickItem , DirectiveQuickPickItem ] => {
378+ return [
379+ createQuickPickSeparator ( groupLength ? groupLength . toString ( ) : undefined ) ,
380+ createDirectiveQuickPickItem ( Directive . Reload , false , {
381+ label : `$(${
382+ context . collapsed . get ( ui ) ? 'chevron-down' : 'chevron-up'
383+ } )\u00a0\u00a0${ launchpadGroupIconMap . get ( ui ) ! } \u00a0\u00a0${ launchpadGroupLabelMap
384+ . get ( ui )
385+ ?. toUpperCase ( ) } `, //'\u00a0',
386+ //detail: groupMap.get(group)?.[0].toUpperCase(),
387+ onDidSelect : ( ) => {
388+ const collapsed = ! context . collapsed . get ( ui ) ;
389+ context . collapsed . set ( ui , collapsed ) ;
390+ if ( state . initialGroup == null ) {
391+ void this . container . storage . store (
392+ 'launchpad:groups:collapsed' ,
393+ Array . from ( context . collapsed . keys ( ) ) . filter ( g => context . collapsed . get ( g ) ) ,
394+ ) ;
395+ }
396+
397+ if ( this . container . telemetry . enabled ) {
398+ updateTelemetryContext ( context ) ;
399+ this . container . telemetry . sendEvent (
400+ 'launchpad/groupToggled' ,
401+ {
402+ ...context . telemetryContext ! ,
403+ group : ui ,
404+ collapsed : collapsed ,
405+ } ,
406+ this . source ,
407+ ) ;
408+ }
409+ } ,
410+ } ) ,
411+ ] ;
412+ } ;
413+
414+ const buildLaunchpadQuickPickItem = (
415+ i : LaunchpadItem ,
416+ ui : LaunchpadGroup ,
417+ topItem : LaunchpadItem | undefined ,
418+ ) : LaunchpadItemQuickPickItem => {
419+ const buttons = [ ] ;
420+
421+ if ( i . actionableCategory === 'mergeable' ) {
422+ buttons . push ( MergeQuickInputButton ) ;
423+ }
424+
425+ buttons . push (
426+ i . viewer . pinned ? UnpinQuickInputButton : PinQuickInputButton ,
427+ i . viewer . snoozed ? UnsnoozeQuickInputButton : SnoozeQuickInputButton ,
428+ ) ;
429+
430+ buttons . push ( ...getOpenOnGitProviderQuickInputButtons ( i . provider . id ) ) ;
431+
432+ if ( ! i . openRepository ?. localBranch ?. current ) {
433+ buttons . push ( OpenWorktreeInNewWindowQuickInputButton ) ;
434+ }
435+
436+ return {
437+ label : i . title . length > 60 ? `${ i . title . substring ( 0 , 60 ) } ...` : i . title ,
438+ // description: `${i.repoAndOwner}#${i.id}, by @${i.author}`,
439+ description : `\u00a0 ${ i . repository . owner . login } /${ i . repository . name } #${ i . id } \u00a0 ${
440+ i . codeSuggestionsCount > 0 ? ` $(gitlens-code-suggestion) ${ i . codeSuggestionsCount } ` : ''
441+ } \u00a0 ${ i . isNew ? '(New since last view)' : '' } `,
442+ detail : ` ${ i . viewer . pinned ? '$(pinned) ' : '' } ${
443+ i . isDraft && ui !== 'draft' ? '$(git-pull-request-draft) ' : ''
444+ } ${
445+ i . actionableCategory === 'other' ? '' : `${ actionGroupMap . get ( i . actionableCategory ) ! [ 0 ] } \u2022 `
446+ } ${ fromNow ( i . updatedDate ) } by @${ i . author ! . username } `,
447+
448+ buttons : buttons ,
449+ iconPath : i . author ?. avatarUrl != null ? Uri . parse ( i . author . avatarUrl ) : undefined ,
450+ item : i ,
451+ picked : i . graphQLId === picked || i . graphQLId === topItem ?. graphQLId ,
452+ group : ui ,
453+ } ;
454+ } ;
455+
373456 const getItems = ( result : LaunchpadCategorizedResult ) => {
374457 const items : ( LaunchpadItemQuickPickItem | DirectiveQuickPickItem | ConnectMoreIntegrationsItem ) [ ] = [ ] ;
375458
@@ -385,86 +468,11 @@ export class LaunchpadCommand extends QuickCommand<State> {
385468 for ( const [ ui , groupItems ] of uiGroups ) {
386469 if ( ! groupItems . length ) continue ;
387470
388- items . push (
389- createQuickPickSeparator ( groupItems . length ? groupItems . length . toString ( ) : undefined ) ,
390- createDirectiveQuickPickItem ( Directive . Reload , false , {
391- label : `$(${
392- context . collapsed . get ( ui ) ? 'chevron-down' : 'chevron-up'
393- } )\u00a0\u00a0${ launchpadGroupIconMap . get ( ui ) ! } \u00a0\u00a0${ launchpadGroupLabelMap
394- . get ( ui )
395- ?. toUpperCase ( ) } `, //'\u00a0',
396- //detail: groupMap.get(group)?.[0].toUpperCase(),
397- onDidSelect : ( ) => {
398- const collapsed = ! context . collapsed . get ( ui ) ;
399- context . collapsed . set ( ui , collapsed ) ;
400- if ( state . initialGroup == null ) {
401- void this . container . storage . store (
402- 'launchpad:groups:collapsed' ,
403- Array . from ( context . collapsed . keys ( ) ) . filter ( g => context . collapsed . get ( g ) ) ,
404- ) ;
405- }
406-
407- if ( this . container . telemetry . enabled ) {
408- updateTelemetryContext ( context ) ;
409- this . container . telemetry . sendEvent (
410- 'launchpad/groupToggled' ,
411- {
412- ...context . telemetryContext ! ,
413- group : ui ,
414- collapsed : collapsed ,
415- } ,
416- this . source ,
417- ) ;
418- }
419- } ,
420- } ) ,
421- ) ;
471+ items . push ( ...buildGroupHeading ( ui , groupItems . length ) ) ;
422472
423473 if ( context . collapsed . get ( ui ) ) continue ;
424474
425- items . push (
426- ...groupItems . map ( i => {
427- const buttons = [ ] ;
428-
429- if ( i . actionableCategory === 'mergeable' ) {
430- buttons . push ( MergeQuickInputButton ) ;
431- }
432-
433- buttons . push (
434- i . viewer . pinned ? UnpinQuickInputButton : PinQuickInputButton ,
435- i . viewer . snoozed ? UnsnoozeQuickInputButton : SnoozeQuickInputButton ,
436- ) ;
437-
438- buttons . push ( ...getOpenOnGitProviderQuickInputButtons ( i . provider . id ) ) ;
439-
440- if ( ! i . openRepository ?. localBranch ?. current ) {
441- buttons . push ( OpenWorktreeInNewWindowQuickInputButton ) ;
442- }
443-
444- return {
445- label : i . title . length > 60 ? `${ i . title . substring ( 0 , 60 ) } ...` : i . title ,
446- // description: `${i.repoAndOwner}#${i.id}, by @${i.author}`,
447- description : `\u00a0 ${ i . repository . owner . login } /${ i . repository . name } #${ i . id } \u00a0 ${
448- i . codeSuggestionsCount > 0
449- ? ` $(gitlens-code-suggestion) ${ i . codeSuggestionsCount } `
450- : ''
451- } \u00a0 ${ i . isNew ? '(New since last view)' : '' } `,
452- detail : ` ${ i . viewer . pinned ? '$(pinned) ' : '' } ${
453- i . isDraft && ui !== 'draft' ? '$(git-pull-request-draft) ' : ''
454- } ${
455- i . actionableCategory === 'other'
456- ? ''
457- : `${ actionGroupMap . get ( i . actionableCategory ) ! [ 0 ] } \u2022 `
458- } ${ fromNow ( i . updatedDate ) } by @${ i . author ! . username } `,
459-
460- buttons : buttons ,
461- iconPath : i . author ?. avatarUrl != null ? Uri . parse ( i . author . avatarUrl ) : undefined ,
462- item : i ,
463- picked : i . graphQLId === picked || i . graphQLId === topItem ?. graphQLId ,
464- group : ui ,
465- } ;
466- } ) ,
467- ) ;
475+ items . push ( ...groupItems . map ( i => buildLaunchpadQuickPickItem ( i , ui , topItem ) ) ) ;
468476 }
469477 }
470478
0 commit comments