@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.

Make "View as Document Type..." only show valid options

Summary:
Ref T13513. Currently, "View as Document Type..." lists every available engine.

This is hard to get completely right because we can't always rebuild the document ref accurately in the endpoint, but try harder to fake something reasonable.

Test Plan: Used "View as Document Type..." on Jupyter notebooks, was given "Jupyter" and "Source" as options.

Maniphest Tasks: T13513

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

+66 -27
+23 -23
resources/celerity/map.php
··· 13 13 'core.pkg.js' => '1e667bcb', 14 14 'dark-console.pkg.js' => '187792c2', 15 15 'differential.pkg.css' => 'd71d4531', 16 - 'differential.pkg.js' => '5ec354a0', 16 + 'differential.pkg.js' => '39781f05', 17 17 'diffusion.pkg.css' => '42c75c37', 18 18 'diffusion.pkg.js' => 'a98c0bf7', 19 19 'maniphest.pkg.css' => '35995d6d', ··· 379 379 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'a2ab19be', 380 380 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9', 381 381 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 382 - 'rsrc/js/application/diff/DiffChangeset.js' => '10ddd7e0', 383 - 'rsrc/js/application/diff/DiffChangesetList.js' => '303efc90', 382 + 'rsrc/js/application/diff/DiffChangeset.js' => '20715b98', 383 + 'rsrc/js/application/diff/DiffChangesetList.js' => '564cbd20', 384 384 'rsrc/js/application/diff/DiffInline.js' => 'a0ef0b54', 385 385 'rsrc/js/application/diff/DiffPathView.js' => '8207abf9', 386 386 'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b', ··· 774 774 'phabricator-darklog' => '3b869402', 775 775 'phabricator-darkmessage' => '26cd4b73', 776 776 'phabricator-dashboard-css' => '5a205b9d', 777 - 'phabricator-diff-changeset' => '10ddd7e0', 778 - 'phabricator-diff-changeset-list' => '303efc90', 777 + 'phabricator-diff-changeset' => '20715b98', 778 + 'phabricator-diff-changeset-list' => '564cbd20', 779 779 'phabricator-diff-inline' => 'a0ef0b54', 780 780 'phabricator-diff-path-view' => '8207abf9', 781 781 'phabricator-diff-tree-view' => '5d83623b', ··· 1019 1019 'phuix-action-view', 1020 1020 'javelin-workflow', 1021 1021 'phuix-icon-view', 1022 - ), 1023 - '10ddd7e0' => array( 1024 - 'javelin-dom', 1025 - 'javelin-util', 1026 - 'javelin-stratcom', 1027 - 'javelin-install', 1028 - 'javelin-workflow', 1029 - 'javelin-router', 1030 - 'javelin-behavior-device', 1031 - 'javelin-vector', 1032 - 'phabricator-diff-inline', 1033 - 'phabricator-diff-path-view', 1034 - 'phuix-button-view', 1035 1022 ), 1036 1023 '111bfd2d' => array( 1037 1024 'javelin-install', ··· 1095 1082 'javelin-behavior', 1096 1083 'javelin-request', 1097 1084 ), 1085 + '20715b98' => array( 1086 + 'javelin-dom', 1087 + 'javelin-util', 1088 + 'javelin-stratcom', 1089 + 'javelin-install', 1090 + 'javelin-workflow', 1091 + 'javelin-router', 1092 + 'javelin-behavior-device', 1093 + 'javelin-vector', 1094 + 'phabricator-diff-inline', 1095 + 'phabricator-diff-path-view', 1096 + 'phuix-button-view', 1097 + ), 1098 1098 '220b85f9' => array( 1099 1099 'syntax-default-css', 1100 1100 ), ··· 1187 1187 'javelin-dom', 1188 1188 'phuix-icon-view', 1189 1189 'phabricator-prefab', 1190 - ), 1191 - '303efc90' => array( 1192 - 'javelin-install', 1193 - 'phuix-button-view', 1194 - 'phabricator-diff-tree-view', 1195 1190 ), 1196 1191 '308f9fe4' => array( 1197 1192 'javelin-install', ··· 1422 1417 'javelin-behavior', 1423 1418 'javelin-stratcom', 1424 1419 'javelin-dom', 1420 + ), 1421 + '564cbd20' => array( 1422 + 'javelin-install', 1423 + 'phuix-button-view', 1424 + 'phabricator-diff-tree-view', 1425 1425 ), 1426 1426 '5793d835' => array( 1427 1427 'javelin-install',
+22
src/applications/differential/parser/DifferentialChangesetParser.php
··· 59 59 private $viewer; 60 60 61 61 private $viewState; 62 + private $availableDocumentEngines; 62 63 63 64 public function setRange($start, $end) { 64 65 $this->rangeStart = $start; ··· 1773 1774 } 1774 1775 } 1775 1776 1777 + $this->availableDocumentEngines = $shared_engines; 1778 + 1776 1779 $viewstate = $this->getViewState(); 1777 1780 1778 1781 $engine_key = $viewstate->getDocumentEngineKey(); ··· 1878 1881 $document_engine_key = null; 1879 1882 } 1880 1883 1884 + $available_keys = array(); 1885 + $engines = $this->availableDocumentEngines; 1886 + if (!$engines) { 1887 + $engines = array(); 1888 + } 1889 + 1890 + $available_keys = mpull($engines, 'getDocumentEngineKey'); 1891 + 1892 + // TODO: Always include "source" as a usable engine to default to 1893 + // the buitin rendering. This is kind of a hack and does not actually 1894 + // use the source engine. The source engine isn't a diff engine, so 1895 + // selecting it causes us to fall through and render with builtin 1896 + // behavior. For now, overall behavir is reasonable. 1897 + 1898 + $available_keys[] = PhabricatorSourceDocumentEngine::ENGINEKEY; 1899 + $available_keys = array_fuse($available_keys); 1900 + $available_keys = array_values($available_keys); 1901 + 1881 1902 $state = array( 1882 1903 'undoTemplates' => $undo_templates, 1883 1904 'rendererKey' => $renderer_key, ··· 1885 1906 'characterEncoding' => $viewstate->getCharacterEncoding(), 1886 1907 'requestDocumentEngineKey' => $viewstate->getDocumentEngineKey(), 1887 1908 'responseDocumentEngineKey' => $document_engine_key, 1909 + 'availableDocumentEngineKeys' => $available_keys, 1888 1910 'isHidden' => $viewstate->getHidden(), 1889 1911 ); 1890 1912
+11 -4
src/applications/system/controller/PhabricatorSystemSelectViewAsController.php
··· 18 18 19 19 $engines = PhabricatorDocumentEngine::getAllEngines(); 20 20 21 + $options = $request->getStrList('options'); 22 + $options = array_fuse($options); 21 23 22 - // TODO: This controller isn't very good because the valid options depend 23 - // on the file being rendered and most of them can't even diff anything, 24 - // and this ref is completely bogus. 24 + // TODO: This controller is a bit rough because it isn't really using the 25 + // file ref to figure out which engines should work. See also T13513. 26 + // Callers can pass a list of "options" to control which options are 27 + // presented, at least. 25 28 26 - // For now, we just show everything. 27 29 $ref = new PhabricatorDocumentRef(); 28 30 29 31 $map = array(); 30 32 foreach ($engines as $engine) { 31 33 $key = $engine->getDocumentEngineKey(); 34 + 35 + if ($options && !isset($options[$key])) { 36 + continue; 37 + } 38 + 32 39 $label = $engine->getViewAsLabel($ref); 33 40 34 41 if (!strlen($label)) {
+6
webroot/rsrc/js/application/diff/DiffChangeset.js
··· 66 66 _highlight: null, 67 67 _requestDocumentEngineKey: null, 68 68 _responseDocumentEngineKey: null, 69 + _availableDocumentEngineKeys: null, 69 70 _characterEncoding: null, 70 71 _undoTemplates: null, 71 72 ··· 420 421 return this._responseDocumentEngineKey; 421 422 }, 422 423 424 + getAvailableDocumentEngineKeys: function() { 425 + return this._availableDocumentEngineKeys; 426 + }, 427 + 423 428 getSelectableItems: function() { 424 429 var items = []; 425 430 ··· 672 677 this._characterEncoding = state.characterEncoding; 673 678 this._requestDocumentEngineKey = state.requestDocumentEngineKey; 674 679 this._responseDocumentEngineKey = state.responseDocumentEngineKey; 680 + this._availableDocumentEngineKeys = state.availableDocumentEngineKeys; 675 681 this._isHidden = state.isHidden; 676 682 677 683 var is_hidden = !this.isVisible();
+4
webroot/rsrc/js/application/diff/DiffChangesetList.js
··· 944 944 .setIcon('fa-file-image-o') 945 945 .setName(pht('View As Document Type...')) 946 946 .setHandler(function(e) { 947 + var options = changeset.getAvailableDocumentEngineKeys() || []; 948 + options = options.join(','); 949 + 947 950 var params = { 948 951 engine: changeset.getResponseDocumentEngineKey(), 952 + options: options 949 953 }; 950 954 951 955 new JX.Workflow('/services/viewas/', params)