From fa2e6be104c934b75350d5951ecd992cc7e59a0f Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 21 Dec 2018 02:11:44 -0500 Subject: [PATCH] Splits views.avatars into separate settings per view --- README.md | 4 +++- package.json | 24 ++++++++++++++++++------ src/extension.ts | 23 ++++++++++++----------- src/ui/config.ts | 15 ++++++++------- src/ui/settings/index.html | 12 ++++++------ src/views/nodes/branchTrackingStatusNode.ts | 6 +++--- src/views/nodes/commitNode.ts | 6 +++--- src/views/nodes/compareResultsNode.ts | 6 +++--- src/views/nodes/folderNode.ts | 6 +++--- src/views/nodes/resultsCommitsNode.ts | 6 +++--- src/views/nodes/resultsFilesNode.ts | 6 +++--- src/views/nodes/searchResultsCommitsNode.ts | 4 ++-- src/views/viewBase.ts | 1 + 13 files changed, 68 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 3d39c73..a037e06 100644 --- a/README.md +++ b/README.md @@ -752,6 +752,7 @@ See also [View Settings](#view-settings- 'Jump to the View settings') | Name | Description | | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.views.repositories.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the _Repositories_ view | | `gitlens.views.repositories.autoRefresh` | Specifies whether to automatically refresh the _Repositories_ view when the repository or the file system changes | | `gitlens.views.repositories.autoReveal` | Specifies whether to automatically reveal repositories in the _Repositories_ view when opening files | | `gitlens.views.repositories.branches.layout` | Specifies how the _Repositories_ view will display branches

`list` - displays branches as a list
`tree` - displays branches as a tree when branch names contain slashes `/` | @@ -790,6 +791,7 @@ See also [View Settings](#view-settings- 'Jump to the View settings') | Name | Description | | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.views.search.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the _Search Commits_ view | | `gitlens.views.search.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Search Commits_ view
Only applies when `gitlens.views.compare.files.layout` is set to `tree` or `auto` | | `gitlens.views.search.enabled` | Specifies whether to show the _Search Commits_ view | | `gitlens.views.search.files.layout` | Specifies how the _Search Commits_ view will display files
`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.compare.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree | @@ -802,6 +804,7 @@ See also [View Settings](#view-settings- 'Jump to the View settings') | Name | Description | | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `gitlens.views.compare.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the _Compare_ view | | `gitlens.views.compare.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Compare_ view. Only applies when `gitlens.views.compare.files.layout` is set to `tree` or `auto` | | `gitlens.views.compare.enabled` | Specifies whether to show the _Compare_ view | | `gitlens.views.compare.files.layout` | Specifies how the _Compare_ view will display files

`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.compare.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree | @@ -812,7 +815,6 @@ See also [View Settings](#view-settings- 'Jump to the View settings') | Name | Description | | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `gitlens.views.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the views | | `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the views

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path | | `gitlens.views.commitFileDescriptionFormat` | Specifies the description format of a committed file in the views

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path | | `gitlens.views.commitFormat` | Specifies the format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting

Available tokens
`${id}`— commit id
`${author}` — commit author
`${message}`— commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}`— formatted commit date (format specified by`gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}`— commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle` | diff --git a/package.json b/package.json index 64960f7..dc2f19e 100644 --- a/package.json +++ b/package.json @@ -1199,12 +1199,6 @@ "markdownDescription": "Specifies the string to be shown in place of the _authors_ code lens when there are unsaved changes", "scope": "window" }, - "gitlens.views.avatars": { - "type": "boolean", - "default": true, - "markdownDescription": "Specifies whether to show avatar images instead of commit (or status) icons in the views", - "scope": "window" - }, "gitlens.views.commitFileFormat": { "type": "string", "default": "${file}", @@ -1229,6 +1223,12 @@ "markdownDescription": "Specifies the description format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`", "scope": "window" }, + "gitlens.views.compare.avatars": { + "type": "boolean", + "default": true, + "markdownDescription": "Specifies whether to show avatar images instead of commit (or status) icons in the _Compare_ view", + "scope": "window" + }, "gitlens.views.compare.enabled": { "type": "boolean", "default": true, @@ -1353,6 +1353,12 @@ "markdownDescription": "Specifies whether to automatically reveal repositories in the _Repositories_ view when opening files", "scope": "window" }, + "gitlens.views.repositories.avatars": { + "type": "boolean", + "default": true, + "markdownDescription": "Specifies whether to show avatar images instead of commit (or status) icons in the _Repositories_ view", + "scope": "window" + }, "gitlens.views.repositories.branches.layout": { "type": "string", "default": "tree", @@ -1435,6 +1441,12 @@ "markdownDescription": "Specifies whether to show the tracking branch when displaying local branches in the _Repositories_ view", "scope": "window" }, + "gitlens.views.search.avatars": { + "type": "boolean", + "default": true, + "markdownDescription": "Specifies whether to show avatar images instead of commit (or status) icons in the _Search Commits_ view", + "scope": "window" + }, "gitlens.views.search.enabled": { "type": "boolean", "default": true, diff --git a/src/extension.ts b/src/extension.ts index e0be570..311b298 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -99,7 +99,12 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin const previous = Versions.fromString(previousVersion); try { - if (Versions.compare(previous, Versions.from(9, 0, 0)) !== 1) { + if (Versions.compare(previous, Versions.from(9, 2, 2)) !== 1) { + await configuration.migrate('views.avatars', configuration.name('views')('compare')('avatars').value); + await configuration.migrate('views.avatars', configuration.name('views')('repositories')('avatars').value); + await configuration.migrate('views.avatars', configuration.name('views')('search')('avatars').value); + } + else if (Versions.compare(previous, Versions.from(9, 0, 0)) !== 1) { await configuration.migrate( 'gitExplorer.autoRefresh', configuration.name('views')('repositories')('autoRefresh').value @@ -197,7 +202,12 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin configuration.name('views')('search')('location').value ); - await configuration.migrate('explorers.avatars', configuration.name('views')('avatars').value); + await configuration.migrate('explorers.avatars', configuration.name('views')('compare')('avatars').value); + await configuration.migrate( + 'explorers.avatars', + configuration.name('views')('repositories')('avatars').value + ); + await configuration.migrate('explorers.avatars', configuration.name('views')('search')('avatars').value); await configuration.migrate( 'explorers.commitFileFormat', configuration.name('views')('commitFileFormat').value @@ -208,15 +218,6 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin configuration.name('views')('defaultItemLimit').value ); await configuration.migrate( - 'explorers.files.compact', - configuration.name('views')('files')('compact').value - ); - await configuration.migrate('explorers.files.layout', configuration.name('views')('files')('layout').value); - await configuration.migrate( - 'explorers.files.threshold', - configuration.name('views')('files')('threshold').value - ); - await configuration.migrate( 'explorers.stashFileFormat', configuration.name('views')('stashFileFormat').value ); diff --git a/src/ui/config.ts b/src/ui/config.ts index 2970750..9faec72 100644 --- a/src/ui/config.ts +++ b/src/ui/config.ts @@ -237,6 +237,7 @@ export interface CodeLensLanguageScope { } export interface CompareViewConfig { + avatars: boolean; enabled: boolean; files: ViewsFilesConfig; location: 'explorer' | 'gitlens' | 'scm'; @@ -248,7 +249,11 @@ export interface FileHistoryViewConfig { location: 'explorer' | 'gitlens' | 'scm'; } -export interface LineHistoryViewConfig extends FileHistoryViewConfig {} +export interface LineHistoryViewConfig { + avatars: boolean; + enabled: boolean; + location: 'explorer' | 'gitlens' | 'scm'; +} export interface MenuConfig { editor: @@ -336,6 +341,7 @@ export interface RemotesUrlsConfig { export interface RepositoriesViewConfig { autoRefresh: boolean; autoReveal: boolean; + avatars: boolean; branches: { layout: ViewBranchesLayout; }; @@ -348,19 +354,14 @@ export interface RepositoriesViewConfig { } export interface SearchViewConfig { + avatars: boolean; enabled: boolean; files: ViewsFilesConfig; location: 'explorer' | 'gitlens' | 'scm'; } export interface ViewsConfig { - avatars: boolean; fileHistory: FileHistoryViewConfig; - files: { - layout: ViewFilesLayout; - compact: boolean; - threshold: number; - }; commitFileDescriptionFormat: string; commitFileFormat: string; commitDescriptionFormat: string; diff --git a/src/ui/settings/index.html b/src/ui/settings/index.html index 1852803..d2f2760 100644 --- a/src/ui/settings/index.html +++ b/src/ui/settings/index.html @@ -2356,7 +2356,7 @@ @@ -2420,7 +2420,7 @@

@@ -2680,7 +2680,7 @@ @@ -2711,7 +2711,7 @@

@@ -2814,7 +2814,7 @@ @@ -2845,7 +2845,7 @@

diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 68e0751..990e60a 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { Container } from '../../container'; import { GitTrackingState, GitUri } from '../../git/gitService'; import { Iterables, Strings } from '../../system'; -import { View } from '../viewBase'; +import { ViewWithFiles } from '../viewBase'; import { CommitNode } from './commitNode'; import { ShowMoreNode } from './common'; import { insertDateMarkers } from './helpers'; @@ -16,12 +16,12 @@ export interface BranchTrackingStatus { upstream?: string; } -export class BranchTrackingStatusNode extends ViewNode implements PageableViewNode { +export class BranchTrackingStatusNode extends ViewNode implements PageableViewNode { readonly supportsPaging: boolean = true; maxCount: number | undefined; constructor( - view: View, + view: ViewWithFiles, parent: ViewNode, public readonly status: BranchTrackingStatus, public readonly direction: 'ahead' | 'behind', diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 1fe0c58..7108af5 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -7,14 +7,14 @@ import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { CommitFormatter, GitBranch, GitLogCommit, ICommitFormatOptions } from '../../git/gitService'; import { Arrays, Iterables, Strings } from '../../system'; -import { View } from '../viewBase'; +import { ViewWithFiles } from '../viewBase'; import { CommitFileNode, CommitFileNodeDisplayAs } from './commitFileNode'; import { FileNode, FolderNode } from './folderNode'; import { ResourceType, ViewNode, ViewRefNode } from './viewNode'; -export class CommitNode extends ViewRefNode { +export class CommitNode extends ViewRefNode { constructor( - view: View, + view: ViewWithFiles, parent: ViewNode, public readonly commit: GitLogCommit, public readonly branch?: GitBranch, diff --git a/src/views/nodes/compareResultsNode.ts b/src/views/nodes/compareResultsNode.ts index 8c3e2a7..9d060d1 100644 --- a/src/views/nodes/compareResultsNode.ts +++ b/src/views/nodes/compareResultsNode.ts @@ -3,14 +3,14 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { Container } from '../../container'; import { GitService, GitUri } from '../../git/gitService'; import { Strings } from '../../system'; -import { View } from '../viewBase'; +import { ViewWithFiles } from '../viewBase'; import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode'; import { ResultsFilesNode } from './resultsFilesNode'; import { NamedRef, ResourceType, ViewNode } from './viewNode'; -export class CompareResultsNode extends ViewNode { +export class CompareResultsNode extends ViewNode { constructor( - view: View, + view: ViewWithFiles, public readonly repoPath: string, ref1: NamedRef, ref2: NamedRef diff --git a/src/views/nodes/folderNode.ts b/src/views/nodes/folderNode.ts index 45f3fc4..1112349 100644 --- a/src/views/nodes/folderNode.ts +++ b/src/views/nodes/folderNode.ts @@ -3,7 +3,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { ViewFilesLayout, ViewsFilesConfig } from '../../configuration'; import { GitUri } from '../../git/gitService'; import { Arrays, Objects } from '../../system'; -import { View } from '../viewBase'; +import { ViewWithFiles } from '../viewBase'; import { ResourceType, ViewNode } from './viewNode'; export interface FileNode extends ViewNode { @@ -14,11 +14,11 @@ export interface FileNode extends ViewNode { root?: Arrays.IHierarchicalItem; } -export class FolderNode extends ViewNode { +export class FolderNode extends ViewNode { readonly priority: number = 1; constructor( - view: View, + view: ViewWithFiles, parent: ViewNode, public readonly repoPath: string, public readonly folderName: string, diff --git a/src/views/nodes/resultsCommitsNode.ts b/src/views/nodes/resultsCommitsNode.ts index 080b8e1..88393a2 100644 --- a/src/views/nodes/resultsCommitsNode.ts +++ b/src/views/nodes/resultsCommitsNode.ts @@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { Container } from '../../container'; import { GitLog, GitUri } from '../../git/gitService'; import { Iterables } from '../../system'; -import { View } from '../viewBase'; +import { ViewWithFiles } from '../viewBase'; import { CommitNode } from './commitNode'; import { ShowMoreNode } from './common'; import { getBranchesAndTagTipsFn, insertDateMarkers } from './helpers'; @@ -14,12 +14,12 @@ export interface CommitsQueryResults { log: GitLog | undefined; } -export class ResultsCommitsNode extends ViewNode implements PageableViewNode { +export class ResultsCommitsNode extends ViewNode implements PageableViewNode { readonly supportsPaging: boolean = true; maxCount: number | undefined; constructor( - view: View, + view: ViewWithFiles, parent: ViewNode, public readonly repoPath: string, private readonly _commitsQuery: (maxCount: number | undefined) => Promise diff --git a/src/views/nodes/resultsFilesNode.ts b/src/views/nodes/resultsFilesNode.ts index 550d3cf..0a0c70d 100644 --- a/src/views/nodes/resultsFilesNode.ts +++ b/src/views/nodes/resultsFilesNode.ts @@ -5,7 +5,7 @@ import { ViewFilesLayout } from '../../configuration'; import { Container } from '../../container'; import { GitFile, GitUri } from '../../git/gitService'; import { Arrays, Iterables, Strings } from '../../system'; -import { View } from '../viewBase'; +import { ViewWithFiles } from '../viewBase'; import { FileNode, FolderNode } from './folderNode'; import { ResultsFileNode } from './resultsFileNode'; import { ResourceType, ViewNode } from './viewNode'; @@ -15,9 +15,9 @@ export interface FilesQueryResults { diff: GitFile[] | undefined; } -export class ResultsFilesNode extends ViewNode { +export class ResultsFilesNode extends ViewNode { constructor( - view: View, + view: ViewWithFiles, parent: ViewNode, public readonly repoPath: string, private readonly _ref1: string, diff --git a/src/views/nodes/searchResultsCommitsNode.ts b/src/views/nodes/searchResultsCommitsNode.ts index ca7425a..4cf5333 100644 --- a/src/views/nodes/searchResultsCommitsNode.ts +++ b/src/views/nodes/searchResultsCommitsNode.ts @@ -3,13 +3,13 @@ import { TreeItem } from 'vscode'; import { SearchCommitsCommandArgs } from '../../commands'; import { Commands } from '../../commands/common'; import { GitRepoSearchBy } from '../../git/gitService'; -import { View } from '../viewBase'; +import { ViewWithFiles } from '../viewBase'; import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode'; import { ResourceType, ViewNode } from './viewNode'; export class SearchResultsCommitsNode extends ResultsCommitsNode { constructor( - view: View, + view: ViewWithFiles, parent: ViewNode, repoPath: string, public readonly search: string, diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index 94a2d88..9d20b1a 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -27,6 +27,7 @@ import { SearchView } from './searchView'; import { RefreshNodeCommandArgs } from './viewCommands'; export type View = RepositoriesView | FileHistoryView | LineHistoryView | CompareView | SearchView; +export type ViewWithFiles = RepositoriesView | CompareView | SearchView; export interface TreeViewNodeStateChangeEvent extends TreeViewExpansionEvent { state: TreeItemCollapsibleState;