Skip to content

Commit e1365c9

Browse files
committed
mhutchie#517 The visibility of actions in the Commit Details View's File Context Menu can now be controlled via the extension setting git-graph.contextMenuActionsVisibility.
1 parent a50bafd commit e1365c9

File tree

5 files changed

+99
-9
lines changed

5 files changed

+99
-9
lines changed

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,47 @@
244244
}
245245
}
246246
},
247+
"commitDetailsViewFile": {
248+
"type": "object",
249+
"properties": {
250+
"viewDiff": {
251+
"type": "boolean",
252+
"title": "View Diff"
253+
},
254+
"viewFileAtThisRevision": {
255+
"type": "boolean",
256+
"title": "View File at this Revision"
257+
},
258+
"viewDiffWithWorkingFile": {
259+
"type": "boolean",
260+
"title": "View Diff with Working File"
261+
},
262+
"openFile": {
263+
"type": "boolean",
264+
"title": "Open File"
265+
},
266+
"markAsReviewed": {
267+
"type": "boolean",
268+
"title": "Mark as Reviewed"
269+
},
270+
"markAsNotReviewed": {
271+
"type": "boolean",
272+
"title": "Mark as Not Reviewed"
273+
},
274+
"resetFileToThisRevision": {
275+
"type": "boolean",
276+
"title": "Reset File to this Revision..."
277+
},
278+
"copyAbsoluteFilePath": {
279+
"type": "boolean",
280+
"title": "Copy Absolute File Path to Clipboard"
281+
},
282+
"copyRelativeFilePath": {
283+
"type": "boolean",
284+
"title": "Copy Relative File Path to Clipboard"
285+
}
286+
}
287+
},
247288
"remoteBranch": {
248289
"type": "object",
249290
"properties": {

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class Config {
8383
const config: ContextMenuActionsVisibility = {
8484
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 },
8585
commit: { addTag: true, createBranch: true, checkout: true, cherrypick: true, revert: true, drop: true, merge: true, rebase: true, reset: true, copyHash: true, copySubject: true },
86+
commitDetailsViewFile: { viewDiff: true, viewFileAtThisRevision: true, viewDiffWithWorkingFile: true, openFile: true, markAsReviewed: true, markAsNotReviewed: true, resetFileToThisRevision: true, copyAbsoluteFilePath: true, copyRelativeFilePath: true },
8687
remoteBranch: { checkout: true, delete: true, fetch: true, merge: true, pull: true, viewIssue: true, createPullRequest: true, createArchive: true, selectInBranchesDropdown: true, unselectInBranchesDropdown: true, copyName: true },
8788
stash: { apply: true, createBranch: true, pop: true, drop: true, copyName: true, copyHash: true },
8889
tag: { viewDetails: true, delete: true, push: true, createArchive: true, copyName: true },

src/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,17 @@ export interface ContextMenuActionsVisibility {
369369
readonly copyHash: boolean;
370370
readonly copySubject: boolean;
371371
};
372+
readonly commitDetailsViewFile: {
373+
readonly viewDiff: boolean;
374+
readonly viewFileAtThisRevision: boolean;
375+
readonly viewDiffWithWorkingFile: boolean;
376+
readonly openFile: boolean;
377+
readonly markAsReviewed: boolean;
378+
readonly markAsNotReviewed: boolean;
379+
readonly resetFileToThisRevision: boolean;
380+
readonly copyAbsoluteFilePath: boolean;
381+
readonly copyRelativeFilePath: boolean;
382+
};
372383
readonly remoteBranch: {
373384
readonly checkout: boolean;
374385
readonly delete: boolean;

tests/config.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,17 @@ describe('Config', () => {
290290
copyHash: true,
291291
copySubject: true
292292
},
293+
commitDetailsViewFile: {
294+
viewDiff: true,
295+
viewFileAtThisRevision: true,
296+
viewDiffWithWorkingFile: true,
297+
openFile: true,
298+
markAsReviewed: true,
299+
markAsNotReviewed: true,
300+
resetFileToThisRevision: true,
301+
copyAbsoluteFilePath: true,
302+
copyRelativeFilePath: true
303+
},
293304
remoteBranch: {
294305
checkout: true,
295306
delete: true,
@@ -361,6 +372,17 @@ describe('Config', () => {
361372
copyHash: true,
362373
copySubject: true
363374
},
375+
commitDetailsViewFile: {
376+
viewDiff: true,
377+
viewFileAtThisRevision: true,
378+
viewDiffWithWorkingFile: true,
379+
openFile: true,
380+
markAsReviewed: true,
381+
markAsNotReviewed: true,
382+
resetFileToThisRevision: true,
383+
copyAbsoluteFilePath: true,
384+
copyRelativeFilePath: true
385+
},
364386
remoteBranch: {
365387
checkout: true,
366388
delete: true,
@@ -407,6 +429,9 @@ describe('Config', () => {
407429
commit: {
408430
checkout: false
409431
},
432+
commitDetailsViewFile: {
433+
resetFileToThisRevision: false
434+
},
410435
remoteBranch: {
411436
delete: true,
412437
fetch: false,
@@ -447,6 +472,17 @@ describe('Config', () => {
447472
copyHash: true,
448473
copySubject: true
449474
},
475+
commitDetailsViewFile: {
476+
viewDiff: true,
477+
viewFileAtThisRevision: true,
478+
viewDiffWithWorkingFile: true,
479+
openFile: true,
480+
markAsReviewed: true,
481+
markAsNotReviewed: true,
482+
resetFileToThisRevision: false,
483+
copyAbsoluteFilePath: true,
484+
copyRelativeFilePath: true
485+
},
450486
remoteBranch: {
451487
checkout: true,
452488
delete: true,

web/main.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,58 +3041,59 @@ class GitGraphView {
30413041
const fileExistsAtThisRevision = file.type !== GG.GitFileStatus.Deleted && !isUncommitted;
30423042
const fileExistsAtThisRevisionAndDiffPossible = fileExistsAtThisRevision && diffPossible;
30433043
const codeReviewInProgressAndNotReviewed = expandedCommit.codeReview !== null && expandedCommit.codeReview.remainingFiles.includes(file.newFilePath);
3044+
const visibility = this.config.contextMenuActionsVisibility.commitDetailsViewFile;
30443045

30453046
contextMenu.show([
30463047
[
30473048
{
30483049
title: 'View Diff',
3049-
visible: diffPossible,
3050+
visible: visibility.viewDiff && diffPossible,
30503051
onClick: () => triggerViewFileDiff(file, fileElem)
30513052
},
30523053
{
30533054
title: 'View File at this Revision',
3054-
visible: fileExistsAtThisRevisionAndDiffPossible,
3055+
visible: visibility.viewFileAtThisRevision && fileExistsAtThisRevisionAndDiffPossible,
30553056
onClick: () => triggerViewFileAtRevision(file, fileElem)
30563057
},
30573058
{
30583059
title: 'View Diff with Working File',
3059-
visible: fileExistsAtThisRevisionAndDiffPossible,
3060+
visible: visibility.viewDiffWithWorkingFile && fileExistsAtThisRevisionAndDiffPossible,
30603061
onClick: () => triggerViewFileDiffWithWorkingFile(file, fileElem)
30613062
},
30623063
{
30633064
title: 'Open File',
3064-
visible: file.type !== GG.GitFileStatus.Deleted,
3065+
visible: visibility.openFile && file.type !== GG.GitFileStatus.Deleted,
30653066
onClick: () => triggerOpenFile(file, fileElem)
30663067
}
30673068
],
30683069
[
30693070
{
30703071
title: 'Mark as Reviewed',
3071-
visible: codeReviewInProgressAndNotReviewed,
3072+
visible: visibility.markAsReviewed && codeReviewInProgressAndNotReviewed,
30723073
onClick: () => this.cdvUpdateFileState(file, fileElem, true, false)
30733074
},
30743075
{
30753076
title: 'Mark as Not Reviewed',
3076-
visible: expandedCommit.codeReview !== null && !codeReviewInProgressAndNotReviewed,
3077+
visible: visibility.markAsNotReviewed && expandedCommit.codeReview !== null && !codeReviewInProgressAndNotReviewed,
30773078
onClick: () => this.cdvUpdateFileState(file, fileElem, false, false)
30783079
}
30793080
],
30803081
[
30813082
{
30823083
title: 'Reset File to this Revision' + ELLIPSIS,
3083-
visible: fileExistsAtThisRevision && expandedCommit.compareWithHash === null,
3084+
visible: visibility.resetFileToThisRevision && fileExistsAtThisRevision && expandedCommit.compareWithHash === null,
30843085
onClick: () => triggerResetFileToRevision(file, fileElem)
30853086
}
30863087
],
30873088
[
30883089
{
30893090
title: 'Copy Absolute File Path to Clipboard',
3090-
visible: true,
3091+
visible: visibility.copyAbsoluteFilePath,
30913092
onClick: () => triggerCopyFilePath(file, true)
30923093
},
30933094
{
30943095
title: 'Copy Relative File Path to Clipboard',
3095-
visible: true,
3096+
visible: visibility.copyRelativeFilePath,
30963097
onClick: () => triggerCopyFilePath(file, false)
30973098
}
30983099
]

0 commit comments

Comments
 (0)