mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
Use hybrid properties + search for Releeph branches, too
Summary: Ref T3092. Same deal as D6771, but for branches rather than projects. Test Plan: {F54855} Reviewers: btrahan, chad Reviewed By: chad CC: chad, aran Maniphest Tasks: T3092 Differential Revision: https://secure.phabricator.com/D6775
This commit is contained in:
parent
dcec8e60cc
commit
43b35a02ce
5 changed files with 95 additions and 22 deletions
|
@ -11,13 +11,15 @@ abstract class ReleephProjectController extends ReleephController {
|
||||||
* referenced in the URL.
|
* referenced in the URL.
|
||||||
*/
|
*/
|
||||||
public function willProcessRequest(array $data) {
|
public function willProcessRequest(array $data) {
|
||||||
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
$project = null;
|
$project = null;
|
||||||
$project_id = idx($data, 'projectID');
|
$project_id = idx($data, 'projectID');
|
||||||
$project_name = idx($data, 'projectName');
|
$project_name = idx($data, 'projectName');
|
||||||
if ($project_id) {
|
if ($project_id) {
|
||||||
$project = id(new ReleephProjectQuery())
|
$project = id(new ReleephProjectQuery())
|
||||||
->setViewer($this->getRequest()->getUser())
|
->setViewer($viewer)
|
||||||
->withIDs(array($project_id))
|
->withIDs(array($project_id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$project) {
|
if (!$project) {
|
||||||
|
@ -38,7 +40,10 @@ abstract class ReleephProjectController extends ReleephController {
|
||||||
$branch_id = idx($data, 'branchID');
|
$branch_id = idx($data, 'branchID');
|
||||||
$branch_name = idx($data, 'branchName');
|
$branch_name = idx($data, 'branchName');
|
||||||
if ($branch_id) {
|
if ($branch_id) {
|
||||||
$branch = id(new ReleephBranch())->load($branch_id);
|
$branch = id(new ReleephBranchQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($branch_id))
|
||||||
|
->executeOne();
|
||||||
if (!$branch) {
|
if (!$branch) {
|
||||||
throw new Exception("Branch with id '{$branch_id}' not found!");
|
throw new Exception("Branch with id '{$branch_id}' not found!");
|
||||||
}
|
}
|
||||||
|
@ -57,6 +62,16 @@ abstract class ReleephProjectController extends ReleephController {
|
||||||
"ReleephBranch with basename '{$branch_name}' not found ".
|
"ReleephBranch with basename '{$branch_name}' not found ".
|
||||||
"in project '{$project->getName()}'!");
|
"in project '{$project->getName()}'!");
|
||||||
}
|
}
|
||||||
|
// Do the branch query again, properly, to hit policies and load attached
|
||||||
|
// data.
|
||||||
|
// TODO: Clean this up with T3657.
|
||||||
|
$branch = id(new ReleephBranchQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($branch->getID()))
|
||||||
|
->executeOne();
|
||||||
|
if (!$branch) {
|
||||||
|
throw new Exception('404!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
|
|
|
@ -13,7 +13,7 @@ final class ReleephBranchAccessController extends ReleephProjectController {
|
||||||
$branch = $this->getReleephBranch();
|
$branch = $this->getReleephBranch();
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
$done_uri = '/releeph/project/'.$branch->getReleephProjectID().'/';
|
$done_uri = $branch->getURI();
|
||||||
|
|
||||||
switch ($this->action) {
|
switch ($this->action) {
|
||||||
case 'close':
|
case 'close':
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class ReleephBranchEditController extends ReleephProjectController {
|
||||||
$releeph_branch->saveTransaction();
|
$releeph_branch->saveTransaction();
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI('/releeph/project/'.$releeph_branch->getReleephProjectID());
|
->setURI($releeph_branch->getURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
$phids = array();
|
$phids = array();
|
||||||
|
|
|
@ -19,6 +19,7 @@ final class ReleephBranchViewController extends ReleephProjectController
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
$controller = id(new PhabricatorApplicationSearchController($request))
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
||||||
|
->setPreface($this->renderPreface())
|
||||||
->setQueryKey($this->queryKey)
|
->setQueryKey($this->queryKey)
|
||||||
->setSearchEngine($this->getSearchEngine())
|
->setSearchEngine($this->getSearchEngine())
|
||||||
->setNavigation($this->buildSideNavView());
|
->setNavigation($this->buildSideNavView());
|
||||||
|
@ -91,5 +92,79 @@ final class ReleephBranchViewController extends ReleephProjectController
|
||||||
return $crumbs;
|
return $crumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function renderPreface() {
|
||||||
|
$branch = $this->getReleephBranch();
|
||||||
|
$viewer = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
$id = $branch->getID();
|
||||||
|
|
||||||
|
$header = id(new PhabricatorHeaderView())
|
||||||
|
->setHeader($branch->getDisplayName());
|
||||||
|
|
||||||
|
if (!$branch->getIsActive()) {
|
||||||
|
$header->addTag(
|
||||||
|
id(new PhabricatorTagView())
|
||||||
|
->setType(PhabricatorTagView::TYPE_STATE)
|
||||||
|
->setBackgroundColor(PhabricatorTagView::COLOR_BLACK)
|
||||||
|
->setName(pht('Closed')));
|
||||||
|
}
|
||||||
|
|
||||||
|
$actions = id(new PhabricatorActionListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($branch)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI());
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$branch,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$edit_uri = $branch->getURI('edit/');
|
||||||
|
$close_uri = $branch->getURI('close/');
|
||||||
|
$reopen_uri = $branch->getURI('re-open/');
|
||||||
|
|
||||||
|
$actions->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Edit Branch'))
|
||||||
|
->setHref($edit_uri)
|
||||||
|
->setIcon('edit')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
if ($branch->getIsActive()) {
|
||||||
|
$actions->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Close Branch'))
|
||||||
|
->setHref($close_uri)
|
||||||
|
->setIcon('delete')
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(true));
|
||||||
|
} else {
|
||||||
|
$actions->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Reopen Branch'))
|
||||||
|
->setHref($reopen_uri)
|
||||||
|
->setIcon('new')
|
||||||
|
->setUser($viewer)
|
||||||
|
->setRenderAsForm(true)
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$properties = id(new PhabricatorPropertyListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($branch);
|
||||||
|
|
||||||
|
$properties->addProperty(
|
||||||
|
pht('Branch'),
|
||||||
|
$branch->getName());
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$header,
|
||||||
|
$actions,
|
||||||
|
$properties,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,25 +90,8 @@ final class ReleephProjectViewController extends ReleephProjectController
|
||||||
->setHref($branch->getURI())
|
->setHref($branch->getURI())
|
||||||
->addAttribute($branch_link);
|
->addAttribute($branch_link);
|
||||||
|
|
||||||
$item->addAction(
|
if (!$branch->getIsActive()) {
|
||||||
id(new PHUIListItemView())
|
|
||||||
->setIcon('edit')
|
|
||||||
->setHref($branch->getURI('edit/')));
|
|
||||||
|
|
||||||
if ($branch->getIsActive()) {
|
|
||||||
$item->setBarColor('blue');
|
|
||||||
$item->addAction(
|
|
||||||
id(new PHUIListItemView())
|
|
||||||
->setIcon('delete')
|
|
||||||
->setWorkflow(true)
|
|
||||||
->setHref($branch->getURI('close/')));
|
|
||||||
} else {
|
|
||||||
$item->setDisabled(true);
|
$item->setDisabled(true);
|
||||||
$item->addAction(
|
|
||||||
id(new PHUIListItemView())
|
|
||||||
->setIcon('enable')
|
|
||||||
->setWorkflow(true)
|
|
||||||
->setHref($branch->getURI('re-open/')));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$commit = $branch->getCutPointCommit();
|
$commit = $branch->getCutPointCommit();
|
||||||
|
|
Loading…
Reference in a new issue