Skip to content

Commit

Permalink
Adds reveal in repos view to search
Browse files Browse the repository at this point in the history
Fixes issue stash reveal button
Updates reveal|open in view icons
Adds gating to reveal methods
  • Loading branch information
eamodio committed Sep 17, 2019
1 parent 88850d8 commit f726420
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 74 deletions.
4 changes: 2 additions & 2 deletions images/dark/icon-eye-selected.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions images/dark/icon-eye.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions images/dark/icon-open.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions images/light/icon-eye-selected.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions images/light/icon-eye.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions images/light/icon-open.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2228,12 +2228,12 @@
},
{
"command": "gitlens.showCommitInView",
"title": "Show Commit in View",
"title": "Open in Search Commits View",
"category": "GitLens"
},
{
"command": "gitlens.showFileHistoryInView",
"title": "Show File History in View",
"title": "Open in File History View",
"category": "GitLens"
},
{
Expand Down
76 changes: 53 additions & 23 deletions src/commands/git/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,18 @@ export class SearchGitCommand extends QuickCommandBase<State> {

static readonly OpenInView: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-link.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-link.svg') as any
dark: Container.context.asAbsolutePath('images/dark/icon-open.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-open.svg') as any
},
tooltip: 'Open in View'
tooltip: 'Open in Search Commits View'
};

static readonly RevealInView: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-eye.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-eye.svg') as any
},
tooltip: 'Reveal in Repositories View'
};

static readonly ShowInView: QuickInputButton = {
Expand Down Expand Up @@ -403,18 +411,30 @@ export class SearchGitCommand extends QuickCommandBase<State> {
)
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView, this.Buttons.OpenInView],
onDidClickButton: (quickpick, button) => {
if (button !== this.Buttons.OpenInView) return;

void Container.searchView.search(
state.repo!.path,
search,
{
label: { label: `for ${state.pattern}` }
},
results
);
if (button === this.Buttons.OpenInView) {
void Container.searchView.search(
state.repo!.path,
search,
{
label: { label: `for ${state.pattern}` }
},
results
);

return;
}

if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealCommit(quickpick.activeItems[0].item, {
select: true,
focus: false,
expand: true
});
}
}
},
keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async (quickpick, key) => {
Expand Down Expand Up @@ -461,17 +481,27 @@ export class SearchGitCommand extends QuickCommandBase<State> {
items: await CommitQuickPick.getItems(pickedCommit, pickedCommit.toGitUri(), {
showChanges: false
}),
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView, this.Buttons.OpenInView],
onDidClickButton: (quickpick, button) => {
if (button !== this.Buttons.OpenInView) return;
if (button === this.Buttons.OpenInView) {
void Container.searchView.search(
pickedCommit!.repoPath,
{ pattern: SearchPattern.fromCommit(pickedCommit!) },
{
label: { label: `for commit id ${pickedCommit!.shortSha}` }
}
);

void Container.searchView.search(
pickedCommit!.repoPath,
{ pattern: SearchPattern.fromCommit(pickedCommit!) },
{
label: { label: `for commit id ${pickedCommit!.shortSha}` }
}
);
return;
}

if (button === this.Buttons.RevealInView) {
void Container.repositoriesView.revealCommit(pickedCommit!, {
select: true,
focus: false,
expand: true
});
}
}
});
const selection: StepSelection<typeof step> = yield step;
Expand Down
45 changes: 21 additions & 24 deletions src/commands/git/stash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable no-loop-func */
import { QuickInputButton, QuickInputButtons, QuickPickItem, Uri, window } from 'vscode';
import { Container } from '../../container';
import { GitStashCommit, GitUri, Repository, SearchPattern } from '../../git/gitService';
import { GitStashCommit, GitUri, Repository } from '../../git/gitService';
import {
BreakQuickCommand,
QuickCommandBase,
Expand Down Expand Up @@ -82,12 +82,12 @@ export interface StashGitCommandArgs {

export class StashGitCommand extends QuickCommandBase<State> {
private readonly Buttons = class {
static readonly OpenInView: QuickInputButton = {
static readonly RevealInView: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-link.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-link.svg') as any
dark: Container.context.asAbsolutePath('images/dark/icon-eye.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-eye.svg') as any
},
tooltip: 'Open in View'
tooltip: 'Reveal in Repositories View'
};
};

Expand Down Expand Up @@ -345,9 +345,9 @@ export class StashGitCommand extends QuickCommandBase<State> {
)
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealStash(quickpick.activeItems[0].item, {
select: true,
Expand Down Expand Up @@ -415,9 +415,9 @@ export class StashGitCommand extends QuickCommandBase<State> {
undefined,
{
placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}`,
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
void Container.repositoriesView.revealStash(state.stash!, {
select: true,
expand: true
Expand Down Expand Up @@ -472,9 +472,9 @@ export class StashGitCommand extends QuickCommandBase<State> {
)
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealStash(quickpick.activeItems[0].item, {
select: true,
Expand Down Expand Up @@ -519,9 +519,9 @@ export class StashGitCommand extends QuickCommandBase<State> {
undefined,
{
placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}`,
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
void Container.repositoriesView.revealStash(state.stash!, {
select: true,
expand: true
Expand Down Expand Up @@ -569,9 +569,9 @@ export class StashGitCommand extends QuickCommandBase<State> {
})
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealStash(quickpick.activeItems[0].item, {
select: true,
Expand Down Expand Up @@ -616,17 +616,14 @@ export class StashGitCommand extends QuickCommandBase<State> {
pickedStash.number === undefined ? '' : `${pickedStash.number}: `
}${pickedStash.getShortMessage()}`,
items: await CommitQuickPick.getItems(pickedStash, pickedStash.toGitUri(), { showChanges: false }),
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button !== this.Buttons.OpenInView) return;
if (button !== this.Buttons.RevealInView) return;

void Container.searchView.search(
pickedStash!.repoPath,
{ pattern: SearchPattern.fromCommit(pickedStash!) },
{
label: { label: `for commit id ${pickedStash!.shortSha}` }
}
);
void Container.repositoriesView.revealStash(pickedStash!, {
select: true,
expand: true
});
}
});
const selection: StepSelection<typeof step> = yield step;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/showQuickFileHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Messages } from '../messages';
import {
CommandQuickPickItem,
FileHistoryQuickPick,
OpenFileHistoryInViewQuickPickItem,
OpenInFileHistoryViewQuickPickItem,
ShowFileHistoryFromQuickPickItem
} from '../quickpicks';
import { Iterables, Strings } from '../system';
Expand Down Expand Up @@ -148,7 +148,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
: undefined,
showInViewCommand:
args.log !== undefined
? new OpenFileHistoryInViewQuickPickItem(
? new OpenInFileHistoryViewQuickPickItem(
gitUri,
(args.reference && args.reference.ref) || gitUri.sha
)
Expand Down
11 changes: 5 additions & 6 deletions src/quickpicks/commitQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import {
CommandQuickPickItem,
getQuickPickIgnoreFocusOut,
KeyCommandQuickPickItem,
OpenCommitInViewQuickPickItem,
OpenInSearchCommitsViewQuickPickItem,
QuickPickItem,
RevealCommitInViewQuickPickItem
RevealInRepositoriesViewQuickPickItem
} from './commonQuickPicks';
import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick';

Expand Down Expand Up @@ -284,11 +284,10 @@ export class CommitQuickPick {
)
);

items.push(new OpenCommitInViewQuickPickItem(commit));
items.push(new RevealCommitInViewQuickPickItem(commit));
items.push(new RevealInRepositoriesViewQuickPickItem(commit));
} else {
items.push(new OpenCommitInViewQuickPickItem(commit));
items.push(new RevealCommitInViewQuickPickItem(commit));
items.push(new OpenInSearchCommitsViewQuickPickItem(commit));
items.push(new RevealInRepositoriesViewQuickPickItem(commit));
items.push(new OpenCommitFilesCommandQuickPickItem(commit));
items.push(new OpenCommitFileRevisionsCommandQuickPickItem(commit));

Expand Down
8 changes: 4 additions & 4 deletions src/quickpicks/commonQuickPicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ export class MessageQuickPickItem extends CommandQuickPickItem {
}
}

export class OpenCommitInViewQuickPickItem extends CommandQuickPickItem {
export class OpenInSearchCommitsViewQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly commit: GitLogCommit,
item: QuickPickItem = {
label: '$(eye) Open in Search Commits View',
label: '$(link-external) Open in Search Commits View',
description: ''
}
) {
Expand All @@ -124,7 +124,7 @@ export class OpenCommitInViewQuickPickItem extends CommandQuickPickItem {
}
}

export class OpenFileHistoryInViewQuickPickItem extends CommandQuickPickItem {
export class OpenInFileHistoryViewQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly uri: GitUri,
public readonly baseRef: string | undefined,
Expand All @@ -141,7 +141,7 @@ export class OpenFileHistoryInViewQuickPickItem extends CommandQuickPickItem {
}
}

export class RevealCommitInViewQuickPickItem extends CommandQuickPickItem {
export class RevealInRepositoriesViewQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly commit: GitLogCommit | GitStashCommit,
item: QuickPickItem = {
Expand Down
16 changes: 12 additions & 4 deletions src/views/repositoriesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ import {
ProgressLocation,
window
} from 'vscode';
import { configuration, RepositoriesViewConfig, ViewFilesLayout, ViewsConfig } from '../configuration';
import {
configuration,
RepositoriesViewConfig,
ViewFilesLayout,
ViewsConfig,
ViewShowBranchComparison
} from '../configuration';
import { CommandContext, setCommandContext, WorkspaceState } from '../constants';
import { Container } from '../container';
import { GitLogCommit, GitService, GitStashCommit } from '../git/gitService';
import {
BranchesNode,
BranchNode,
Expand All @@ -22,10 +29,8 @@ import {
StashNode,
ViewNode
} from './nodes';
import { gate } from '../system';
import { ViewBase } from './viewBase';
import { ViewShowBranchComparison } from '../config';
import { GitLogCommit, GitStashCommit } from '../git/git';
import { GitService } from '../git/gitService';

export class RepositoriesView extends ViewBase<RepositoriesNode> {
constructor() {
Expand Down Expand Up @@ -175,6 +180,7 @@ export class RepositoriesView extends ViewBase<RepositoriesNode> {
});
}

@gate<RepositoriesView['revealCommit']>(() => '')
revealCommit(
commit: GitLogCommit | { repoPath: string; ref: string },
options?: {
Expand Down Expand Up @@ -214,6 +220,7 @@ export class RepositoriesView extends ViewBase<RepositoriesNode> {
);
}

@gate<RepositoriesView['revealStash']>(() => '')
async revealStash(
stash: GitStashCommit | { repoPath: string; ref: string; stashName: string },
options?: {
Expand All @@ -239,6 +246,7 @@ export class RepositoriesView extends ViewBase<RepositoriesNode> {
);
}

@gate<RepositoriesView['revealStashes']>(() => '')
async revealStashes(
repoPath: string,
options?: {
Expand Down

0 comments on commit f726420

Please sign in to comment.