Browse Source

Adds status colors to pull request icons

main
Eric Amodio 3 years ago
parent
commit
ebd9a3660a
9 changed files with 91 additions and 37 deletions
  1. +42
    -15
      package.json
  2. +6
    -6
      src/annotations/annotations.ts
  3. +4
    -4
      src/annotations/fileAnnotationController.ts
  4. +16
    -0
      src/constants.ts
  5. +3
    -3
      src/views/nodes/branchNode.ts
  6. +4
    -3
      src/views/nodes/branchTrackingStatusNode.ts
  7. +2
    -2
      src/views/nodes/commitNode.ts
  8. +2
    -2
      src/views/nodes/fileRevisionAsCommitNode.ts
  9. +12
    -2
      src/views/nodes/pullRequestNode.ts

+ 42
- 15
package.json View File

@ -2616,30 +2616,57 @@
}
},
{
"id": "gitlens.viewCommitToPushIconColor",
"description": "Specifies the icon color of un-pushed commits in the GitLens views",
"id": "gitlens.closedPullRequestIconColor",
"description": "Specifies the icon color of closed pull requests in the GitLens views",
"defaults": {
"dark": "#35B15E",
"light": "#35B15E",
"highContrast": "#35B15E"
"dark": "#f85149",
"light": "#f85149",
"highContrast": "#ff544b"
}
},
{
"id": "gitlens.viewChangesToPushIconColor",
"description": "Specifies the icon color of the _Changes to push_ node in the GitLens views",
"id": "gitlens.openPullRequestIconColor",
"description": "Specifies the icon color of open pull requests in the GitLens views",
"defaults": {
"dark": "#35B15E",
"light": "#35B15E",
"highContrast": "#35B15E"
"dark": "#56d364",
"light": "#56d364",
"highContrast": "#68ff79"
}
},
{
"id": "gitlens.viewChangesToPullIconColor",
"description": "Specifies the icon color of the _Changes to pull_ node in the GitLens views",
"id": "gitlens.mergedPullRequestIconColor",
"description": "Specifies the icon color of merged pull requests in the GitLens views",
"defaults": {
"dark": "#B15E35",
"light": "#B15E35",
"highContrast": "#B15E35"
"dark": "#995dff",
"light": "#995dff",
"highContrast": "#8945ff"
}
},
{
"id": "gitlens.unpushlishedChangesIconColor",
"description": "Specifies the icon color of unpublished changes in the GitLens views",
"defaults": {
"dark": "#35b15e",
"light": "#35b15e",
"highContrast": "#4dff88"
}
},
{
"id": "gitlens.unpublishedCommitIconColor",
"description": "Specifies the icon color of unpublished commits in the GitLens views",
"defaults": {
"dark": "#35b15e",
"light": "#35b15e",
"highContrast": "#4dff88"
}
},
{
"id": "gitlens.unpulledChangesIconColor",
"description": "Specifies the icon color of unpulled changes in the GitLens views",
"defaults": {
"dark": "#b15e35",
"light": "#b15e35",
"highContrast": "#ff874c"
}
}
],

+ 6
- 6
src/annotations/annotations.ts View File

@ -13,7 +13,7 @@ import {
} from 'vscode';
import { HeatmapLocations } from '../config';
import { Config, configuration } from '../configuration';
import { GlyphChars } from '../constants';
import { Colors, GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter, GitCommit } from '../git/git';
import { Objects, Strings } from '../system';
@ -210,10 +210,10 @@ export class Annotations {
}
return {
backgroundColor: new ThemeColor('gitlens.gutterBackgroundColor'),
backgroundColor: new ThemeColor(Colors.GutterBackgroundColor),
borderStyle: borderStyle,
borderWidth: borderWidth,
color: new ThemeColor('gitlens.gutterForegroundColor'),
color: new ThemeColor(Colors.GutterForegroundColor),
fontWeight: 'normal',
fontStyle: 'normal',
height: '100%',
@ -222,7 +222,7 @@ export class Annotations {
avatars ? ';padding: 0 0 0 18px' : ''
}`,
width: width,
uncommittedColor: new ThemeColor('gitlens.gutterUncommittedForegroundColor'),
uncommittedColor: new ThemeColor(Colors.GutterUncommittedForegroundColor),
};
}
@ -249,8 +249,8 @@ export class Annotations {
return {
renderOptions: {
after: {
backgroundColor: new ThemeColor('gitlens.trailingLineBackgroundColor'),
color: new ThemeColor('gitlens.trailingLineForegroundColor'),
backgroundColor: new ThemeColor(Colors.TrailingLineBackgroundColor),
color: new ThemeColor(Colors.TrailingLineForegroundColor),
contentText: Strings.pad(message.replace(/ /g, GlyphChars.Space), 1, 1),
fontWeight: 'normal',
fontStyle: 'normal',

+ 4
- 4
src/annotations/fileAnnotationController.ts View File

@ -26,7 +26,7 @@ import {
configuration,
FileAnnotationType,
} from '../configuration';
import { ContextKeys, isTextEditor, setContext } from '../constants';
import { Colors, ContextKeys, isTextEditor, setContext } from '../constants';
import { Container } from '../container';
import { GutterBlameAnnotationProvider } from './gutterBlameAnnotationProvider';
import { GutterChangesAnnotationProvider } from './gutterChangesAnnotationProvider';
@ -107,7 +107,7 @@ export class FileAnnotationController implements Disposable {
const { locations } = highlight;
// TODO@eamodio: Read from the theme color when the API exists
const gutterHighlightColor = '#00bcf2'; // new ThemeColor('gitlens.lineHighlightOverviewRulerColor')
const gutterHighlightColor = '#00bcf2'; // new ThemeColor(Colors.LineHighlightOverviewRulerColor)
const gutterHighlightUri = locations.includes(BlameHighlightLocations.Gutter)
? Uri.parse(
`data:image/svg+xml,${encodeURIComponent(
@ -122,10 +122,10 @@ export class FileAnnotationController implements Disposable {
isWholeLine: true,
overviewRulerLane: OverviewRulerLane.Right,
backgroundColor: locations.includes(BlameHighlightLocations.Line)
? new ThemeColor('gitlens.lineHighlightBackgroundColor')
? new ThemeColor(Colors.LineHighlightBackgroundColor)
: undefined,
overviewRulerColor: locations.includes(BlameHighlightLocations.Overview)
? new ThemeColor('gitlens.lineHighlightOverviewRulerColor')
? new ThemeColor(Colors.LineHighlightOverviewRulerColor)
: undefined,
});
}

+ 16
- 0
src/constants.ts View File

@ -56,6 +56,22 @@ export function setContext(key: ContextKeys | string, value: any) {
return commands.executeCommand(BuiltInCommands.SetContext, key, value);
}
export enum Colors {
GutterBackgroundColor = 'gitlens.gutterBackgroundColor',
GutterForegroundColor = 'gitlens.gutterForegroundColor',
GutterUncommittedForegroundColor = 'gitlens.gutterUncommittedForegroundColor',
TrailingLineBackgroundColor = 'gitlens.trailingLineBackgroundColor',
TrailingLineForegroundColor = 'gitlens.trailingLineForegroundColor',
LineHighlightBackgroundColor = 'gitlens.lineHighlightBackgroundColor',
LineHighlightOverviewRulerColor = 'gitlens.lineHighlightOverviewRulerColor',
ClosedPullRequestIconColor = 'gitlens.closedPullRequestIconColor',
OpenPullRequestIconColor = 'gitlens.openPullRequestIconColor',
MergedPullRequestIconColor = 'gitlens.mergedPullRequestIconColor',
UnpushlishedChangesIconColor = 'gitlens.unpushlishedChangesIconColor',
UnpublishedCommitIconColor = 'gitlens.unpublishedCommitIconColor',
UnpulledChangesIconColor = 'gitlens.unpulledChangesIconColor',
}
export enum DocumentSchemes {
DebugConsole = 'debug',
File = 'file',

+ 3
- 3
src/views/nodes/branchNode.ts View File

@ -7,7 +7,7 @@ import { CommitsView } from '../commitsView';
import { LoadMoreNode, MessageNode } from './common';
import { CompareBranchNode } from './compareBranchNode';
import { ViewBranchesLayout, ViewShowBranchComparison } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Colors, GlyphChars } from '../../constants';
import { Container } from '../../container';
import {
BranchDateFormatting,
@ -354,12 +354,12 @@ export class BranchNode
if (this.branch.state.ahead || this.branch.state.behind) {
if (this.branch.state.ahead) {
contextValue += '+ahead';
color = new ThemeColor('gitlens.viewChangesToPushIconColor');
color = new ThemeColor(Colors.UnpushlishedChangesIconColor);
iconSuffix = '-green';
}
if (this.branch.state.behind) {
contextValue += '+behind';
color = new ThemeColor('gitlens.viewChangesToPullIconColor');
color = new ThemeColor(Colors.UnpulledChangesIconColor);
iconSuffix = this.branch.state.ahead ? '-yellow' : '-red';
}
}

+ 4
- 3
src/views/nodes/branchTrackingStatusNode.ts View File

@ -4,6 +4,7 @@ import { BranchNode } from './branchNode';
import { BranchTrackingStatusFilesNode } from './branchTrackingStatusFilesNode';
import { CommitNode } from './commitNode';
import { LoadMoreNode } from './common';
import { Colors } from '../../constants';
import { Container } from '../../container';
import { GitBranch, GitLog, GitRemote, GitRevision, GitTrackingState } from '../../git/git';
import { GitUri } from '../../git/gitUri';
@ -177,7 +178,7 @@ export class BranchTrackingStatusNode extends ViewNode impleme
contextValue = this.root
? ContextValues.StatusAheadOfUpstream
: ContextValues.BranchStatusAheadOfUpstream;
icon = new ThemeIcon('cloud-upload', new ThemeColor('gitlens.viewChangesToPushIconColor'));
icon = new ThemeIcon('cloud-upload', new ThemeColor(Colors.UnpushlishedChangesIconColor));
break;
}
@ -200,7 +201,7 @@ export class BranchTrackingStatusNode extends ViewNode impleme
contextValue = this.root
? ContextValues.StatusBehindUpstream
: ContextValues.BranchStatusBehindUpstream;
icon = new ThemeIcon('cloud-download', new ThemeColor('gitlens.viewChangesToPullIconColor'));
icon = new ThemeIcon('cloud-download', new ThemeColor(Colors.UnpulledChangesIconColor));
break;
}
@ -237,7 +238,7 @@ export class BranchTrackingStatusNode extends ViewNode impleme
contextValue = this.root ? ContextValues.StatusNoUpstream : ContextValues.BranchStatusNoUpstream;
icon = new ThemeIcon(
'cloud-upload',
remotes.length ? new ThemeColor('gitlens.viewChangesToPushIconColor') : undefined,
remotes.length ? new ThemeColor(Colors.UnpushlishedChangesIconColor) : undefined,
);
break;

+ 2
- 2
src/views/nodes/commitNode.ts View File

@ -4,7 +4,7 @@ import { Command, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } fr
import { Commands, DiffWithPreviousCommandArgs } from '../../commands';
import { CommitFileNode } from './commitFileNode';
import { ViewFilesLayout } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Colors, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { FileNode, FolderNode } from './folderNode';
import { CommitFormatter, GitBranch, GitLogCommit, GitRevisionReference } from '../../git/git';
@ -122,7 +122,7 @@ export class CommitNode extends ViewRefNode
messageTruncateAtNewLine: true,
});
item.iconPath = this.unpublished
? new ThemeIcon('arrow-up', new ThemeColor('gitlens.viewCommitToPushIconColor'))
? new ThemeIcon('arrow-up', new ThemeColor(Colors.UnpublishedCommitIconColor))
: this.view.config.avatars
? await this.commit.getAvatarUri({ defaultStyle: Container.config.defaultGravatarsStyle })
: new ThemeIcon('git-commit');

+ 2
- 2
src/views/nodes/fileRevisionAsCommitNode.ts View File

@ -2,7 +2,7 @@
import * as paths from 'path';
import { Command, Selection, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs } from '../../commands';
import { GlyphChars } from '../../constants';
import { Colors, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { FileHistoryView } from '../fileHistoryView';
import {
@ -126,7 +126,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode
if (!this.commit.isUncommitted && this.view.config.avatars) {
item.iconPath = this._options.unpublished
? new ThemeIcon('arrow-up', new ThemeColor('gitlens.viewCommitToPushIconColor'))
? new ThemeIcon('arrow-up', new ThemeColor(Colors.UnpublishedCommitIconColor))
: await this.commit.getAvatarUri({ defaultStyle: Container.config.defaultGravatarsStyle });
}

+ 12
- 2
src/views/nodes/pullRequestNode.ts View File

@ -1,7 +1,8 @@
'use strict';
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { BranchesView } from '../branchesView';
import { CommitsView } from '../commitsView';
import { Colors } from '../../constants';
import { ContributorsView } from '../contributorsView';
import { GitBranch, GitCommit, PullRequest, PullRequestState } from '../../git/git';
import { GitUri } from '../../git/gitUri';
@ -44,7 +45,16 @@ export class PullRequestNode extends ViewNode<
const item = new TreeItem(`#${this.pullRequest.id}: ${this.pullRequest.title}`, TreeItemCollapsibleState.None);
item.contextValue = ContextValues.PullRequest;
item.description = `${this.pullRequest.state}, ${this.pullRequest.formatDateFromNow()}`;
item.iconPath = new ThemeIcon('git-pull-request');
item.iconPath = new ThemeIcon(
'git-pull-request',
new ThemeColor(
this.pullRequest.state === PullRequestState.Closed
? Colors.ClosedPullRequestIconColor
: this.pullRequest.state === PullRequestState.Merged
? Colors.MergedPullRequestIconColor
: Colors.OpenPullRequestIconColor,
),
);
item.id = this.id;
item.tooltip = `${this.pullRequest.title}\n#${this.pullRequest.id} by ${this.pullRequest.author.name} was ${
this.pullRequest.state === PullRequestState.Open ? 'opened' : this.pullRequest.state.toLowerCase()

Loading…
Cancel
Save