diff --git a/src/plus/integrations/providers/github/github.ts b/src/plus/integrations/providers/github/github.ts index 078bdbc59f7c3..9e65bba150d89 100644 --- a/src/plus/integrations/providers/github/github.ts +++ b/src/plus/integrations/providers/github/github.ts @@ -25,7 +25,12 @@ import { PullRequestMergeMethod } from '../../../../git/models/pullRequest'; import type { Provider } from '../../../../git/models/remoteProvider'; import type { RepositoryMetadata } from '../../../../git/models/repositoryMetadata'; import type { GitRevisionRange } from '../../../../git/models/revision'; -import { createRevisionRange , getRevisionRangeParts, isRevisionRange, isSha } from '../../../../git/models/revision.utils'; +import { + createRevisionRange, + getRevisionRangeParts, + isRevisionRange, + isSha, +} from '../../../../git/models/revision.utils'; import type { GitUser } from '../../../../git/models/user'; import { getGitHubNoReplyAddressParts } from '../../../../git/remotes/github'; import { @@ -98,6 +103,7 @@ headRepository { url } isCrossRepository +isDraft mergedAt permalink repository { @@ -122,7 +128,6 @@ assignees(first: 10) { } checksUrl deletions -isDraft mergeable mergedBy { login diff --git a/src/plus/integrations/providers/github/models.ts b/src/plus/integrations/providers/github/models.ts index 99b3f55c849ac..73dd37800a0bc 100644 --- a/src/plus/integrations/providers/github/models.ts +++ b/src/plus/integrations/providers/github/models.ts @@ -105,6 +105,7 @@ export interface GitHubPullRequestLite extends Omit { await updateContextItems(this.container, context, { force: newlyConnected }); if (state.counter < 1 || state.item == null) { + if (state.id != null) { + const item = context.result.items?.find(item => item.uuid === state.id?.uuid); + if (item != null) { + state.item = { ...item, group: state.id.group }; + if (state.counter < 1) { + state.counter = 1; + } + continue; + } + } + if (this.container.telemetry.enabled) { this.container.telemetry.sendEvent( opened ? 'launchpad/steps/main' : 'launchpad/opened', diff --git a/src/webviews/apps/plus/home/components/branch-card.ts b/src/webviews/apps/plus/home/components/branch-card.ts index c3c108152ff06..b9b6461fbfc2e 100644 --- a/src/webviews/apps/plus/home/components/branch-card.ts +++ b/src/webviews/apps/plus/home/components/branch-card.ts @@ -4,7 +4,7 @@ import { customElement, property, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { when } from 'lit/directives/when.js'; import type { Commands } from '../../../../../constants.commands'; -import type { LaunchpadItem } from '../../../../../plus/launchpad/launchpadProvider'; +import type { LaunchpadCommandArgs } from '../../../../../plus/launchpad/launchpad'; import { actionGroupMap, launchpadCategoryToGroupMap, @@ -422,10 +422,7 @@ export abstract class GlBranchCardBase extends GlElement { } get cardIndicator() { - if (this.launchpadItem && this.pr?.state === 'opened') { - return getLaunchpadItemGrouping(this.launchpadItem.category) ?? 'base'; - } - return 'base'; + return getLaunchpadItemGrouping(getLaunchpadItemGroup(this.pr, this.launchpadItem)) ?? 'base'; } get branchCardIndicator() { @@ -715,14 +712,9 @@ export abstract class GlBranchCardBase extends GlElement { return nothing; } - let indicator: GlCard['indicator']; - if (this.branch.opened) { - if (this.launchpadItem && this.pr?.state === 'opened') { - indicator = getLaunchpadItemGrouping(this.launchpadItem.category) ?? 'base'; - } else { - indicator = 'base'; - } - } + const indicator: GlCard['indicator'] = this.branch.opened + ? getLaunchpadItemGrouping(getLaunchpadItemGroup(this.pr, this.launchpadItem)) ?? 'base' + : undefined; const actions = this.renderPrActions(); return html` @@ -730,7 +722,7 @@ export abstract class GlBranchCardBase extends GlElement {

- + ${this.pr.title}>('gitlens.showLaunchpad', { - // source: 'home', - // state: { - // item: { ...this.launchpadItem.item, group: group }, - // }, - // } satisfies Omit)} - // class="launchpad__grouping" - // > - const tooltip = interpolate(actionGroupMap.get(this.launchpadItem.category)![1], { author: this.launchpadItem.author?.username ?? 'unknown', createdDateRelative: fromNow(new Date(this.launchpadItem.createdDate)), }); return html`

${groupIconString ? html`, + launchpadItem: Awaited>['launchpad']>, +) { + if (launchpadItem == null || pr?.state !== 'opened') return undefined; + if (pr.draft && launchpadItem.category === 'unassigned-reviewers') return undefined; + + const group = launchpadCategoryToGroupMap.get(launchpadItem.category); + if (group == null || group === 'other' || group === 'draft' || group === 'current-branch') { + return undefined; + } + + return group; +} +function getLaunchpadItemGrouping(group: ReturnType) { switch (group) { case 'mergeable': return 'mergeable'; diff --git a/src/webviews/apps/shared/components/rich/pr-icon.ts b/src/webviews/apps/shared/components/rich/pr-icon.ts index 575231bb12526..a2992b2c53fbe 100644 --- a/src/webviews/apps/shared/components/rich/pr-icon.ts +++ b/src/webviews/apps/shared/components/rich/pr-icon.ts @@ -12,11 +12,14 @@ export class PrIcon extends LitElement { @property() state?: 'merged' | 'opened' | 'closed' | string; + @property({ type: Boolean }) + draft = false; + @property({ attribute: 'pr-id' }) prId?: string; get icon() { - let prIcon = 'git-pull-request'; + let prIcon = this.draft ? 'git-pull-request-draft' : 'git-pull-request'; if (this.state) { switch (this.state) { case 'merged': @@ -31,15 +34,18 @@ export class PrIcon extends LitElement { } get classes() { - if (!this.state) return 'pr-icon'; + if (!this.state || (this.draft && this.state === 'opened')) { + return 'pr-icon'; + } return `pr-icon pr-icon--${this.state}`; } get label() { - if (!this.state) return 'Pull request'; + const type = this.draft ? 'Draft pull request' : 'Pull request'; + if (!this.state) return type; - return `Pull request ${this.prId ? `#${this.prId}` : ''} is ${this.state}`; + return `${type} ${this.prId ? `#${this.prId}` : ''} is ${this.state}`; } override render() { diff --git a/src/webviews/home/homeWebview.ts b/src/webviews/home/homeWebview.ts index 2eb4ef98b292d..55febe361d591 100644 --- a/src/webviews/home/homeWebview.ts +++ b/src/webviews/home/homeWebview.ts @@ -1460,6 +1460,7 @@ async function getLaunchpadItemInfo( if (lpi == null) return undefined; return { + uuid: lpi.uuid, category: lpi.actionableCategory, groups: getLaunchpadItemGroups(lpi), suggestedActions: lpi.suggestedActions, @@ -1498,6 +1499,7 @@ async function getPullRequestInfo( url: pr.url, state: pr.state, title: pr.title, + draft: pr.isDraft, launchpad: getLaunchpadItemInfo(container, pr, launchpadPromise), }; } diff --git a/src/webviews/home/protocol.ts b/src/webviews/home/protocol.ts index 728ce0f75062b..eae8a9fca3166 100644 --- a/src/webviews/home/protocol.ts +++ b/src/webviews/home/protocol.ts @@ -147,9 +147,11 @@ export interface GetOverviewBranch { title: string; state: string; url: string; + draft?: boolean; launchpad?: Promise< | { + uuid: string; category: LaunchpadItem['actionableCategory']; groups: LaunchpadGroup[]; suggestedActions: LaunchpadItem['suggestedActions'];