mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 19:22:42 +01:00
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
This commit is contained in:
parent
dd6e82698a
commit
afc3099ee7
6 changed files with 91 additions and 13 deletions
|
@ -388,7 +388,7 @@ return array(
|
||||||
'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'f01586dc',
|
'rsrc/js/application/diffusion/behavior-pull-lastmodified.js' => 'f01586dc',
|
||||||
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '1db13e70',
|
'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => '1db13e70',
|
||||||
'rsrc/js/application/drydock/drydock-live-operation-status.js' => '901935ef',
|
'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-icon-composer.js' => '8499b6ab',
|
||||||
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
|
'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888',
|
||||||
'rsrc/js/application/harbormaster/behavior-harbormaster-log.js' => '549459b8',
|
'rsrc/js/application/harbormaster/behavior-harbormaster-log.js' => '549459b8',
|
||||||
|
@ -600,7 +600,7 @@ return array(
|
||||||
'javelin-behavior-diffusion-commit-graph' => '75b83cbb',
|
'javelin-behavior-diffusion-commit-graph' => '75b83cbb',
|
||||||
'javelin-behavior-diffusion-locate-file' => '6d3e1947',
|
'javelin-behavior-diffusion-locate-file' => '6d3e1947',
|
||||||
'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc',
|
'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc',
|
||||||
'javelin-behavior-document-engine' => 'ee0deff8',
|
'javelin-behavior-document-engine' => '3935d8c4',
|
||||||
'javelin-behavior-doorkeeper-tag' => '1db13e70',
|
'javelin-behavior-doorkeeper-tag' => '1db13e70',
|
||||||
'javelin-behavior-drydock-live-operation-status' => '901935ef',
|
'javelin-behavior-drydock-live-operation-status' => '901935ef',
|
||||||
'javelin-behavior-durable-column' => '2ae077e1',
|
'javelin-behavior-durable-column' => '2ae077e1',
|
||||||
|
@ -1080,6 +1080,11 @@ return array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'javelin-vector',
|
'javelin-vector',
|
||||||
),
|
),
|
||||||
|
'3935d8c4' => array(
|
||||||
|
'javelin-behavior',
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-stratcom',
|
||||||
|
),
|
||||||
'3ab51e2c' => array(
|
'3ab51e2c' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-behavior-device',
|
'javelin-behavior-device',
|
||||||
|
@ -2105,11 +2110,6 @@ return array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-uri',
|
'javelin-uri',
|
||||||
),
|
),
|
||||||
'ee0deff8' => array(
|
|
||||||
'javelin-behavior',
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-stratcom',
|
|
||||||
),
|
|
||||||
'efe49472' => array(
|
'efe49472' => array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
'javelin-util',
|
'javelin-util',
|
||||||
|
|
|
@ -69,7 +69,7 @@ final class DiffusionDocumentRenderingEngine
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function willRenderRef(PhabricatorDocumentRef $ref) {
|
protected function willStageRef(PhabricatorDocumentRef $ref) {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
|
||||||
$blame_uri = (string)$drequest->generateURI(
|
$blame_uri = (string)$drequest->generateURI(
|
||||||
|
@ -78,9 +78,13 @@ final class DiffusionDocumentRenderingEngine
|
||||||
'stable' => true,
|
'stable' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$ref
|
$ref->setBlameURI($blame_uri);
|
||||||
->setSymbolMetadata($this->getSymbolMetadata())
|
}
|
||||||
->setBlameURI($blame_uri);
|
|
||||||
|
protected function willRenderRef(PhabricatorDocumentRef $ref) {
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
|
||||||
|
$ref->setSymbolMetadata($this->getSymbolMetadata());
|
||||||
|
|
||||||
$coverage = $drequest->loadCoverage();
|
$coverage = $drequest->loadCoverage();
|
||||||
if (strlen($coverage)) {
|
if (strlen($coverage)) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ abstract class PhabricatorDocumentEngine
|
||||||
private $highlightedLines = array();
|
private $highlightedLines = array();
|
||||||
private $encodingConfiguration;
|
private $encodingConfiguration;
|
||||||
private $highlightingConfiguration;
|
private $highlightingConfiguration;
|
||||||
|
private $blameConfiguration = true;
|
||||||
|
|
||||||
final public function setViewer(PhabricatorUser $viewer) {
|
final public function setViewer(PhabricatorUser $viewer) {
|
||||||
$this->viewer = $viewer;
|
$this->viewer = $viewer;
|
||||||
|
@ -60,6 +61,19 @@ abstract class PhabricatorDocumentEngine
|
||||||
return $this->highlightingConfiguration;
|
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) {
|
public function shouldRenderAsync(PhabricatorDocumentRef $ref) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ final class PhabricatorSourceDocumentEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array();
|
$options = array();
|
||||||
if ($ref->getBlameURI()) {
|
if ($ref->getBlameURI() && $this->getBlameEnabled()) {
|
||||||
$content = phutil_split_lines($content);
|
$content = phutil_split_lines($content);
|
||||||
$blame = range(1, count($content));
|
$blame = range(1, count($content));
|
||||||
$blame = array_fuse($blame);
|
$blame = array_fuse($blame);
|
||||||
|
|
|
@ -69,6 +69,9 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||||
$engine->setHighlightingConfiguration($highlight_setting);
|
$engine->setHighlightingConfiguration($highlight_setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$blame_setting = ($request->getStr('blame') !== 'off');
|
||||||
|
$engine->setBlameConfiguration($blame_setting);
|
||||||
|
|
||||||
$views = array();
|
$views = array();
|
||||||
foreach ($engines as $candidate_key => $candidate_engine) {
|
foreach ($engines as $candidate_key => $candidate_engine) {
|
||||||
$label = $candidate_engine->getViewAsLabel($ref);
|
$label = $candidate_engine->getViewAsLabel($ref);
|
||||||
|
@ -104,6 +107,8 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||||
'controlID' => $control_id,
|
'controlID' => $control_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->willStageRef($ref);
|
||||||
|
|
||||||
if ($engine->shouldRenderAsync($ref)) {
|
if ($engine->shouldRenderAsync($ref)) {
|
||||||
$content = $engine->newLoadingContent($ref);
|
$content = $engine->newLoadingContent($ref);
|
||||||
$config['next'] = 'render';
|
$config['next'] = 'render';
|
||||||
|
@ -142,7 +147,11 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||||
'value' => $highlight_setting,
|
'value' => $highlight_setting,
|
||||||
),
|
),
|
||||||
'blame' => array(
|
'blame' => array(
|
||||||
|
'icon' => 'fa-backward',
|
||||||
|
'hide' => pht('Hide Blame'),
|
||||||
|
'show' => pht('Show Blame'),
|
||||||
'uri' => $ref->getBlameURI(),
|
'uri' => $ref->getBlameURI(),
|
||||||
|
'enabled' => $blame_setting,
|
||||||
'value' => null,
|
'value' => null,
|
||||||
),
|
),
|
||||||
'coverage' => array(
|
'coverage' => array(
|
||||||
|
@ -180,6 +189,7 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function newRenderResponse(PhabricatorDocumentRef $ref) {
|
final public function newRenderResponse(PhabricatorDocumentRef $ref) {
|
||||||
|
$this->willStageRef($ref);
|
||||||
$this->willRenderRef($ref);
|
$this->willRenderRef($ref);
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
@ -207,6 +217,9 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||||
$engine->setHighlightingConfiguration($highlight_setting);
|
$engine->setHighlightingConfiguration($highlight_setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$blame_setting = ($request->getStr('blame') !== 'off');
|
||||||
|
$engine->setBlameConfiguration($blame_setting);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$content = $engine->newDocument($ref);
|
$content = $engine->newDocument($ref);
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
@ -314,6 +327,10 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function willStageRef(PhabricatorDocumentRef $ref) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
protected function willRenderRef(PhabricatorDocumentRef $ref) {
|
protected function willRenderRef(PhabricatorDocumentRef $ref) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,29 @@ JX.behavior('document-engine', function(config, statics) {
|
||||||
|
|
||||||
list.addItem(highlight_item);
|
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.setContent(list.getNode());
|
||||||
|
|
||||||
menu.listen('open', function() {
|
menu.listen('open', function() {
|
||||||
|
@ -118,8 +141,22 @@ JX.behavior('document-engine', function(config, statics) {
|
||||||
if (is_selected) {
|
if (is_selected) {
|
||||||
encode_item.setDisabled(!engine.spec.canEncode);
|
encode_item.setDisabled(!engine.spec.canEncode);
|
||||||
highlight_item.setDisabled(!engine.spec.canHighlight);
|
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;
|
data.menu = menu;
|
||||||
|
@ -137,6 +174,12 @@ JX.behavior('document-engine', function(config, statics) {
|
||||||
uri.setQueryParam('encode', data.encode.value);
|
uri.setQueryParam('encode', data.encode.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.blame.enabled) {
|
||||||
|
uri.setQueryParam('blame', null);
|
||||||
|
} else {
|
||||||
|
uri.setQueryParam('blame', 'off');
|
||||||
|
}
|
||||||
|
|
||||||
return uri.toString();
|
return uri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +254,7 @@ JX.behavior('document-engine', function(config, statics) {
|
||||||
JX.DOM.setContent(viewport, JX.$H(r.markup));
|
JX.DOM.setContent(viewport, JX.$H(r.markup));
|
||||||
|
|
||||||
// If this engine supports rendering blame, populate or draw it.
|
// If this engine supports rendering blame, populate or draw it.
|
||||||
if (spec.canBlame) {
|
if (spec.canBlame && data.blame.enabled) {
|
||||||
blame(data);
|
blame(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue