Browse Source

Adds toggle for relative date markers

main
Eric Amodio 4 years ago
parent
commit
6017c1da98
5 changed files with 63 additions and 4 deletions
  1. +33
    -0
      package.json
  2. +2
    -1
      src/views/nodes/common.ts
  3. +10
    -2
      src/views/nodes/helpers.ts
  4. +1
    -0
      src/views/nodes/viewNode.ts
  5. +17
    -1
      src/views/viewCommands.ts

+ 33
- 0
package.json View File

@ -3652,6 +3652,16 @@
}
},
{
"command": "gitlens.views.setShowRelativeDateMarkersOn",
"title": "Show Date Markers",
"category": "GitLens"
},
{
"command": "gitlens.views.setShowRelativeDateMarkersOff",
"title": "Hide Date Markers",
"category": "GitLens"
},
{
"command": "gitlens.views.branches.copy",
"title": "Copy",
"category": "GitLens"
@ -5013,6 +5023,14 @@
"when": "false"
},
{
"command": "gitlens.views.setShowRelativeDateMarkersOn",
"when": "false"
},
{
"command": "gitlens.views.setShowRelativeDateMarkersOff",
"when": "false"
},
{
"command": "gitlens.views.branches.copy",
"when": "false"
},
@ -6366,6 +6384,16 @@
"group": "1_gitlens@0"
},
{
"command": "gitlens.views.setShowRelativeDateMarkersOn",
"when": "view =~ /^gitlens\.views\.(repositories|commits|fileHistory|branches|remotes|tags)/ && !config.gitlens.views.showRelativeDateMarkers",
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.setShowRelativeDateMarkersOff",
"when": "view =~ /^gitlens\.views\.(repositories|commits|fileHistory|branches|remotes|tags)/ && config.gitlens.views.showRelativeDateMarkers",
"group": "1_gitlens@2"
},
{
"command": "gitlens.showSettingsPage#branches-view",
"when": "view =~ /^gitlens\.views\.branches/",
"group": "9_gitlens@1"
@ -7398,6 +7426,11 @@
"command": "gitlens.views.loadAllChildren",
"when": "viewItem =~ /gitlens:pager\b/",
"group": "1_gitlens_actions@1"
},
{
"command": "gitlens.views.setShowRelativeDateMarkersOff",
"when": "viewItem == gitlens:date-marker && config.gitlens.views.showRelativeDateMarkers",
"group": "1_gitlens@0"
}
]
},

+ 2
- 1
src/views/nodes/common.ts View File

@ -19,6 +19,7 @@ export class MessageNode extends ViewNode {
dark: string | Uri;
}
| ThemeIcon,
private readonly _contextValue?: string,
) {
super(unknownGitUri, view, parent);
}
@ -29,7 +30,7 @@ export class MessageNode extends ViewNode {
getTreeItem(): TreeItem | Promise<TreeItem> {
const item = new TreeItem(this._message, TreeItemCollapsibleState.None);
item.contextValue = ContextValues.Message;
item.contextValue = this._contextValue ?? ContextValues.Message;
item.description = this._description;
item.tooltip = this._tooltip;
item.iconPath = this._iconPath;

+ 10
- 2
src/views/nodes/helpers.ts View File

@ -1,7 +1,7 @@
'use strict';
import { GitLogCommit } from '../../git/git';
import { MessageNode } from './common';
import { ViewNode } from './viewNode';
import { ContextValues, ViewNode } from './viewNode';
const markers: [number, string][] = [
[0, 'Less than a week ago'],
@ -50,7 +50,15 @@ export function* insertDateMarkers
// Don't show the marker if it is the first node
if (!first) {
yield new MessageNode(parent.view, parent, '', marker);
yield new MessageNode(
parent.view,
parent,
'',
marker,
undefined,
undefined,
ContextValues.DateMarker,
);
}
index++;

+ 1
- 0
src/views/nodes/viewNode.ts View File

@ -23,6 +23,7 @@ export enum ContextValues {
CompareResults = 'gitlens:compare:results',
Contributor = 'gitlens:contributor',
Contributors = 'gitlens:contributors',
DateMarker = 'gitlens:date-marker',
File = 'gitlens:file',
FileHistory = 'gitlens:history:file',
Folder = 'gitlens:folder',

+ 17
- 1
src/views/viewCommands.ts View File

@ -11,7 +11,7 @@ import {
OpenFileAtRevisionCommandArgs,
OpenFileOnRemoteCommandArgs,
} from '../commands';
import { FileAnnotationType, ViewShowBranchComparison } from '../config';
import { configuration, FileAnnotationType, ViewShowBranchComparison } from '../configuration';
import { BuiltInCommands, CommandContext, setCommandContext } from '../constants';
import { Container } from '../container';
import { GitReference, GitRevision } from '../git/git';
@ -99,6 +99,17 @@ export class ViewCommands {
commands.registerCommand('gitlens.views.loadMoreChildren', (node: PagerNode) => node.loadMore(), this);
commands.registerCommand('gitlens.views.loadAllChildren', (node: PagerNode) => node.loadAll(), this);
commands.registerCommand(
'gitlens.views.setShowRelativeDateMarkersOn',
() => this.setShowRelativeDateMarkers(true),
this,
);
commands.registerCommand(
'gitlens.views.setShowRelativeDateMarkersOff',
() => this.setShowRelativeDateMarkers(false),
this,
);
commands.registerCommand('gitlens.views.fetch', this.fetch, this);
commands.registerCommand('gitlens.views.publishBranch', this.publishBranch, this);
commands.registerCommand('gitlens.views.pull', this.pull, this);
@ -490,6 +501,11 @@ export class ViewCommands {
}
@debug()
private setShowRelativeDateMarkers(enabled: boolean) {
return configuration.updateEffective('views', 'showRelativeDateMarkers', enabled);
}
@debug()
private async stageFile(node: CommitFileNode | StatusFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return;

||||||
x
 
000:0
Loading…
Cancel
Save