Skip to content

Commit

Permalink
Hides unclickable actions on the confirm action screen
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeibbb committed Nov 25, 2024
1 parent 6985546 commit 8481954
Showing 1 changed file with 58 additions and 41 deletions.
99 changes: 58 additions & 41 deletions src/plus/launchpad/launchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ export class LaunchpadCommand extends QuickCommand<State> {
createQuickPickSeparator('Actions'),
];

const checkoutable =
state.item.type === 'pullrequest' &&
state.item.headRef != null &&
state.item.repoIdentity?.remote?.url != null;

for (const action of state.item.suggestedActions) {
switch (action) {
case 'merge': {
Expand Down Expand Up @@ -814,41 +819,50 @@ export class LaunchpadCommand extends QuickCommand<State> {
),
);
break;
case 'switch':
confirmations.push(
createQuickPickItemOfT(
{
label: 'Switch to Branch',
detail: 'Will checkout the branch, create or open a worktree',
},
action,
),
);
case 'switch': {
if (checkoutable) {
confirmations.push(
createQuickPickItemOfT(
{
label: 'Switch to Branch',
detail: 'Will checkout the branch, create or open a worktree',
},
action,
),
);
}
break;
case 'open-worktree':
confirmations.push(
createQuickPickItemOfT(
{
label: 'Open in Worktree',
detail: 'Will create or open a worktree in a new window',
},
action,
),
);
}
case 'open-worktree': {
if (checkoutable) {
confirmations.push(
createQuickPickItemOfT(
{
label: 'Open in Worktree',
detail: 'Will create or open a worktree in a new window',
},
action,
),
);
}
break;
case 'switch-and-code-suggest':
confirmations.push(
createQuickPickItemOfT(
{
label: `Switch & Suggest ${
state.item.viewer.isAuthor ? 'Additional ' : ''
}Code Changes`,
detail: 'Will checkout and start suggesting code changes',
},
action,
),
);
}
case 'switch-and-code-suggest': {
if (checkoutable) {
confirmations.push(
createQuickPickItemOfT(
{
label: `Switch & Suggest ${
state.item.viewer.isAuthor ? 'Additional ' : ''
}Code Changes`,
detail: 'Will checkout and start suggesting code changes',
},
action,
),
);
}
break;
}
case 'code-suggest':
confirmations.push(
createQuickPickItemOfT(
Expand Down Expand Up @@ -882,16 +896,19 @@ export class LaunchpadCommand extends QuickCommand<State> {
),
);
break;
case 'open-in-graph':
confirmations.push(
createQuickPickItemOfT(
{
label: 'Open in Commit Graph',
},
action,
),
);
case 'open-in-graph': {
if (checkoutable) {
confirmations.push(
createQuickPickItemOfT(
{
label: 'Open in Commit Graph',
},
action,
),
);
}
break;
}
}
}

Expand Down

0 comments on commit 8481954

Please sign in to comment.