Page MenuHomePhabricator

D20832.diff
No OneTemporary

D20832.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -12,7 +12,7 @@
'core.pkg.css' => 'c69171e6',
'core.pkg.js' => '6e5c894f',
'differential.pkg.css' => 'eef74643',
- 'differential.pkg.js' => '0b037a4f',
+ 'differential.pkg.js' => '49515551',
'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7',
'maniphest.pkg.css' => '35995d6d',
@@ -376,8 +376,8 @@
'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'a2ab19be',
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
- 'rsrc/js/application/diff/DiffChangeset.js' => 'd0a85a85',
- 'rsrc/js/application/diff/DiffChangesetList.js' => '04023d82',
+ 'rsrc/js/application/diff/DiffChangeset.js' => 'a31ffc00',
+ 'rsrc/js/application/diff/DiffChangesetList.js' => '40850e53',
'rsrc/js/application/diff/DiffInline.js' => 'a4a14a94',
'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17',
'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd',
@@ -773,8 +773,8 @@
'phabricator-darklog' => '3b869402',
'phabricator-darkmessage' => '26cd4b73',
'phabricator-dashboard-css' => '5a205b9d',
- 'phabricator-diff-changeset' => 'd0a85a85',
- 'phabricator-diff-changeset-list' => '04023d82',
+ 'phabricator-diff-changeset' => 'a31ffc00',
+ 'phabricator-diff-changeset-list' => '40850e53',
'phabricator-diff-inline' => 'a4a14a94',
'phabricator-drag-and-drop-file-upload' => '4370900d',
'phabricator-draggable-list' => 'c9ad6f70',
@@ -944,10 +944,6 @@
'03e8891f' => array(
'javelin-install',
),
- '04023d82' => array(
- 'javelin-install',
- 'phuix-button-view',
- ),
'04f8a1e3' => array(
'javelin-behavior',
'javelin-stratcom',
@@ -1263,6 +1259,10 @@
'javelin-behavior',
'javelin-uri',
),
+ '40850e53' => array(
+ 'javelin-install',
+ 'phuix-button-view',
+ ),
'4234f572' => array(
'syntax-default-css',
),
@@ -1788,6 +1788,17 @@
'javelin-workflow',
'phabricator-draggable-list',
),
+ 'a31ffc00' => array(
+ 'javelin-dom',
+ 'javelin-util',
+ 'javelin-stratcom',
+ 'javelin-install',
+ 'javelin-workflow',
+ 'javelin-router',
+ 'javelin-behavior-device',
+ 'javelin-vector',
+ 'phabricator-diff-inline',
+ ),
'a4356cde' => array(
'javelin-install',
'javelin-dom',
@@ -2034,17 +2045,6 @@
'javelin-dom',
'javelin-stratcom',
),
- 'd0a85a85' => array(
- 'javelin-dom',
- 'javelin-util',
- 'javelin-stratcom',
- 'javelin-install',
- 'javelin-workflow',
- 'javelin-router',
- 'javelin-behavior-device',
- 'javelin-vector',
- 'phabricator-diff-inline',
- ),
'd12d214f' => array(
'javelin-install',
'javelin-dom',
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4876,6 +4876,7 @@
'PhabricatorSystemRemoveWorkflow' => 'applications/system/management/PhabricatorSystemRemoveWorkflow.php',
'PhabricatorSystemSelectEncodingController' => 'applications/system/controller/PhabricatorSystemSelectEncodingController.php',
'PhabricatorSystemSelectHighlightController' => 'applications/system/controller/PhabricatorSystemSelectHighlightController.php',
+ 'PhabricatorSystemSelectViewAsController' => 'applications/system/controller/PhabricatorSystemSelectViewAsController.php',
'PhabricatorTOTPAuthFactor' => 'applications/auth/factor/PhabricatorTOTPAuthFactor.php',
'PhabricatorTOTPAuthFactorTestCase' => 'applications/auth/factor/__tests__/PhabricatorTOTPAuthFactorTestCase.php',
'PhabricatorTaskmasterDaemon' => 'infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php',
@@ -11503,6 +11504,7 @@
'PhabricatorSystemRemoveWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorSystemSelectEncodingController' => 'PhabricatorController',
'PhabricatorSystemSelectHighlightController' => 'PhabricatorController',
+ 'PhabricatorSystemSelectViewAsController' => 'PhabricatorController',
'PhabricatorTOTPAuthFactor' => 'PhabricatorAuthFactor',
'PhabricatorTOTPAuthFactorTestCase' => 'PhabricatorTestCase',
'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon',
diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php
--- a/src/applications/differential/parser/DifferentialChangesetParser.php
+++ b/src/applications/differential/parser/DifferentialChangesetParser.php
@@ -59,6 +59,7 @@
private $highlightEngine;
private $viewer;
+ private $documentEngineKey;
public function setRange($start, $end) {
$this->rangeStart = $start;
@@ -159,6 +160,15 @@
return $this->viewer;
}
+ public function setDocumentEngineKey($document_engine_key) {
+ $this->documentEngineKey = $document_engine_key;
+ return $this;
+ }
+
+ public function getDocumentEngineKey() {
+ return $this->documentEngineKey;
+ }
+
public static function getDefaultRendererForViewer(PhabricatorUser $viewer) {
$is_unified = $viewer->compareUserSetting(
PhabricatorUnifiedDiffsSetting::SETTINGKEY,
@@ -174,6 +184,7 @@
public function readParametersFromRequest(AphrontRequest $request) {
$this->setCharacterEncoding($request->getStr('encoding'));
$this->setHighlightAs($request->getStr('highlight'));
+ $this->setDocumentEngineKey($request->getStr('engine'));
$renderer = null;
@@ -1695,14 +1706,22 @@
$shared_engines = array_intersect_key($old_engines, $new_engines);
- $document_engine = null;
- foreach ($shared_engines as $shared_engine) {
- if ($shared_engine->canDiffDocuments($old_ref, $new_ref)) {
- $document_engine = $shared_engine;
- break;
+ foreach ($shared_engines as $key => $shared_engine) {
+ if (!$shared_engine->canDiffDocuments($old_ref, $new_ref)) {
+ unset($shared_engines[$key]);
}
}
+ $engine_key = $this->getDocumentEngineKey();
+ if (strlen($engine_key)) {
+ if (isset($shared_engines[$engine_key])) {
+ $document_engine = $shared_engines[$engine_key];
+ } else {
+ $document_engine = null;
+ }
+ } else {
+ $document_engine = head($shared_engines);
+ }
if ($document_engine) {
return $document_engine->newDiffView(
diff --git a/src/applications/differential/view/DifferentialChangesetListView.php b/src/applications/differential/view/DifferentialChangesetListView.php
--- a/src/applications/differential/view/DifferentialChangesetListView.php
+++ b/src/applications/differential/view/DifferentialChangesetListView.php
@@ -240,6 +240,7 @@
'View Unified' => pht('View Unified'),
'Change Text Encoding...' => pht('Change Text Encoding...'),
'Highlight As...' => pht('Highlight As...'),
+ 'View As...' => pht('View As...'),
'Loading...' => pht('Loading...'),
diff --git a/src/applications/system/application/PhabricatorSystemApplication.php b/src/applications/system/application/PhabricatorSystemApplication.php
--- a/src/applications/system/application/PhabricatorSystemApplication.php
+++ b/src/applications/system/application/PhabricatorSystemApplication.php
@@ -22,6 +22,7 @@
'/services/' => array(
'encoding/' => 'PhabricatorSystemSelectEncodingController',
'highlight/' => 'PhabricatorSystemSelectHighlightController',
+ 'viewas/' => 'PhabricatorSystemSelectViewAsController',
),
'/readonly/' => array(
'(?P<reason>[^/]+)/' => 'PhabricatorSystemReadOnlyController',
diff --git a/src/applications/system/controller/PhabricatorSystemSelectViewAsController.php b/src/applications/system/controller/PhabricatorSystemSelectViewAsController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/system/controller/PhabricatorSystemSelectViewAsController.php
@@ -0,0 +1,63 @@
+<?php
+
+final class PhabricatorSystemSelectViewAsController
+ extends PhabricatorController {
+
+ public function shouldRequireLogin() {
+ return false;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $this->getViewer();
+ $v_engine = $request->getStr('engine');
+
+ if ($request->isFormPost()) {
+ $result = array('engine' => $v_engine);
+ return id(new AphrontAjaxResponse())->setContent($result);
+ }
+
+ $engines = PhabricatorDocumentEngine::getAllEngines();
+
+
+ // TODO: This controller isn't very good because the valid options depend
+ // on the file being rendered and most of them can't even diff anything,
+ // and this ref is completely bogus.
+
+ // For now, we just show everything.
+ $ref = new PhabricatorDocumentRef();
+
+ $map = array();
+ foreach ($engines as $engine) {
+ $key = $engine->getDocumentEngineKey();
+ $label = $engine->getViewAsLabel($ref);
+
+ if (!strlen($label)) {
+ continue;
+ }
+
+ $map[$key] = $label;
+ }
+
+ asort($map);
+
+ $map = array(
+ '' => pht('(Use Default)'),
+ ) + $map;
+
+ $form = id(new AphrontFormView())
+ ->setViewer($viewer)
+ ->appendRemarkupInstructions(pht('Choose a document engine to use.'))
+ ->appendChild(
+ id(new AphrontFormSelectControl())
+ ->setLabel(pht('View As'))
+ ->setName('engine')
+ ->setValue($v_engine)
+ ->setOptions($map));
+
+ return $this->newDialog()
+ ->setTitle(pht('Select Document Engine'))
+ ->appendForm($form)
+ ->addSubmitButton(pht('Choose Engine'))
+ ->addCancelButton('/');
+ }
+}
diff --git a/webroot/rsrc/js/application/diff/DiffChangeset.js b/webroot/rsrc/js/application/diff/DiffChangeset.js
--- a/webroot/rsrc/js/application/diff/DiffChangeset.js
+++ b/webroot/rsrc/js/application/diff/DiffChangeset.js
@@ -24,6 +24,7 @@
this._ref = data.ref;
this._renderer = data.renderer;
this._highlight = data.highlight;
+ this._documentEngine = data.documentEngine;
this._encoding = data.encoding;
this._loaded = data.loaded;
this._treeNodeID = data.treeNodeID;
@@ -47,6 +48,7 @@
_ref: null,
_renderer: null,
_highlight: null,
+ _documentEngine: null,
_encoding: null,
_undoTemplates: null,
@@ -310,6 +312,7 @@
ref: this._ref,
renderer: this.getRenderer() || '',
highlight: this._highlight || '',
+ engine: this._documentEngine || '',
encoding: this._encoding || ''
};
},
@@ -366,6 +369,14 @@
return this._highlight;
},
+ setDocumentEngine: function(engine) {
+ this._documentEngine = engine;
+ },
+
+ getDocumentEngine: function(engine) {
+ return this._documentEngine;
+ },
+
getSelectableItems: function() {
var items = [];
diff --git a/webroot/rsrc/js/application/diff/DiffChangesetList.js b/webroot/rsrc/js/application/diff/DiffChangesetList.js
--- a/webroot/rsrc/js/application/diff/DiffChangesetList.js
+++ b/webroot/rsrc/js/application/diff/DiffChangesetList.js
@@ -827,6 +827,26 @@
});
list.addItem(highlight_item);
+ var engine_item = new JX.PHUIXActionView()
+ .setIcon('fa-file-image-o')
+ .setName(pht('View As...'))
+ .setHandler(function(e) {
+ var params = {
+ engine: changeset.getDocumentEngine(),
+ };
+
+ new JX.Workflow('/services/viewas/', params)
+ .setHandler(function(r) {
+ changeset.setDocumentEngine(r.engine);
+ changeset.reload();
+ })
+ .start();
+
+ e.prevent();
+ menu.close();
+ });
+ list.addItem(engine_item);
+
add_link('fa-arrow-left', pht('Show Raw File (Left)'), data.leftURI);
add_link('fa-arrow-right', pht('Show Raw File (Right)'), data.rightURI);
add_link('fa-pencil', pht('Open in Editor'), data.editor, true);
@@ -860,6 +880,7 @@
encoding_item.setDisabled(!changeset.isLoaded());
highlight_item.setDisabled(!changeset.isLoaded());
+ engine_item.setDisabled(!changeset.isLoaded());
if (changeset.isLoaded()) {
if (changeset.getRenderer() == '2up') {

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 6, 7:38 PM (2 d, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7682993
Default Alt Text
D20832.diff (12 KB)

Event Timeline