Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2695024
D25536.1734815163.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
9 KB
Referenced Files
None
Subscribers
None
D25536.1734815163.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -14,7 +14,7 @@
'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '6d3700f0',
'differential.pkg.js' => '46fcb3af',
- 'diffusion.pkg.css' => '42c75c37',
+ 'diffusion.pkg.css' => '8ba9c05b',
'diffusion.pkg.js' => '78c9885d',
'maniphest.pkg.css' => '35995d6d',
'maniphest.pkg.js' => 'c9308721',
@@ -69,7 +69,7 @@
'rsrc/css/application/differential/revision-history.css' => '237a2979',
'rsrc/css/application/differential/revision-list.css' => '93d2df7d',
'rsrc/css/application/differential/table-of-contents.css' => 'bba788b9',
- 'rsrc/css/application/diffusion/diffusion-icons.css' => '23b31a1b',
+ 'rsrc/css/application/diffusion/diffusion-icons.css' => '964c777a',
'rsrc/css/application/diffusion/diffusion-readme.css' => 'b68a76e4',
'rsrc/css/application/diffusion/diffusion-repository.css' => 'b89e8c6c',
'rsrc/css/application/diffusion/diffusion.css' => 'e46232d6',
@@ -470,7 +470,7 @@
'rsrc/js/core/behavior-badge-view.js' => '92cdd7b6',
'rsrc/js/core/behavior-bulk-editor.js' => 'aa6d2308',
'rsrc/js/core/behavior-choose-control.js' => '04f8a1e3',
- 'rsrc/js/core/behavior-copy.js' => 'cf32921f',
+ 'rsrc/js/core/behavior-copy.js' => '95d96a9c',
'rsrc/js/core/behavior-detect-timezone.js' => '78bc5d94',
'rsrc/js/core/behavior-device.js' => 'ac2b1e01',
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6bc7ccf7',
@@ -567,7 +567,7 @@
'differential-revision-list-css' => '93d2df7d',
'differential-table-of-contents-css' => 'bba788b9',
'diffusion-css' => 'e46232d6',
- 'diffusion-icons-css' => '23b31a1b',
+ 'diffusion-icons-css' => '964c777a',
'diffusion-readme-css' => 'b68a76e4',
'diffusion-repository-css' => 'b89e8c6c',
'diviner-shared-css' => '4bd263b0',
@@ -644,7 +644,7 @@
'javelin-behavior-owners-path-editor' => 'ff688a7a',
'javelin-behavior-passphrase-credential-control' => '48fe33d0',
'javelin-behavior-phabricator-autofocus' => '65bb0011',
- 'javelin-behavior-phabricator-clipboard-copy' => 'cf32921f',
+ 'javelin-behavior-phabricator-clipboard-copy' => '95d96a9c',
'javelin-behavior-phabricator-gesture' => 'b58d1a2a',
'javelin-behavior-phabricator-gesture-example' => '242dedd0',
'javelin-behavior-phabricator-keyboard-pager' => '1325b731',
@@ -1763,6 +1763,12 @@
'phabricator-prefab',
'javelin-json',
),
+ '95d96a9c' => array(
+ 'javelin-behavior',
+ 'javelin-dom',
+ 'javelin-stratcom',
+ 'phabricator-notification',
+ ),
'9623adc1' => array(
'javelin-behavior',
'javelin-stratcom',
@@ -2063,11 +2069,6 @@
'phuix-formation-column-view',
'phuix-formation-flank-view',
),
- 'cf32921f' => array(
- 'javelin-behavior',
- 'javelin-dom',
- 'javelin-stratcom',
- ),
'd12d214f' => array(
'javelin-install',
'javelin-dom',
diff --git a/src/applications/diffusion/view/DiffusionCloneURIView.php b/src/applications/diffusion/view/DiffusionCloneURIView.php
--- a/src/applications/diffusion/view/DiffusionCloneURIView.php
+++ b/src/applications/diffusion/view/DiffusionCloneURIView.php
@@ -40,6 +40,7 @@
require_celerity_resource('diffusion-icons-css');
Javelin::initBehavior('select-content');
+ Javelin::initBehavior('phabricator-clipboard-copy');
$uri_id = celerity_generate_unique_node_id();
@@ -84,6 +85,21 @@
'selectID' => $uri_id,
));
+ $copy = id(new PHUIButtonView())
+ ->setTag('a')
+ ->setColor(PHUIButtonView::GREY)
+ ->setIcon('fa-clipboard')
+ ->setHref('#')
+ ->addSigil('clipboard-copy')
+ ->addSigil('has-tooltip')
+ ->setMetadata(
+ array(
+ 'tip' => pht('Copy repository URI'),
+ 'text' => $display,
+ 'successMessage' => pht('Repository URI copied.'),
+ 'errorMessage' => pht('Copy of Repository URI failed.'),
+ ));
+
switch ($uri->getEffectiveIOType()) {
case PhabricatorRepositoryURI::IO_READ:
case PhabricatorRepositoryURI::IO_READWRITE:
@@ -121,19 +137,18 @@
->setHref($auth_uri)
->setDisabled($auth_disabled);
- $cells = array();
- $cells[] = phutil_tag('td', array(), $input);
- $cells[] = phutil_tag('th', array(), $io);
- $cells[] = phutil_tag('th', array(), $credentials);
-
- $row = phutil_tag('tr', array(), $cells);
+ $elements = array();
+ $elements[] = $io;
+ $elements[] = $input;
+ $elements[] = $copy;
+ $elements[] = $credentials;
return phutil_tag(
- 'table',
+ 'div',
array(
- 'class' => 'diffusion-clone-uri-table',
+ 'class' => 'diffusion-clone-uri-wrapper',
),
- $row);
+ $elements);
}
}
diff --git a/src/applications/uiexample/examples/PHUIButtonExample.php b/src/applications/uiexample/examples/PHUIButtonExample.php
--- a/src/applications/uiexample/examples/PHUIButtonExample.php
+++ b/src/applications/uiexample/examples/PHUIButtonExample.php
@@ -115,6 +115,8 @@
$button->setMetadata(
array(
'text' => $copy,
+ 'successMessage' => pht('Text copied into clipboard.'),
+ 'errorMessage' => pht('Failed to copy text into clipboard.'),
));
}
diff --git a/webroot/rsrc/css/application/diffusion/diffusion-icons.css b/webroot/rsrc/css/application/diffusion/diffusion-icons.css
--- a/webroot/rsrc/css/application/diffusion/diffusion-icons.css
+++ b/webroot/rsrc/css/application/diffusion/diffusion-icons.css
@@ -2,11 +2,6 @@
* @provides diffusion-icons-css
*/
-input.diffusion-clone-uri {
- display: block;
- width: 100%;
-}
-
.diffusion-clone-extras {
font-size: 11px;
text-align: right;
@@ -35,21 +30,31 @@
padding: 0;
}
-.diffusion-clone-uri-table {
- width: 100%;
-}
-
-.diffusion-clone-uri-table th {
- width: 24px;
- padding: 0 0 0 4px;
+.diffusion-clone-uri-wrapper {
+ display: flex;
}
-.diffusion-clone-uri-table th a.button {
+.diffusion-clone-uri-wrapper a.button {
width: 12px;
height: 19px;
+ margin-left: 4px;
}
-.diffusion-clone-uri-table th a.button .phui-icon-view {
+.diffusion-clone-uri-wrapper a.button .phui-icon-view {
left: 15px;
top: 7px;
}
+
+.diffusion-clone-uri-wrapper a.button:first-child {
+ border-top-right-radius: 0px;
+ border-bottom-right-radius: 0px;
+ margin-left: 0;
+}
+
+.diffusion-clone-uri-wrapper input.diffusion-clone-uri {
+ border-left: none;
+ border-top-left-radius: 0px;
+ border-bottom-left-radius: 0px;
+ display: block;
+ width: 100%;
+}
diff --git a/webroot/rsrc/js/core/behavior-copy.js b/webroot/rsrc/js/core/behavior-copy.js
--- a/webroot/rsrc/js/core/behavior-copy.js
+++ b/webroot/rsrc/js/core/behavior-copy.js
@@ -3,27 +3,32 @@
* @requires javelin-behavior
* javelin-dom
* javelin-stratcom
+ * phabricator-notification
* @javelin
*/
JX.behavior('phabricator-clipboard-copy', function() {
- if (!document.queryCommandSupported) {
- return;
- }
+ var fallback_working = document.queryCommandSupported &&
+ document.queryCommandSupported('copy');
- if (!document.queryCommandSupported('copy')) {
+ if (!navigator.clipboard && !fallback_working) {
return;
}
JX.DOM.alterClass(document.body, 'supports-clipboard', true);
- JX.Stratcom.listen('click', 'clipboard-copy', function(e) {
- e.kill();
+ var copy = function(text) {
+ if (navigator.clipboard) {
+ return navigator.clipboard.writeText(text || '');
+ }
+ return Promise.reject();
+ };
- var data = e.getNodeData('clipboard-copy');
+ var copy_fallback = function(text) {
+ var promise;
var attr = {
- value: data.text || '',
+ value: text || '',
className: 'clipboard-buffer'
};
@@ -33,11 +38,48 @@
try {
node.select();
document.execCommand('copy');
- } catch (ignored) {
- // Ignore any errors we hit.
+ promise = Promise.resolve();
+ } catch (error) {
+ promise = Promise.reject(error);
+ }
+
+ JX.DOM.remove(node);
+ return promise;
+ };
+
+ var show_success_message = function(message) {
+ if (!message) {
+ return;
+ }
+ new JX.Notification()
+ .setContent(message)
+ .alterClassName('jx-notification-done', true)
+ .setDuration(8000)
+ .show();
+ };
+
+ var show_error_message = function(message) {
+ if (!message) {
+ return;
}
+ new JX.Notification()
+ .setContent(message)
+ .alterClassName('jx-notification-error', true)
+ .setDuration(8000)
+ .show();
+ };
+
+ JX.Stratcom.listen('click', 'clipboard-copy', function(e) {
+ e.kill();
+
+ var data = e.getNodeData('clipboard-copy');
- JX.DOM.remove(node);
+ copy(data.text)
+ .catch(copy_fallback.bind(undefined, data.text))
+ .then(
+ show_success_message.bind(undefined, data.successMessage),
+ show_error_message.bind(undefined, data.errorMessage)
+ );
});
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 21:06 (18 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1025026
Default Alt Text
D25536.1734815163.diff (9 KB)
Attached To
Mode
D25536: Implements copy button in clone repo modal
Attached
Detach File
Event Timeline
Log In to Comment