3 final class DiffusionRepositoryManagePanelsController
4 extends DiffusionRepositoryManageController
{
8 public function buildApplicationMenu() {
9 // TODO: This is messy for now; the mobile menu should be set automatically
10 // when the body content is a two-column view with navigation.
11 if ($this->navigation
) {
12 return $this->navigation
->getMenu();
14 return parent
::buildApplicationMenu();
18 public function handleRequest(AphrontRequest
$request) {
19 $response = $this->loadDiffusionContext();
24 $viewer = $this->getViewer();
25 $drequest = $this->getDiffusionRequest();
26 $repository = $drequest->getRepository();
28 $panels = DiffusionRepositoryManagementPanel
::getAllPanels();
30 foreach ($panels as $key => $panel) {
33 ->setRepository($repository)
34 ->setController($this);
36 if (!$panel->shouldEnableForRepository($repository)) {
42 $selected = $request->getURIData('panel');
43 if ($selected === null ||
!strlen($selected)) {
44 $selected = head_key($panels);
47 if (empty($panels[$selected])) {
48 return new Aphront404Response();
51 $nav = $this->renderSideNav($repository, $panels, $selected);
52 $this->navigation
= $nav;
54 $panel = $panels[$selected];
56 $crumbs = $this->buildApplicationCrumbs();
57 $crumbs->addTextCrumb($panel->getManagementPanelLabel());
58 $crumbs->setBorder(true);
60 $content = $panel->buildManagementPanelContent();
63 $panel->getManagementPanelLabel(),
64 $repository->getDisplayName(),
67 $header = $this->buildHeaderView($repository->getDisplayName());
69 $view = id(new PHUITwoColumnView())
71 ->setMainColumn($content);
73 $curtain = $panel->buildManagementPanelCurtain();
75 $view->setCurtain($curtain);
78 return $this->newPage()
85 private function renderSideNav(
86 PhabricatorRepository
$repository,
90 $base_uri = $repository->getPathURI('manage/');
91 $base_uri = new PhutilURI($base_uri);
93 $nav = id(new AphrontSideNavFilterView())
94 ->setBaseURI($base_uri);
96 $groups = DiffusionRepositoryManagementPanelGroup
::getAllPanelGroups();
97 $panel_groups = mgroup($panels, 'getManagementPanelGroupKey');
98 $other_key = DiffusionRepositoryManagementOtherPanelGroup
::PANELGROUPKEY
;
100 foreach ($groups as $group_key => $group) {
101 // If this is the "Other" group, include everything else that isn't in
102 // some actual group.
103 if ($group_key === $other_key) {
104 $group_panels = array_mergev($panel_groups);
105 $panel_groups = array();
107 $group_panels = idx($panel_groups, $group_key);
108 unset($panel_groups[$group_key]);
111 if (!$group_panels) {
115 $label = $group->getManagementPanelGroupLabel();
117 $nav->addLabel($label);
120 foreach ($group_panels as $panel) {
121 $key = $panel->getManagementPanelKey();
122 $label = $panel->getManagementPanelLabel();
123 $icon = $panel->getManagementPanelIcon();
124 $href = $panel->getPanelNavigationURI();
126 $item = id(new PHUIListItemView())
129 ->setType(PHUIListItemView
::TYPE_LINK
)
133 $nav->addMenuItem($item);
137 $nav->selectFilter($selected);
142 public function buildHeaderView($title) {
143 $viewer = $this->getViewer();
145 $drequest = $this->getDiffusionRequest();
146 $repository = $drequest->getRepository();
148 $header = id(new PHUIHeaderView())
150 ->setProfileHeader(true)
151 ->setHref($repository->getURI())
152 ->setImage($repository->getProfileImageURI());
154 if ($repository->isTracked()) {
155 $header->setStatus('fa-check', 'bluegrey', pht('Active'));
157 $header->setStatus('fa-ban', 'dark', pht('Inactive'));
160 $doc_href = PhabricatorEnv
::getDoclink(
161 'Diffusion User Guide: Managing Repositories');
163 $header->addActionLink(
164 id(new PHUIButtonView())
166 ->setText(pht('View Repository'))
167 ->setHref($repository->getURI())
169 ->setColor(PHUIButtonView
::GREY
));
171 $header->addActionLink(
172 id(new PHUIButtonView())
176 ->setText(pht('Help'))
177 ->setColor(PHUIButtonView
::GREY
));
182 public function newTimeline(PhabricatorRepository
$repository) {
183 $timeline = $this->buildTransactionTimeline(
185 new PhabricatorRepositoryTransactionQuery());
186 $timeline->setShouldTerminate(true);