Merge pull request #13751 from uttiya10/copy-relative-path-changed-files

Add "Copy Relative File Path" Option to Changed Files' Context Menu
This commit is contained in:
tidy-dev 2022-02-08 08:44:03 -05:00 committed by GitHub
commit e9b6653a3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View file

@ -23,6 +23,7 @@ import {
CopyFilePathLabel,
RevealInFileManagerLabel,
OpenWithDefaultProgramLabel,
CopyRelativeFilePathLabel,
} from '../lib/context-menu'
import { CommitMessage } from './commit-message'
import { ChangedFile } from './changed-file'
@ -405,6 +406,15 @@ export class ChangesList extends React.Component<
}
}
private getCopyRelativePathMenuItem = (
file: WorkingDirectoryFileChange
): IMenuItem => {
return {
label: CopyRelativeFilePathLabel,
action: () => clipboard.writeText(Path.normalize(file.path)),
}
}
private getRevealInFileManagerMenuItem = (
file: WorkingDirectoryFileChange
): IMenuItem => {
@ -517,6 +527,8 @@ export class ChangesList extends React.Component<
items.push(
{ type: 'separator' },
this.getCopyPathMenuItem(file),
this.getCopyRelativePathMenuItem(file),
{ type: 'separator' },
this.getRevealInFileManagerMenuItem(file),
this.getOpenInExternalEditorMenuItem(file, enabled),
{
@ -549,6 +561,8 @@ export class ChangesList extends React.Component<
items.push(
this.getCopyPathMenuItem(file),
this.getCopyRelativePathMenuItem(file),
{ type: 'separator' },
this.getRevealInFileManagerMenuItem(file),
this.getOpenInExternalEditorMenuItem(file, enabled),
{

View file

@ -18,6 +18,7 @@ import {
DefaultEditorLabel,
RevealInFileManagerLabel,
OpenWithDefaultProgramLabel,
CopyRelativeFilePathLabel,
} from '../lib/context-menu'
import { ThrottledScheduler } from '../lib/throttled-scheduler'
@ -363,6 +364,11 @@ export class SelectedCommit extends React.Component<
label: CopyFilePathLabel,
action: () => clipboard.writeText(fullPath),
},
{
label: CopyRelativeFilePathLabel,
action: () => clipboard.writeText(Path.normalize(file.path)),
},
{ type: 'separator' },
]
let viewOnGitHubLabel = 'View on GitHub'

View file

@ -3,6 +3,10 @@ export const CopyFilePathLabel = __DARWIN__
? 'Copy File Path'
: 'Copy file path'
export const CopyRelativeFilePathLabel = __DARWIN__
? 'Copy Relative File Path'
: 'Copy relative file path'
export const DefaultEditorLabel = __DARWIN__
? 'Open in External Editor'
: 'Open in external editor'