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 Dec 18, 2024
1 parent 8fdc262 commit ec53d49
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 @@ -954,6 +954,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 @@ -1001,41 +1006,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 @@ -1069,16 +1083,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 ec53d49

Please sign in to comment.