Skip to content

Commit

Permalink
Adds Branches and History views
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Sep 11, 2020
1 parent 99a32c0 commit eee360b
Show file tree
Hide file tree
Showing 36 changed files with 1,854 additions and 387 deletions.
442 changes: 393 additions & 49 deletions package.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/commands/setViewsLayout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
import { commands, ConfigurationTarget, window } from 'vscode';
import { configuration, viewKeys, ViewLocation } from '../configuration';
import { configuration, ViewLocation, viewsWithLocationConfigKeys } from '../configuration';
import { command, Command, Commands } from './common';
import { extensionId } from '../constants';

Expand Down Expand Up @@ -58,7 +58,7 @@ export class SetViewsLayoutCommand extends Command {
return;
}

for (const view of viewKeys) {
for (const view of viewsWithLocationConfigKeys) {
if (configuration.get('views', view, 'location') === location) {
await commands.executeCommand(`${extensionId}.views.${view}:${location}.resetViewLocation`);
} else {
Expand Down
175 changes: 132 additions & 43 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,25 +304,6 @@ export interface CodeLensLanguageScope {
symbolScopes?: string[];
}

export interface CompareViewConfig {
avatars: boolean;
enabled: boolean;
files: ViewsFilesConfig;
location: ViewLocation;
}

export interface FileHistoryViewConfig {
avatars: boolean;
enabled: boolean;
location: ViewLocation;
}

export interface LineHistoryViewConfig {
avatars: boolean;
enabled: boolean;
location: ViewLocation;
}

export interface MenuConfig {
editor:
| false
Expand Down Expand Up @@ -416,6 +397,130 @@ export interface RemotesUrlsConfig {
fileRange: string;
}

export interface ViewsCommonConfig {
commitFileDescriptionFormat: string;
commitFileFormat: string;
commitDescriptionFormat: string;
commitFormat: string;
defaultItemLimit: number;
pageItemLimit: number;
showRelativeDateMarkers: boolean;
stashFileDescriptionFormat: string;
stashFileFormat: string;
stashDescriptionFormat: string;
stashFormat: string;
statusFileDescriptionFormat: string;
statusFileFormat: string;
}

export const viewsCommonConfigKeys: (keyof ViewsCommonConfig)[] = [
'commitFileDescriptionFormat',
'commitFileFormat',
'commitDescriptionFormat',
'commitFormat',
'defaultItemLimit',
'pageItemLimit',
'showRelativeDateMarkers',
'stashFileDescriptionFormat',
'stashFileFormat',
'stashDescriptionFormat',
'stashFormat',
'statusFileDescriptionFormat',
'statusFileFormat',
];

interface ViewsConfigs {
branches: BranchesViewConfig;
compare: CompareViewConfig;
contributors: ContributorsViewConfig;
fileHistory: FileHistoryViewConfig;
history: HistoryViewConfig;
lineHistory: LineHistoryViewConfig;
remotes: RemotesViewConfig;
repositories: RepositoriesViewConfig;
search: SearchViewConfig;
stashes: StashesViewConfig;
tags: TagsViewConfig;
}

export type ViewsConfigKeys = keyof ViewsConfigs;
export const viewsConfigKeys: ViewsConfigKeys[] = [
'branches',
'compare',
'contributors',
'fileHistory',
'history',
'lineHistory',
'remotes',
'repositories',
'search',
'stashes',
'tags',
];

export type ViewsConfig = ViewsCommonConfig & ViewsConfigs;

type ViewsWithLocation = keyof Pick<
ViewsConfigs,
'compare' | 'fileHistory' | 'lineHistory' | 'repositories' | 'search'
>;

export const viewsWithLocationConfigKeys: ViewsWithLocation[] = [
'compare',
'fileHistory',
'lineHistory',
'repositories',
'search',
];

export interface BranchesViewConfig {
avatars: boolean;
branches: {
layout: ViewBranchesLayout;
};
files: ViewsFilesConfig;
showTrackingBranch: boolean;
}

export interface CompareViewConfig {
avatars: boolean;
enabled: boolean;
files: ViewsFilesConfig;
location: ViewLocation;
}

export interface ContributorsViewConfig {
avatars: boolean;
files: ViewsFilesConfig;
}

export interface FileHistoryViewConfig {
avatars: boolean;
enabled: boolean;
location: ViewLocation;
}

export interface HistoryViewConfig {
avatars: boolean;
branches: undefined;
files: ViewsFilesConfig;
showTrackingBranch: boolean;
}

export interface LineHistoryViewConfig {
avatars: boolean;
enabled: boolean;
location: ViewLocation;
}

export interface RemotesViewConfig {
avatars: boolean;
branches: {
layout: ViewBranchesLayout;
};
files: ViewsFilesConfig;
}

export interface RepositoriesViewConfig {
autoRefresh: boolean;
autoReveal: boolean;
Expand All @@ -439,34 +544,18 @@ export interface SearchViewConfig {
location: ViewLocation;
}

export interface ViewsConfig {
fileHistory: FileHistoryViewConfig;
commitFileDescriptionFormat: string;
commitFileFormat: string;
commitDescriptionFormat: string;
commitFormat: string;
compare: CompareViewConfig;
defaultItemLimit: number;
lineHistory: LineHistoryViewConfig;
pageItemLimit: number;
repositories: RepositoriesViewConfig;
search: SearchViewConfig;
showRelativeDateMarkers: boolean;
stashFileDescriptionFormat: string;
stashFileFormat: string;
stashDescriptionFormat: string;
stashFormat: string;
statusFileDescriptionFormat: string;
statusFileFormat: string;
export interface StashesViewConfig {
avatars: boolean;
files: ViewsFilesConfig;
}

export interface TagsViewConfig {
avatars: boolean;
files: ViewsFilesConfig;
}

export interface ViewsFilesConfig {
compact: boolean;
layout: ViewFilesLayout;
threshold: number;
}

export const viewKeys: (keyof Pick<
Config['views'],
'repositories' | 'fileHistory' | 'lineHistory' | 'compare' | 'search'
>)[] = ['repositories', 'fileHistory', 'lineHistory', 'compare', 'search'];
33 changes: 31 additions & 2 deletions src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { LineAnnotationController } from './annotations/lineAnnotationController
import { clearAvatarCache } from './avatars';
import { GitCodeLensController } from './codelens/codeLensController';
import { Commands, ToggleFileAnnotationCommandArgs } from './commands';
import { AnnotationsToggleMode, Config, configuration, ConfigurationWillChangeEvent, viewKeys } from './configuration';
import {
AnnotationsToggleMode,
Config,
configuration,
ConfigurationWillChangeEvent,
viewsWithLocationConfigKeys,
} from './configuration';
import { extensionId } from './constants';
import { GitFileSystemProvider } from './git/fsProvider';
import { GitService } from './git/gitService';
Expand All @@ -17,8 +23,10 @@ import { StatusBarController } from './statusbar/statusBarController';
import { GitTerminalLinkProvider } from './terminal/linkProvider';
import { GitDocumentTracker } from './trackers/gitDocumentTracker';
import { GitLineTracker } from './trackers/gitLineTracker';
import { BranchesView } from './views/branchesView';
import { CompareView } from './views/compareView';
import { FileHistoryView } from './views/fileHistoryView';
import { HistoryView } from './views/historyView';
import { LineHistoryView } from './views/lineHistoryView';
import { RepositoriesView } from './views/repositoriesView';
import { SearchView } from './views/searchView';
Expand Down Expand Up @@ -56,6 +64,9 @@ export class Container {
context.subscriptions.push((this._settingsWebview = new SettingsWebview()));
context.subscriptions.push((this._welcomeWebview = new WelcomeWebview()));

context.subscriptions.push((this._branchesView = new BranchesView()));
context.subscriptions.push((this._historyView = new HistoryView()));

if (config.views.compare.enabled) {
context.subscriptions.push((this._compareView = new CompareView()));
} else {
Expand Down Expand Up @@ -129,7 +140,7 @@ export class Container {
clearAvatarCache();
}

for (const view of viewKeys) {
for (const view of viewsWithLocationConfigKeys) {
if (configuration.changed(e.change, 'views', view, 'location')) {
setTimeout(
() =>
Expand Down Expand Up @@ -167,6 +178,15 @@ export class Container {
return this._codeLensController;
}

private static _branchesView: BranchesView | undefined;
static get branchesView() {
if (this._branchesView === undefined) {
this._context.subscriptions.push((this._branchesView = new BranchesView()));
}

return this._branchesView;
}

private static _compareView: CompareView | undefined;
static get compareView() {
if (this._compareView === undefined) {
Expand Down Expand Up @@ -226,6 +246,15 @@ export class Container {
}
}

private static _historyView: HistoryView | undefined;
static get historyView() {
if (this._historyView === undefined) {
this._context.subscriptions.push((this._historyView = new HistoryView()));
}

return this._historyView;
}

private static _keyboard: Keyboard;
static get keyboard() {
return this._keyboard;
Expand Down

0 comments on commit eee360b

Please sign in to comment.