From df07b28065198ac47dba1379d476a827dafe16d0 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 13 Nov 2018 03:30:13 -0500 Subject: [PATCH] Adds support gitlens command and icon to views --- BACKERS.md | 4 +-- README.md | 8 ++--- images/dark/icon-gear.svg | 3 ++ images/dark/icon-heart.svg | 3 ++ images/light/icon-gear.svg | 3 ++ images/light/icon-heart.svg | 3 ++ package.json | 79 +++++++++++++++++++++++++++--------------- src/commands.ts | 1 + src/commands/common.ts | 1 + src/commands/supportGitLens.ts | 14 ++++++++ src/constants.ts | 1 + src/messages.ts | 41 ++++++++++++++++++++-- src/ui/config.ts | 1 + src/ui/settings/index.html | 8 ++--- src/ui/welcome/index.html | 22 ++++++------ 15 files changed, 141 insertions(+), 51 deletions(-) create mode 100644 images/dark/icon-gear.svg create mode 100644 images/dark/icon-heart.svg create mode 100644 images/light/icon-gear.svg create mode 100644 images/light/icon-heart.svg create mode 100644 src/commands/supportGitLens.ts diff --git a/BACKERS.md b/BACKERS.md index 4d10d0d..581067f 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -1,8 +1,8 @@

Sponsors & Backers

-To my incredible backers — 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 — 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) diff --git a/README.md b/README.md index 68849d1..9ed654d 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,13 @@ While I enjoy giving my free time and attention to GitLens' development and grow ### Show Your Support ❤ -To my incredible backers — 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 — 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 — feel free to choose more than one. 😉 +If you'd like to join in supporting GitLens, please consider the following — feel free to choose more than one. 😉 - [Become a Sponsor](https://www.patreon.com/eamodio 'Become a sponsor on Patreon') — 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') diff --git a/images/dark/icon-gear.svg b/images/dark/icon-gear.svg new file mode 100644 index 0000000..4d0452b --- /dev/null +++ b/images/dark/icon-gear.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/dark/icon-heart.svg b/images/dark/icon-heart.svg new file mode 100644 index 0000000..5229de7 --- /dev/null +++ b/images/dark/icon-heart.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/light/icon-gear.svg b/images/light/icon-gear.svg new file mode 100644 index 0000000..9a1d05c --- /dev/null +++ b/images/light/icon-gear.svg @@ -0,0 +1,3 @@ + + + diff --git a/images/light/icon-heart.svg b/images/light/icon-heart.svg new file mode 100644 index 0000000..01547e7 --- /dev/null +++ b/images/light/icon-heart.svg @@ -0,0 +1,3 @@ + + + diff --git a/package.json b/package.json index ade8865..6f293cf 100644 --- a/package.json +++ b/package.json @@ -1448,7 +1448,8 @@ "suppressGitVersionWarning": false, "suppressLineUncommittedWarning": false, "suppressNoRepositoryWarning": false, - "suppressShowKeyBindingsNotice": false + "suppressShowKeyBindingsNotice": false, + "suppressSupportGitLensNotification": false }, "properties": { "suppressCommitHasNoPreviousCommitWarning": { @@ -1482,6 +1483,10 @@ "suppressShowKeyBindingsNotice": { "type": "boolean", "default": false + }, + "suppressSupportGitLensNotification": { + "type": "boolean", + "default": false } }, "description": "Specifies which messages should be suppressed", @@ -1574,9 +1579,22 @@ ], "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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -3492,6 +3510,11 @@ "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\\..*:/", "group": "9_gitlens" diff --git a/src/commands.ts b/src/commands.ts index e740720..5e4a6a7 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -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'; diff --git a/src/commands/common.ts b/src/commands/common.ts index df9cc29..ff3eb8a 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -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', diff --git a/src/commands/supportGitLens.ts b/src/commands/supportGitLens.ts new file mode 100644 index 0000000..0f94c3f --- /dev/null +++ b/src/commands/supportGitLens.ts @@ -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(); + } +} diff --git a/src/constants.ts b/src/constants.ts index 5fc5b33..7967cdc 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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', diff --git a/src/messages.ts b/src/messages.ts index 9a072f9..9480144 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -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'; @@ -13,7 +14,8 @@ export enum SuppressedMessages { GitVersionWarning = 'suppressGitVersionWarning', LineUncommittedWarning = 'suppressLineUncommittedWarning', NoRepositoryWarning = 'suppressNoRepositoryWarning', - ShowKeyBindingsNotice = 'suppressShowKeyBindingsNotice' + ShowKeyBindingsNotice = 'suppressShowKeyBindingsNotice', + SupportGitLensNotification = 'suppressSupportGitLensNotification' } export class Messages { @@ -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( type: 'info' | 'warn' | 'error', message: string, diff --git a/src/ui/config.ts b/src/ui/config.ts index fa8ca8c..866dd4e 100644 --- a/src/ui/config.ts +++ b/src/ui/config.ts @@ -115,6 +115,7 @@ export interface AdvancedConfig { suppressLineUncommittedWarning: boolean; suppressNoRepositoryWarning: boolean; suppressShowKeyBindingsNotice: boolean; + suppressSupportGitLensNotification: boolean; }; quickPick: { closeOnFocusOut: boolean; diff --git a/src/ui/settings/index.html b/src/ui/settings/index.html index c1eb8cd..6fc2116 100644 --- a/src/ui/settings/index.html +++ b/src/ui/settings/index.html @@ -2792,17 +2792,17 @@ > Donations via PayPalDonate via PayPal Donations via Cash AppDonate via Cash App