@@ -15,7 +15,7 @@ import type { AssociateIssueWithBranchCommandArgs } from '../../../../../plus/st
1515import { createCommandLink } from '../../../../../system/commands' ;
1616import { fromNow } from '../../../../../system/date' ;
1717import { interpolate , pluralize } from '../../../../../system/string' ;
18- import type { BranchRef , GetOverviewBranch , OpenInGraphParams } from '../../../../home/protocol' ;
18+ import type { BranchRef , GetOverviewBranch , OpenInGraphParams , OverviewBranchIssue } from '../../../../home/protocol' ;
1919import { renderBranchName } from '../../../shared/components/branch-name' ;
2020import type { GlCard } from '../../../shared/components/card/card' ;
2121import { GlElement , observe } from '../../../shared/components/element' ;
@@ -58,6 +58,25 @@ export const branchCardStyles = css`
5858 flex-direction: column;
5959 gap: 0.4rem;
6060 }
61+
62+ .branch-item__unplug {
63+ padding: 0.2em;
64+ margin-block: -0.2em;
65+ opacity: 0;
66+ border-radius: 3px;
67+ }
68+
69+ .branch-item__section:hover .branch-item__unplug,
70+ .branch-item__section:focus-within .branch-item__unplug {
71+ opacity: 1;
72+ }
73+
74+ .branch-item__unplug:hover,
75+ .branch-item__unplug:focus {
76+ background-color: var(--vscode-toolbar-hoverBackground);
77+ outline: 1px dashed var(--vscode-toolbar-hoverOutline);
78+ }
79+
6180 .branch-item__section > * {
6281 margin-block: 0;
6382 }
@@ -499,19 +518,47 @@ export abstract class GlBranchCardBase extends GlElement {
499518 this . toggleExpanded ( true ) ;
500519 }
501520
502- protected renderIssues ( ) : TemplateResult | NothingType {
521+ private getIssues ( ) : OverviewBranchIssue [ ] {
503522 const { autolinks, issues } = this ;
504- const issuesSource = issues ?. length ? issues : autolinks ;
505- if ( ! issuesSource ?. length ) return nothing ;
523+ const issuesMap : Record < string , OverviewBranchIssue > = { } ;
524+ autolinks ?. map ( autolink => {
525+ if ( autolink . type !== 'issue' ) {
526+ return ;
527+ }
528+ issuesMap [ autolink . url ] = autolink ;
529+ } ) ;
530+ issues ?. map ( issue => {
531+ issuesMap [ issue . url ] = issue ;
532+ } ) ;
533+ return Object . values ( issuesMap ) ;
534+ }
506535
536+ protected renderIssues ( issues : OverviewBranchIssue [ ] ) {
537+ if ( ! issues . length ) return nothing ;
507538 return html `
508- ${ issuesSource . map ( issue => {
539+ ${ issues . map ( issue => {
509540 return html `
510541 < p class ="branch-item__grouping ">
511542 < span class ="branch-item__icon ">
512543 < issue-icon state =${ issue . state } issue-id =${ issue . id } > </ issue-icon >
513544 </ span >
514545 < a href =${ issue . url } class ="branch-item__name branch-item__name--secondary"> ${ issue . title } </ a >
546+ ${ when (
547+ issue . isAutolink && this . expanded ,
548+ ( ) => html `
549+ < gl-tooltip >
550+ < a
551+ class ="branch-item__unplug "
552+ href =${ createCommandLink ( 'gitlens.home.unlinkIssue' , {
553+ issue : issue ,
554+ reference : this . branch . reference ,
555+ } ) }
556+ > < code-icon icon ="gl-unplug "> </ code-icon
557+ > </ a >
558+ < div slot ="content "> Unlink automatically linked issue</ div >
559+ </ gl-tooltip >
560+ ` ,
561+ ) }
515562 < span class ="branch-item__identifier "> #${ issue . id } </ span >
516563 </ p >
517564 ` ;
@@ -791,7 +838,7 @@ export abstract class GlBranchCardBase extends GlElement {
791838 }
792839
793840 protected renderIssuesItem ( ) : TemplateResult | NothingType {
794- const issues = [ ... ( this . issues ?? [ ] ) , ... ( this . autolinks ?? [ ] ) ] ;
841+ const issues = this . getIssues ( ) ;
795842 if ( ! issues . length ) {
796843 if ( ! this . expanded ) return nothing ;
797844
@@ -821,7 +868,7 @@ export abstract class GlBranchCardBase extends GlElement {
821868
822869 return html `
823870 < gl-work-item ?expanded =${ this . expanded } ?nested =${ ! this . branch . opened } .indicator=${ indicator } >
824- < div class ="branch-item__section "> ${ this . renderIssues ( ) } </ div >
871+ < div class ="branch-item__section "> ${ this . renderIssues ( issues ) } </ div >
825872 </ gl-work-item >
826873 ` ;
827874 }
0 commit comments