Skip to content

Commit

Permalink
Adds support gitlens command and icon to views
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Nov 13, 2018
1 parent a78456e commit df07b28
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 51 deletions.
4 changes: 2 additions & 2 deletions BACKERS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h1 align="center">Sponsors &amp; Backers</h1>

To my incredible backers &mdash; thank you so much for your contributions. I am truly humbled by your generosity and support. Please know that your support plays a important role in helping me realize GitLens' potential in making developer's lives easier.
To my incredible backers &mdash; thank you so much for your contributions. I am truly humbled by your generosity and support. Please know that your support plays an important role in helping me realize GitLens' potential in making developer's lives easier.

If you'd like to join them in supporting GitLens, please consider:
If you'd like to join in supporting GitLens, please consider:

- [Become a backer or sponsor on Patreon](https://www.patreon.com/eamodio)
- [PayPal donations](https://www.paypal.me/eamodio)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ While I enjoy giving my free time and attention to GitLens' development and grow

### Show Your Support &#x2764;

To my incredible backers &mdash; thank you so much for your contributions. I am truly humbled by your generosity and support. Please know that your support plays a important role in helping me realize GitLens' potential in making developer's lives easier.
To my incredible backers &mdash; thank you so much for your contributions. I am truly humbled by your generosity and support. Please know that your support plays an important role in helping me realize GitLens' potential in making developer's lives easier.

If you'd like to join them in supporting GitLens, please consider the following &mdash; feel free to choose more than one. &#x1F609;
If you'd like to join in supporting GitLens, please consider the following &mdash; feel free to choose more than one. &#x1F609;

- [Become a Sponsor](https://www.patreon.com/eamodio 'Become a sponsor on Patreon') &mdash; join the growing group of generous [backers](https://github.com/eamodio/vscode-gitlens/blob/master/BACKERS.md)
- [Donations via PayPal](https://www.paypal.me/eamodio 'One-time donations via PayPal')
- [Donations via Cash App](https://cash.me/$eamodio 'One-time donations via Cash App')
- [Donate via PayPal](https://www.paypal.me/eamodio 'Donate via PayPal')
- [Donate via Cash App](https://cash.me/$eamodio 'Donate via Cash App')
- [Write a Review](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens#review-details 'Write a review')
- [Star or Fork me on GitHub](https://github.com/eamodio/vscode-gitlens 'Star or fork me on GitHub')
- [Follow me on Twitter](https://twitter.com/eamodio 'Follow me on Twitter')
Expand Down
3 changes: 3 additions & 0 deletions images/dark/icon-gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/dark/icon-heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/light/icon-gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/light/icon-heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 51 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,8 @@
"suppressGitVersionWarning": false,
"suppressLineUncommittedWarning": false,
"suppressNoRepositoryWarning": false,
"suppressShowKeyBindingsNotice": false
"suppressShowKeyBindingsNotice": false,
"suppressSupportGitLensNotification": false
},
"properties": {
"suppressCommitHasNoPreviousCommitWarning": {
Expand Down Expand Up @@ -1482,6 +1483,10 @@
"suppressShowKeyBindingsNotice": {
"type": "boolean",
"default": false
},
"suppressSupportGitLensNotification": {
"type": "boolean",
"default": false
}
},
"description": "Specifies which messages should be suppressed",
Expand Down Expand Up @@ -1573,10 +1578,23 @@
}
],
"commands": [
{
"command": "gitlens.supportGitLens",
"title": "Support GitLens ❤",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-heart.svg",
"light": "images/light/icon-heart.svg"
}
},
{
"command": "gitlens.showSettingsPage",
"title": "Open Settings",
"category": "GitLens"
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-gear.svg",
"light": "images/light/icon-gear.svg"
}
},
{
"command": "gitlens.showWelcomePage",
Expand Down Expand Up @@ -3309,22 +3327,22 @@
{
"command": "gitlens.pushRepositories",
"when": "gitlens:enabled && view =~ /^gitlens\\.views\\.repositories:/",
"group": "navigation@6"
"group": "navigation@10"
},
{
"command": "gitlens.pullRepositories",
"when": "gitlens:enabled && view =~ /^gitlens\\.views\\.repositories:/",
"group": "navigation@7"
"group": "navigation@11"
},
{
"command": "gitlens.fetchRepositories",
"when": "gitlens:enabled && view =~ /^gitlens\\.views\\.repositories:/",
"group": "navigation@8"
"group": "navigation@12"
},
{
"command": "gitlens.views.repositories.refresh",
"when": "view =~ /^gitlens\\.views\\.repositories:/",
"group": "navigation@98"
"group": "navigation@99"
},
{
"command": "gitlens.views.repositories.setFilesLayoutToAuto",
Expand Down Expand Up @@ -3354,17 +3372,17 @@
{
"command": "gitlens.views.fileHistory.setEditorFollowingOn",
"when": "view =~ /^gitlens\\.views\\.fileHistory:/ && !gitlens:views:fileHistory:editorFollowing",
"group": "navigation@1"
"group": "navigation@10"
},
{
"command": "gitlens.views.fileHistory.setEditorFollowingOff",
"when": "view =~ /^gitlens\\.views\\.fileHistory:/ && gitlens:views:fileHistory:editorFollowing",
"group": "navigation@1"
"group": "navigation@10"
},
{
"command": "gitlens.views.fileHistory.changeBase",
"when": "view =~ /^gitlens\\.views\\.fileHistory:/",
"group": "navigation@2"
"group": "navigation@11"
},
{
"command": "gitlens.views.fileHistory.refresh",
Expand All @@ -3384,17 +3402,17 @@
{
"command": "gitlens.views.lineHistory.setEditorFollowingOn",
"when": "view =~ /^gitlens\\.views\\.lineHistory:/ && !gitlens:views:lineHistory:editorFollowing",
"group": "navigation@1"
"group": "navigation@10"
},
{
"command": "gitlens.views.lineHistory.setEditorFollowingOff",
"when": "view =~ /^gitlens\\.views\\.lineHistory:/ && gitlens:views:lineHistory:editorFollowing",
"group": "navigation@1"
"group": "navigation@10"
},
{
"command": "gitlens.views.lineHistory.changeBase",
"when": "view =~ /^gitlens\\.views\\.lineHistory:/",
"group": "navigation@2"
"group": "navigation@11"
},
{
"command": "gitlens.views.lineHistory.refresh",
Expand All @@ -3414,22 +3432,22 @@
{
"command": "gitlens.views.compare.selectForCompare",
"when": "view =~ /^gitlens\\.views\\.compare:/",
"group": "navigation@1"
},
{
"command": "gitlens.views.compare.clear",
"when": "view =~ /^gitlens\\.views\\.compare:/",
"group": "navigation@2"
"group": "navigation@10"
},
{
"command": "gitlens.views.compare.setKeepResultsToOn",
"when": "view =~ /^gitlens\\.views\\.compare:/ && !gitlens:views:compare:keepResults",
"group": "navigation@3"
"group": "navigation@11"
},
{
"command": "gitlens.views.compare.setKeepResultsToOff",
"when": "view =~ /^gitlens\\.views\\.compare:/ && gitlens:views:compare:keepResults",
"group": "navigation@3"
"group": "navigation@11"
},
{
"command": "gitlens.views.compare.clear",
"when": "view =~ /^gitlens\\.views\\.compare:/",
"group": "navigation@98"
},
{
"command": "gitlens.views.compare.refresh",
Expand All @@ -3454,22 +3472,22 @@
{
"command": "gitlens.views.search.searchCommits",
"when": "view =~ /^gitlens\\.views\\.search:/",
"group": "navigation@1"
},
{
"command": "gitlens.views.search.clear",
"when": "view =~ /^gitlens\\.views\\.search:/",
"group": "navigation@2"
"group": "navigation@10"
},
{
"command": "gitlens.views.search.setKeepResultsToOn",
"when": "view =~ /^gitlens\\.views\\.search:/ && !gitlens:views:search:keepResults",
"group": "navigation@3"
"group": "navigation@11"
},
{
"command": "gitlens.views.search.setKeepResultsToOff",
"when": "view =~ /^gitlens\\.views\\.search:/ && gitlens:views:search:keepResults",
"group": "navigation@3"
"group": "navigation@11"
},
{
"command": "gitlens.views.search.clear",
"when": "view =~ /^gitlens\\.views\\.search:/",
"group": "navigation@98"
},
{
"command": "gitlens.views.search.refresh",
Expand All @@ -3491,6 +3509,11 @@
"when": "view =~ /^gitlens\\.views\\.search:/",
"group": "1_gitlens"
},
{
"command": "gitlens.supportGitLens",
"when": "view =~ /^gitlens\\.views\\..*:/ && config.gitlens.advanced.messages.suppressSupportGitLensNotification != true && gitlens:views:supportGitLens:hide != true",
"group": "navigation@1"
},
{
"command": "gitlens.showSettingsPage",
"when": "view =~ /^gitlens\\.views\\..*:/",
Expand Down
1 change: 1 addition & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export * from './commands/showView';
export * from './commands/stashApply';
export * from './commands/stashDelete';
export * from './commands/stashSave';
export * from './commands/supportGitLens';
export * from './commands/switchMode';
export * from './commands/toggleCodeLens';
1 change: 1 addition & 0 deletions src/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export enum Commands {
StashApply = 'gitlens.stashApply',
StashDelete = 'gitlens.stashDelete',
StashSave = 'gitlens.stashSave',
SupportGitLens = 'gitlens.supportGitLens',
SwitchMode = 'gitlens.switchMode',
ToggleCodeLens = 'gitlens.toggleCodeLens',
ToggleFileBlame = 'gitlens.toggleFileBlame',
Expand Down
14 changes: 14 additions & 0 deletions src/commands/supportGitLens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
import { Messages } from '../messages';
import { command, Command, Commands } from './common';

@command()
export class SupportGitLensCommand extends Command {
constructor() {
super(Commands.SupportGitLens);
}

async execute() {
return Messages.showSupportGitLensMessage();
}
}
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export enum CommandContext {
ViewsCanCompare = 'gitlens:views:canCompare',
ViewsCanCompareFile = 'gitlens:views:canCompare:file',
ViewsCompareKeepResults = 'gitlens:views:compare:keepResults',
ViewsHideSupportGitLens = 'gitlens:supportGitLens:hide',
ViewsFileHistoryEditorFollowing = 'gitlens:views:fileHistory:editorFollowing',
ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing',
ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh',
Expand Down
41 changes: 39 additions & 2 deletions src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
import { ConfigurationTarget, MessageItem, window } from 'vscode';
import { commands, ConfigurationTarget, MessageItem, Uri, window } from 'vscode';
import { configuration, KeyMap } from './configuration';
import { BuiltInCommands, CommandContext, setCommandContext } from './constants';
import { Container } from './container';
import { GitCommit } from './git/gitService';
import { Logger } from './logger';
Expand All @@ -13,7 +14,8 @@ export enum SuppressedMessages {
GitVersionWarning = 'suppressGitVersionWarning',
LineUncommittedWarning = 'suppressLineUncommittedWarning',
NoRepositoryWarning = 'suppressNoRepositoryWarning',
ShowKeyBindingsNotice = 'suppressShowKeyBindingsNotice'
ShowKeyBindingsNotice = 'suppressShowKeyBindingsNotice',
SupportGitLensNotification = 'suppressSupportGitLensNotification'
}

export class Messages {
Expand Down Expand Up @@ -134,6 +136,41 @@ export class Messages {
);
}

static async showSupportGitLensMessage() {
const actions: MessageItem[] = [
{ title: 'Become a Sponsor' },
{ title: 'Donate via PayPal' },
{ title: 'Donate via Cash App' }
];

const result = await Messages.showMessage(
'info',
`While GitLens is offered to everyone for free, if you find it useful please consider supporting it. Thank you! ❤`,
undefined,
null,
...actions
);

if (result != null) {
let uri;
if (result === actions[0]) {
uri = Uri.parse('https://www.patreon.com/eamodio');
}
else if (result === actions[1]) {
uri = Uri.parse('https://www.paypal.me/eamodio');
}
else if (result === actions[2]) {
uri = Uri.parse('https://cash.me/$eamodio');
}

if (uri !== undefined) {
await setCommandContext(CommandContext.ViewsHideSupportGitLens, true);
await this.suppressedMessage(SuppressedMessages.SupportGitLensNotification!);
await commands.executeCommand(BuiltInCommands.Open, uri);
}
}
}

private static async showMessage<T extends MessageItem>(
type: 'info' | 'warn' | 'error',
message: string,
Expand Down
1 change: 1 addition & 0 deletions src/ui/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export interface AdvancedConfig {
suppressLineUncommittedWarning: boolean;
suppressNoRepositoryWarning: boolean;
suppressShowKeyBindingsNotice: boolean;
suppressSupportGitLensNotification: boolean;
};
quickPick: {
closeOnFocusOut: boolean;
Expand Down
8 changes: 4 additions & 4 deletions src/ui/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2792,17 +2792,17 @@ <h2>Show Your Support</h2>
>
<a
class="button button--flat-primary"
title="One-time donations via PayPal"
title="Donate via PayPal"
href="https://www.paypal.me/eamodio"
target="_blank"
>Donations via PayPal</a
>Donate via PayPal</a
>
<a
class="button button--flat-primary"
title="One-time donations via Cash App"
title="Donate via Cash App"
href="https://cash.me/$eamodio"
target="_blank"
>Donations via Cash App</a
>Donate via Cash App</a
>
</div>
<ul>
Expand Down
Loading

0 comments on commit df07b28

Please sign in to comment.