Przeglądaj źródła

Renames directive quickpick item

main
Eric Amodio 5 lat temu
rodzic
commit
558a743537
7 zmienionych plików z 52 dodań i 39 usunięć
  1. +6
    -2
      src/commands/git/cherry-pick.ts
  2. +3
    -2
      src/commands/git/merge.ts
  3. +3
    -2
      src/commands/git/rebase.ts
  4. +9
    -3
      src/commands/git/stash.ts
  5. +14
    -14
      src/commands/gitCommands.ts
  6. +4
    -8
      src/commands/quickCommand.ts
  7. +13
    -8
      src/quickpicks/gitQuickPicks.ts

+ 6
- 2
src/commands/git/cherry-pick.ts Wyświetl plik

@ -6,9 +6,10 @@ import { GlyphChars } from '../../constants';
import { Iterables, Strings } from '../../system';
import { getBranchesAndOrTags, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import {
BackOrCancelQuickPickItem,
BranchQuickPickItem,
CommitQuickPickItem,
Directive,
DirectiveQuickPickItem,
RefQuickPickItem,
RepositoryQuickPickItem
} from '../../quickpicks';
@ -137,7 +138,10 @@ export class CherryPickGitCommand extends QuickCommandBase {
: `Choose commits to cherry-pick onto ${state.destination.name}`,
items:
log === undefined
? [BackOrCancelQuickPickItem.create(false, true), BackOrCancelQuickPickItem.create()]
? [
DirectiveQuickPickItem.create(Directive.Back, true),
DirectiveQuickPickItem.create(Directive.Cancel)
]
: [
...Iterables.map(log.commits.values(), commit =>
CommitQuickPickItem.create(

+ 3
- 2
src/commands/git/merge.ts Wyświetl plik

@ -5,8 +5,9 @@ import { GitBranch, GitTag, Repository } from '../../git/gitService';
import { GlyphChars } from '../../constants';
import { getBranchesAndOrTags, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import {
BackOrCancelQuickPickItem,
BranchQuickPickItem,
Directive,
DirectiveQuickPickItem,
RepositoryQuickPickItem,
TagQuickPickItem
} from '../../quickpicks';
@ -107,7 +108,7 @@ export class MergeGitCommand extends QuickCommandBase {
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[],
{
cancel: BackOrCancelQuickPickItem.create(true, true, {
cancel: DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: `${state.destination.name} is up to date with ${state.source.name}`
})

+ 3
- 2
src/commands/git/rebase.ts Wyświetl plik

@ -5,8 +5,9 @@ import { GitBranch, GitTag, Repository } from '../../git/gitService';
import { GlyphChars } from '../../constants';
import { getBranchesAndOrTags, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import {
BackOrCancelQuickPickItem,
BranchQuickPickItem,
Directive,
DirectiveQuickPickItem,
RepositoryQuickPickItem,
TagQuickPickItem
} from '../../quickpicks';
@ -107,7 +108,7 @@ export class RebaseGitCommand extends QuickCommandBase {
`Confirm ${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${state.repo.formattedName}`,
[],
{
cancel: BackOrCancelQuickPickItem.create(true, true, {
cancel: DirectiveQuickPickItem.create(Directive.Cancel, true, {
label: `Cancel ${this.title}`,
detail: `${state.destination.name} is up to date with ${state.source.name}`
})

+ 9
- 3
src/commands/git/stash.ts Wyświetl plik

@ -3,7 +3,7 @@ import { QuickPickItem, Uri, window } from 'vscode';
import { Container } from '../../container';
import { GitStashCommit, GitUri, Repository } from '../../git/gitService';
import { BreakQuickCommand, QuickCommandBase, QuickInputStep, QuickPickStep, StepState } from '../quickCommand';
import { BackOrCancelQuickPickItem, CommitQuickPickItem, RepositoryQuickPickItem } from '../../quickpicks';
import { CommitQuickPickItem, Directive, DirectiveQuickPickItem, RepositoryQuickPickItem } from '../../quickpicks';
import { Iterables, Strings } from '../../system';
import { GlyphChars } from '../../constants';
import { Logger } from '../../logger';
@ -262,7 +262,10 @@ export class StashGitCommand extends QuickCommandBase {
: 'Choose a stash to apply to your working tree',
items:
stash === undefined
? [BackOrCancelQuickPickItem.create(false, true), BackOrCancelQuickPickItem.create()]
? [
DirectiveQuickPickItem.create(Directive.Back, true),
DirectiveQuickPickItem.create(Directive.Cancel)
]
: [
...Iterables.map(stash.commits.values(), c =>
CommitQuickPickItem.create(
@ -361,7 +364,10 @@ export class StashGitCommand extends QuickCommandBase {
: 'Choose a stash to delete',
items:
stash === undefined
? [BackOrCancelQuickPickItem.create(false, true), BackOrCancelQuickPickItem.create()]
? [
DirectiveQuickPickItem.create(Directive.Back, true),
DirectiveQuickPickItem.create(Directive.Cancel)
]
: [
...Iterables.map(stash.commits.values(), c =>
CommitQuickPickItem.create(

+ 14
- 14
src/commands/gitCommands.ts Wyświetl plik

@ -3,7 +3,7 @@ import { Disposable, InputBox, QuickInputButtons, QuickPick, QuickPickItem, wind
import { command, Command, Commands } from './common';
import { log } from '../system';
import { isQuickInputStep, isQuickPickStep, QuickCommandBase, QuickInputStep, QuickPickStep } from './quickCommand';
import { BackOrCancelQuickPickItem } from '../quickpicks';
import { Directive, DirectiveQuickPickItem } from '../quickpicks';
import { CommandArgs as CheckoutCommandArgs, CheckoutGitCommand } from './git/checkout';
import { CherryPickGitCommand } from './git/cherry-pick';
import { CommandArgs as FetchCommandArgs, FetchGitCommand } from './git/fetch';
@ -279,20 +279,20 @@ export class GitCommandsCommand extends Command {
if (items.length === 1) {
const item = items[0];
if (BackOrCancelQuickPickItem.is(item)) {
if (item.cancelled) {
resolve();
return;
if (DirectiveQuickPickItem.is(item)) {
switch (item.directive) {
case Directive.Cancel:
resolve();
return;
case Directive.Back:
quickpick.value = '';
if (commandsStep.command !== undefined) {
quickpick.busy = true;
resolve((await commandsStep.command.previous()) || commandsStep);
}
return;
}
quickpick.value = '';
if (commandsStep.command !== undefined) {
quickpick.busy = true;
resolve((await commandsStep.command.previous()) || commandsStep);
}
return;
}
}

+ 4
- 8
src/commands/quickCommand.ts Wyświetl plik

@ -1,7 +1,7 @@
'use strict';
import { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode';
import { Promises } from '../system';
import { BackOrCancelQuickPickItem } from '../quickpicks';
import { Directive, DirectiveQuickPickItem } from '../quickpicks';
export * from './quickCommand.helpers';
@ -11,10 +11,6 @@ export class BreakQuickCommand extends Error {
}
}
export enum Directive {
Back = 'back'
}
export interface QuickInputStep {
buttons?: QuickInputButton[];
placeholder?: string;
@ -32,7 +28,7 @@ export function isQuickInputStep(item: QuickPickStep | QuickInputStep): item is
export interface QuickPickStep<T extends QuickPickItem = any> {
buttons?: QuickInputButton[];
selectedItems?: QuickPickItem[];
items: (BackOrCancelQuickPickItem | T)[] | BackOrCancelQuickPickItem[];
items: (DirectiveQuickPickItem | T)[] | DirectiveQuickPickItem[];
matchOnDescription?: boolean;
matchOnDetail?: boolean;
multiselect?: boolean;
@ -118,14 +114,14 @@ export abstract class QuickCommandBase implements QuickPickItem {
cancel,
placeholder
}: {
cancel?: BackOrCancelQuickPickItem;
cancel?: DirectiveQuickPickItem;
placeholder?: string;
} = {}
): QuickPickStep<T> {
return this.createPickStep<T>({
placeholder: placeholder || `Confirm ${this.title}`,
title: title,
items: [...confirmations, cancel || BackOrCancelQuickPickItem.create()],
items: [...confirmations, cancel || DirectiveQuickPickItem.create(Directive.Cancel)],
selectedItems: [confirmations[0]]
});
}

+ 13
- 8
src/quickpicks/gitQuickPicks.ts Wyświetl plik

@ -14,28 +14,33 @@ import {
} from '../git/gitService';
import { emojify } from '../emojis';
export interface BackOrCancelQuickPickItem extends QuickPickItem {
cancelled: boolean;
export enum Directive {
Back = 'Back',
Cancel = 'Cancel'
}
export namespace BackOrCancelQuickPickItem {
export interface DirectiveQuickPickItem extends QuickPickItem {
directive: Directive;
}
export namespace DirectiveQuickPickItem {
export function create(
cancelled: boolean = true,
directive: Directive,
picked?: boolean,
options: { label?: string; description?: string; detail?: string } = {}
) {
const item: BackOrCancelQuickPickItem = {
label: options.label || (cancelled ? 'Cancel' : 'Back'),
const item: DirectiveQuickPickItem = {
label: options.label || directive,
description: options.description || '',
detail: options.detail,
picked: picked,
cancelled: cancelled
directive: directive
};
return item;
}
export function is(item: QuickPickItem): item is BackOrCancelQuickPickItem {
export function is(item: QuickPickItem): item is DirectiveQuickPickItem {
return item != null && 'cancelled' in item;
}
}

Ładowanie…
Anuluj
Zapisz