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

Port Repository "Symbols" to Manage/Panel UI

Summary: Ref T10748. Port this, add EditEngine support, add some type validation to the transaction.

Test Plan:
- Edited via EditEngine.
- Edited via Conduit.
- Viewed via Management UI.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10748

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

+128 -1
+2
src/__phutil_library_map__.php
··· 784 784 'DiffusionRepositoryStatusManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php', 785 785 'DiffusionRepositoryStorageManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php', 786 786 'DiffusionRepositorySymbolsController' => 'applications/diffusion/controller/DiffusionRepositorySymbolsController.php', 787 + 'DiffusionRepositorySymbolsManagementPanel' => 'applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php', 787 788 'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php', 788 789 'DiffusionRepositoryTestAutomationController' => 'applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php', 789 790 'DiffusionRepositoryURIsIndexEngineExtension' => 'applications/diffusion/engineextension/DiffusionRepositoryURIsIndexEngineExtension.php', ··· 5001 5002 'DiffusionRepositoryStatusManagementPanel' => 'DiffusionRepositoryManagementPanel', 5002 5003 'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel', 5003 5004 'DiffusionRepositorySymbolsController' => 'DiffusionRepositoryEditController', 5005 + 'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel', 5004 5006 'DiffusionRepositoryTag' => 'Phobject', 5005 5007 'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController', 5006 5008 'DiffusionRepositoryURIsIndexEngineExtension' => 'PhabricatorIndexEngineExtension',
+24
src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
··· 183 183 ->setConduitDescription(pht('Change automation blueprints.')) 184 184 ->setConduitTypeDescription(pht('New blueprint PHIDs.')) 185 185 ->setValue($object->getAutomationBlueprintPHIDs()), 186 + id(new PhabricatorStringListEditField()) 187 + ->setKey('symbolLanguages') 188 + ->setLabel(pht('Languages')) 189 + ->setTransactionType( 190 + PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE) 191 + ->setIsCopyable(true) 192 + ->setDescription( 193 + pht('Languages which define symbols in this repository.')) 194 + ->setConduitDescription( 195 + pht('Change symbol languages for this repository.')) 196 + ->setConduitTypeDescription( 197 + pht('New symbol langauges.')) 198 + ->setValue($object->getSymbolLanguages()), 199 + id(new PhabricatorDatasourceEditField()) 200 + ->setKey('symbolRepositoryPHIDs') 201 + ->setLabel(pht('Uses Symbols From')) 202 + ->setTransactionType( 203 + PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES) 204 + ->setIsCopyable(true) 205 + ->setDatasource(new DiffusionRepositoryDatasource()) 206 + ->setDescription(pht('Repositories to link symbols from.')) 207 + ->setConduitDescription(pht('Change symbol source repositories.')) 208 + ->setConduitTypeDescription(pht('New symbol repositories.')) 209 + ->setValue($object->getSymbolSources()), 186 210 id(new PhabricatorPolicyEditField()) 187 211 ->setKey('policy.push') 188 212 ->setLabel(pht('Push Policy'))
+1 -1
src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php
··· 10 10 } 11 11 12 12 public function getManagementPanelOrder() { 13 - return 900; 13 + return 2000; 14 14 } 15 15 16 16 public function buildManagementPanelContent() {
+64
src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositorySymbolsManagementPanel 4 + extends DiffusionRepositoryManagementPanel { 5 + 6 + const PANELKEY = 'symbols'; 7 + 8 + public function getManagementPanelLabel() { 9 + return pht('Symbols'); 10 + } 11 + 12 + public function getManagementPanelOrder() { 13 + return 900; 14 + } 15 + 16 + protected function buildManagementPanelActions() { 17 + $repository = $this->getRepository(); 18 + $viewer = $this->getViewer(); 19 + 20 + $can_edit = PhabricatorPolicyFilter::hasCapability( 21 + $viewer, 22 + $repository, 23 + PhabricatorPolicyCapability::CAN_EDIT); 24 + 25 + $symbols_uri = $repository->getPathURI('edit/symbols/'); 26 + 27 + return array( 28 + id(new PhabricatorActionView()) 29 + ->setIcon('fa-pencil') 30 + ->setName(pht('Edit Symbols')) 31 + ->setHref($symbols_uri) 32 + ->setDisabled(!$can_edit) 33 + ->setWorkflow(!$can_edit), 34 + ); 35 + } 36 + 37 + public function buildManagementPanelContent() { 38 + $repository = $this->getRepository(); 39 + $viewer = $this->getViewer(); 40 + 41 + $view = id(new PHUIPropertyListView()) 42 + ->setViewer($viewer) 43 + ->setActionList($this->newActions()); 44 + 45 + $languages = $repository->getSymbolLanguages(); 46 + if ($languages) { 47 + $languages = implode(', ', $languages); 48 + } else { 49 + $languages = phutil_tag('em', array(), pht('Any')); 50 + } 51 + $view->addProperty(pht('Languages'), $languages); 52 + 53 + $sources = $repository->getSymbolSources(); 54 + if ($sources) { 55 + $sources = $viewer->renderHandleList($sources); 56 + } else { 57 + $sources = phutil_tag('em', array(), pht('This Repository Only')); 58 + } 59 + $view->addProperty(pht('Uses Symbols From'), $sources); 60 + 61 + return $this->newBox(pht('Symbols'), $view); 62 + } 63 + 64 + }
+37
src/applications/repository/editor/PhabricatorRepositoryEditor.php
··· 636 636 } 637 637 } 638 638 break; 639 + 640 + case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: 641 + foreach ($xactions as $xaction) { 642 + $old = $object->getSymbolSources(); 643 + $new = $xaction->getNewValue(); 644 + 645 + // If the viewer is adding new repositories, make sure they are 646 + // valid and visible. 647 + $add = array_diff($new, $old); 648 + if (!$add) { 649 + continue; 650 + } 651 + 652 + $repositories = id(new PhabricatorRepositoryQuery()) 653 + ->setViewer($this->getActor()) 654 + ->withPHIDs($add) 655 + ->execute(); 656 + $repositories = mpull($repositories, null, 'getPHID'); 657 + 658 + foreach ($add as $phid) { 659 + if (isset($repositories[$phid])) { 660 + continue; 661 + } 662 + 663 + $errors[] = new PhabricatorApplicationTransactionValidationError( 664 + $type, 665 + pht('Invalid'), 666 + pht( 667 + 'Repository ("%s") does not exist, or you do not have '. 668 + 'permission to see it.', 669 + $phid), 670 + $xaction); 671 + break; 672 + } 673 + } 674 + break; 675 + 639 676 } 640 677 641 678 return $errors;