@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add an "Open in External Editor" keystroke to Differential

Summary: Ref T13515. See PHI1661. If a file is selected, add a keystroke to click the "Open in External Editor" link.

Test Plan: In Safari, Chrome, and Firefox: used "J" to select a file, then "\" to open it in an external editor. (In Safari and Chrome, this prompts.)

Maniphest Tasks: T13515

Differential Revision: https://secure.phabricator.com/D21135

+157 -35
+20 -20
resources/celerity/map.php
··· 12 12 'core.pkg.css' => '86f155f9', 13 13 'core.pkg.js' => '705aec2c', 14 14 'differential.pkg.css' => '607c84be', 15 - 'differential.pkg.js' => '1b97518d', 15 + 'differential.pkg.js' => 'd73a942b', 16 16 'diffusion.pkg.css' => '42c75c37', 17 17 'diffusion.pkg.js' => 'a98c0bf7', 18 18 'maniphest.pkg.css' => '35995d6d', ··· 377 377 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'a2ab19be', 378 378 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9', 379 379 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 380 - 'rsrc/js/application/diff/DiffChangeset.js' => 'a31ffc00', 381 - 'rsrc/js/application/diff/DiffChangesetList.js' => '0f5c016d', 380 + 'rsrc/js/application/diff/DiffChangeset.js' => '7ccc4153', 381 + 'rsrc/js/application/diff/DiffChangesetList.js' => '2e636e0a', 382 382 'rsrc/js/application/diff/DiffInline.js' => 'a4a14a94', 383 383 'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17', 384 384 'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd', ··· 774 774 'phabricator-darklog' => '3b869402', 775 775 'phabricator-darkmessage' => '26cd4b73', 776 776 'phabricator-dashboard-css' => '5a205b9d', 777 - 'phabricator-diff-changeset' => 'a31ffc00', 778 - 'phabricator-diff-changeset-list' => '0f5c016d', 777 + 'phabricator-diff-changeset' => '7ccc4153', 778 + 'phabricator-diff-changeset-list' => '2e636e0a', 779 779 'phabricator-diff-inline' => 'a4a14a94', 780 780 'phabricator-drag-and-drop-file-upload' => '4370900d', 781 781 'phabricator-draggable-list' => '0169e425', ··· 1015 1015 'javelin-workflow', 1016 1016 'phuix-icon-view', 1017 1017 ), 1018 - '0f5c016d' => array( 1019 - 'javelin-install', 1020 - 'phuix-button-view', 1021 - ), 1022 1018 '111bfd2d' => array( 1023 1019 'javelin-install', 1024 1020 ), ··· 1172 1168 'javelin-install', 1173 1169 'javelin-util', 1174 1170 'javelin-stratcom', 1171 + ), 1172 + '2e636e0a' => array( 1173 + 'javelin-install', 1174 + 'phuix-button-view', 1175 1175 ), 1176 1176 '2f1db1ed' => array( 1177 1177 'javelin-util', ··· 1612 1612 'javelin-install', 1613 1613 'javelin-dom', 1614 1614 ), 1615 + '7ccc4153' => array( 1616 + 'javelin-dom', 1617 + 'javelin-util', 1618 + 'javelin-stratcom', 1619 + 'javelin-install', 1620 + 'javelin-workflow', 1621 + 'javelin-router', 1622 + 'javelin-behavior-device', 1623 + 'javelin-vector', 1624 + 'phabricator-diff-inline', 1625 + ), 1615 1626 '80bff3af' => array( 1616 1627 'javelin-install', 1617 1628 'javelin-typeahead-source', ··· 1804 1815 'javelin-stratcom', 1805 1816 'javelin-workflow', 1806 1817 'phabricator-draggable-list', 1807 - ), 1808 - 'a31ffc00' => array( 1809 - 'javelin-dom', 1810 - 'javelin-util', 1811 - 'javelin-stratcom', 1812 - 'javelin-install', 1813 - 'javelin-workflow', 1814 - 'javelin-router', 1815 - 'javelin-behavior-device', 1816 - 'javelin-vector', 1817 - 'phabricator-diff-inline', 1818 1818 ), 1819 1819 'a4356cde' => array( 1820 1820 'javelin-install',
+59
src/applications/differential/view/DifferentialChangesetDetailView.php
··· 13 13 private $autoload; 14 14 private $loaded; 15 15 private $renderer; 16 + private $repository; 17 + private $diff; 16 18 17 19 public function setAutoload($autoload) { 18 20 $this->autoload = $autoload; ··· 196 198 'path' => $display_filename, 197 199 'icon' => $display_icon, 198 200 'treeNodeID' => 'tree-node-'.$changeset->getAnchorName(), 201 + 202 + 'editorURI' => $this->getEditorURI(), 203 + 'editorConfigureURI' => $this->getEditorConfigureURI(), 199 204 ), 200 205 'class' => $class, 201 206 'id' => $id, ··· 224 229 )); 225 230 } 226 231 232 + public function setRepository(PhabricatorRepository $repository) { 233 + $this->repository = $repository; 234 + return $this; 235 + } 236 + 237 + public function getRepository() { 238 + return $this->repository; 239 + } 240 + 241 + public function getChangeset() { 242 + return $this->changeset; 243 + } 244 + 245 + public function setDiff(DifferentialDiff $diff) { 246 + $this->diff = $diff; 247 + return $this; 248 + } 249 + 250 + public function getDiff() { 251 + return $this->diff; 252 + } 253 + 254 + private function getEditorURI() { 255 + $viewer = $this->getViewer(); 256 + 257 + if (!$viewer->isLoggedIn()) { 258 + return null; 259 + } 260 + 261 + $repository = $this->getRepository(); 262 + if (!$repository) { 263 + return null; 264 + } 265 + 266 + $changeset = $this->getChangeset(); 267 + $diff = $this->getDiff(); 268 + 269 + $path = $changeset->getAbsoluteRepositoryPath($repository, $diff); 270 + $path = ltrim($path, '/'); 271 + 272 + $line = idx($changeset->getMetadata(), 'line:first', 1); 273 + 274 + return $viewer->loadEditorLink($path, $line, $repository); 275 + } 276 + 277 + private function getEditorConfigureURI() { 278 + $viewer = $this->getViewer(); 279 + 280 + if (!$viewer->isLoggedIn()) { 281 + return null; 282 + } 283 + 284 + return '/settings/panel/display/'; 285 + } 227 286 228 287 }
+28 -13
src/applications/differential/view/DifferentialChangesetListView.php
··· 79 79 return $this; 80 80 } 81 81 82 + public function getRepository() { 83 + return $this->repository; 84 + } 85 + 82 86 public function setDiff(DifferentialDiff $diff) { 83 87 $this->diff = $diff; 84 88 return $this; 89 + } 90 + 91 + public function getDiff() { 92 + return $this->diff; 85 93 } 86 94 87 95 public function setRenderingReferences(array $references) { ··· 148 156 $renderer = DifferentialChangesetParser::getDefaultRendererForViewer( 149 157 $viewer); 150 158 159 + $repository = $this->getRepository(); 160 + $diff = $this->getDiff(); 161 + 151 162 $output = array(); 152 163 $ids = array(); 153 164 foreach ($changesets as $key => $changeset) { ··· 157 168 158 169 $detail = id(new DifferentialChangesetDetailView()) 159 170 ->setUser($viewer); 171 + 172 + if ($repository) { 173 + $detail->setRepository($repository); 174 + } 175 + 176 + if ($diff) { 177 + $detail->setDiff($diff); 178 + } 160 179 161 180 $uniq_id = 'diff-'.$changeset->getAnchorName(); 162 181 $detail->setID($uniq_id); ··· 310 329 311 330 'Finish editing inline comments before changing display modes.' => 312 331 pht('Finish editing inline comments before changing display modes.'), 332 + 333 + 'Open file in external editor.' => 334 + pht('Open file in external editor.'), 335 + 336 + 'You must select a file to edit.' => 337 + pht('You must select a file to edit.'), 338 + 339 + 'No external editor is configured.' => 340 + pht('No external editor is configured.'), 313 341 ), 314 342 )); 315 343 ··· 385 413 $uri = new PhutilURI($this->rightRawFileURI); 386 414 $uri = $this->appendDefaultQueryParams($uri, $qparams); 387 415 $meta['rightURI'] = (string)$uri; 388 - } 389 - } 390 - 391 - if ($viewer && $repository) { 392 - $path = ltrim( 393 - $changeset->getAbsoluteRepositoryPath($repository, $this->diff), 394 - '/'); 395 - $line = idx($changeset->getMetadata(), 'line:first', 1); 396 - $editor_link = $viewer->loadEditorLink($path, $line, $repository); 397 - if ($editor_link) { 398 - $meta['editor'] = $editor_link; 399 - } else { 400 - $meta['editorConfigure'] = '/settings/panel/display/'; 401 416 } 402 417 } 403 418
+14
webroot/rsrc/js/application/diff/DiffChangeset.js
··· 35 35 this._displayPath = JX.$H(data.displayPath); 36 36 this._icon = data.icon; 37 37 38 + this._editorURI = data.editorURI; 39 + this._editorConfigureURI = data.editorConfigureURI; 40 + 38 41 this._inlines = []; 39 42 }, 40 43 ··· 64 67 _changesetList: null, 65 68 _icon: null, 66 69 _treeNodeID: null, 70 + 71 + _editorURI: null, 72 + _editorConfigureURI: null, 73 + 74 + getEditorURI: function() { 75 + return this._editorURI; 76 + }, 77 + 78 + getEditorConfigureURI: function() { 79 + return this._editorConfigureURI; 80 + }, 67 81 68 82 getLeftChangesetID: function() { 69 83 return this._leftID;
+36 -2
webroot/rsrc/js/application/diff/DiffChangesetList.js
··· 211 211 label = pht('Hide or show all inline comments.'); 212 212 this._installKey('A', label, this._onkeyhideall); 213 213 214 + label = pht('Open file in external editor.'); 215 + this._installKey('\\', label, this._onkeyopeneditor); 216 + 214 217 }, 215 218 216 219 isAsleep: function() { ··· 448 451 449 452 var pht = this.getTranslations(); 450 453 this._warnUser(pht('You must select a file to hide or show.')); 454 + }, 455 + 456 + _onkeyopeneditor: function() { 457 + var pht = this.getTranslations(); 458 + var cursor = this._cursorItem; 459 + 460 + if (cursor) { 461 + if (cursor.type == 'file') { 462 + var changeset = cursor.changeset; 463 + var editor_uri = changeset.getEditorURI(); 464 + 465 + if (editor_uri === null) { 466 + this._warnUser(pht('No external editor is configured.')); 467 + return; 468 + } 469 + 470 + JX.$U(editor_uri).go(); 471 + 472 + return; 473 + } 474 + } 475 + 476 + this._warnUser(pht('You must select a file to edit.')); 451 477 }, 452 478 453 479 _onkeycollapse: function() { ··· 849 875 850 876 add_link('fa-arrow-left', pht('Show Raw File (Left)'), data.leftURI); 851 877 add_link('fa-arrow-right', pht('Show Raw File (Right)'), data.rightURI); 852 - add_link('fa-pencil', pht('Open in Editor'), data.editor, true); 853 - add_link('fa-wrench', pht('Configure Editor'), data.editorConfigure); 878 + 879 + var editor_uri = changeset.getEditorURI(); 880 + if (editor_uri !== null) { 881 + add_link('fa-pencil', pht('Open in Editor'), editor_uri, true); 882 + } else { 883 + var configure_uri = changeset.getEditorConfigureURI(); 884 + if (configure_uri !== null) { 885 + add_link('fa-wrench', pht('Configure Editor'), configure_uri); 886 + } 887 + } 854 888 855 889 menu.setContent(list.getNode()); 856 890