@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+95 -22
+17 -2
src/applications/releeph/controller/ReleephProjectController.php
··· 11 11 * referenced in the URL. 12 12 */ 13 13 public function willProcessRequest(array $data) { 14 + $viewer = $this->getRequest()->getUser(); 15 + 14 16 // Project 15 17 $project = null; 16 18 $project_id = idx($data, 'projectID'); 17 19 $project_name = idx($data, 'projectName'); 18 20 if ($project_id) { 19 21 $project = id(new ReleephProjectQuery()) 20 - ->setViewer($this->getRequest()->getUser()) 22 + ->setViewer($viewer) 21 23 ->withIDs(array($project_id)) 22 24 ->executeOne(); 23 25 if (!$project) { ··· 38 40 $branch_id = idx($data, 'branchID'); 39 41 $branch_name = idx($data, 'branchName'); 40 42 if ($branch_id) { 41 - $branch = id(new ReleephBranch())->load($branch_id); 43 + $branch = id(new ReleephBranchQuery()) 44 + ->setViewer($viewer) 45 + ->withIDs(array($branch_id)) 46 + ->executeOne(); 42 47 if (!$branch) { 43 48 throw new Exception("Branch with id '{$branch_id}' not found!"); 44 49 } ··· 56 61 throw new Exception( 57 62 "ReleephBranch with basename '{$branch_name}' not found ". 58 63 "in project '{$project->getName()}'!"); 64 + } 65 + // Do the branch query again, properly, to hit policies and load attached 66 + // data. 67 + // TODO: Clean this up with T3657. 68 + $branch = id(new ReleephBranchQuery()) 69 + ->setViewer($viewer) 70 + ->withIDs(array($branch->getID())) 71 + ->executeOne(); 72 + if (!$branch) { 73 + throw new Exception('404!'); 59 74 } 60 75 } 61 76
+1 -1
src/applications/releeph/controller/branch/ReleephBranchAccessController.php
··· 13 13 $branch = $this->getReleephBranch(); 14 14 $request = $this->getRequest(); 15 15 16 - $done_uri = '/releeph/project/'.$branch->getReleephProjectID().'/'; 16 + $done_uri = $branch->getURI(); 17 17 18 18 switch ($this->action) { 19 19 case 'close':
+1 -1
src/applications/releeph/controller/branch/ReleephBranchEditController.php
··· 34 34 $releeph_branch->saveTransaction(); 35 35 36 36 return id(new AphrontRedirectResponse()) 37 - ->setURI('/releeph/project/'.$releeph_branch->getReleephProjectID()); 37 + ->setURI($releeph_branch->getURI()); 38 38 } 39 39 40 40 $phids = array();
+75
src/applications/releeph/controller/branch/ReleephBranchViewController.php
··· 19 19 $request = $this->getRequest(); 20 20 21 21 $controller = id(new PhabricatorApplicationSearchController($request)) 22 + ->setPreface($this->renderPreface()) 22 23 ->setQueryKey($this->queryKey) 23 24 ->setSearchEngine($this->getSearchEngine()) 24 25 ->setNavigation($this->buildSideNavView()); ··· 91 92 return $crumbs; 92 93 } 93 94 95 + private function renderPreface() { 96 + $branch = $this->getReleephBranch(); 97 + $viewer = $this->getRequest()->getUser(); 98 + 99 + $id = $branch->getID(); 100 + 101 + $header = id(new PhabricatorHeaderView()) 102 + ->setHeader($branch->getDisplayName()); 103 + 104 + if (!$branch->getIsActive()) { 105 + $header->addTag( 106 + id(new PhabricatorTagView()) 107 + ->setType(PhabricatorTagView::TYPE_STATE) 108 + ->setBackgroundColor(PhabricatorTagView::COLOR_BLACK) 109 + ->setName(pht('Closed'))); 110 + } 111 + 112 + $actions = id(new PhabricatorActionListView()) 113 + ->setUser($viewer) 114 + ->setObject($branch) 115 + ->setObjectURI($this->getRequest()->getRequestURI()); 116 + 117 + $can_edit = PhabricatorPolicyFilter::hasCapability( 118 + $viewer, 119 + $branch, 120 + PhabricatorPolicyCapability::CAN_EDIT); 121 + 122 + $edit_uri = $branch->getURI('edit/'); 123 + $close_uri = $branch->getURI('close/'); 124 + $reopen_uri = $branch->getURI('re-open/'); 125 + 126 + $actions->addAction( 127 + id(new PhabricatorActionView()) 128 + ->setName(pht('Edit Branch')) 129 + ->setHref($edit_uri) 130 + ->setIcon('edit') 131 + ->setDisabled(!$can_edit) 132 + ->setWorkflow(!$can_edit)); 133 + 134 + if ($branch->getIsActive()) { 135 + $actions->addAction( 136 + id(new PhabricatorActionView()) 137 + ->setName(pht('Close Branch')) 138 + ->setHref($close_uri) 139 + ->setIcon('delete') 140 + ->setDisabled(!$can_edit) 141 + ->setWorkflow(true)); 142 + } else { 143 + $actions->addAction( 144 + id(new PhabricatorActionView()) 145 + ->setName(pht('Reopen Branch')) 146 + ->setHref($reopen_uri) 147 + ->setIcon('new') 148 + ->setUser($viewer) 149 + ->setRenderAsForm(true) 150 + ->setDisabled(!$can_edit) 151 + ->setWorkflow(true)); 152 + } 153 + 154 + 155 + $properties = id(new PhabricatorPropertyListView()) 156 + ->setUser($viewer) 157 + ->setObject($branch); 158 + 159 + $properties->addProperty( 160 + pht('Branch'), 161 + $branch->getName()); 162 + 163 + return array( 164 + $header, 165 + $actions, 166 + $properties, 167 + ); 168 + } 94 169 95 170 }
+1 -18
src/applications/releeph/controller/project/ReleephProjectViewController.php
··· 90 90 ->setHref($branch->getURI()) 91 91 ->addAttribute($branch_link); 92 92 93 - $item->addAction( 94 - id(new PHUIListItemView()) 95 - ->setIcon('edit') 96 - ->setHref($branch->getURI('edit/'))); 97 - 98 - if ($branch->getIsActive()) { 99 - $item->setBarColor('blue'); 100 - $item->addAction( 101 - id(new PHUIListItemView()) 102 - ->setIcon('delete') 103 - ->setWorkflow(true) 104 - ->setHref($branch->getURI('close/'))); 105 - } else { 93 + if (!$branch->getIsActive()) { 106 94 $item->setDisabled(true); 107 - $item->addAction( 108 - id(new PHUIListItemView()) 109 - ->setIcon('enable') 110 - ->setWorkflow(true) 111 - ->setHref($branch->getURI('re-open/'))); 112 95 } 113 96 114 97 $commit = $branch->getCutPointCommit();