@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 a view option to disable blame in Diffusion and fix some view transition bugs

Summary:
See PHI604. Ref T13130. Ref T13105. There's currently no way to turn blame off in Diffusion. Add a "Hide Blame" option to the "View Options" dropdown so it can be toggled off.

Also fix a couple of bugs around this: for example, if you loaded a Jupyter notebook and then switched to "Source" view, blame would incorrectly fail to activate because the original rendering of the "stage" used an asynchronous engine so `willRenderRef()` wasn't called to populate blame.

Test Plan:
- Viewed a source file, toggled blame off/on, reloaded page to see state stick in URL.
- Viewed a Jupyter notebook, toggled to "Source" view, saw blame.
- Viewed stuff in Files (no blame UI options).
- Tried to do some invalid stuff like toggle blame on a non-blame engine (options disable properly).

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13130, T13105

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

+91 -13
+7 -7
resources/celerity/map.php
··· 388 388 'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'f01586dc', 389 389 'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '1db13e70', 390 390 'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef', 391 - 'rsrc/js/application/files/behavior-document-engine.js' => 'ee0deff8', 391 + 'rsrc/js/application/files/behavior-document-engine.js' => '3935d8c4', 392 392 'rsrc/js/application/files/behavior-icon-composer.js' => '8499b6ab', 393 393 'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888', 394 394 'rsrc/js/application/harbormaster/behavior-harbormaster-log.js' => '549459b8', ··· 600 600 'javelin-behavior-diffusion-commit-graph' => '75b83cbb', 601 601 'javelin-behavior-diffusion-locate-file' => '6d3e1947', 602 602 'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc', 603 - 'javelin-behavior-document-engine' => 'ee0deff8', 603 + 'javelin-behavior-document-engine' => '3935d8c4', 604 604 'javelin-behavior-doorkeeper-tag' => '1db13e70', 605 605 'javelin-behavior-drydock-live-operation-status' => '901935ef', 606 606 'javelin-behavior-durable-column' => '2ae077e1', ··· 1079 1079 'javelin-util', 1080 1080 'javelin-dom', 1081 1081 'javelin-vector', 1082 + ), 1083 + '3935d8c4' => array( 1084 + 'javelin-behavior', 1085 + 'javelin-dom', 1086 + 'javelin-stratcom', 1082 1087 ), 1083 1088 '3ab51e2c' => array( 1084 1089 'javelin-behavior', ··· 2104 2109 'edf8a145' => array( 2105 2110 'javelin-behavior', 2106 2111 'javelin-uri', 2107 - ), 2108 - 'ee0deff8' => array( 2109 - 'javelin-behavior', 2110 - 'javelin-dom', 2111 - 'javelin-stratcom', 2112 2112 ), 2113 2113 'efe49472' => array( 2114 2114 'javelin-install',
+8 -4
src/applications/diffusion/document/DiffusionDocumentRenderingEngine.php
··· 69 69 return; 70 70 } 71 71 72 - protected function willRenderRef(PhabricatorDocumentRef $ref) { 72 + protected function willStageRef(PhabricatorDocumentRef $ref) { 73 73 $drequest = $this->getDiffusionRequest(); 74 74 75 75 $blame_uri = (string)$drequest->generateURI( ··· 78 78 'stable' => true, 79 79 )); 80 80 81 - $ref 82 - ->setSymbolMetadata($this->getSymbolMetadata()) 83 - ->setBlameURI($blame_uri); 81 + $ref->setBlameURI($blame_uri); 82 + } 83 + 84 + protected function willRenderRef(PhabricatorDocumentRef $ref) { 85 + $drequest = $this->getDiffusionRequest(); 86 + 87 + $ref->setSymbolMetadata($this->getSymbolMetadata()); 84 88 85 89 $coverage = $drequest->loadCoverage(); 86 90 if (strlen($coverage)) {
+14
src/applications/files/document/PhabricatorDocumentEngine.php
··· 7 7 private $highlightedLines = array(); 8 8 private $encodingConfiguration; 9 9 private $highlightingConfiguration; 10 + private $blameConfiguration = true; 10 11 11 12 final public function setViewer(PhabricatorUser $viewer) { 12 13 $this->viewer = $viewer; ··· 58 59 59 60 final public function getHighlightingConfiguration() { 60 61 return $this->highlightingConfiguration; 62 + } 63 + 64 + final public function setBlameConfiguration($blame_configuration) { 65 + $this->blameConfiguration = $blame_configuration; 66 + return $this; 67 + } 68 + 69 + final public function getBlameConfiguration() { 70 + return $this->blameConfiguration; 71 + } 72 + 73 + final protected function getBlameEnabled() { 74 + return $this->blameConfiguration; 61 75 } 62 76 63 77 public function shouldRenderAsync(PhabricatorDocumentRef $ref) {
+1 -1
src/applications/files/document/PhabricatorSourceDocumentEngine.php
··· 50 50 } 51 51 52 52 $options = array(); 53 - if ($ref->getBlameURI()) { 53 + if ($ref->getBlameURI() && $this->getBlameEnabled()) { 54 54 $content = phutil_split_lines($content); 55 55 $blame = range(1, count($content)); 56 56 $blame = array_fuse($blame);
+17
src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
··· 69 69 $engine->setHighlightingConfiguration($highlight_setting); 70 70 } 71 71 72 + $blame_setting = ($request->getStr('blame') !== 'off'); 73 + $engine->setBlameConfiguration($blame_setting); 74 + 72 75 $views = array(); 73 76 foreach ($engines as $candidate_key => $candidate_engine) { 74 77 $label = $candidate_engine->getViewAsLabel($ref); ··· 103 106 $config = array( 104 107 'controlID' => $control_id, 105 108 ); 109 + 110 + $this->willStageRef($ref); 106 111 107 112 if ($engine->shouldRenderAsync($ref)) { 108 113 $content = $engine->newLoadingContent($ref); ··· 142 147 'value' => $highlight_setting, 143 148 ), 144 149 'blame' => array( 150 + 'icon' => 'fa-backward', 151 + 'hide' => pht('Hide Blame'), 152 + 'show' => pht('Show Blame'), 145 153 'uri' => $ref->getBlameURI(), 154 + 'enabled' => $blame_setting, 146 155 'value' => null, 147 156 ), 148 157 'coverage' => array( ··· 180 189 } 181 190 182 191 final public function newRenderResponse(PhabricatorDocumentRef $ref) { 192 + $this->willStageRef($ref); 183 193 $this->willRenderRef($ref); 184 194 185 195 $request = $this->getRequest(); ··· 206 216 if (strlen($highlight_setting)) { 207 217 $engine->setHighlightingConfiguration($highlight_setting); 208 218 } 219 + 220 + $blame_setting = ($request->getStr('blame') !== 'off'); 221 + $engine->setBlameConfiguration($blame_setting); 209 222 210 223 try { 211 224 $content = $engine->newDocument($ref); ··· 311 324 protected function addApplicationCrumbs( 312 325 PHUICrumbsView $crumbs, 313 326 PhabricatorDocumentRef $ref = null) { 327 + return; 328 + } 329 + 330 + protected function willStageRef(PhabricatorDocumentRef $ref) { 314 331 return; 315 332 } 316 333
+44 -1
webroot/rsrc/js/application/files/behavior-document-engine.js
··· 105 105 106 106 list.addItem(highlight_item); 107 107 108 + var blame_item; 109 + if (data.blame.uri) { 110 + blame_item = new JX.PHUIXActionView() 111 + .setIcon(data.blame.icon); 112 + 113 + var onblame = JX.bind(null, function(data, e) { 114 + e.prevent(); 115 + 116 + if (blame_item.getDisabled()) { 117 + return; 118 + } 119 + 120 + data.blame.enabled = !data.blame.enabled; 121 + onview(data); 122 + 123 + menu.close(); 124 + }, data); 125 + 126 + blame_item.setHandler(onblame); 127 + 128 + list.addItem(blame_item); 129 + } 130 + 108 131 menu.setContent(list.getNode()); 109 132 110 133 menu.listen('open', function() { ··· 118 141 if (is_selected) { 119 142 encode_item.setDisabled(!engine.spec.canEncode); 120 143 highlight_item.setDisabled(!engine.spec.canHighlight); 144 + if (blame_item) { 145 + blame_item.setDisabled(!engine.spec.canBlame); 146 + } 121 147 } 122 148 } 149 + 150 + if (blame_item) { 151 + var blame_label; 152 + if (data.blame.enabled) { 153 + blame_label = data.blame.hide; 154 + } else { 155 + blame_label = data.blame.show; 156 + } 157 + 158 + blame_item.setName(blame_label); 159 + } 123 160 }); 124 161 125 162 data.menu = menu; ··· 135 172 136 173 if (data.encode.value) { 137 174 uri.setQueryParam('encode', data.encode.value); 175 + } 176 + 177 + if (data.blame.enabled) { 178 + uri.setQueryParam('blame', null); 179 + } else { 180 + uri.setQueryParam('blame', 'off'); 138 181 } 139 182 140 183 return uri.toString(); ··· 211 254 JX.DOM.setContent(viewport, JX.$H(r.markup)); 212 255 213 256 // If this engine supports rendering blame, populate or draw it. 214 - if (spec.canBlame) { 257 + if (spec.canBlame && data.blame.enabled) { 215 258 blame(data); 216 259 } 217 260 }