mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
e582e9172b
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
129 lines
3.2 KiB
PHP
129 lines
3.2 KiB
PHP
<?php
|
|
|
|
final class DiffusionRepositoryManageController
|
|
extends DiffusionController {
|
|
|
|
private $navigation;
|
|
|
|
public function buildApplicationMenu() {
|
|
// TODO: This is messy for now; the mobile menu should be set automatically
|
|
// when the body content is a two-column view with navigation.
|
|
if ($this->navigation) {
|
|
return $this->navigation->getMenu();
|
|
}
|
|
return parent::buildApplicationMenu();
|
|
}
|
|
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContext();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$viewer = $this->getViewer();
|
|
$drequest = $this->getDiffusionRequest();
|
|
$repository = $drequest->getRepository();
|
|
|
|
$panels = DiffusionRepositoryManagementPanel::getAllPanels();
|
|
|
|
foreach ($panels as $panel) {
|
|
$panel
|
|
->setViewer($viewer)
|
|
->setRepository($repository)
|
|
->setController($this);
|
|
}
|
|
|
|
$selected = $request->getURIData('panel');
|
|
if (!strlen($selected)) {
|
|
$selected = head_key($panels);
|
|
}
|
|
|
|
if (empty($panels[$selected])) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$nav = $this->renderSideNav($repository, $panels, $selected);
|
|
$this->navigation = $nav;
|
|
|
|
$panel = $panels[$selected];
|
|
|
|
$content = $panel->buildManagementPanelContent();
|
|
|
|
$title = array(
|
|
$panel->getManagementPanelLabel(),
|
|
$repository->getDisplayName(),
|
|
);
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
$crumbs->addTextCrumb(
|
|
$repository->getDisplayName(),
|
|
$repository->getURI());
|
|
$crumbs->addTextCrumb(
|
|
pht('Manage'),
|
|
$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)
|
|
->appendChild($view);
|
|
}
|
|
|
|
private function renderSideNav(
|
|
PhabricatorRepository $repository,
|
|
array $panels,
|
|
$selected) {
|
|
|
|
$base_uri = $repository->getPathURI('manage/');
|
|
$base_uri = new PhutilURI($base_uri);
|
|
|
|
$nav = id(new AphrontSideNavFilterView())
|
|
->setBaseURI($base_uri);
|
|
|
|
foreach ($panels as $panel) {
|
|
$nav->addFilter(
|
|
$panel->getManagementPanelKey(),
|
|
$panel->getManagementPanelLabel());
|
|
}
|
|
|
|
$nav->selectFilter($selected);
|
|
|
|
return $nav;
|
|
}
|
|
|
|
public function newTimeline(PhabricatorRepository $repository) {
|
|
$timeline = $this->buildTransactionTimeline(
|
|
$repository,
|
|
new PhabricatorRepositoryTransactionQuery());
|
|
$timeline->setShouldTerminate(true);
|
|
|
|
return $timeline;
|
|
}
|
|
|
|
|
|
}
|