diff --git a/package.json b/package.json index 4b1c6d15..3d024431 100644 --- a/package.json +++ b/package.json @@ -244,6 +244,47 @@ } } }, + "commitDetailsViewFile": { + "type": "object", + "properties": { + "viewDiff": { + "type": "boolean", + "title": "View Diff" + }, + "viewFileAtThisRevision": { + "type": "boolean", + "title": "View File at this Revision" + }, + "viewDiffWithWorkingFile": { + "type": "boolean", + "title": "View Diff with Working File" + }, + "openFile": { + "type": "boolean", + "title": "Open File" + }, + "markAsReviewed": { + "type": "boolean", + "title": "Mark as Reviewed" + }, + "markAsNotReviewed": { + "type": "boolean", + "title": "Mark as Not Reviewed" + }, + "resetFileToThisRevision": { + "type": "boolean", + "title": "Reset File to this Revision..." + }, + "copyAbsoluteFilePath": { + "type": "boolean", + "title": "Copy Absolute File Path to Clipboard" + }, + "copyRelativeFilePath": { + "type": "boolean", + "title": "Copy Relative File Path to Clipboard" + } + } + }, "remoteBranch": { "type": "object", "properties": { diff --git a/src/config.ts b/src/config.ts index 88a05740..8d777ca8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -83,6 +83,7 @@ class Config { const config: ContextMenuActionsVisibility = { branch: { checkout: true, rename: true, delete: true, merge: true, rebase: true, push: true, viewIssue: true, createPullRequest: true, createArchive: true, selectInBranchesDropdown: true, unselectInBranchesDropdown: true, copyName: true }, commit: { addTag: true, createBranch: true, checkout: true, cherrypick: true, revert: true, drop: true, merge: true, rebase: true, reset: true, copyHash: true, copySubject: true }, + commitDetailsViewFile: { viewDiff: true, viewFileAtThisRevision: true, viewDiffWithWorkingFile: true, openFile: true, markAsReviewed: true, markAsNotReviewed: true, resetFileToThisRevision: true, copyAbsoluteFilePath: true, copyRelativeFilePath: true }, remoteBranch: { checkout: true, delete: true, fetch: true, merge: true, pull: true, viewIssue: true, createPullRequest: true, createArchive: true, selectInBranchesDropdown: true, unselectInBranchesDropdown: true, copyName: true }, stash: { apply: true, createBranch: true, pop: true, drop: true, copyName: true, copyHash: true }, tag: { viewDetails: true, delete: true, push: true, createArchive: true, copyName: true }, diff --git a/src/types.ts b/src/types.ts index 17b3612b..c543fa9f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -369,6 +369,17 @@ export interface ContextMenuActionsVisibility { readonly copyHash: boolean; readonly copySubject: boolean; }; + readonly commitDetailsViewFile: { + readonly viewDiff: boolean; + readonly viewFileAtThisRevision: boolean; + readonly viewDiffWithWorkingFile: boolean; + readonly openFile: boolean; + readonly markAsReviewed: boolean; + readonly markAsNotReviewed: boolean; + readonly resetFileToThisRevision: boolean; + readonly copyAbsoluteFilePath: boolean; + readonly copyRelativeFilePath: boolean; + }; readonly remoteBranch: { readonly checkout: boolean; readonly delete: boolean; diff --git a/tests/config.test.ts b/tests/config.test.ts index 62e0e39f..69924d51 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -290,6 +290,17 @@ describe('Config', () => { copyHash: true, copySubject: true }, + commitDetailsViewFile: { + viewDiff: true, + viewFileAtThisRevision: true, + viewDiffWithWorkingFile: true, + openFile: true, + markAsReviewed: true, + markAsNotReviewed: true, + resetFileToThisRevision: true, + copyAbsoluteFilePath: true, + copyRelativeFilePath: true + }, remoteBranch: { checkout: true, delete: true, @@ -361,6 +372,17 @@ describe('Config', () => { copyHash: true, copySubject: true }, + commitDetailsViewFile: { + viewDiff: true, + viewFileAtThisRevision: true, + viewDiffWithWorkingFile: true, + openFile: true, + markAsReviewed: true, + markAsNotReviewed: true, + resetFileToThisRevision: true, + copyAbsoluteFilePath: true, + copyRelativeFilePath: true + }, remoteBranch: { checkout: true, delete: true, @@ -407,6 +429,9 @@ describe('Config', () => { commit: { checkout: false }, + commitDetailsViewFile: { + resetFileToThisRevision: false + }, remoteBranch: { delete: true, fetch: false, @@ -447,6 +472,17 @@ describe('Config', () => { copyHash: true, copySubject: true }, + commitDetailsViewFile: { + viewDiff: true, + viewFileAtThisRevision: true, + viewDiffWithWorkingFile: true, + openFile: true, + markAsReviewed: true, + markAsNotReviewed: true, + resetFileToThisRevision: false, + copyAbsoluteFilePath: true, + copyRelativeFilePath: true + }, remoteBranch: { checkout: true, delete: true, diff --git a/web/main.ts b/web/main.ts index aa82f719..29c23c82 100644 --- a/web/main.ts +++ b/web/main.ts @@ -3041,58 +3041,59 @@ class GitGraphView { const fileExistsAtThisRevision = file.type !== GG.GitFileStatus.Deleted && !isUncommitted; const fileExistsAtThisRevisionAndDiffPossible = fileExistsAtThisRevision && diffPossible; const codeReviewInProgressAndNotReviewed = expandedCommit.codeReview !== null && expandedCommit.codeReview.remainingFiles.includes(file.newFilePath); + const visibility = this.config.contextMenuActionsVisibility.commitDetailsViewFile; contextMenu.show([ [ { title: 'View Diff', - visible: diffPossible, + visible: visibility.viewDiff && diffPossible, onClick: () => triggerViewFileDiff(file, fileElem) }, { title: 'View File at this Revision', - visible: fileExistsAtThisRevisionAndDiffPossible, + visible: visibility.viewFileAtThisRevision && fileExistsAtThisRevisionAndDiffPossible, onClick: () => triggerViewFileAtRevision(file, fileElem) }, { title: 'View Diff with Working File', - visible: fileExistsAtThisRevisionAndDiffPossible, + visible: visibility.viewDiffWithWorkingFile && fileExistsAtThisRevisionAndDiffPossible, onClick: () => triggerViewFileDiffWithWorkingFile(file, fileElem) }, { title: 'Open File', - visible: file.type !== GG.GitFileStatus.Deleted, + visible: visibility.openFile && file.type !== GG.GitFileStatus.Deleted, onClick: () => triggerOpenFile(file, fileElem) } ], [ { title: 'Mark as Reviewed', - visible: codeReviewInProgressAndNotReviewed, + visible: visibility.markAsReviewed && codeReviewInProgressAndNotReviewed, onClick: () => this.cdvUpdateFileState(file, fileElem, true, false) }, { title: 'Mark as Not Reviewed', - visible: expandedCommit.codeReview !== null && !codeReviewInProgressAndNotReviewed, + visible: visibility.markAsNotReviewed && expandedCommit.codeReview !== null && !codeReviewInProgressAndNotReviewed, onClick: () => this.cdvUpdateFileState(file, fileElem, false, false) } ], [ { title: 'Reset File to this Revision' + ELLIPSIS, - visible: fileExistsAtThisRevision && expandedCommit.compareWithHash === null, + visible: visibility.resetFileToThisRevision && fileExistsAtThisRevision && expandedCommit.compareWithHash === null, onClick: () => triggerResetFileToRevision(file, fileElem) } ], [ { title: 'Copy Absolute File Path to Clipboard', - visible: true, + visible: visibility.copyAbsoluteFilePath, onClick: () => triggerCopyFilePath(file, true) }, { title: 'Copy Relative File Path to Clipboard', - visible: true, + visible: visibility.copyRelativeFilePath, onClick: () => triggerCopyFilePath(file, false) } ]