Page MenuHomePhabricator

D19414.diff
No OneTemporary

D19414.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -388,7 +388,7 @@
'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'f01586dc',
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '1db13e70',
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef',
- 'rsrc/js/application/files/behavior-document-engine.js' => 'ee0deff8',
+ 'rsrc/js/application/files/behavior-document-engine.js' => '3935d8c4',
'rsrc/js/application/files/behavior-icon-composer.js' => '8499b6ab',
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
'rsrc/js/application/harbormaster/behavior-harbormaster-log.js' => '549459b8',
@@ -600,7 +600,7 @@
'javelin-behavior-diffusion-commit-graph' => '75b83cbb',
'javelin-behavior-diffusion-locate-file' => '6d3e1947',
'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc',
- 'javelin-behavior-document-engine' => 'ee0deff8',
+ 'javelin-behavior-document-engine' => '3935d8c4',
'javelin-behavior-doorkeeper-tag' => '1db13e70',
'javelin-behavior-drydock-live-operation-status' => '901935ef',
'javelin-behavior-durable-column' => '2ae077e1',
@@ -1080,6 +1080,11 @@
'javelin-dom',
'javelin-vector',
),
+ '3935d8c4' => array(
+ 'javelin-behavior',
+ 'javelin-dom',
+ 'javelin-stratcom',
+ ),
'3ab51e2c' => array(
'javelin-behavior',
'javelin-behavior-device',
@@ -2105,11 +2110,6 @@
'javelin-behavior',
'javelin-uri',
),
- 'ee0deff8' => array(
- 'javelin-behavior',
- 'javelin-dom',
- 'javelin-stratcom',
- ),
'efe49472' => array(
'javelin-install',
'javelin-util',
diff --git a/src/applications/diffusion/document/DiffusionDocumentRenderingEngine.php b/src/applications/diffusion/document/DiffusionDocumentRenderingEngine.php
--- a/src/applications/diffusion/document/DiffusionDocumentRenderingEngine.php
+++ b/src/applications/diffusion/document/DiffusionDocumentRenderingEngine.php
@@ -69,7 +69,7 @@
return;
}
- protected function willRenderRef(PhabricatorDocumentRef $ref) {
+ protected function willStageRef(PhabricatorDocumentRef $ref) {
$drequest = $this->getDiffusionRequest();
$blame_uri = (string)$drequest->generateURI(
@@ -78,9 +78,13 @@
'stable' => true,
));
- $ref
- ->setSymbolMetadata($this->getSymbolMetadata())
- ->setBlameURI($blame_uri);
+ $ref->setBlameURI($blame_uri);
+ }
+
+ protected function willRenderRef(PhabricatorDocumentRef $ref) {
+ $drequest = $this->getDiffusionRequest();
+
+ $ref->setSymbolMetadata($this->getSymbolMetadata());
$coverage = $drequest->loadCoverage();
if (strlen($coverage)) {
diff --git a/src/applications/files/document/PhabricatorDocumentEngine.php b/src/applications/files/document/PhabricatorDocumentEngine.php
--- a/src/applications/files/document/PhabricatorDocumentEngine.php
+++ b/src/applications/files/document/PhabricatorDocumentEngine.php
@@ -7,6 +7,7 @@
private $highlightedLines = array();
private $encodingConfiguration;
private $highlightingConfiguration;
+ private $blameConfiguration = true;
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
@@ -60,6 +61,19 @@
return $this->highlightingConfiguration;
}
+ final public function setBlameConfiguration($blame_configuration) {
+ $this->blameConfiguration = $blame_configuration;
+ return $this;
+ }
+
+ final public function getBlameConfiguration() {
+ return $this->blameConfiguration;
+ }
+
+ final protected function getBlameEnabled() {
+ return $this->blameConfiguration;
+ }
+
public function shouldRenderAsync(PhabricatorDocumentRef $ref) {
return false;
}
diff --git a/src/applications/files/document/PhabricatorSourceDocumentEngine.php b/src/applications/files/document/PhabricatorSourceDocumentEngine.php
--- a/src/applications/files/document/PhabricatorSourceDocumentEngine.php
+++ b/src/applications/files/document/PhabricatorSourceDocumentEngine.php
@@ -50,7 +50,7 @@
}
$options = array();
- if ($ref->getBlameURI()) {
+ if ($ref->getBlameURI() && $this->getBlameEnabled()) {
$content = phutil_split_lines($content);
$blame = range(1, count($content));
$blame = array_fuse($blame);
diff --git a/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php b/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
--- a/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
+++ b/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
@@ -69,6 +69,9 @@
$engine->setHighlightingConfiguration($highlight_setting);
}
+ $blame_setting = ($request->getStr('blame') !== 'off');
+ $engine->setBlameConfiguration($blame_setting);
+
$views = array();
foreach ($engines as $candidate_key => $candidate_engine) {
$label = $candidate_engine->getViewAsLabel($ref);
@@ -104,6 +107,8 @@
'controlID' => $control_id,
);
+ $this->willStageRef($ref);
+
if ($engine->shouldRenderAsync($ref)) {
$content = $engine->newLoadingContent($ref);
$config['next'] = 'render';
@@ -142,7 +147,11 @@
'value' => $highlight_setting,
),
'blame' => array(
+ 'icon' => 'fa-backward',
+ 'hide' => pht('Hide Blame'),
+ 'show' => pht('Show Blame'),
'uri' => $ref->getBlameURI(),
+ 'enabled' => $blame_setting,
'value' => null,
),
'coverage' => array(
@@ -180,6 +189,7 @@
}
final public function newRenderResponse(PhabricatorDocumentRef $ref) {
+ $this->willStageRef($ref);
$this->willRenderRef($ref);
$request = $this->getRequest();
@@ -207,6 +217,9 @@
$engine->setHighlightingConfiguration($highlight_setting);
}
+ $blame_setting = ($request->getStr('blame') !== 'off');
+ $engine->setBlameConfiguration($blame_setting);
+
try {
$content = $engine->newDocument($ref);
} catch (Exception $ex) {
@@ -314,6 +327,10 @@
return;
}
+ protected function willStageRef(PhabricatorDocumentRef $ref) {
+ return;
+ }
+
protected function willRenderRef(PhabricatorDocumentRef $ref) {
return;
}
diff --git a/webroot/rsrc/js/application/files/behavior-document-engine.js b/webroot/rsrc/js/application/files/behavior-document-engine.js
--- a/webroot/rsrc/js/application/files/behavior-document-engine.js
+++ b/webroot/rsrc/js/application/files/behavior-document-engine.js
@@ -105,6 +105,29 @@
list.addItem(highlight_item);
+ var blame_item;
+ if (data.blame.uri) {
+ blame_item = new JX.PHUIXActionView()
+ .setIcon(data.blame.icon);
+
+ var onblame = JX.bind(null, function(data, e) {
+ e.prevent();
+
+ if (blame_item.getDisabled()) {
+ return;
+ }
+
+ data.blame.enabled = !data.blame.enabled;
+ onview(data);
+
+ menu.close();
+ }, data);
+
+ blame_item.setHandler(onblame);
+
+ list.addItem(blame_item);
+ }
+
menu.setContent(list.getNode());
menu.listen('open', function() {
@@ -118,8 +141,22 @@
if (is_selected) {
encode_item.setDisabled(!engine.spec.canEncode);
highlight_item.setDisabled(!engine.spec.canHighlight);
+ if (blame_item) {
+ blame_item.setDisabled(!engine.spec.canBlame);
+ }
}
}
+
+ if (blame_item) {
+ var blame_label;
+ if (data.blame.enabled) {
+ blame_label = data.blame.hide;
+ } else {
+ blame_label = data.blame.show;
+ }
+
+ blame_item.setName(blame_label);
+ }
});
data.menu = menu;
@@ -137,6 +174,12 @@
uri.setQueryParam('encode', data.encode.value);
}
+ if (data.blame.enabled) {
+ uri.setQueryParam('blame', null);
+ } else {
+ uri.setQueryParam('blame', 'off');
+ }
+
return uri.toString();
}
@@ -211,7 +254,7 @@
JX.DOM.setContent(viewport, JX.$H(r.markup));
// If this engine supports rendering blame, populate or draw it.
- if (spec.canBlame) {
+ if (spec.canBlame && data.blame.enabled) {
blame(data);
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 10:06 PM (18 h, 12 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6776124
Default Alt Text
D19414.diff (8 KB)

Event Timeline