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:
parent
dc389c90bb
commit
916c4cb78a
1 changed files with 33 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue