Refactors the quickpick menus

Consolidated lots of duplicate functionality
go back navigation should be robust now
This commit is contained in:
Eric Amodio
2017-02-16 04:07:54 -05:00
parent beb6740120
commit 8594a5dd38
6 changed files with 233 additions and 267 deletions

View File

@@ -1,13 +1,22 @@
'use strict';
import { QuickPickItem, Uri } from 'vscode';
import { commands, QuickPickItem, Uri } from 'vscode';
import { Commands } from '../constants';
import { GitCommit, GitUri } from '../gitProvider';
import * as moment from 'moment';
import * as path from 'path';
export interface CommandQuickPickItem extends QuickPickItem {
command: Commands;
args?: any[];
export class CommandQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
constructor(item: QuickPickItem, public command: Commands, public args?: any[]) {
Object.assign(this, item);
}
execute() {
return commands.executeCommand(this.command, ...(this.args || []));
}
}
export class CommitQuickPickItem implements QuickPickItem {
@@ -28,25 +37,14 @@ export class FileQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
sha: string;
uri: GitUri;
constructor(commit: GitCommit, public fileName: string) {
this.label = fileName;
this.sha = commit.sha;
this.uri = GitUri.fromUri(Uri.file(path.resolve(commit.repoPath, fileName)));
}
}
export class ShowAllCommitsQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
constructor(maxItems: number) {
this.label = `$(sync) Show Full History`;
this.description = `\u2014 Currently only showing the first ${maxItems} commits`;
this.detail = `This may take a while`;
}
}