1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 03:02:43 +01:00

Add Copy file path button to file header bar in Differential/Diffusion

Summary:
When looking at a commit/revision, allow to copy the path of a file to the clipboard, so you can quickly open that file in your local code checkout from the command line.

Closes T15897

Test Plan:
Open a proposed commit in Differential or a merged commit in Diffusion. Click the "Copy file path" button, paste that clipboard content.
Change the width of the viewport and see that the button is not rendered when in phone mode.
Run `./bin/celerity map` again and no changes.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15897

Differential Revision: https://we.phorge.it/D25757
This commit is contained in:
Andre Klapper 2024-07-30 19:24:31 +02:00
parent 0bfe9ca88f
commit ec6ba69666
3 changed files with 43 additions and 9 deletions

View file

@ -12,7 +12,7 @@ return array(
'core.pkg.css' => 'ac619266', 'core.pkg.css' => 'ac619266',
'core.pkg.js' => '2eeda9e0', 'core.pkg.js' => '2eeda9e0',
'dark-console.pkg.js' => '187792c2', 'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '6d3700f0', 'differential.pkg.css' => 'fda9518d',
'differential.pkg.js' => '46fcb3af', 'differential.pkg.js' => '46fcb3af',
'diffusion.pkg.css' => '354279ea', 'diffusion.pkg.css' => '354279ea',
'diffusion.pkg.js' => '78c9885d', 'diffusion.pkg.js' => '78c9885d',
@ -63,7 +63,7 @@ return array(
'rsrc/css/application/diff/diff-tree-view.css' => 'e2d3e222', 'rsrc/css/application/diff/diff-tree-view.css' => 'e2d3e222',
'rsrc/css/application/diff/inline-comment-summary.css' => '81eb368d', 'rsrc/css/application/diff/inline-comment-summary.css' => '81eb368d',
'rsrc/css/application/differential/add-comment.css' => '7e5900d9', 'rsrc/css/application/differential/add-comment.css' => '7e5900d9',
'rsrc/css/application/differential/changeset-view.css' => '1b0476bc', 'rsrc/css/application/differential/changeset-view.css' => '979e688c',
'rsrc/css/application/differential/core.css' => '7300a73e', 'rsrc/css/application/differential/core.css' => '7300a73e',
'rsrc/css/application/differential/phui-inline-comment.css' => '9863a85e', 'rsrc/css/application/differential/phui-inline-comment.css' => '9863a85e',
'rsrc/css/application/differential/revision-comment.css' => '7dbc8d1d', 'rsrc/css/application/differential/revision-comment.css' => '7dbc8d1d',
@ -560,7 +560,7 @@ return array(
'conpherence-transaction-css' => '3a3f5e7e', 'conpherence-transaction-css' => '3a3f5e7e',
'd3' => 'e97b4b78', 'd3' => 'e97b4b78',
'diff-tree-view-css' => 'e2d3e222', 'diff-tree-view-css' => 'e2d3e222',
'differential-changeset-view-css' => '1b0476bc', 'differential-changeset-view-css' => '979e688c',
'differential-core-view-css' => '7300a73e', 'differential-core-view-css' => '7300a73e',
'differential-revision-add-comment-css' => '7e5900d9', 'differential-revision-add-comment-css' => '7e5900d9',
'differential-revision-comment-css' => '7dbc8d1d', 'differential-revision-comment-css' => '7dbc8d1d',
@ -1056,9 +1056,6 @@ return array(
'javelin-util', 'javelin-util',
'phabricator-keyboard-shortcut-manager', 'phabricator-keyboard-shortcut-manager',
), ),
'1b0476bc' => array(
'phui-inline-comment-view-css',
),
'1b6acc2a' => array( '1b6acc2a' => array(
'javelin-magical-init', 'javelin-magical-init',
'javelin-util', 'javelin-util',
@ -1777,6 +1774,9 @@ return array(
'javelin-stratcom', 'javelin-stratcom',
'phabricator-notification', 'phabricator-notification',
), ),
'979e688c' => array(
'phui-inline-comment-view-css',
),
'98ef467f' => array( '98ef467f' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',

View file

@ -233,6 +233,22 @@ final class DifferentialChangesetDetailView extends AphrontView {
$show_directory_uri = phutil_string_cast($show_directory_uri); $show_directory_uri = phutil_string_cast($show_directory_uri);
} }
Javelin::initBehavior('phabricator-clipboard-copy');
$path_copy_button = id(new PHUIButtonView())
->setTag('a')
->setColor(PHUIButtonView::GREY)
->setIcon('fa-clipboard')
->setHref('#')
->addSigil('clipboard-copy')
->addSigil('has-tooltip')
->setMetadata(
array(
'tip' => pht('Copy file path'),
'text' => $display_filename,
'successMessage' => pht('File path copied.'),
'errorMessage' => pht('Copy of file path failed.'),
));
return javelin_tag( return javelin_tag(
'div', 'div',
array( array(
@ -278,7 +294,16 @@ final class DifferentialChangesetDetailView extends AphrontView {
'sigil' => 'changeset-header', 'sigil' => 'changeset-header',
), ),
array( array(
$icon, javelin_tag(
'span',
array(
'class' => 'differential-changeset-path-copy-button',
'meta' => array(
'selectID' => $display_filename,
'once' => true,
),
),
$path_copy_button),
javelin_tag( javelin_tag(
'span', 'span',
array( array(

View file

@ -340,7 +340,7 @@ td.cov-I {
.differential-file-icon-header .phui-icon-view { .differential-file-icon-header .phui-icon-view {
display: inline-block; display: inline-block;
margin: 0 6px 2px 0; margin: 0 0 2px 0;
vertical-align: middle; vertical-align: middle;
font-size: 14px; font-size: 14px;
} }
@ -349,6 +349,15 @@ td.cov-I {
display: none; display: none;
} }
.differential-changeset-path-copy-button {
margin-right: 0;
padding-right: 10px;
}
.device-phone .differential-changeset-path-copy-button {
display: none;
}
.differential-changeset-buttons { .differential-changeset-buttons {
float: right; float: right;
margin-top: 16px; margin-top: 16px;