diff --git a/src/commandsAndMenu.tsx b/src/commandsAndMenu.tsx index c807732b4..619366e33 100644 --- a/src/commandsAndMenu.tsx +++ b/src/commandsAndMenu.tsx @@ -34,7 +34,8 @@ import { discardIcon, gitIcon, openIcon, - removeIcon + removeIcon, + historyIcon } from './style/icons'; import { CommandIDs, @@ -893,6 +894,17 @@ export function addCommands( } }); + commands.addCommand(ContextCommandIDs.gitFileHistory, { + label: trans.__('History'), + caption: trans.__('View the history of this file'), + execute: args => { + // TODO: Implement + const { files } = args as any as CommandArguments.IGitContextAction; + console.log('History Clicked', files.length === 1); + }, + icon: historyIcon.bindprops({ stylesheet: 'menuItem' }) + }); + commands.addCommand(ContextCommandIDs.gitNoAction, { label: trans.__('No actions available'), isEnabled: () => false, @@ -1071,6 +1083,14 @@ export function addFileBrowserContextMenu( ) ); + // if looking at a single file that is not untracked + if ( + items.length === 1 && + (allCommands.size === 0 || !statuses.has('untracked')) + ) { + allCommands.add(ContextCommandIDs.gitFileHistory); + } + // if looking at a tracked file with no changes, // it has no status, nor any actions available // (although `git rm` would be a valid action) diff --git a/src/style/icons.ts b/src/style/icons.ts index fd5e8191c..b93b74e77 100644 --- a/src/style/icons.ts +++ b/src/style/icons.ts @@ -17,6 +17,7 @@ import removeSvg from '../../style/icons/remove.svg'; import rewindSvg from '../../style/icons/rewind.svg'; import tagSvg from '../../style/icons/tag.svg'; import trashSvg from '../../style/icons/trash.svg'; +import clockSvg from '../../style/icons/clock.svg'; export const gitIcon = new LabIcon({ name: 'git', svgstr: gitSvg }); export const addIcon = new LabIcon({ @@ -79,3 +80,7 @@ export const trashIcon = new LabIcon({ name: 'git:trash', svgstr: trashSvg }); +export const historyIcon = new LabIcon({ + name: 'git:history', + svgstr: clockSvg +}); diff --git a/src/tokens.ts b/src/tokens.ts index 5b6902fc7..19ea5e3d8 100644 --- a/src/tokens.ts +++ b/src/tokens.ts @@ -958,6 +958,7 @@ export enum ContextCommandIDs { gitFileUnstage = 'git:context-unstage', gitFileStage = 'git:context-stage', gitFileTrack = 'git:context-track', + gitFileHistory = 'git:context-history', gitIgnore = 'git:context-ignore', gitIgnoreExtension = 'git:context-ignoreExtension', gitNoAction = 'git:no-action' diff --git a/style/icons/clock.svg b/style/icons/clock.svg new file mode 100644 index 000000000..b46649488 --- /dev/null +++ b/style/icons/clock.svg @@ -0,0 +1,14 @@ +