Skip to content

Commit

Permalink
Improves icon and text for launchpad status of branch card PR section
Browse files Browse the repository at this point in the history
  • Loading branch information
axosoft-ramint committed Dec 19, 2024
1 parent 2370c72 commit b11b769
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 155 deletions.
14 changes: 3 additions & 11 deletions src/plus/launchpad/launchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,15 @@ import { executeCommand } from '../../system/vscode/command';
import { configuration } from '../../system/vscode/configuration';
import { openUrl } from '../../system/vscode/utils';
import { ProviderBuildStatusState, ProviderPullRequestReviewState } from '../integrations/providers/models';
import type {
LaunchpadAction,
LaunchpadActionCategory,
LaunchpadCategorizedResult,
LaunchpadGroup,
LaunchpadItem,
LaunchpadTargetAction,
} from './launchpadProvider';
import type { LaunchpadCategorizedResult, LaunchpadItem } from './launchpadProvider';
import {
countLaunchpadItemGroups,
getLaunchpadItemIdHash,
groupAndSortLaunchpadItems,
launchpadGroupIconMap,
launchpadGroupLabelMap,
launchpadGroups,
supportedLaunchpadIntegrations,
} from './launchpadProvider';
import type { LaunchpadAction, LaunchpadActionCategory, LaunchpadGroup, LaunchpadTargetAction } from './models';
import { launchpadGroupIconMap, launchpadGroupLabelMap, launchpadGroups } from './models';
import { isMaybeSupportedLaunchpadPullRequestSearchUrl } from './utils';

const actionGroupMap = new Map<LaunchpadActionCategory, string[]>([
Expand Down
11 changes: 4 additions & 7 deletions src/plus/launchpad/launchpadIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ import { executeCommand, registerCommand } from '../../system/vscode/command';
import { configuration } from '../../system/vscode/configuration';
import type { ConnectionStateChangeEvent } from '../integrations/integrationService';
import type { LaunchpadCommandArgs } from './launchpad';
import type { LaunchpadGroup, LaunchpadItem, LaunchpadProvider, LaunchpadRefreshEvent } from './launchpadProvider';
import {
groupAndSortLaunchpadItems,
launchpadGroupIconMap,
launchpadPriorityGroups,
supportedLaunchpadIntegrations,
} from './launchpadProvider';
import type { LaunchpadItem, LaunchpadProvider, LaunchpadRefreshEvent } from './launchpadProvider';
import { groupAndSortLaunchpadItems, supportedLaunchpadIntegrations } from './launchpadProvider';
import type { LaunchpadGroup } from './models';
import { launchpadGroupIconMap, launchpadPriorityGroups } from './models';

type LaunchpadIndicatorState = 'idle' | 'disconnected' | 'loading' | 'load' | 'failed';

Expand Down
129 changes: 8 additions & 121 deletions src/plus/launchpad/launchpadProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,129 +51,16 @@ import {
} from '../integrations/providers/models';
import type { EnrichableItem, EnrichedItem } from './enrichmentService';
import { convertRemoteProviderIdToEnrichProvider, isEnrichableRemoteProviderId } from './enrichmentService';
import type { LaunchpadAction, LaunchpadActionCategory, LaunchpadGroup } from './models';
import {
launchpadActionCategories,
launchpadCategoryToGroupMap,
launchpadGroups,
prActionsMap,
sharedCategoryToLaunchpadActionCategoryMap,
} from './models';
import { getPullRequestIdentityFromMaybeUrl } from './utils';

export const launchpadActionCategories = [
'mergeable',
'unassigned-reviewers',
'failed-checks',
'conflicts',
'needs-my-review',
'code-suggestions',
'changes-requested',
'reviewer-commented',
'waiting-for-review',
'draft',
'other',
] as const;
export type LaunchpadActionCategory = (typeof launchpadActionCategories)[number];

export const launchpadGroups = [
'current-branch',
'pinned',
'mergeable',
'blocked',
'follow-up',
'needs-review',
'waiting-for-review',
'draft',
'other',
'snoozed',
] as const;
export type LaunchpadGroup = (typeof launchpadGroups)[number];

export const launchpadPriorityGroups = [
'mergeable',
'blocked',
'follow-up',
'needs-review',
] satisfies readonly LaunchpadPriorityGroup[] as readonly LaunchpadGroup[];
export type LaunchpadPriorityGroup = Extract<LaunchpadGroup, 'mergeable' | 'blocked' | 'follow-up' | 'needs-review'>;

export const launchpadGroupIconMap = new Map<LaunchpadGroup, `$(${string})`>([
['current-branch', '$(git-branch)'],
['pinned', '$(pinned)'],
['mergeable', '$(rocket)'],
['blocked', '$(error)'], //bracket-error
['follow-up', '$(report)'],
['needs-review', '$(comment-unresolved)'], // feedback
['waiting-for-review', '$(gitlens-clock)'],
['draft', '$(git-pull-request-draft)'],
['other', '$(ellipsis)'],
['snoozed', '$(bell-slash)'],
]);

export const launchpadGroupLabelMap = new Map<LaunchpadGroup, string>([
['current-branch', 'Current Branch'],
['pinned', 'Pinned'],
['mergeable', 'Ready to Merge'],
['blocked', 'Blocked'],
['follow-up', 'Requires Follow-up'],
['needs-review', 'Needs Your Review'],
['waiting-for-review', 'Waiting for Review'],
['draft', 'Draft'],
['other', 'Other'],
['snoozed', 'Snoozed'],
]);

export const launchpadCategoryToGroupMap = new Map<LaunchpadActionCategory, LaunchpadGroup>([
['mergeable', 'mergeable'],
['conflicts', 'blocked'],
['failed-checks', 'blocked'],
['unassigned-reviewers', 'blocked'],
['needs-my-review', 'needs-review'],
['code-suggestions', 'follow-up'],
['changes-requested', 'follow-up'],
['reviewer-commented', 'follow-up'],
['waiting-for-review', 'waiting-for-review'],
['draft', 'draft'],
['other', 'other'],
]);

export const sharedCategoryToLaunchpadActionCategoryMap = new Map<string, LaunchpadActionCategory>([
['readyToMerge', 'mergeable'],
['unassignedReviewers', 'unassigned-reviewers'],
['failingCI', 'failed-checks'],
['conflicts', 'conflicts'],
['needsMyReview', 'needs-my-review'],
['changesRequested', 'changes-requested'],
['reviewerCommented', 'reviewer-commented'],
['waitingForReview', 'waiting-for-review'],
['draft', 'draft'],
['other', 'other'],
]);

export type LaunchpadAction =
| 'merge'
| 'open'
| 'soft-open'
| 'switch'
| 'switch-and-code-suggest'
| 'open-worktree'
| 'code-suggest'
| 'show-overview'
| 'open-changes'
| 'open-in-graph';

export type LaunchpadTargetAction = {
action: 'open-suggestion';
target: string;
};

const prActionsMap = new Map<LaunchpadActionCategory, LaunchpadAction[]>([
['mergeable', ['merge']],
['unassigned-reviewers', ['open']],
['failed-checks', ['open']],
['conflicts', ['open']],
['needs-my-review', ['open']],
['code-suggestions', ['open']],
['changes-requested', ['open']],
['reviewer-commented', ['open']],
['waiting-for-review', ['open']],
['draft', ['open']],
['other', []],
]);

export function getSuggestedActions(category: LaunchpadActionCategory, isCurrentBranch: boolean): LaunchpadAction[] {
const actions = [...prActionsMap.get(category)!];
if (isCurrentBranch) {
Expand Down
120 changes: 120 additions & 0 deletions src/plus/launchpad/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
export const launchpadActionCategories = [
'mergeable',
'unassigned-reviewers',
'failed-checks',
'conflicts',
'needs-my-review',
'code-suggestions',
'changes-requested',
'reviewer-commented',
'waiting-for-review',
'draft',
'other',
] as const;
export type LaunchpadActionCategory = (typeof launchpadActionCategories)[number];

export const launchpadGroups = [
'current-branch',
'pinned',
'mergeable',
'blocked',
'follow-up',
'needs-review',
'waiting-for-review',
'draft',
'other',
'snoozed',
] as const;
export type LaunchpadGroup = (typeof launchpadGroups)[number];

export const launchpadPriorityGroups = [
'mergeable',
'blocked',
'follow-up',
'needs-review',
] satisfies readonly LaunchpadPriorityGroup[] as readonly LaunchpadGroup[];
export type LaunchpadPriorityGroup = Extract<LaunchpadGroup, 'mergeable' | 'blocked' | 'follow-up' | 'needs-review'>;

export const launchpadGroupIconMap = new Map<LaunchpadGroup, `$(${string})`>([
['current-branch', '$(git-branch)'],
['pinned', '$(pinned)'],
['mergeable', '$(rocket)'],
['blocked', '$(error)'], //bracket-error
['follow-up', '$(report)'],
['needs-review', '$(comment-unresolved)'], // feedback
['waiting-for-review', '$(gitlens-clock)'],
['draft', '$(git-pull-request-draft)'],
['other', '$(ellipsis)'],
['snoozed', '$(bell-slash)'],
]);

export const launchpadGroupLabelMap = new Map<LaunchpadGroup, string>([
['current-branch', 'Current Branch'],
['pinned', 'Pinned'],
['mergeable', 'Ready to Merge'],
['blocked', 'Blocked'],
['follow-up', 'Requires Follow-up'],
['needs-review', 'Needs Your Review'],
['waiting-for-review', 'Waiting for Review'],
['draft', 'Draft'],
['other', 'Other'],
['snoozed', 'Snoozed'],
]);

export const launchpadCategoryToGroupMap = new Map<LaunchpadActionCategory, LaunchpadGroup>([
['mergeable', 'mergeable'],
['conflicts', 'blocked'],
['failed-checks', 'blocked'],
['unassigned-reviewers', 'blocked'],
['needs-my-review', 'needs-review'],
['code-suggestions', 'follow-up'],
['changes-requested', 'follow-up'],
['reviewer-commented', 'follow-up'],
['waiting-for-review', 'waiting-for-review'],
['draft', 'draft'],
['other', 'other'],
]);

export const sharedCategoryToLaunchpadActionCategoryMap = new Map<string, LaunchpadActionCategory>([
['readyToMerge', 'mergeable'],
['unassignedReviewers', 'unassigned-reviewers'],
['failingCI', 'failed-checks'],
['conflicts', 'conflicts'],
['needsMyReview', 'needs-my-review'],
['changesRequested', 'changes-requested'],
['reviewerCommented', 'reviewer-commented'],
['waitingForReview', 'waiting-for-review'],
['draft', 'draft'],
['other', 'other'],
]);

export type LaunchpadAction =
| 'merge'
| 'open'
| 'soft-open'
| 'switch'
| 'switch-and-code-suggest'
| 'open-worktree'
| 'code-suggest'
| 'show-overview'
| 'open-changes'
| 'open-in-graph';

export type LaunchpadTargetAction = {
action: 'open-suggestion';
target: string;
};

export const prActionsMap = new Map<LaunchpadActionCategory, LaunchpadAction[]>([
['mergeable', ['merge']],
['unassigned-reviewers', ['open']],
['failed-checks', ['open']],
['conflicts', ['open']],
['needs-my-review', ['open']],
['code-suggestions', ['open']],
['changes-requested', ['open']],
['reviewer-commented', ['open']],
['waiting-for-review', ['open']],
['draft', ['open']],
['other', []],
]);
2 changes: 1 addition & 1 deletion src/plus/launchpad/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../integrations/providers/gitlab/models';
import type { LaunchpadSummaryResult } from './launchpadIndicator';
import { generateLaunchpadSummary } from './launchpadIndicator';
import type { LaunchpadGroup } from './launchpadProvider';
import type { LaunchpadGroup } from './models';

export async function getLaunchpadSummary(container: Container): Promise<LaunchpadSummaryResult | { error: Error }> {
const result = await container.launchpad.getCategorizedItems();
Expand Down
10 changes: 4 additions & 6 deletions src/views/launchpadView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import { GitUri, unknownGitUri } from '../git/gitUri';
import type { SubscriptionChangeEvent } from '../plus/gk/account/subscriptionService';
import { ensurePlusFeaturesEnabled } from '../plus/gk/utils';
import type { LaunchpadCommandArgs } from '../plus/launchpad/launchpad';
import type { LaunchpadGroup, LaunchpadItem } from '../plus/launchpad/launchpadProvider';
import {
groupAndSortLaunchpadItems,
launchpadGroupIconMap,
launchpadGroupLabelMap,
} from '../plus/launchpad/launchpadProvider';
import type { LaunchpadItem } from '../plus/launchpad/launchpadProvider';
import { groupAndSortLaunchpadItems } from '../plus/launchpad/launchpadProvider';
import type { LaunchpadGroup } from '../plus/launchpad/models';
import { launchpadGroupIconMap, launchpadGroupLabelMap } from '../plus/launchpad/models';
import { createCommand, executeCommand } from '../system/vscode/command';
import { configuration } from '../system/vscode/configuration';
import { CacheableChildrenViewNode } from './nodes/abstract/cacheableChildrenViewNode';
Expand Down
5 changes: 3 additions & 2 deletions src/views/nodes/abstract/viewNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import type { Repository } from '../../../git/models/repository';
import type { GitTag } from '../../../git/models/tag';
import type { GitWorktree } from '../../../git/models/worktree';
import type { Draft } from '../../../gk/models/drafts';
import type { LaunchpadGroup, LaunchpadItem } from '../../../plus/launchpad/launchpadProvider';
import type { LaunchpadItem } from '../../../plus/launchpad/launchpadProvider';
import type { LaunchpadGroup } from '../../../plus/launchpad/models';
import {
launchpadCategoryToGroupMap,
sharedCategoryToLaunchpadActionCategoryMap,
} from '../../../plus/launchpad/launchpadProvider';
} from '../../../plus/launchpad/models';
import type {
CloudWorkspace,
CloudWorkspaceRepositoryDescriptor,
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/launchpadViewGroupingNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TreeItem } from 'vscode';
import { Disposable, TreeItemCollapsibleState } from 'vscode';
import type { LaunchpadGroup } from '../../plus/launchpad/launchpadProvider';
import type { LaunchpadGroup } from '../../plus/launchpad/models';
import type { TreeViewNodeCollapsibleStateChangeEvent, View } from '../viewBase';
import type { ViewNode } from './abstract/viewNode';
import { GroupingNode } from './groupingNode';
Expand Down
Loading

0 comments on commit b11b769

Please sign in to comment.