@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.

Move edit/deactivate operations onto project view page in Releeph

Summary:
Ref T3092.

Releeph's objects basically go like this:

- At the top level, we have Projects (like "www" or "libphutil")
- Each project has Branches (like "LATEST" or "v1.1.3")
- Each branch has Requests (like pull requests, e.g. "please merge commit X into branch Y (in project Z)")

Currently, there's no real "project detail" or "branch detail" page. Instead, we have a search results page for their contained objects. That is, the "project detail" page shows a list of branches in the project, using ApplicationSearch.

This means that operations like "edit" and "deactivate" are one level up, on the respective list pages.

Instead, move details onto the detail pages. This gives us more room for actions and information, and simplifies the list views.

Basically, these are "detail pages" where the object content is a search interface. We do something simliar to this in Phame right now, although it's messier there (no ApplicationSearch yet).

@chad, you might have some ideas here. Roughly, the design question is "How should we present an object's detail view when its content is really a search interface (Phame Blog for Posts, Releeph Project for Branches)?"

I think the simple approach I've taken here (see screenshot) gives us reasonable results, but overall it's something we haven't done much or done too much thinking about, I think.

Test Plan: {F54774}

Reviewers: btrahan

Reviewed By: btrahan

CC: chad, aran

Maniphest Tasks: T3092

Differential Revision: https://secure.phabricator.com/D6771

+133 -63
+4 -1
src/applications/releeph/controller/ReleephProjectController.php
··· 16 16 $project_id = idx($data, 'projectID'); 17 17 $project_name = idx($data, 'projectName'); 18 18 if ($project_id) { 19 - $project = id(new ReleephProject())->load($project_id); 19 + $project = id(new ReleephProjectQuery()) 20 + ->setViewer($this->getRequest()->getUser()) 21 + ->withIDs(array($project_id)) 22 + ->executeOne(); 20 23 if (!$project) { 21 24 throw new Exception( 22 25 "ReleephProject with id '{$project_id}' not found!");
+24 -36
src/applications/releeph/controller/project/ReleephProjectActionController.php
··· 11 11 12 12 public function processRequest() { 13 13 $request = $this->getRequest(); 14 + $viewer = $request->getUser(); 14 15 15 16 $action = $this->action; 16 - $rph_project = $this->getReleephProject(); 17 + 18 + $project = id(new ReleephProjectQuery()) 19 + ->withIDs(array($this->getReleephProject()->getID())) 20 + ->requireCapabilities( 21 + array( 22 + PhabricatorPolicyCapability::CAN_VIEW, 23 + PhabricatorPolicyCapability::CAN_EDIT, 24 + )) 25 + ->setViewer($viewer) 26 + ->executeOne(); 27 + if (!$project) { 28 + return new Aphront404Response(); 29 + } 30 + 31 + $project_id = $project->getID(); 32 + $project_uri = $this->getApplicationURI("project/{$project_id}/"); 17 33 18 34 switch ($action) { 19 35 case 'deactivate': 20 36 if ($request->isDialogFormPost()) { 21 - $rph_project->deactivate($request->getUser())->save(); 22 - return id(new AphrontRedirectResponse())->setURI('/releeph'); 37 + $project->deactivate($viewer)->save(); 38 + return id(new AphrontRedirectResponse())->setURI($project_uri); 23 39 } 24 40 25 41 $dialog = id(new AphrontDialogView()) ··· 29 45 'p', 30 46 array(), 31 47 pht('Really deactivate the Releeph project: %s?', 32 - $rph_project->getName()))) 33 - ->appendChild(phutil_tag( 34 - 'p', 35 - array(), 36 - pht('It will still exist, but '. 37 - 'will be hidden from the list of active projects.'))) 38 - ->addSubmitButton(pht('Deactivate Releeph Project')) 39 - ->addCancelButton($request->getRequestURI()); 48 + $project->getName()))) 49 + ->addSubmitButton(pht('Deactivate Project')) 50 + ->addCancelButton($project_uri); 40 51 41 52 return id(new AphrontDialogResponse())->setDialog($dialog); 42 - 43 53 case 'activate': 44 - $rph_project->setIsActive(1)->save(); 45 - return id(new AphrontRedirectResponse())->setURI('/releeph'); 46 - 47 - case 'delete': 48 - if ($request->isDialogFormPost()) { 49 - $rph_project->delete(); 50 - return id(new AphrontRedirectResponse()) 51 - ->setURI('/releeph/project/inactive'); 52 - } 53 - 54 - $dialog = id(new AphrontDialogView()) 55 - ->setUser($request->getUser()) 56 - ->setTitle(pht('Really delete Releeph Project?')) 57 - ->appendChild(phutil_tag( 58 - 'p', 59 - array(), 60 - pht('Really delete the Releeph project: %s? '. 61 - 'This cannot be undone!'), 62 - $rph_project->getName())) 63 - ->setHeaderColor(PhabricatorActionHeaderView::HEADER_RED) 64 - ->addSubmitButton(pht('Delete')) 65 - ->addCancelButton($request->getRequestURI()); 66 - return id(new AphrontDialogResponse())->setDialog($dialog); 67 - 54 + $project->setIsActive(1)->save(); 55 + return id(new AphrontRedirectResponse())->setURI($project_uri); 68 56 } 69 57 } 70 58 }
+1 -26
src/applications/releeph/controller/project/ReleephProjectListController.php
··· 39 39 ->setHeader($project->getName()) 40 40 ->setHref($this->getApplicationURI("project/{$id}/")); 41 41 42 - $edit_uri = $this->getApplicationURI("project/{$id}/edit/"); 43 - $item->addAction( 44 - id(new PHUIListItemView()) 45 - ->setIcon('edit') 46 - ->setHref($edit_uri)); 47 - 48 - if ($project->getIsActive()) { 49 - $disable_uri = $this->getApplicationURI( 50 - "project/{$id}/action/deactivate/"); 51 - 52 - $item->addAction( 53 - id(new PHUIListItemView()) 54 - ->setIcon('delete') 55 - ->setName(pht('Deactivate')) 56 - ->setWorkflow(true) 57 - ->setHref($disable_uri)); 58 - } else { 59 - $enable_uri = $this->getApplicationURI( 60 - "project/{$id}/action/activate/"); 61 - 42 + if (!$project->getIsActive()) { 62 43 $item->setDisabled(true); 63 44 $item->addIcon('none', pht('Inactive')); 64 - $item->addAction( 65 - id(new PHUIListItemView()) 66 - ->setIcon('new') 67 - ->setName(pht('Reactivate')) 68 - ->setWorkflow(true) 69 - ->setHref($enable_uri)); 70 45 } 71 46 72 47 $repo = $project->getRepository();
+89
src/applications/releeph/controller/project/ReleephProjectViewController.php
··· 18 18 $request = $this->getRequest(); 19 19 $controller = id(new PhabricatorApplicationSearchController($request)) 20 20 ->setQueryKey($this->queryKey) 21 + ->setPreface($this->renderPreface()) 21 22 ->setSearchEngine( 22 23 id(new ReleephBranchSearchEngine()) 23 24 ->setProjectID($this->getReleephProject()->getID())) ··· 163 164 ->setIcon('create')); 164 165 165 166 return $crumbs; 167 + } 168 + 169 + private function renderPreface() { 170 + $project = $this->getReleephProject(); 171 + $viewer = $this->getRequest()->getUser(); 172 + 173 + $id = $project->getID(); 174 + 175 + $header = id(new PhabricatorHeaderView()) 176 + ->setHeader($project->getName()); 177 + 178 + if (!$project->getIsActive()) { 179 + $header->addTag( 180 + id(new PhabricatorTagView()) 181 + ->setType(PhabricatorTagView::TYPE_STATE) 182 + ->setBackgroundColor(PhabricatorTagView::COLOR_BLACK) 183 + ->setName(pht('Deactivated'))); 184 + } 185 + 186 + $actions = id(new PhabricatorActionListView()) 187 + ->setUser($viewer) 188 + ->setObject($project) 189 + ->setObjectURI($this->getRequest()->getRequestURI()); 190 + 191 + $can_edit = PhabricatorPolicyFilter::hasCapability( 192 + $viewer, 193 + $project, 194 + PhabricatorPolicyCapability::CAN_EDIT); 195 + 196 + $edit_uri = $this->getApplicationURI("project/{$id}/edit/"); 197 + 198 + $deactivate_uri = "project/{$id}/action/deactivate/"; 199 + $deactivate_uri = $this->getApplicationURI($deactivate_uri); 200 + 201 + $reactivate_uri = "project/{$id}/action/activate/"; 202 + $reactivate_uri = $this->getApplicationURI($reactivate_uri); 203 + 204 + $actions->addAction( 205 + id(new PhabricatorActionView()) 206 + ->setName(pht('Edit Project')) 207 + ->setHref($edit_uri) 208 + ->setIcon('edit') 209 + ->setDisabled(!$can_edit) 210 + ->setWorkflow(!$can_edit)); 211 + 212 + if ($project->getIsActive()) { 213 + $actions->addAction( 214 + id(new PhabricatorActionView()) 215 + ->setName(pht('Deactivate Project')) 216 + ->setHref($deactivate_uri) 217 + ->setIcon('delete') 218 + ->setDisabled(!$can_edit) 219 + ->setWorkflow(true)); 220 + } else { 221 + $actions->addAction( 222 + id(new PhabricatorActionView()) 223 + ->setName(pht('Reactivate Project')) 224 + ->setHref($reactivate_uri) 225 + ->setIcon('new') 226 + ->setUser($viewer) 227 + ->setRenderAsForm(true) 228 + ->setDisabled(!$can_edit) 229 + ->setWorkflow(true)); 230 + } 231 + 232 + 233 + $properties = id(new PhabricatorPropertyListView()) 234 + ->setUser($viewer) 235 + ->setObject($project); 236 + 237 + $properties->addProperty( 238 + pht('Repository'), 239 + $project->getRepository()->getName()); 240 + 241 + $pushers = $project->getPushers(); 242 + if ($pushers) { 243 + $this->loadHandles($pushers); 244 + $properties->addProperty( 245 + pht('Pushers'), 246 + $this->renderHandlesForPHIDs($pushers)); 247 + } 248 + 249 + return array( 250 + $header, 251 + $actions, 252 + $properties, 253 + ); 254 + 166 255 } 167 256 168 257 }
+1
src/applications/releeph/storage/ReleephProject.php
··· 181 181 public function getCapabilities() { 182 182 return array( 183 183 PhabricatorPolicyCapability::CAN_VIEW, 184 + PhabricatorPolicyCapability::CAN_EDIT, 184 185 ); 185 186 } 186 187
+14
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 6 6 private $searchEngine; 7 7 private $navigation; 8 8 private $queryKey; 9 + private $preface; 10 + 11 + public function setPreface($preface) { 12 + $this->preface = $preface; 13 + return $this; 14 + } 15 + 16 + public function getPreface() { 17 + return $this->preface; 18 + } 9 19 10 20 public function setQueryKey($query_key) { 11 21 $this->queryKey = $query_key; ··· 164 174 pht('Hide Query'), 165 175 $description, 166 176 $this->getApplicationURI('query/advanced/?query='.$query_key)); 177 + } 178 + 179 + if ($this->getPreface()) { 180 + $nav->appendChild($this->getPreface()); 167 181 } 168 182 169 183 $nav->appendChild($filter_view);