1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Separate the repository management UI into sections

Summary: Depends on D19826. Ref T13216. We have a fair number of options here; add some groups so the "Build" stuff can go in a little subcategory and such.

Test Plan: {F6020896}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13216

Differential Revision: https://secure.phabricator.com/D19827
This commit is contained in:
epriestley 2018-11-21 11:35:08 -08:00
parent c457d23a1d
commit c25d2a399d
11 changed files with 146 additions and 14 deletions

View file

@ -952,7 +952,12 @@ phutil_register_library_map(array(
'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 @@ phutil_register_library_map(array(
'DiffusionRepositoryListController' => 'DiffusionController',
'DiffusionRepositoryManageController' => 'DiffusionController',
'DiffusionRepositoryManagePanelsController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryManagementBuildsPanelGroup' => 'DiffusionRepositoryManagementPanelGroup',
'DiffusionRepositoryManagementIntegrationsPanelGroup' => 'DiffusionRepositoryManagementPanelGroup',
'DiffusionRepositoryManagementMainPanelGroup' => 'DiffusionRepositoryManagementPanelGroup',
'DiffusionRepositoryManagementOtherPanelGroup' => 'DiffusionRepositoryManagementPanelGroup',
'DiffusionRepositoryManagementPanel' => 'Phobject',
'DiffusionRepositoryManagementPanelGroup' => 'Phobject',
'DiffusionRepositoryPath' => 'Phobject',
'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryProfilePictureController' => 'DiffusionController',

View file

@ -93,20 +93,45 @@ final class DiffusionRepositoryManagePanelsController
$nav = id(new AphrontSideNavFilterView())
->setBaseURI($base_uri);
foreach ($panels as $panel) {
$key = $panel->getManagementPanelKey();
$label = $panel->getManagementPanelLabel();
$icon = $panel->getManagementPanelIcon();
$href = $panel->getPanelNavigationURI();
$groups = DiffusionRepositoryManagementPanelGroup::getAllPanelGroups();
$panel_groups = mgroup($panels, 'getManagementPanelGroupKey');
$other_key = DiffusionRepositoryManagementOtherPanelGroup::PANELGROUPKEY;
$item = id(new PHUIListItemView())
->setKey($key)
->setName($label)
->setType(PHUIListItemView::TYPE_LINK)
->setHref($href)
->setIcon($icon);
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]);
}
$nav->addMenuItem($item);
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);

View file

@ -13,6 +13,10 @@ final class DiffusionRepositoryAutomationManagementPanel
return 800;
}
public function getManagementPanelGroupKey() {
return DiffusionRepositoryManagementBuildsPanelGroup::PANELGROUPKEY;
}
public function shouldEnableForRepository(
PhabricatorRepository $repository) {
return $repository->isGit();

View file

@ -0,0 +1,16 @@
<?php
final class DiffusionRepositoryManagementBuildsPanelGroup
extends DiffusionRepositoryManagementPanelGroup {
const PANELGROUPKEY = 'builds';
public function getManagementPanelGroupLabel() {
return pht('Builds');
}
public function getManagementPanelGroupOrder() {
return 2000;
}
}

View file

@ -0,0 +1,16 @@
<?php
final class DiffusionRepositoryManagementIntegrationsPanelGroup
extends DiffusionRepositoryManagementPanelGroup {
const PANELGROUPKEY = 'integrations';
public function getManagementPanelGroupLabel() {
return pht('Integrations');
}
public function getManagementPanelGroupOrder() {
return 4000;
}
}

View file

@ -0,0 +1,16 @@
<?php
final class DiffusionRepositoryManagementMainPanelGroup
extends DiffusionRepositoryManagementPanelGroup {
const PANELGROUPKEY = 'main';
public function getManagementPanelGroupLabel() {
return null;
}
public function getManagementPanelGroupOrder() {
return 1000;
}
}

View file

@ -0,0 +1,16 @@
<?php
final class DiffusionRepositoryManagementOtherPanelGroup
extends DiffusionRepositoryManagementPanelGroup {
const PANELGROUPKEY = 'other';
public function getManagementPanelGroupLabel() {
return pht('Other');
}
public function getManagementPanelGroupOrder() {
return 9999;
}
}

View file

@ -47,8 +47,8 @@ abstract class DiffusionRepositoryManagementPanel
return 'fa-pencil';
}
protected function buildManagementPanelActions() {
return array();
public function getManagementPanelGroupKey() {
return DiffusionRepositoryManagementMainPanelGroup::PANELGROUPKEY;
}
public function shouldEnableForRepository(

View file

@ -0,0 +1,21 @@
<?php
abstract class DiffusionRepositoryManagementPanelGroup
extends Phobject {
final public function getManagementPanelGroupKey() {
return $this->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();
}
}

View file

@ -13,6 +13,10 @@ final class DiffusionRepositoryStagingManagementPanel
return 700;
}
public function getManagementPanelGroupKey() {
return DiffusionRepositoryManagementBuildsPanelGroup::PANELGROUPKEY;
}
public function shouldEnableForRepository(
PhabricatorRepository $repository) {
return $repository->isGit();

View file

@ -13,6 +13,10 @@ final class DiffusionRepositorySymbolsManagementPanel
return 900;
}
public function getManagementPanelGroupKey() {
return DiffusionRepositoryManagementIntegrationsPanelGroup::PANELGROUPKEY;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();