From e582e9172bcd561034fe4af62406d5c50ff6aa2b Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 16 Apr 2016 17:33:27 -0700 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 6 + .../DiffusionRepositoryManageController.php | 32 ++++- ...ffusionRepositoryBasicsManagementPanel.php | 122 ++++++++++++++++++ ...fusionRepositoryClusterManagementPanel.php | 2 +- ...fusionRepositoryHistoryManagementPanel.php | 21 +++ .../DiffusionRepositoryManagementPanel.php | 58 +++++++++ ...usionRepositoryPoliciesManagementPanel.php | 73 +++++++++++ 7 files changed, 312 insertions(+), 2 deletions(-) create mode 100644 src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php create mode 100644 src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php create mode 100644 src/applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 0d12e403c4..3496529362 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -739,6 +739,7 @@ phutil_register_library_map(array( 'DiffusionRefTableController' => 'applications/diffusion/controller/DiffusionRefTableController.php', 'DiffusionRefsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php', 'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php', + 'DiffusionRepositoryBasicsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php', 'DiffusionRepositoryByIDRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryByIDRemarkupRule.php', 'DiffusionRepositoryClusterManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryClusterManagementPanel.php', 'DiffusionRepositoryController' => 'applications/diffusion/controller/DiffusionRepositoryController.php', @@ -763,11 +764,13 @@ phutil_register_library_map(array( 'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php', 'DiffusionRepositoryEditUpdateController' => 'applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php', 'DiffusionRepositoryEditproController' => 'applications/diffusion/controller/DiffusionRepositoryEditproController.php', + 'DiffusionRepositoryHistoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php', 'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php', 'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php', 'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php', 'DiffusionRepositoryNewController' => 'applications/diffusion/controller/DiffusionRepositoryNewController.php', 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', + 'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php', 'DiffusionRepositoryRef' => 'applications/diffusion/data/DiffusionRepositoryRef.php', 'DiffusionRepositoryRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryRemarkupRule.php', 'DiffusionRepositorySearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRepositorySearchConduitAPIMethod.php', @@ -4934,6 +4937,7 @@ phutil_register_library_map(array( 'DiffusionRefTableController' => 'DiffusionController', 'DiffusionRefsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionRenameHistoryQuery' => 'Phobject', + 'DiffusionRepositoryBasicsManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryByIDRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'DiffusionRepositoryClusterManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryController' => 'DiffusionController', @@ -4958,11 +4962,13 @@ phutil_register_library_map(array( 'DiffusionRepositoryEditSubversionController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditproController' => 'DiffusionRepositoryEditController', + 'DiffusionRepositoryHistoryManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryListController' => 'DiffusionController', 'DiffusionRepositoryManageController' => 'DiffusionController', 'DiffusionRepositoryManagementPanel' => 'Phobject', 'DiffusionRepositoryNewController' => 'DiffusionController', 'DiffusionRepositoryPath' => 'Phobject', + 'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryRef' => 'Phobject', 'DiffusionRepositoryRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'DiffusionRepositorySearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', diff --git a/src/applications/diffusion/controller/DiffusionRepositoryManageController.php b/src/applications/diffusion/controller/DiffusionRepositoryManageController.php index d4ba97440d..aa34f8f909 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryManageController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryManageController.php @@ -30,7 +30,8 @@ final class DiffusionRepositoryManageController foreach ($panels as $panel) { $panel ->setViewer($viewer) - ->setRepository($repository); + ->setRepository($repository) + ->setController($this); } $selected = $request->getURIData('panel'); @@ -63,10 +64,30 @@ final class DiffusionRepositoryManageController $repository->getPathURI('manage/')); $crumbs->addTextCrumb($panel->getManagementPanelLabel()); + $header_text = pht( + '%s: %s', + $repository->getDisplayName(), + $panel->getManagementPanelLabel()); + + $header = id(new PHUIHeaderView()) + ->setHeader($header_text) + ->setHeaderIcon('fa-pencil'); + if ($repository->isTracked()) { + $header->setStatus('fa-check', 'bluegrey', pht('Active')); + } else { + $header->setStatus('fa-ban', 'dark', pht('Inactive')); + } + $view = id(new PHUITwoColumnView()) + ->setHeader($header) ->setNavigation($nav) ->setMainColumn($content); + $curtain = $panel->buildManagementPanelCurtain(); + if ($curtain) { + $view->setCurtain($curtain); + } + return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) @@ -95,5 +116,14 @@ final class DiffusionRepositoryManageController return $nav; } + public function newTimeline(PhabricatorRepository $repository) { + $timeline = $this->buildTransactionTimeline( + $repository, + new PhabricatorRepositoryTransactionQuery()); + $timeline->setShouldTerminate(true); + + return $timeline; + } + } diff --git a/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php new file mode 100644 index 0000000000..2810d0dc9a --- /dev/null +++ b/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php @@ -0,0 +1,122 @@ +getRepository(); + $viewer = $this->getViewer(); + + $can_edit = PhabricatorPolicyFilter::hasCapability( + $viewer, + $repository, + PhabricatorPolicyCapability::CAN_EDIT); + + $edit_uri = $repository->getPathURI('manage/'); + $activate_uri = $repository->getPathURI('edit/activate/'); + $delete_uri = $repository->getPathURI('edit/delete/'); + + if ($repository->isTracked()) { + $activate_icon = 'fa-pause'; + $activate_label = pht('Deactivate Repository'); + } else { + $activate_icon = 'fa-play'; + $activate_label = pht('Activate Repository'); + } + + return array( + id(new PhabricatorActionView()) + ->setIcon('fa-pencil') + ->setName(pht('Edit Basic Information')) + ->setHref($edit_uri) + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit), + id(new PhabricatorActionView()) + ->setHref($activate_uri) + ->setIcon($activate_icon) + ->setName($activate_label) + ->setDisabled(!$can_edit) + ->setWorkflow(true), + id(new PhabricatorActionView()) + ->setName(pht('Delete Repository')) + ->setIcon('fa-times') + ->setHref($delete_uri) + ->setDisabled(true) + ->setWorkflow(true), + ); + } + + public function buildManagementPanelContent() { + $result = array(); + + $result[] = $this->newBox(pht('Repository Basics'), $this->buildBasics()); + + $description = $this->buildDescription(); + if ($description) { + $result[] = $this->newBox(pht('Description'), $description); + } + + return $result; + } + + private function buildBasics() { + $repository = $this->getRepository(); + $viewer = $this->getViewer(); + + $view = id(new PHUIPropertyListView()) + ->setViewer($viewer) + ->setActionList($this->newActions()); + + $name = $repository->getName(); + $view->addProperty(pht('Name'), $name); + + $type = PhabricatorRepositoryType::getNameForRepositoryType( + $repository->getVersionControlSystem()); + $view->addProperty(pht('Type'), $type); + + $callsign = $repository->getCallsign(); + if (!strlen($callsign)) { + $callsign = phutil_tag('em', array(), pht('No Callsign')); + } + $view->addProperty(pht('Callsign'), $callsign); + + $short_name = $repository->getRepositorySlug(); + if ($short_name === null) { + $short_name = $repository->getCloneName(); + $short_name = phutil_tag('em', array(), $short_name); + } + $view->addProperty(pht('Short Name'), $short_name); + + return $view; + } + + + private function buildDescription() { + $repository = $this->getRepository(); + $viewer = $this->getViewer(); + + $description = $repository->getDetail('description'); + + $view = id(new PHUIPropertyListView()) + ->setViewer($viewer); + if (!strlen($description)) { + $description = phutil_tag('em', array(), pht('No description provided.')); + } else { + $description = new PHUIRemarkupView($viewer, $description); + } + $view->addTextContent($description); + + return $view; + } + +} diff --git a/src/applications/diffusion/management/DiffusionRepositoryClusterManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryClusterManagementPanel.php index 27991f62c7..5ab907924b 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryClusterManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryClusterManagementPanel.php @@ -10,7 +10,7 @@ final class DiffusionRepositoryClusterManagementPanel } public function getManagementPanelOrder() { - return 12345; + return 600; } public function buildManagementPanelContent() { diff --git a/src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php new file mode 100644 index 0000000000..c98d3d76ca --- /dev/null +++ b/src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php @@ -0,0 +1,21 @@ +newTimeline(); + } + + +} diff --git a/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php index b72411cd58..f278c3323a 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php @@ -5,6 +5,7 @@ abstract class DiffusionRepositoryManagementPanel private $viewer; private $repository; + private $controller; final public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; @@ -24,6 +25,11 @@ abstract class DiffusionRepositoryManagementPanel return $this->repository; } + final public function setController(PhabricatorController $controller) { + $this->controller = $controller; + return $this; + } + final public function getManagementPanelKey() { return $this->getPhobjectClassConstant('PANELKEY'); } @@ -32,6 +38,47 @@ abstract class DiffusionRepositoryManagementPanel abstract public function getManagementPanelOrder(); abstract public function buildManagementPanelContent(); + protected function buildManagementPanelActions() { + return array(); + } + + final protected function newActions() { + $actions = $this->buildManagementPanelActions(); + if (!$actions) { + return null; + } + + $viewer = $this->getViewer(); + + $action_list = id(new PhabricatorActionListView()) + ->setViewer($viewer); + + foreach ($actions as $action) { + $action_list->addAction($action); + } + + return $action_list; + } + + public function buildManagementPanelCurtain() { + // TODO: Delete or fix this, curtains always render in the left gutter + // at the moment. + return null; + + $actions = $this->newActions(); + if (!$actions) { + return null; + } + + $viewer = $this->getViewer(); + + $curtain = id(new PHUICurtainView()) + ->setViewer($viewer) + ->setActionList($actions); + + return $curtain; + } + public static function getAllPanels() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) @@ -40,4 +87,15 @@ abstract class DiffusionRepositoryManagementPanel ->execute(); } + final protected function newBox($header_text, $body) { + return id(new PHUIObjectBoxView()) + ->setHeaderText($header_text) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) + ->appendChild($body); + } + + final protected function newTimeline() { + return $this->controller->newTimeline($this->getRepository()); + } + } diff --git a/src/applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php new file mode 100644 index 0000000000..9bfe572070 --- /dev/null +++ b/src/applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php @@ -0,0 +1,73 @@ +getRepository(); + $viewer = $this->getViewer(); + + $can_edit = PhabricatorPolicyFilter::hasCapability( + $viewer, + $repository, + PhabricatorPolicyCapability::CAN_EDIT); + + $edit_uri = $repository->getPathURI('manage/'); + + return array( + id(new PhabricatorActionView()) + ->setIcon('fa-pencil') + ->setName(pht('Edit Policies')) + ->setHref($edit_uri) + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit), + ); + } + + public function buildManagementPanelContent() { + $repository = $this->getRepository(); + $viewer = $this->getViewer(); + + $view = id(new PHUIPropertyListView()) + ->setViewer($viewer) + ->setActionList($this->newActions()); + + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( + $viewer, + $repository); + + $view_parts = array(); + if (PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) { + $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID( + $repository); + $view_parts[] = $viewer->renderHandle($space_phid); + } + $view_parts[] = $descriptions[PhabricatorPolicyCapability::CAN_VIEW]; + + $view->addProperty( + pht('Visible To'), + phutil_implode_html(" \xC2\xB7 ", $view_parts)); + + $view->addProperty( + pht('Editable By'), + $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); + + $pushable = $repository->isHosted() + ? $descriptions[DiffusionPushCapability::CAPABILITY] + : phutil_tag('em', array(), pht('Not a Hosted Repository')); + $view->addProperty(pht('Pushable By'), $pushable); + + return $this->newBox(pht('Policies'), $view); + } + +}