Improve minor client behaviors for document rendering
Summary: Ref T13105. This adds various small client-side improvements to document rendering. - In the menu, show which renderer is in use. - Make linking to lines work. - Make URIs persist information about which rendering engine is in use. - Improve the UI feedback for transitions between document types. - Load slower documents asynchronously by default. - Discard irrelevant requests if you spam the view menu. Test Plan: Loaded files, linked to lines, swapped between modes, copy/pasted URLs. Maniphest Tasks: T13105 Differential Revision: https://secure.phabricator.com/D19256
This commit is contained in:
@@ -4,6 +4,7 @@ abstract class PhabricatorDocumentEngine
|
||||
extends Phobject {
|
||||
|
||||
private $viewer;
|
||||
private $highlightedLines = array();
|
||||
|
||||
final public function setViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
@@ -14,10 +15,23 @@ abstract class PhabricatorDocumentEngine
|
||||
return $this->viewer;
|
||||
}
|
||||
|
||||
final public function setHighlightedLines(array $highlighted_lines) {
|
||||
$this->highlightedLines = $highlighted_lines;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getHighlightedLines() {
|
||||
return $this->highlightedLines;
|
||||
}
|
||||
|
||||
final public function canRenderDocument(PhabricatorDocumentRef $ref) {
|
||||
return $this->canRenderDocumentType($ref);
|
||||
}
|
||||
|
||||
public function shouldRenderAsync(PhabricatorDocumentRef $ref) {
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract protected function canRenderDocumentType(
|
||||
PhabricatorDocumentRef $ref);
|
||||
|
||||
@@ -49,6 +63,10 @@ abstract class PhabricatorDocumentEngine
|
||||
return 'fa-file-o';
|
||||
}
|
||||
|
||||
protected function getDocumentRenderingText(PhabricatorDocumentRef $ref) {
|
||||
return pht('Loading...');
|
||||
}
|
||||
|
||||
final public function getDocumentEngineKey() {
|
||||
return $this->getPhobjectClassConstant('ENGINEKEY');
|
||||
}
|
||||
@@ -177,4 +195,20 @@ abstract class PhabricatorDocumentEngine
|
||||
$message);
|
||||
}
|
||||
|
||||
final public function newLoadingContent(PhabricatorDocumentRef $ref) {
|
||||
$spinner = id(new PHUIIconView())
|
||||
->setIcon('fa-gear')
|
||||
->addClass('ph-spin');
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'document-engine-loading',
|
||||
),
|
||||
array(
|
||||
$spinner,
|
||||
$this->getDocumentRenderingText($ref),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user