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 @@ -952,7 +952,12 @@ 'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php', 'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php', 'DiffusionRepositoryManagePanelsController' => 'applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php', + 'DiffusionRepositoryManagementBuildsPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php', + 'DiffusionRepositoryManagementIntegrationsPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementIntegrationsPanelGroup.php', + 'DiffusionRepositoryManagementMainPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementMainPanelGroup.php', + 'DiffusionRepositoryManagementOtherPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementOtherPanelGroup.php', 'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php', + 'DiffusionRepositoryManagementPanelGroup' => 'applications/diffusion/management/DiffusionRepositoryManagementPanelGroup.php', 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', 'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php', 'DiffusionRepositoryProfilePictureController' => 'applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php', @@ -6335,7 +6340,12 @@ 'DiffusionRepositoryListController' => 'DiffusionController', 'DiffusionRepositoryManageController' => 'DiffusionController', 'DiffusionRepositoryManagePanelsController' => 'DiffusionRepositoryManageController', + 'DiffusionRepositoryManagementBuildsPanelGroup' => 'DiffusionRepositoryManagementPanelGroup', + 'DiffusionRepositoryManagementIntegrationsPanelGroup' => 'DiffusionRepositoryManagementPanelGroup', + 'DiffusionRepositoryManagementMainPanelGroup' => 'DiffusionRepositoryManagementPanelGroup', + 'DiffusionRepositoryManagementOtherPanelGroup' => 'DiffusionRepositoryManagementPanelGroup', 'DiffusionRepositoryManagementPanel' => 'Phobject', + 'DiffusionRepositoryManagementPanelGroup' => 'Phobject', 'DiffusionRepositoryPath' => 'Phobject', 'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryProfilePictureController' => 'DiffusionController', diff --git a/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php b/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php --- a/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php @@ -93,20 +93,45 @@ $nav = id(new AphrontSideNavFilterView()) ->setBaseURI($base_uri); - foreach ($panels as $panel) { - $key = $panel->getManagementPanelKey(); - $label = $panel->getManagementPanelLabel(); - $icon = $panel->getManagementPanelIcon(); - $href = $panel->getPanelNavigationURI(); - - $item = id(new PHUIListItemView()) - ->setKey($key) - ->setName($label) - ->setType(PHUIListItemView::TYPE_LINK) - ->setHref($href) - ->setIcon($icon); - - $nav->addMenuItem($item); + $groups = DiffusionRepositoryManagementPanelGroup::getAllPanelGroups(); + $panel_groups = mgroup($panels, 'getManagementPanelGroupKey'); + $other_key = DiffusionRepositoryManagementOtherPanelGroup::PANELGROUPKEY; + + foreach ($groups as $group_key => $group) { + // If this is the "Other" group, include everything else that isn't in + // some actual group. + if ($group_key === $other_key) { + $group_panels = array_mergev($panel_groups); + $panel_groups = array(); + } else { + $group_panels = idx($panel_groups, $group_key); + unset($panel_groups[$group_key]); + } + + if (!$group_panels) { + continue; + } + + $label = $group->getManagementPanelGroupLabel(); + if ($label) { + $nav->addLabel($label); + } + + foreach ($group_panels as $panel) { + $key = $panel->getManagementPanelKey(); + $label = $panel->getManagementPanelLabel(); + $icon = $panel->getManagementPanelIcon(); + $href = $panel->getPanelNavigationURI(); + + $item = id(new PHUIListItemView()) + ->setKey($key) + ->setName($label) + ->setType(PHUIListItemView::TYPE_LINK) + ->setHref($href) + ->setIcon($icon); + + $nav->addMenuItem($item); + } } $nav->selectFilter($selected); diff --git a/src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php --- a/src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php @@ -13,6 +13,10 @@ return 800; } + public function getManagementPanelGroupKey() { + return DiffusionRepositoryManagementBuildsPanelGroup::PANELGROUPKEY; + } + public function shouldEnableForRepository( PhabricatorRepository $repository) { return $repository->isGit(); diff --git a/src/applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php b/src/applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php new file mode 100644 --- /dev/null +++ b/src/applications/diffusion/management/DiffusionRepositoryManagementBuildsPanelGroup.php @@ -0,0 +1,16 @@ +getPhobjectClassConstant('PANELGROUPKEY'); + } + + abstract public function getManagementPanelGroupOrder(); + abstract public function getManagementPanelGroupLabel(); + + public static function getAllPanelGroups() { + return id(new PhutilClassMapQuery()) + ->setAncestorClass(__CLASS__) + ->setUniqueMethod('getManagementPanelGroupKey') + ->setSortMethod('getManagementPanelGroupOrder') + ->execute(); + } + +} diff --git a/src/applications/diffusion/management/DiffusionRepositoryStagingManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryStagingManagementPanel.php --- a/src/applications/diffusion/management/DiffusionRepositoryStagingManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryStagingManagementPanel.php @@ -13,6 +13,10 @@ return 700; } + public function getManagementPanelGroupKey() { + return DiffusionRepositoryManagementBuildsPanelGroup::PANELGROUPKEY; + } + public function shouldEnableForRepository( PhabricatorRepository $repository) { return $repository->isGit(); diff --git a/src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php --- a/src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php @@ -13,6 +13,10 @@ return 900; } + public function getManagementPanelGroupKey() { + return DiffusionRepositoryManagementIntegrationsPanelGroup::PANELGROUPKEY; + } + public function getManagementPanelIcon() { $repository = $this->getRepository();