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

Add policy header and actions to repositories

Summary: Get thee modernized.

Test Plan: See screenshot.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D7040
This commit is contained in:
epriestley 2013-09-19 11:57:09 -07:00
parent dc389c90bb
commit 916c4cb78a

View file

@ -137,7 +137,11 @@ final class DiffusionRepositoryController extends DiffusionController {
$user = $this->getRequest()->getUser();
$header = id(new PHUIHeaderView())
->setHeader($repository->getName());
->setHeader($repository->getName())
->setUser($user)
->setPolicyObject($repository);
$actions = $this->buildActionList($repository);
$view = id(new PhabricatorPropertyListView())
->setUser($user);
@ -166,7 +170,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$view->addTextContent($description);
}
return array($header, $view);
return array($header, $actions, $view);
}
private function buildBranchListTable(DiffusionRequest $drequest) {
@ -288,4 +292,31 @@ final class DiffusionRepositoryController extends DiffusionController {
return $panel;
}
private function buildActionList(PhabricatorRepository $repository) {
$viewer = $this->getRequest()->getUser();
$view_uri = $this->getApplicationURI($repository->getCallsign().'/');
$edit_uri = $this->getApplicationURI($repository->getCallsign().'/edit/');
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($repository)
->setObjectURI($view_uri);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$repository,
PhabricatorPolicyCapability::CAN_EDIT);
$view->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Repository'))
->setIcon('edit')
->setHref($edit_uri)
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
return $view;
}
}