Skip to content

Commit

Permalink
#517 The visibility of actions in the Commit Details View's File Cont…
Browse files Browse the repository at this point in the history
…ext Menu can now be controlled via the extension setting `git-graph.contextMenuActionsVisibility`.
  • Loading branch information
mhutchie committed May 30, 2021
1 parent a50bafd commit e1365c9
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 9 deletions.
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
11 changes: 11 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 36 additions & 0 deletions tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -407,6 +429,9 @@ describe('Config', () => {
commit: {
checkout: false
},
commitDetailsViewFile: {
resetFileToThisRevision: false
},
remoteBranch: {
delete: true,
fetch: false,
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 10 additions & 9 deletions web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
]
Expand Down

0 comments on commit e1365c9

Please sign in to comment.