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

Sync up UI with actual policy rules in Phame

Summary: Fixes T10504. The "Create Blog" buttons weren't generated by EditEngine, but should be, so that the UI and policies are in sync.

Test Plan:
- Viewed blog list as user with and without permission to create blogs. Saw correct button state.
- Tried to create blogs, saw correct result.
- Viewed empty state of home, clicked "New Blog" buttons.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10504

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

+33 -57
+2 -2
src/applications/phame/application/PhabricatorPhameApplication.php
··· 60 60 'blog/' => array( 61 61 '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhameBlogListController', 62 62 'archive/(?P<id>[^/]+)/' => 'PhameBlogArchiveController', 63 - 'edit/(?P<id>[^/]+)/' => 'PhameBlogEditController', 63 + $this->getEditRoutePattern('edit/') 64 + => 'PhameBlogEditController', 64 65 'view/(?P<blogID>\d+)/' => 'PhameBlogViewController', 65 66 'manage/(?P<id>[^/]+)/' => 'PhameBlogManageController', 66 67 'feed/(?P<id>[^/]+)/' => 'PhameBlogFeedController', 67 - 'new/' => 'PhameBlogEditController', 68 68 'picture/(?P<id>[1-9]\d*)/' => 'PhameBlogProfilePictureController', 69 69 ), 70 70 ) + $this->getResourceSubroutes(),
+11 -22
src/applications/phame/controller/PhameHomeController.php
··· 6 6 return true; 7 7 } 8 8 9 + protected function buildApplicationCrumbs() { 10 + $crumbs = parent::buildApplicationCrumbs(); 11 + 12 + id(new PhameBlogEditEngine()) 13 + ->setViewer($this->getViewer()) 14 + ->addActionToCrumbs($crumbs); 15 + 16 + return $crumbs; 17 + } 18 + 9 19 public function handleRequest(AphrontRequest $request) { 10 20 $viewer = $request->getViewer(); 11 21 ··· 44 54 $create_button = id(new PHUIButtonView()) 45 55 ->setTag('a') 46 56 ->setText(pht('Create a Blog')) 47 - ->setHref('/phame/blog/new/') 57 + ->setHref('/phame/blog/edit/') 48 58 ->setColor(PHUIButtonView::GREEN); 49 59 50 60 $post_list = id(new PHUIBigInfoView()) ··· 116 126 array( 117 127 $phame_home, 118 128 )); 119 - 120 - 121 - } 122 - 123 - private function renderBlogs($viewer, $blogs) {} 124 - 125 - protected function buildApplicationCrumbs() { 126 - $crumbs = parent::buildApplicationCrumbs(); 127 - 128 - $can_create = $this->hasApplicationCapability( 129 - PhameBlogCreateCapability::CAPABILITY); 130 - 131 - $crumbs->addAction( 132 - id(new PHUIListItemView()) 133 - ->setName(pht('New Blog')) 134 - ->setHref($this->getApplicationURI('/blog/new/')) 135 - ->setIcon('fa-plus-square') 136 - ->setDisabled(!$can_create) 137 - ->setWorkflow(!$can_create)); 138 - 139 - return $crumbs; 140 129 } 141 130 142 131 }
+6 -31
src/applications/phame/controller/blog/PhameBlogListController.php
··· 7 7 } 8 8 9 9 public function handleRequest(AphrontRequest $request) { 10 - $query_key = $request->getURIData('queryKey'); 11 - $controller = id(new PhabricatorApplicationSearchController()) 12 - ->setQueryKey($query_key) 13 - ->setSearchEngine(new PhameBlogSearchEngine()) 14 - ->setNavigation($this->buildSideNavView()); 15 - 16 - return $this->delegateToController($controller); 10 + return id(new PhameBlogSearchEngine()) 11 + ->setController($this) 12 + ->buildResponse(); 17 13 } 18 14 19 - public function buildSideNavView() { 20 - $viewer = $this->getRequest()->getUser(); 21 - 22 - $nav = new AphrontSideNavFilterView(); 23 - $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 24 - 25 - id(new PhameBlogSearchEngine()) 26 - ->setViewer($viewer) 27 - ->addNavigationItems($nav->getMenu()); 28 - 29 - $nav->selectFilter(null); 30 - 31 - return $nav; 32 - } 33 15 34 16 protected function buildApplicationCrumbs() { 35 17 $crumbs = parent::buildApplicationCrumbs(); 36 18 37 - $can_create = $this->hasApplicationCapability( 38 - PhameBlogCreateCapability::CAPABILITY); 39 - 40 - $crumbs->addAction( 41 - id(new PHUIListItemView()) 42 - ->setName(pht('New Blog')) 43 - ->setHref($this->getApplicationURI('/blog/new/')) 44 - ->setIcon('fa-plus-square') 45 - ->setDisabled(!$can_create) 46 - ->setWorkflow(!$can_create)); 19 + id(new PhameBlogEditEngine()) 20 + ->setViewer($this->getViewer()) 21 + ->addActionToCrumbs($crumbs); 47 22 48 23 return $crumbs; 49 24 }
+13 -1
src/applications/phame/editor/PhameBlogEditEngine.php
··· 46 46 return pht('Create Blog'); 47 47 } 48 48 49 + protected function getObjectCreateCancelURI($object) { 50 + return $this->getApplication()->getApplicationURI('blog/'); 51 + } 52 + 53 + protected function getEditorURI() { 54 + return $this->getApplication()->getApplicationURI('blog/edit/'); 55 + } 56 + 49 57 protected function getObjectViewURI($object) { 50 58 return $object->getManageURI(); 51 59 } 52 60 61 + protected function getCreateNewObjectPolicy() { 62 + return $this->getApplication()->getPolicy( 63 + PhameBlogCreateCapability::CAPABILITY); 64 + } 65 + 53 66 protected function buildCustomEditFields($object) { 54 - 55 67 return array( 56 68 id(new PhabricatorTextEditField()) 57 69 ->setKey('name')
+1 -1
src/applications/phame/view/PhameBlogListView.php
··· 72 72 $list = phutil_tag( 73 73 'a', 74 74 array( 75 - 'href' => '/phame/blog/new/', 75 + 'href' => '/phame/blog/edit/', 76 76 ), 77 77 pht('Create a Blog')); 78 78 }