Browse Source

Removes QuickPickSeparator namespace

main
Eric Amodio 1 year ago
parent
commit
556004ed6c
3 changed files with 34 additions and 35 deletions
  1. +2
    -2
      src/commands/git/worktree.ts
  2. +30
    -29
      src/commands/quickCommand.steps.ts
  3. +2
    -4
      src/quickpicks/items/common.ts

+ 2
- 2
src/commands/git/worktree.ts View File

@ -16,7 +16,7 @@ import type { Repository } from '../../git/models/repository';
import { GitWorktree } from '../../git/models/worktree'; import { GitWorktree } from '../../git/models/worktree';
import { showGenericErrorMessage } from '../../messages'; import { showGenericErrorMessage } from '../../messages';
import type { QuickPickItemOfT } from '../../quickpicks/items/common'; import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { QuickPickSeparator } from '../../quickpicks/items/common';
import { createQuickPickSeparator } from '../../quickpicks/items/common';
import { Directive } from '../../quickpicks/items/directive'; import { Directive } from '../../quickpicks/items/directive';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags'; import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags'; import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
@ -621,7 +621,7 @@ export class WorktreeGitCommand extends QuickCommand {
), ),
...(canCreateDirectlyInPicked ...(canCreateDirectlyInPicked
? [ ? [
QuickPickSeparator.create(),
createQuickPickSeparator(),
createFlagsQuickPickItem<CreateFlags, Uri>( createFlagsQuickPickItem<CreateFlags, Uri>(
state.flags, state.flags,
['--direct'], ['--direct'],

+ 30
- 29
src/commands/quickCommand.steps.ts View File

@ -54,7 +54,8 @@ import {
CommitRestoreFileChangesCommandQuickPickItem, CommitRestoreFileChangesCommandQuickPickItem,
OpenChangedFilesCommandQuickPickItem, OpenChangedFilesCommandQuickPickItem,
} from '../quickpicks/items/commits'; } from '../quickpicks/items/commits';
import { CommandQuickPickItem, QuickPickSeparator } from '../quickpicks/items/common';
import type { QuickPickSeparator } from '../quickpicks/items/common';
import { CommandQuickPickItem, createQuickPickSeparator } from '../quickpicks/items/common';
import type { DirectiveQuickPickItem } from '../quickpicks/items/directive'; import type { DirectiveQuickPickItem } from '../quickpicks/items/directive';
import { createDirectiveQuickPickItem, Directive } from '../quickpicks/items/directive'; import { createDirectiveQuickPickItem, Directive } from '../quickpicks/items/directive';
import type { import type {
@ -305,7 +306,7 @@ export async function getBranchesAndOrTags(
if (branches != null && branches.length !== 0 && (tags == null || tags.length === 0)) { if (branches != null && branches.length !== 0 && (tags == null || tags.length === 0)) {
return [ return [
QuickPickSeparator.create('Branches'),
createQuickPickSeparator('Branches'),
...(await Promise.all( ...(await Promise.all(
branches branches
.filter(b => !b.remote) .filter(b => !b.remote)
@ -323,7 +324,7 @@ export async function getBranchesAndOrTags(
), ),
), ),
)), )),
QuickPickSeparator.create('Remote Branches'),
createQuickPickSeparator('Remote Branches'),
...(await Promise.all( ...(await Promise.all(
branches branches
.filter(b => b.remote) .filter(b => b.remote)
@ -359,7 +360,7 @@ export async function getBranchesAndOrTags(
} }
return [ return [
QuickPickSeparator.create('Branches'),
createQuickPickSeparator('Branches'),
...(await Promise.all( ...(await Promise.all(
branches! branches!
.filter(b => !b.remote) .filter(b => !b.remote)
@ -376,7 +377,7 @@ export async function getBranchesAndOrTags(
), ),
), ),
)), )),
QuickPickSeparator.create('Tags'),
createQuickPickSeparator('Tags'),
...tags!.map(t => ...tags!.map(t =>
createTagQuickPickItem( createTagQuickPickItem(
t, t,
@ -389,7 +390,7 @@ export async function getBranchesAndOrTags(
}, },
), ),
), ),
QuickPickSeparator.create('Remote Branches'),
createQuickPickSeparator('Remote Branches'),
...(await Promise.all( ...(await Promise.all(
branches! branches!
.filter(b => b.remote) .filter(b => b.remote)
@ -1793,7 +1794,7 @@ async function getShowCommitOrStashStepItems<
if (isStash(state.reference)) { if (isStash(state.reference)) {
items.push( items.push(
QuickPickSeparator.create('Actions'),
createQuickPickSeparator('Actions'),
new GitCommandQuickPickItem('Apply Stash...', { new GitCommandQuickPickItem('Apply Stash...', {
command: 'stash', command: 'stash',
state: { state: {
@ -1811,14 +1812,14 @@ async function getShowCommitOrStashStepItems<
}, },
}), }),
QuickPickSeparator.create(),
createQuickPickSeparator(),
new CommitCopyMessageQuickPickItem(state.reference), new CommitCopyMessageQuickPickItem(state.reference),
); );
} else { } else {
const remotes = await Container.instance.git.getRemotesWithProviders(state.repo.path, { sort: true }); const remotes = await Container.instance.git.getRemotesWithProviders(state.repo.path, { sort: true });
if (remotes?.length) { if (remotes?.length) {
items.push( items.push(
QuickPickSeparator.create(GitRemote.getHighlanderProviderName(remotes) ?? 'Remote'),
createQuickPickSeparator(GitRemote.getHighlanderProviderName(remotes) ?? 'Remote'),
new OpenRemoteResourceCommandQuickPickItem(remotes, { new OpenRemoteResourceCommandQuickPickItem(remotes, {
type: RemoteResourceType.Commit, type: RemoteResourceType.Commit,
sha: state.reference.sha, sha: state.reference.sha,
@ -1830,7 +1831,7 @@ async function getShowCommitOrStashStepItems<
); );
} }
items.push(QuickPickSeparator.create('Actions'));
items.push(createQuickPickSeparator('Actions'));
const branch = await Container.instance.git.getBranch(state.repo.path); const branch = await Container.instance.git.getBranch(state.repo.path);
const [branches, published] = await Promise.all([ const [branches, published] = await Promise.all([
@ -1915,7 +1916,7 @@ async function getShowCommitOrStashStepItems<
}, },
}), }),
QuickPickSeparator.create(),
createQuickPickSeparator(),
new GitCommandQuickPickItem('Create Branch at Commit...', { new GitCommandQuickPickItem('Create Branch at Commit...', {
command: 'branch', command: 'branch',
state: { state: {
@ -1933,36 +1934,36 @@ async function getShowCommitOrStashStepItems<
}, },
}), }),
QuickPickSeparator.create('Copy'),
createQuickPickSeparator('Copy'),
new CommitCopyIdQuickPickItem(state.reference), new CommitCopyIdQuickPickItem(state.reference),
new CommitCopyMessageQuickPickItem(state.reference), new CommitCopyMessageQuickPickItem(state.reference),
); );
} }
items.push( items.push(
QuickPickSeparator.create('Open'),
createQuickPickSeparator('Open'),
new CommitOpenAllChangesCommandQuickPickItem(state.reference), new CommitOpenAllChangesCommandQuickPickItem(state.reference),
new CommitOpenAllChangesWithWorkingCommandQuickPickItem(state.reference), new CommitOpenAllChangesWithWorkingCommandQuickPickItem(state.reference),
new CommitOpenAllChangesWithDiffToolCommandQuickPickItem(state.reference), new CommitOpenAllChangesWithDiffToolCommandQuickPickItem(state.reference),
QuickPickSeparator.create(),
createQuickPickSeparator(),
new CommitOpenFilesCommandQuickPickItem(state.reference), new CommitOpenFilesCommandQuickPickItem(state.reference),
new CommitOpenRevisionsCommandQuickPickItem(state.reference), new CommitOpenRevisionsCommandQuickPickItem(state.reference),
); );
items.push( items.push(
QuickPickSeparator.create('Compare'),
createQuickPickSeparator('Compare'),
new CommitCompareWithHEADCommandQuickPickItem(state.reference), new CommitCompareWithHEADCommandQuickPickItem(state.reference),
new CommitCompareWithWorkingCommandQuickPickItem(state.reference), new CommitCompareWithWorkingCommandQuickPickItem(state.reference),
); );
items.push( items.push(
QuickPickSeparator.create(),
createQuickPickSeparator(),
new CommitOpenDirectoryCompareCommandQuickPickItem(state.reference), new CommitOpenDirectoryCompareCommandQuickPickItem(state.reference),
new CommitOpenDirectoryCompareWithWorkingCommandQuickPickItem(state.reference), new CommitOpenDirectoryCompareWithWorkingCommandQuickPickItem(state.reference),
); );
items.push( items.push(
QuickPickSeparator.create('Browse'),
createQuickPickSeparator('Browse'),
new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, { openInNewWindow: false }), new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, { openInNewWindow: false }),
new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, { new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, {
before: true, before: true,
@ -2018,7 +2019,7 @@ export function* showCommitOrStashFilesStep<
picked: state.fileName == null, picked: state.fileName == null,
hint: `Click to see ${isStash(state.reference) ? 'stash' : 'commit'} actions`, hint: `Click to see ${isStash(state.reference) ? 'stash' : 'commit'} actions`,
}), }),
QuickPickSeparator.create('Files'),
createQuickPickSeparator('Files'),
...(state.reference.files?.map( ...(state.reference.files?.map(
fs => new CommitFileQuickPickItem(state.reference, fs, options?.picked === fs.path), fs => new CommitFileQuickPickItem(state.reference, fs, options?.picked === fs.path),
) ?? []), ) ?? []),
@ -2149,19 +2150,19 @@ async function getShowCommitOrStashFileStepItems<
if (isStash(state.reference)) { if (isStash(state.reference)) {
items.push( items.push(
QuickPickSeparator.create(),
createQuickPickSeparator(),
new CommitCopyMessageQuickPickItem(state.reference), new CommitCopyMessageQuickPickItem(state.reference),
QuickPickSeparator.create('Actions'),
createQuickPickSeparator('Actions'),
new CommitApplyFileChangesCommandQuickPickItem(state.reference, file), new CommitApplyFileChangesCommandQuickPickItem(state.reference, file),
new CommitRestoreFileChangesCommandQuickPickItem(state.reference, file), new CommitRestoreFileChangesCommandQuickPickItem(state.reference, file),
QuickPickSeparator.create(),
createQuickPickSeparator(),
new CommitCopyMessageQuickPickItem(state.reference), new CommitCopyMessageQuickPickItem(state.reference),
); );
} else { } else {
const remotes = await Container.instance.git.getRemotesWithProviders(state.repo.path, { sort: true }); const remotes = await Container.instance.git.getRemotesWithProviders(state.repo.path, { sort: true });
if (remotes?.length) { if (remotes?.length) {
items.push( items.push(
QuickPickSeparator.create(GitRemote.getHighlanderProviderName(remotes) ?? 'Remote'),
createQuickPickSeparator(GitRemote.getHighlanderProviderName(remotes) ?? 'Remote'),
new OpenRemoteResourceCommandQuickPickItem(remotes, { new OpenRemoteResourceCommandQuickPickItem(remotes, {
type: RemoteResourceType.Revision, type: RemoteResourceType.Revision,
fileName: state.fileName, fileName: state.fileName,
@ -2172,7 +2173,7 @@ async function getShowCommitOrStashFileStepItems<
fileName: state.fileName, fileName: state.fileName,
commit: state.reference, commit: state.reference,
}), }),
QuickPickSeparator.create(),
createQuickPickSeparator(),
new OpenRemoteResourceCommandQuickPickItem(remotes, { new OpenRemoteResourceCommandQuickPickItem(remotes, {
type: RemoteResourceType.Commit, type: RemoteResourceType.Commit,
sha: state.reference.ref, sha: state.reference.ref,
@ -2185,21 +2186,21 @@ async function getShowCommitOrStashFileStepItems<
} }
items.push( items.push(
QuickPickSeparator.create('Actions'),
createQuickPickSeparator('Actions'),
new CommitApplyFileChangesCommandQuickPickItem(state.reference, file), new CommitApplyFileChangesCommandQuickPickItem(state.reference, file),
new CommitRestoreFileChangesCommandQuickPickItem(state.reference, file), new CommitRestoreFileChangesCommandQuickPickItem(state.reference, file),
QuickPickSeparator.create('Copy'),
createQuickPickSeparator('Copy'),
new CommitCopyIdQuickPickItem(state.reference), new CommitCopyIdQuickPickItem(state.reference),
new CommitCopyMessageQuickPickItem(state.reference), new CommitCopyMessageQuickPickItem(state.reference),
); );
} }
items.push( items.push(
QuickPickSeparator.create('Open'),
createQuickPickSeparator('Open'),
new CommitOpenChangesCommandQuickPickItem(state.reference, state.fileName), new CommitOpenChangesCommandQuickPickItem(state.reference, state.fileName),
new CommitOpenChangesWithWorkingCommandQuickPickItem(state.reference, state.fileName), new CommitOpenChangesWithWorkingCommandQuickPickItem(state.reference, state.fileName),
new CommitOpenChangesWithDiffToolCommandQuickPickItem(state.reference, state.fileName), new CommitOpenChangesWithDiffToolCommandQuickPickItem(state.reference, state.fileName),
QuickPickSeparator.create(),
createQuickPickSeparator(),
); );
if (file.status !== 'D') { if (file.status !== 'D') {
@ -2208,13 +2209,13 @@ async function getShowCommitOrStashFileStepItems<
items.push(new CommitOpenRevisionCommandQuickPickItem(state.reference, file)); items.push(new CommitOpenRevisionCommandQuickPickItem(state.reference, file));
items.push( items.push(
QuickPickSeparator.create('Compare'),
createQuickPickSeparator('Compare'),
new CommitCompareWithHEADCommandQuickPickItem(state.reference), new CommitCompareWithHEADCommandQuickPickItem(state.reference),
new CommitCompareWithWorkingCommandQuickPickItem(state.reference), new CommitCompareWithWorkingCommandQuickPickItem(state.reference),
); );
items.push( items.push(
QuickPickSeparator.create('Browse'),
createQuickPickSeparator('Browse'),
new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, { openInNewWindow: false }), new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, { openInNewWindow: false }),
new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, { new CommitBrowseRepositoryFromHereCommandQuickPickItem(state.reference, {
before: true, before: true,

+ 2
- 4
src/quickpicks/items/common.ts View File

@ -14,10 +14,8 @@ export interface QuickPickSeparator extends QuickPickItem {
kind: QuickPickItemKind.Separator; kind: QuickPickItemKind.Separator;
} }
export namespace QuickPickSeparator {
export function create(label?: string): QuickPickSeparator {
return { kind: QuickPickItemKind.Separator, label: label ?? '' };
}
export function createQuickPickSeparator(label?: string): QuickPickSeparator {
return { kind: QuickPickItemKind.Separator, label: label ?? '' };
} }
export interface QuickPickItemOfT<T = any> extends QuickPickItem { export interface QuickPickItemOfT<T = any> extends QuickPickItem {

Loading…
Cancel
Save