Ver a proveniência

Allows passing step props to createConfirmStep

main
Eric Amodio há 5 anos
ascendente
cometimento
2b1cb1ac5e
6 ficheiros alterados com 60 adições e 62 eliminações
  1. +6
    -7
      src/commands/git/merge.ts
  2. +37
    -32
      src/commands/git/pull.ts
  3. +4
    -6
      src/commands/git/push.ts
  4. +5
    -7
      src/commands/git/rebase.ts
  5. +3
    -1
      src/commands/git/stash.ts
  6. +5
    -9
      src/commands/quickCommand.ts

+ 6
- 7
src/commands/git/merge.ts Ver ficheiro

@ -145,15 +145,14 @@ export class MergeGitCommand extends QuickCommandBase {
const step = this.createConfirmStep(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[],
{
cancel: DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: `${destination.name} is up to date with ${state.reference.name}`
})
}
);
DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: `${destination.name} is up to date with ${state.reference.name}`
})
);
yield step;
break;
}

+ 37
- 32
src/commands/git/pull.ts Ver ficheiro

@ -170,40 +170,45 @@ export class PullGitCommand extends QuickCommandBase {
).fromNow()}`;
}
const step = this.createConfirmStep<GitFlagsQuickPickItem>(`${title}${fetchedOn}`, [
{
label: this.title,
description: '',
detail: `Will pull ${detail}`,
item: []
},
const step = this.createConfirmStep<GitFlagsQuickPickItem>(
`${title}${fetchedOn}`,
[
{
label: this.title,
description: '',
detail: `Will pull ${detail}`,
item: []
},
{
label: `${this.title} with Rebase`,
description: '--rebase',
detail: `Will pull ${detail} with rebase`,
item: ['--rebase']
}
],
undefined,
{
label: `${this.title} with Rebase`,
description: '--rebase',
detail: `Will pull ${detail} with rebase`,
item: ['--rebase']
}
]);
step.additionalButtons = [this.Buttons.Fetch];
step.onDidClickButton = async (quickpick, button) => {
if (button !== this.Buttons.Fetch) return;
quickpick.title = `${title}${Strings.pad(GlyphChars.Dot, 2, 2)}Fetching${GlyphChars.Ellipsis}`;
quickpick.busy = true;
quickpick.enabled = false;
try {
await repo.fetch({ progress: true });
const step = await this.getSingleRepoConfirmStep(state);
quickpick.title = step.title;
quickpick.items = step.items as any;
} finally {
quickpick.busy = false;
quickpick.enabled = true;
additionalButtons: [this.Buttons.Fetch],
onDidClickButton: async (quickpick, button) => {
if (button !== this.Buttons.Fetch) return;
quickpick.title = `${title}${Strings.pad(GlyphChars.Dot, 2, 2)}Fetching${GlyphChars.Ellipsis}`;
quickpick.busy = true;
quickpick.enabled = false;
try {
await repo.fetch({ progress: true });
const step = await this.getSingleRepoConfirmStep(state);
quickpick.title = step.title;
quickpick.items = step.items as any;
} finally {
quickpick.busy = false;
quickpick.enabled = true;
}
}
}
};
);
return step;
}

+ 4
- 6
src/commands/git/push.ts Ver ficheiro

@ -153,12 +153,10 @@ export class PushGitCommand extends QuickCommandBase {
return this.createConfirmStep(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${repo.formattedName}`,
[],
{
cancel: DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: 'No commits to push'
})
}
DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: 'No commits to push'
})
);
}

+ 5
- 7
src/commands/git/rebase.ts Ver ficheiro

@ -228,15 +228,13 @@ export class RebaseGitCommand extends QuickCommandBase {
const step = this.createConfirmStep(
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[],
{
cancel: DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: `${destination.name} is up to date with ${state.reference.name}`
})
}
DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: `${destination.name} is up to date with ${state.reference.name}`
})
);
yield step;
break;
}

+ 3
- 1
src/commands/git/stash.ts Ver ficheiro

@ -381,6 +381,7 @@ export class StashGitCommand extends QuickCommandBase {
item: []
}
],
undefined,
{ placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}` }
);
const selection: StepSelection<typeof step> = yield step;
@ -442,7 +443,6 @@ export class StashGitCommand extends QuickCommandBase {
state.stash = selection[0].item;
}
// if (this.confirm(state.confirm)) {
const message =
state.stash.message.length > 80
? `${state.stash.message.substring(0, 80)}${GlyphChars.Ellipsis}`
@ -459,6 +459,7 @@ export class StashGitCommand extends QuickCommandBase {
detail: `Will delete ${state.stash.stashName}`
}
],
undefined,
{ placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}` }
);
const selection: StepSelection<typeof step> = yield step;
@ -611,6 +612,7 @@ export class StashGitCommand extends QuickCommandBase {
item: ['--keep-index']
}
],
undefined,
{ placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}` }
);
const selection: StepSelection<typeof step> = yield step;

+ 5
- 9
src/commands/quickCommand.ts Ver ficheiro

@ -156,19 +156,15 @@ export abstract class QuickCommandBase implements QuickPickItem {
protected createConfirmStep<T extends QuickPickItem>(
title: string,
confirmations: T[],
{
cancel,
placeholder
}: {
cancel?: DirectiveQuickPickItem;
placeholder?: string;
} = {}
cancel?: DirectiveQuickPickItem,
options: Partial<QuickPickStep<T>> = {}
): QuickPickStep<T> {
return this.createPickStep<T>({
placeholder: placeholder || `Confirm ${this.title}`,
placeholder: `Confirm ${this.title}`,
title: title,
items: [...confirmations, cancel || DirectiveQuickPickItem.create(Directive.Cancel)],
selectedItems: [confirmations[0]]
selectedItems: [confirmations[0]],
...options
});
}

Carregando…
Cancelar
Guardar