Ver código fonte

Closes #710, #711 - Prompts on disabled views

main
Eric Amodio 5 anos atrás
pai
commit
03d6a0eff9
9 arquivos alterados com 38 adições e 10 exclusões
  1. +4
    -0
      CHANGELOG.md
  2. +1
    -1
      src/commands/common.ts
  3. +5
    -1
      src/container.ts
  4. +1
    -1
      src/views/compareView.ts
  5. +1
    -1
      src/views/fileHistoryView.ts
  6. +1
    -1
      src/views/lineHistoryView.ts
  7. +1
    -1
      src/views/repositoriesView.ts
  8. +1
    -1
      src/views/searchView.ts
  9. +23
    -3
      src/views/viewBase.ts

+ 4
- 0
CHANGELOG.md Ver arquivo

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds a prompt to enable the view to the _Show \* View_ commands when the specified view is disabled — closes [#710](https://github.com/eamodio/vscode-gitlens/issues/710) & [#711](https://github.com/eamodio/vscode-gitlens/issues/711)
### Removed
- Removes `-m` flag from `git log` when following renames (using `--follow`), because it ends up returning all merge commits (regardless if the file in question was changed or not)

+ 1
- 1
src/commands/common.ts Ver arquivo

@ -107,7 +107,7 @@ export enum Commands {
}
interface CommandConstructor {
new (): any;
new (): Command;
}
const registrableCommands: CommandConstructor[] = [];

+ 5
- 1
src/container.ts Ver arquivo

@ -226,7 +226,11 @@ export class Container {
private static _repositoriesView: RepositoriesView | undefined;
static get repositoriesView(): RepositoriesView {
return this._repositoriesView!;
if (this._repositoriesView === undefined) {
this._context.subscriptions.push((this._repositoriesView = new RepositoriesView()));
}
return this._repositoriesView;
}
private static _searchView: SearchView | undefined;

+ 1
- 1
src/views/compareView.ts Ver arquivo

@ -15,7 +15,7 @@ import { ViewBase } from './viewBase';
export class CompareView extends ViewBase<CompareNode> {
constructor() {
super('gitlens.views.compare');
super('gitlens.views.compare', 'Compare');
setCommandContext(CommandContext.ViewsCompareKeepResults, this.keepResults);
}

+ 1
- 1
src/views/fileHistoryView.ts Ver arquivo

@ -9,7 +9,7 @@ import { ViewBase } from './viewBase';
export class FileHistoryView extends ViewBase<FileHistoryTrackerNode> {
constructor() {
super('gitlens.views.fileHistory');
super('gitlens.views.fileHistory', 'File History');
}
getRoot() {

+ 1
- 1
src/views/lineHistoryView.ts Ver arquivo

@ -8,7 +8,7 @@ import { ViewBase } from './viewBase';
export class LineHistoryView extends ViewBase<LineHistoryTrackerNode> {
constructor() {
super('gitlens.views.lineHistory');
super('gitlens.views.lineHistory', 'Line History');
}
getRoot() {

+ 1
- 1
src/views/repositoriesView.ts Ver arquivo

@ -8,7 +8,7 @@ import { ViewBase } from './viewBase';
export class RepositoriesView extends ViewBase<RepositoriesNode> {
constructor() {
super('gitlens.views.repositories');
super('gitlens.views.repositories', 'Repositories');
}
private _onDidChangeAutoRefresh = new EventEmitter<void>();

+ 1
- 1
src/views/searchView.ts Ver arquivo

@ -15,7 +15,7 @@ interface SearchQueryResult {
export class SearchView extends ViewBase<SearchNode> {
constructor() {
super('gitlens.views.search');
super('gitlens.views.search', 'Search Commits');
setCommandContext(CommandContext.ViewsSearchKeepResults, this.keepResults);
}

+ 23
- 3
src/views/viewBase.ts Ver arquivo

@ -2,9 +2,11 @@
import {
commands,
ConfigurationChangeEvent,
ConfigurationTarget,
Disposable,
Event,
EventEmitter,
MessageItem,
TreeDataProvider,
TreeItem,
TreeItemCollapsibleState,
@ -16,7 +18,7 @@ import {
import { configuration } from '../configuration';
import { Container } from '../container';
import { Logger } from '../logger';
import { debug, Functions, log } from '../system';
import { debug, Functions, log, Strings } from '../system';
import { CompareView } from './compareView';
import { FileHistoryView } from './fileHistoryView';
import { LineHistoryView } from './lineHistoryView';
@ -53,7 +55,7 @@ export abstract class ViewBase> implements TreeData
protected _root: TRoot | undefined;
protected _tree: TreeView<ViewNode> | undefined;
constructor(public readonly id: string) {
constructor(public readonly id: string, public readonly name: string) {
this.registerCommands();
Container.context.subscriptions.push(configuration.onDidChange(this.onConfigurationChanged, this));
@ -194,12 +196,30 @@ export abstract class ViewBase> implements TreeData
@log()
async show() {
const location = this.location;
try {
const location = this.location;
return await commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`);
}
catch (ex) {
Logger.error(ex);
const setting = `${Strings.splitSingle(this.id, '.')[1]}.enabled`;
if (!configuration.get(setting)) {
const actions: MessageItem[] = [{ title: 'Enable' }, { title: 'Cancel', isCloseAffordance: true }];
const result = await window.showErrorMessage(
`Unable to show the ${this.name} view since it's currently disabled. Would you like to enable it?`,
...actions
);
if (result === actions[0]) {
await configuration.update(setting, true, ConfigurationTarget.Global);
return commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`);
}
}
return undefined;
}
}

Carregando…
Cancelar
Salvar