Browse Source

Adds a modal to worktree creation flow

main
Eric Amodio 1 year ago
parent
commit
16d5b770f5
1 changed files with 14 additions and 6 deletions
  1. +14
    -6
      src/commands/git/worktree.ts

+ 14
- 6
src/commands/git/worktree.ts View File

@ -322,6 +322,7 @@ export class WorktreeGitCommand extends QuickCommand {
icon: false, icon: false,
label: state.reference.refType !== 'branch', label: state.reference.refType !== 'branch',
})}`, })}`,
defaultUri: context.defaultUri,
}); });
if (result === StepResult.Break) continue; if (result === StepResult.Break) continue;
@ -478,21 +479,28 @@ export class WorktreeGitCommand extends QuickCommand {
private async *createCommandChoosePathStep( private async *createCommandChoosePathStep(
state: CreateStepState, state: CreateStepState,
context: Context, context: Context,
options?: { titleContext?: string },
options: { titleContext: string; defaultUri?: Uri },
): AsyncStepResultGenerator<Uri> { ): AsyncStepResultGenerator<Uri> {
const step = QuickCommand.createCustomStep<Uri>({ const step = QuickCommand.createCustomStep<Uri>({
show: async (_step: CustomStep<Uri>) => { show: async (_step: CustomStep<Uri>) => {
const hasDefault = options?.defaultUri != null;
const result = await window.showInformationMessage(
`Choose a location in which to create the worktree${options.titleContext}.`,
{ modal: true },
{ title: 'Choose Location' },
...(hasDefault ? [{ title: 'Use Default Location' }] : []),
);
if (result == null) return Directive.Back;
if (result.title === 'Use Default Location') return options.defaultUri!;
const uris = await window.showOpenDialog({ const uris = await window.showOpenDialog({
canSelectFiles: false, canSelectFiles: false,
canSelectFolders: true, canSelectFolders: true,
canSelectMany: false, canSelectMany: false,
defaultUri: context.pickedUri ?? state.uri ?? context.defaultUri, defaultUri: context.pickedUri ?? state.uri ?? context.defaultUri,
openLabel: 'Select Worktree Location', openLabel: 'Select Worktree Location',
title: `${appendReposToTitle(
`Choose Worktree Location${options?.titleContext ?? ''}`,
state,
context,
)}`,
title: `${appendReposToTitle(`Choose a Worktree Location${options.titleContext}`, state, context)}`,
}); });
if (uris == null || uris.length === 0) return Directive.Back; if (uris == null || uris.length === 0) return Directive.Back;

Loading…
Cancel
Save