1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

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
This commit is contained in:
epriestley 2016-04-16 17:33:27 -07:00
parent adf42db5ea
commit e582e9172b
7 changed files with 312 additions and 2 deletions

View file

@ -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',

View file

@ -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;
}
}

View file

@ -0,0 +1,122 @@
<?php
final class DiffusionRepositoryBasicsManagementPanel
extends DiffusionRepositoryManagementPanel {
const PANELKEY = 'basics';
public function getManagementPanelLabel() {
return pht('Basics');
}
public function getManagementPanelOrder() {
return 100;
}
protected function buildManagementPanelActions() {
$repository = $this->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;
}
}

View file

@ -10,7 +10,7 @@ final class DiffusionRepositoryClusterManagementPanel
}
public function getManagementPanelOrder() {
return 12345;
return 600;
}
public function buildManagementPanelContent() {

View file

@ -0,0 +1,21 @@
<?php
final class DiffusionRepositoryHistoryManagementPanel
extends DiffusionRepositoryManagementPanel {
const PANELKEY = 'history';
public function getManagementPanelLabel() {
return pht('History');
}
public function getManagementPanelOrder() {
return 900;
}
public function buildManagementPanelContent() {
return $this->newTimeline();
}
}

View file

@ -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());
}
}

View file

@ -0,0 +1,73 @@
<?php
final class DiffusionRepositoryPoliciesManagementPanel
extends DiffusionRepositoryManagementPanel {
const PANELKEY = 'policies';
public function getManagementPanelLabel() {
return pht('Policies');
}
public function getManagementPanelOrder() {
return 300;
}
protected function buildManagementPanelActions() {
$repository = $this->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);
}
}