Browse Source

Improves Git Command Palette confirm messaging

main
Eric Amodio 1 year ago
parent
commit
a5c1fcd58d
4 changed files with 33 additions and 27 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +16
    -12
      src/commands/gitCommands.ts
  3. +11
    -13
      src/commands/quickCommand.buttons.ts
  4. +5
    -2
      src/commands/quickCommand.ts

+ 1
- 0
CHANGELOG.md View File

@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Changed
- Improves accuracy, performance, and memory usage related to parsing diffs, used in _Changes_ hovers, _Changes_ file annotations, etc
- Improves confirmation messaging in the _Git Command Palette_
- Refines merge/rebase messaging when there is nothing to do — refs [#1660](https://github.com/gitkraken/vscode-gitlens/issues/1660)
### Fixed

+ 16
- 12
src/commands/gitCommands.ts View File

@ -249,22 +249,26 @@ export class GitCommandsCommand extends Command {
if (command?.canConfirm) {
if (command.canSkipConfirm) {
const willConfirmToggle = new WillConfirmToggleQuickInputButton(command.confirm(), async () => {
if (command?.skipConfirmKey == null) return;
const willConfirmToggle = new WillConfirmToggleQuickInputButton(
command.confirm(),
step?.isConfirmationStep ?? false,
async () => {
if (command?.skipConfirmKey == null) return;
const skipConfirmations = configuration.get('gitCommands.skipConfirmations') ?? [];
const skipConfirmations = configuration.get('gitCommands.skipConfirmations') ?? [];
const index = skipConfirmations.indexOf(command.skipConfirmKey);
if (index !== -1) {
skipConfirmations.splice(index, 1);
} else {
skipConfirmations.push(command.skipConfirmKey);
}
const index = skipConfirmations.indexOf(command.skipConfirmKey);
if (index !== -1) {
skipConfirmations.splice(index, 1);
} else {
skipConfirmations.push(command.skipConfirmKey);
}
await configuration.updateEffective('gitCommands.skipConfirmations', skipConfirmations);
});
await configuration.updateEffective('gitCommands.skipConfirmations', skipConfirmations);
},
);
buttons.push(willConfirmToggle);
} else {
} else if (!step?.isConfirmationStep) {
buttons.push(WillConfirmForcedQuickInputButton);
}
}

+ 11
- 13
src/commands/quickCommand.buttons.ts View File

@ -149,27 +149,25 @@ export const ShowTagsToggleQuickInputButton = class extends SelectableQuickInput
};
export const WillConfirmForcedQuickInputButton: QuickInputButton = {
iconPath: new ThemeIcon('check'),
tooltip: 'Will always confirm',
iconPath: new ThemeIcon('gitlens-confirm-checked'),
tooltip: 'You will be presented with a required confirmation step before the action is performed',
};
export const WillConfirmToggleQuickInputButton = class extends ToggleQuickInputButton {
constructor(on = false, onDidClick?: (quickInput: QuickInput) => void) {
constructor(on = false, isConfirmationStep: boolean, onDidClick?: (quickInput: QuickInput) => void) {
super(
() => ({
on: {
tooltip: 'Will confirm',
icon: {
dark: Uri.file(Container.instance.context.asAbsolutePath('images/dark/icon-check.svg')),
light: Uri.file(Container.instance.context.asAbsolutePath('images/light/icon-check.svg')),
},
tooltip: isConfirmationStep
? 'For future actions, you will be presented with confirmation step before the action is performed\nClick to toggle'
: 'You will be presented with confirmation step before the action is performed\nClick to toggle',
icon: new ThemeIcon('gitlens-confirm-checked'),
},
off: {
tooltip: 'Skips confirm',
icon: {
dark: Uri.file(Container.instance.context.asAbsolutePath('images/dark/icon-no-check.svg')),
light: Uri.file(Container.instance.context.asAbsolutePath('images/light/icon-no-check.svg')),
},
tooltip: isConfirmationStep
? "For future actions, you won't be presented with confirmation step before the action is performed\nClick to toggle"
: "You won't be presented with confirmation step before the action is performed\nClick to toggle",
icon: new ThemeIcon('gitlens-confirm-unchecked'),
},
}),
on,

+ 5
- 2
src/commands/quickCommand.ts View File

@ -21,6 +21,7 @@ export interface QuickInputStep {
additionalButtons?: QuickInputButton[];
buttons?: QuickInputButton[];
ignoreFocusOut?: boolean;
isConfirmationStep?: boolean;
keys?: StepNavigationKeys[];
placeholder?: string;
prompt?: string;
@ -43,6 +44,7 @@ export interface QuickPickStep {
allowEmpty?: boolean;
buttons?: QuickInputButton[];
ignoreFocusOut?: boolean;
isConfirmationStep?: boolean;
items: (DirectiveQuickPickItem | T)[]; // | DirectiveQuickPickItem[];
keys?: StepNavigationKeys[];
matchOnDescription?: boolean;
@ -323,15 +325,16 @@ export function createConfirmStep
confirmations: T[],
context: Context,
cancel?: DirectiveQuickPickItem,
options: Partial<QuickPickStep<T>> = {},
options?: Partial<QuickPickStep<T>>,
): QuickPickStep<T> {
return createPickStep<T>({
isConfirmationStep: true,
placeholder: `Confirm ${context.title}`,
title: title,
ignoreFocusOut: true,
items: [...confirmations, cancel ?? createDirectiveQuickPickItem(Directive.Cancel)],
selectedItems: [confirmations.find(c => c.picked) ?? confirmations[0]],
...options,
...(options ?? {}),
});
}

Loading…
Cancel
Save