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

Rough in basics + policies + history repository management panels

Summary:
Ref T10748. This is roughly where I'm headed, if it makes some kind of sense? The "Edit" links in sub-sections don't work yet since I haven't built the thing.

Probably depends on D15736.

Test Plan: Manually navigated to `/manage/`, clicked around.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10748

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

+312 -2
+6
src/__phutil_library_map__.php
··· 739 739 'DiffusionRefTableController' => 'applications/diffusion/controller/DiffusionRefTableController.php', 740 740 'DiffusionRefsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php', 741 741 'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php', 742 + 'DiffusionRepositoryBasicsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php', 742 743 'DiffusionRepositoryByIDRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryByIDRemarkupRule.php', 743 744 'DiffusionRepositoryClusterManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryClusterManagementPanel.php', 744 745 'DiffusionRepositoryController' => 'applications/diffusion/controller/DiffusionRepositoryController.php', ··· 763 764 'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php', 764 765 'DiffusionRepositoryEditUpdateController' => 'applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php', 765 766 'DiffusionRepositoryEditproController' => 'applications/diffusion/controller/DiffusionRepositoryEditproController.php', 767 + 'DiffusionRepositoryHistoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php', 766 768 'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php', 767 769 'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php', 768 770 'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php', 769 771 'DiffusionRepositoryNewController' => 'applications/diffusion/controller/DiffusionRepositoryNewController.php', 770 772 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', 773 + 'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php', 771 774 'DiffusionRepositoryRef' => 'applications/diffusion/data/DiffusionRepositoryRef.php', 772 775 'DiffusionRepositoryRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryRemarkupRule.php', 773 776 'DiffusionRepositorySearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRepositorySearchConduitAPIMethod.php', ··· 4934 4937 'DiffusionRefTableController' => 'DiffusionController', 4935 4938 'DiffusionRefsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 4936 4939 'DiffusionRenameHistoryQuery' => 'Phobject', 4940 + 'DiffusionRepositoryBasicsManagementPanel' => 'DiffusionRepositoryManagementPanel', 4937 4941 'DiffusionRepositoryByIDRemarkupRule' => 'PhabricatorObjectRemarkupRule', 4938 4942 'DiffusionRepositoryClusterManagementPanel' => 'DiffusionRepositoryManagementPanel', 4939 4943 'DiffusionRepositoryController' => 'DiffusionController', ··· 4958 4962 'DiffusionRepositoryEditSubversionController' => 'DiffusionRepositoryEditController', 4959 4963 'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryEditController', 4960 4964 'DiffusionRepositoryEditproController' => 'DiffusionRepositoryEditController', 4965 + 'DiffusionRepositoryHistoryManagementPanel' => 'DiffusionRepositoryManagementPanel', 4961 4966 'DiffusionRepositoryListController' => 'DiffusionController', 4962 4967 'DiffusionRepositoryManageController' => 'DiffusionController', 4963 4968 'DiffusionRepositoryManagementPanel' => 'Phobject', 4964 4969 'DiffusionRepositoryNewController' => 'DiffusionController', 4965 4970 'DiffusionRepositoryPath' => 'Phobject', 4971 + 'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel', 4966 4972 'DiffusionRepositoryRef' => 'Phobject', 4967 4973 'DiffusionRepositoryRemarkupRule' => 'PhabricatorObjectRemarkupRule', 4968 4974 'DiffusionRepositorySearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
+31 -1
src/applications/diffusion/controller/DiffusionRepositoryManageController.php
··· 30 30 foreach ($panels as $panel) { 31 31 $panel 32 32 ->setViewer($viewer) 33 - ->setRepository($repository); 33 + ->setRepository($repository) 34 + ->setController($this); 34 35 } 35 36 36 37 $selected = $request->getURIData('panel'); ··· 63 64 $repository->getPathURI('manage/')); 64 65 $crumbs->addTextCrumb($panel->getManagementPanelLabel()); 65 66 67 + $header_text = pht( 68 + '%s: %s', 69 + $repository->getDisplayName(), 70 + $panel->getManagementPanelLabel()); 71 + 72 + $header = id(new PHUIHeaderView()) 73 + ->setHeader($header_text) 74 + ->setHeaderIcon('fa-pencil'); 75 + if ($repository->isTracked()) { 76 + $header->setStatus('fa-check', 'bluegrey', pht('Active')); 77 + } else { 78 + $header->setStatus('fa-ban', 'dark', pht('Inactive')); 79 + } 80 + 66 81 $view = id(new PHUITwoColumnView()) 82 + ->setHeader($header) 67 83 ->setNavigation($nav) 68 84 ->setMainColumn($content); 85 + 86 + $curtain = $panel->buildManagementPanelCurtain(); 87 + if ($curtain) { 88 + $view->setCurtain($curtain); 89 + } 69 90 70 91 return $this->newPage() 71 92 ->setTitle($title) ··· 93 114 $nav->selectFilter($selected); 94 115 95 116 return $nav; 117 + } 118 + 119 + public function newTimeline(PhabricatorRepository $repository) { 120 + $timeline = $this->buildTransactionTimeline( 121 + $repository, 122 + new PhabricatorRepositoryTransactionQuery()); 123 + $timeline->setShouldTerminate(true); 124 + 125 + return $timeline; 96 126 } 97 127 98 128
+122
src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositoryBasicsManagementPanel 4 + extends DiffusionRepositoryManagementPanel { 5 + 6 + const PANELKEY = 'basics'; 7 + 8 + public function getManagementPanelLabel() { 9 + return pht('Basics'); 10 + } 11 + 12 + public function getManagementPanelOrder() { 13 + return 100; 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 + $edit_uri = $repository->getPathURI('manage/'); 26 + $activate_uri = $repository->getPathURI('edit/activate/'); 27 + $delete_uri = $repository->getPathURI('edit/delete/'); 28 + 29 + if ($repository->isTracked()) { 30 + $activate_icon = 'fa-pause'; 31 + $activate_label = pht('Deactivate Repository'); 32 + } else { 33 + $activate_icon = 'fa-play'; 34 + $activate_label = pht('Activate Repository'); 35 + } 36 + 37 + return array( 38 + id(new PhabricatorActionView()) 39 + ->setIcon('fa-pencil') 40 + ->setName(pht('Edit Basic Information')) 41 + ->setHref($edit_uri) 42 + ->setDisabled(!$can_edit) 43 + ->setWorkflow(!$can_edit), 44 + id(new PhabricatorActionView()) 45 + ->setHref($activate_uri) 46 + ->setIcon($activate_icon) 47 + ->setName($activate_label) 48 + ->setDisabled(!$can_edit) 49 + ->setWorkflow(true), 50 + id(new PhabricatorActionView()) 51 + ->setName(pht('Delete Repository')) 52 + ->setIcon('fa-times') 53 + ->setHref($delete_uri) 54 + ->setDisabled(true) 55 + ->setWorkflow(true), 56 + ); 57 + } 58 + 59 + public function buildManagementPanelContent() { 60 + $result = array(); 61 + 62 + $result[] = $this->newBox(pht('Repository Basics'), $this->buildBasics()); 63 + 64 + $description = $this->buildDescription(); 65 + if ($description) { 66 + $result[] = $this->newBox(pht('Description'), $description); 67 + } 68 + 69 + return $result; 70 + } 71 + 72 + private function buildBasics() { 73 + $repository = $this->getRepository(); 74 + $viewer = $this->getViewer(); 75 + 76 + $view = id(new PHUIPropertyListView()) 77 + ->setViewer($viewer) 78 + ->setActionList($this->newActions()); 79 + 80 + $name = $repository->getName(); 81 + $view->addProperty(pht('Name'), $name); 82 + 83 + $type = PhabricatorRepositoryType::getNameForRepositoryType( 84 + $repository->getVersionControlSystem()); 85 + $view->addProperty(pht('Type'), $type); 86 + 87 + $callsign = $repository->getCallsign(); 88 + if (!strlen($callsign)) { 89 + $callsign = phutil_tag('em', array(), pht('No Callsign')); 90 + } 91 + $view->addProperty(pht('Callsign'), $callsign); 92 + 93 + $short_name = $repository->getRepositorySlug(); 94 + if ($short_name === null) { 95 + $short_name = $repository->getCloneName(); 96 + $short_name = phutil_tag('em', array(), $short_name); 97 + } 98 + $view->addProperty(pht('Short Name'), $short_name); 99 + 100 + return $view; 101 + } 102 + 103 + 104 + private function buildDescription() { 105 + $repository = $this->getRepository(); 106 + $viewer = $this->getViewer(); 107 + 108 + $description = $repository->getDetail('description'); 109 + 110 + $view = id(new PHUIPropertyListView()) 111 + ->setViewer($viewer); 112 + if (!strlen($description)) { 113 + $description = phutil_tag('em', array(), pht('No description provided.')); 114 + } else { 115 + $description = new PHUIRemarkupView($viewer, $description); 116 + } 117 + $view->addTextContent($description); 118 + 119 + return $view; 120 + } 121 + 122 + }
+1 -1
src/applications/diffusion/management/DiffusionRepositoryClusterManagementPanel.php
··· 10 10 } 11 11 12 12 public function getManagementPanelOrder() { 13 - return 12345; 13 + return 600; 14 14 } 15 15 16 16 public function buildManagementPanelContent() {
+21
src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositoryHistoryManagementPanel 4 + extends DiffusionRepositoryManagementPanel { 5 + 6 + const PANELKEY = 'history'; 7 + 8 + public function getManagementPanelLabel() { 9 + return pht('History'); 10 + } 11 + 12 + public function getManagementPanelOrder() { 13 + return 900; 14 + } 15 + 16 + public function buildManagementPanelContent() { 17 + return $this->newTimeline(); 18 + } 19 + 20 + 21 + }
+58
src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php
··· 5 5 6 6 private $viewer; 7 7 private $repository; 8 + private $controller; 8 9 9 10 final public function setViewer(PhabricatorUser $viewer) { 10 11 $this->viewer = $viewer; ··· 24 25 return $this->repository; 25 26 } 26 27 28 + final public function setController(PhabricatorController $controller) { 29 + $this->controller = $controller; 30 + return $this; 31 + } 32 + 27 33 final public function getManagementPanelKey() { 28 34 return $this->getPhobjectClassConstant('PANELKEY'); 29 35 } ··· 32 38 abstract public function getManagementPanelOrder(); 33 39 abstract public function buildManagementPanelContent(); 34 40 41 + protected function buildManagementPanelActions() { 42 + return array(); 43 + } 44 + 45 + final protected function newActions() { 46 + $actions = $this->buildManagementPanelActions(); 47 + if (!$actions) { 48 + return null; 49 + } 50 + 51 + $viewer = $this->getViewer(); 52 + 53 + $action_list = id(new PhabricatorActionListView()) 54 + ->setViewer($viewer); 55 + 56 + foreach ($actions as $action) { 57 + $action_list->addAction($action); 58 + } 59 + 60 + return $action_list; 61 + } 62 + 63 + public function buildManagementPanelCurtain() { 64 + // TODO: Delete or fix this, curtains always render in the left gutter 65 + // at the moment. 66 + return null; 67 + 68 + $actions = $this->newActions(); 69 + if (!$actions) { 70 + return null; 71 + } 72 + 73 + $viewer = $this->getViewer(); 74 + 75 + $curtain = id(new PHUICurtainView()) 76 + ->setViewer($viewer) 77 + ->setActionList($actions); 78 + 79 + return $curtain; 80 + } 81 + 35 82 public static function getAllPanels() { 36 83 return id(new PhutilClassMapQuery()) 37 84 ->setAncestorClass(__CLASS__) 38 85 ->setUniqueMethod('getManagementPanelKey') 39 86 ->setSortMethod('getManagementPanelOrder') 40 87 ->execute(); 88 + } 89 + 90 + final protected function newBox($header_text, $body) { 91 + return id(new PHUIObjectBoxView()) 92 + ->setHeaderText($header_text) 93 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 94 + ->appendChild($body); 95 + } 96 + 97 + final protected function newTimeline() { 98 + return $this->controller->newTimeline($this->getRepository()); 41 99 } 42 100 43 101 }
+73
src/applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositoryPoliciesManagementPanel 4 + extends DiffusionRepositoryManagementPanel { 5 + 6 + const PANELKEY = 'policies'; 7 + 8 + public function getManagementPanelLabel() { 9 + return pht('Policies'); 10 + } 11 + 12 + public function getManagementPanelOrder() { 13 + return 300; 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 + $edit_uri = $repository->getPathURI('manage/'); 26 + 27 + return array( 28 + id(new PhabricatorActionView()) 29 + ->setIcon('fa-pencil') 30 + ->setName(pht('Edit Policies')) 31 + ->setHref($edit_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 + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( 46 + $viewer, 47 + $repository); 48 + 49 + $view_parts = array(); 50 + if (PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) { 51 + $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID( 52 + $repository); 53 + $view_parts[] = $viewer->renderHandle($space_phid); 54 + } 55 + $view_parts[] = $descriptions[PhabricatorPolicyCapability::CAN_VIEW]; 56 + 57 + $view->addProperty( 58 + pht('Visible To'), 59 + phutil_implode_html(" \xC2\xB7 ", $view_parts)); 60 + 61 + $view->addProperty( 62 + pht('Editable By'), 63 + $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); 64 + 65 + $pushable = $repository->isHosted() 66 + ? $descriptions[DiffusionPushCapability::CAPABILITY] 67 + : phutil_tag('em', array(), pht('Not a Hosted Repository')); 68 + $view->addProperty(pht('Pushable By'), $pushable); 69 + 70 + return $this->newBox(pht('Policies'), $view); 71 + } 72 + 73 + }