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

Drive menu icons from Applications

Summary:
This makes no changes, it just moves the menu icons to the applications instead of hard-coded on the page.

I'm going to try to address some of the angst in T1593 next...

Test Plan: Loaded logged-in / logged out pages. Clicked menu items. Looked at /applications/.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1593, T1569

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

+260 -63
+6
src/__phutil_library_map__.php
··· 540 540 'PhabricatorApplication' => 'applications/base/PhabricatorApplication.php', 541 541 'PhabricatorApplicationApplications' => 'applications/meta/application/PhabricatorApplicationApplications.php', 542 542 'PhabricatorApplicationAudit' => 'applications/audit/application/PhabricatorApplicationAudit.php', 543 + 'PhabricatorApplicationAuth' => 'applications/auth/application/PhabricatorApplicationAuth.php', 543 544 'PhabricatorApplicationDifferential' => 'applications/differential/application/PhabricatorApplicationDifferential.php', 544 545 'PhabricatorApplicationDiffusion' => 'applications/diffusion/application/PhabricatorApplicationDiffusion.php', 545 546 'PhabricatorApplicationFact' => 'applications/fact/application/PhabricatorApplicationFact.php', 546 547 'PhabricatorApplicationFlags' => 'applications/flag/application/PhabricatorApplicationFlags.php', 547 548 'PhabricatorApplicationLaunchView' => 'applications/meta/view/PhabricatorApplicationLaunchView.php', 548 549 'PhabricatorApplicationManiphest' => 'applications/maniphest/application/PhabricatorApplicationManiphest.php', 550 + 'PhabricatorApplicationPeople' => 'applications/people/application/PhabricatorApplicationPeople.php', 549 551 'PhabricatorApplicationPhriction' => 'applications/phriction/application/PhabricatorApplicationPhriction.php', 552 + 'PhabricatorApplicationSettings' => 'applications/people/application/PhabricatorApplicationSettings.php', 550 553 'PhabricatorApplicationStatusView' => 'applications/meta/view/PhabricatorApplicationStatusView.php', 551 554 'PhabricatorApplicationsController' => 'applications/meta/controller/PhabricatorApplicationsController.php', 552 555 'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php', ··· 1617 1620 'Phabricator404Controller' => 'PhabricatorController', 1618 1621 'PhabricatorApplicationApplications' => 'PhabricatorApplication', 1619 1622 'PhabricatorApplicationAudit' => 'PhabricatorApplication', 1623 + 'PhabricatorApplicationAuth' => 'PhabricatorApplication', 1620 1624 'PhabricatorApplicationDifferential' => 'PhabricatorApplication', 1621 1625 'PhabricatorApplicationDiffusion' => 'PhabricatorApplication', 1622 1626 'PhabricatorApplicationFact' => 'PhabricatorApplication', 1623 1627 'PhabricatorApplicationFlags' => 'PhabricatorApplication', 1624 1628 'PhabricatorApplicationLaunchView' => 'AphrontView', 1625 1629 'PhabricatorApplicationManiphest' => 'PhabricatorApplication', 1630 + 'PhabricatorApplicationPeople' => 'PhabricatorApplication', 1626 1631 'PhabricatorApplicationPhriction' => 'PhabricatorApplication', 1632 + 'PhabricatorApplicationSettings' => 'PhabricatorApplication', 1627 1633 'PhabricatorApplicationStatusView' => 'AphrontView', 1628 1634 'PhabricatorApplicationsController' => 'PhabricatorController', 1629 1635 'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController',
+4
src/aphront/AphrontController.php
··· 32 32 return; 33 33 } 34 34 35 + public function didProcessRequest($response) { 36 + return $response; 37 + } 38 + 35 39 abstract public function processRequest(); 36 40 37 41 final public function __construct(AphrontRequest $request) {
-42
src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
··· 67 67 '/phid/' => array( 68 68 '' => 'PhabricatorPHIDLookupController', 69 69 ), 70 - '/people/' => array( 71 - '' => 'PhabricatorPeopleListController', 72 - 'logs/' => 'PhabricatorPeopleLogsController', 73 - 'edit/(?:(?P<id>\d+)/(?:(?P<view>\w+)/)?)?' 74 - => 'PhabricatorPeopleEditController', 75 - 'ldap/' => 'PhabricatorPeopleLdapController', 76 - ), 77 - '/p/(?P<username>[\w._-]+)/(?:(?P<page>\w+)/)?' 78 - => 'PhabricatorPeopleProfileController', 79 70 '/conduit/' => array( 80 71 '' => 'PhabricatorConduitListController', 81 72 'method/(?P<method>[^/]+)/' => 'PhabricatorConduitConsoleController', ··· 151 142 ), 152 143 153 144 '/~/' => 'DarkConsoleController', 154 - 155 - '/settings/' => array( 156 - '(?:page/(?P<page>[^/]+)/)?' => 'PhabricatorUserSettingsController', 157 - ), 158 145 159 146 '/repository/' => array( 160 147 '' => 'PhabricatorRepositoryListController', ··· 486 473 } 487 474 488 475 public function willSendResponse(AphrontResponse $response) { 489 - $request = $this->getRequest(); 490 - $response->setRequest($request); 491 - if ($response instanceof AphrontDialogResponse) { 492 - if (!$request->isAjax()) { 493 - $view = new PhabricatorStandardPageView(); 494 - $view->setRequest($request); 495 - $view->appendChild( 496 - '<div style="padding: 2em 0;">'. 497 - $response->buildResponseString(). 498 - '</div>'); 499 - $response = new AphrontWebpageResponse(); 500 - $response->setContent($view->render()); 501 - return $response; 502 - } else { 503 - return id(new AphrontAjaxResponse()) 504 - ->setContent(array( 505 - 'dialog' => $response->buildResponseString(), 506 - )); 507 - } 508 - } else if ($response instanceof AphrontRedirectResponse) { 509 - if ($request->isAjax()) { 510 - return id(new AphrontAjaxResponse()) 511 - ->setContent( 512 - array( 513 - 'redirect' => $response->getURI(), 514 - )); 515 - } 516 - } 517 - 518 476 return $response; 519 477 } 520 478
+45
src/applications/auth/application/PhabricatorApplicationAuth.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class PhabricatorApplicationAuth extends PhabricatorApplication { 20 + 21 + public function shouldAppearInLaunchView() { 22 + return false; 23 + } 24 + 25 + public function buildMainMenuItems( 26 + PhabricatorUser $user, 27 + PhabricatorController $controller) { 28 + 29 + $items = array(); 30 + 31 + if ($user->isLoggedIn()) { 32 + require_celerity_resource('phabricator-glyph-css'); 33 + 34 + $item = new PhabricatorMainMenuIconView(); 35 + $item->setName(pht('Log Out')); 36 + $item->addClass('glyph glyph-logout'); 37 + $item->setHref('/logout/'); 38 + $item->setSortOrder(1.0); 39 + $items[] = $item; 40 + } 41 + 42 + return $items; 43 + } 44 + 45 + }
+6
src/applications/base/PhabricatorApplication.php
··· 85 85 return array(); 86 86 } 87 87 88 + public function buildMainMenuItems( 89 + PhabricatorUser $user, 90 + PhabricatorController $controller) { 91 + return array(); 92 + } 93 + 88 94 89 95 /* -( Application Management )--------------------------------------------- */ 90 96
+34
src/applications/base/controller/PhabricatorController.php
··· 111 111 public function buildStandardPageView() { 112 112 $view = new PhabricatorStandardPageView(); 113 113 $view->setRequest($this->getRequest()); 114 + $view->setController($this); 114 115 115 116 if ($this->shouldRequireAdmin()) { 116 117 $view->setIsAdminInterface(true); ··· 124 125 $page->appendChild($view); 125 126 $response = new AphrontWebpageResponse(); 126 127 $response->setContent($page->render()); 128 + return $response; 129 + } 130 + 131 + public function didProcessRequest($response) { 132 + $request = $this->getRequest(); 133 + $response->setRequest($request); 134 + if ($response instanceof AphrontDialogResponse) { 135 + if (!$request->isAjax()) { 136 + $view = new PhabricatorStandardPageView(); 137 + $view->setRequest($request); 138 + $view->setController($this); 139 + $view->appendChild( 140 + '<div style="padding: 2em 0;">'. 141 + $response->buildResponseString(). 142 + '</div>'); 143 + $response = new AphrontWebpageResponse(); 144 + $response->setContent($view->render()); 145 + return $response; 146 + } else { 147 + return id(new AphrontAjaxResponse()) 148 + ->setContent(array( 149 + 'dialog' => $response->buildResponseString(), 150 + )); 151 + } 152 + } else if ($response instanceof AphrontRedirectResponse) { 153 + if ($request->isAjax()) { 154 + return id(new AphrontAjaxResponse()) 155 + ->setContent( 156 + array( 157 + 'redirect' => $response->getURI(), 158 + )); 159 + } 160 + } 127 161 return $response; 128 162 } 129 163
+66
src/applications/people/application/PhabricatorApplicationPeople.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class PhabricatorApplicationPeople extends PhabricatorApplication { 20 + 21 + public function getShortDescription() { 22 + return 'User Accounts'; 23 + } 24 + 25 + public function getBaseURI() { 26 + return '/people/'; 27 + } 28 + 29 + public function getIconURI() { 30 + return celerity_get_resource_uri('/rsrc/image/app/app_people.png'); 31 + } 32 + 33 + public function getRoutes() { 34 + return array( 35 + '/people/' => array( 36 + '' => 'PhabricatorPeopleListController', 37 + 'logs/' => 'PhabricatorPeopleLogsController', 38 + 'edit/(?:(?P<id>\d+)/(?:(?P<view>\w+)/)?)?' 39 + => 'PhabricatorPeopleEditController', 40 + 'ldap/' => 'PhabricatorPeopleLdapController', 41 + ), 42 + '/p/(?P<username>[\w._-]+)/(?:(?P<page>\w+)/)?' 43 + => 'PhabricatorPeopleProfileController', 44 + ); 45 + } 46 + 47 + public function buildMainMenuItems( 48 + PhabricatorUser $user, 49 + PhabricatorController $controller) { 50 + 51 + $items = array(); 52 + 53 + if ($user->isLoggedIn()) { 54 + require_celerity_resource('phabricator-glyph-css'); 55 + $item = new PhabricatorMainMenuIconView(); 56 + $item->setName($user->getUsername()); 57 + $item->addClass('glyph glyph-profile'); 58 + $item->setHref('/p/'.$user->getUsername().'/'); 59 + $item->setSortOrder(0.0); 60 + $items[] = $item; 61 + } 62 + 63 + return $items; 64 + } 65 + 66 + }
+61
src/applications/people/application/PhabricatorApplicationSettings.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class PhabricatorApplicationSettings extends PhabricatorApplication { 20 + 21 + public function getBaseURI() { 22 + return '/settings/'; 23 + } 24 + 25 + public function getShortDescription() { 26 + return 'User Preferences'; 27 + } 28 + 29 + public function getIconURI() { 30 + return celerity_get_resource_uri('/rsrc/image/app/app_settings.png'); 31 + } 32 + 33 + public function getRoutes() { 34 + return array( 35 + '/settings/' => array( 36 + '(?:page/(?P<page>[^/]+)/)?' => 'PhabricatorUserSettingsController', 37 + ), 38 + ); 39 + } 40 + 41 + public function buildMainMenuItems( 42 + PhabricatorUser $user, 43 + PhabricatorController $controller) { 44 + 45 + $items = array(); 46 + 47 + if ($user->isLoggedIn()) { 48 + require_celerity_resource('phabricator-glyph-css'); 49 + 50 + $item = new PhabricatorMainMenuIconView(); 51 + $item->setName(pht('Settings')); 52 + $item->addClass('glyph glyph-settings'); 53 + $item->setHref('/settings/'); 54 + $item->setSortOrder(0.90); 55 + $items[] = $item; 56 + } 57 + 58 + return $items; 59 + } 60 + 61 + }
+20 -20
src/view/page/PhabricatorStandardPageView.php
··· 32 32 private $disableConsole; 33 33 private $searchDefaultScope; 34 34 private $pageObjects = array(); 35 + private $controller; 36 + 37 + public function setController(AphrontController $controller) { 38 + $this->controller = $controller; 39 + return $this; 40 + } 41 + 42 + public function getController() { 43 + return $this->controller; 44 + } 35 45 36 46 public function setIsAdminInterface($is_admin_interface) { 37 47 $this->isAdminInterface = $is_admin_interface; ··· 505 515 506 516 Javelin::initBehavior('phabricator-keyboard-shortcuts', $keyboard_config); 507 517 508 - if ($user->isLoggedIn()) { 509 - require_celerity_resource('phabricator-glyph-css'); 510 - 511 - $item = new PhabricatorMainMenuIconView(); 512 - $item->setName($user->getUsername()); 513 - $item->addClass('glyph glyph-profile'); 514 - $item->setHref('/p/'.$user->getUsername().'/'); 515 - $menu->appendChild($item); 516 - 517 - $item = new PhabricatorMainMenuIconView(); 518 - $item->setName(pht('Settings')); 519 - $item->addClass('glyph glyph-settings'); 520 - $item->setHref('/settings/'); 521 - $menu->appendChild($item); 522 - 523 - $item = new PhabricatorMainMenuIconView(); 524 - $item->setName(pht('Log Out')); 525 - $item->addClass('glyph glyph-logout'); 526 - $item->setHref('/logout/'); 527 - $menu->appendChild($item); 518 + $applications = PhabricatorApplication::getAllInstalledApplications(); 519 + $icon_views = array(); 520 + foreach ($applications as $application) { 521 + $icon_views[] = $application->buildMainMenuItems( 522 + $this->getRequest()->getUser(), 523 + $this->getController()); 528 524 } 525 + $icon_views = array_mergev($icon_views); 526 + $icon_views = msort($icon_views, 'getSortOrder'); 527 + 528 + $menu->appendChild($icon_views); 529 529 530 530 return $menu->render(); 531 531 }
+16
src/view/page/menu/PhabricatorMainMenuIconView.php
··· 21 21 private $classes = array(); 22 22 private $href; 23 23 private $name; 24 + private $sortOrder = 0.5; 24 25 25 26 public function setName($name) { 26 27 $this->name = $name; ··· 45 46 return $this; 46 47 } 47 48 49 + /** 50 + * Provide a float, where 0.0 is the profile item and 1.0 is the logout 51 + * item. Normally you should pick something between the two. 52 + * 53 + * @param float Sort order. 54 + * @return this 55 + */ 56 + public function setSortOrder($sort_order) { 57 + $this->sortOrder = $sort_order; 58 + return $this; 59 + } 60 + 61 + public function getSortOrder() { 62 + return $this->sortOrder; 63 + } 48 64 49 65 public function render() { 50 66 $name = $this->getName();
+2 -1
webroot/index.php
··· 192 192 if (!$response) { 193 193 $controller->willProcessRequest($uri_data); 194 194 $response = $controller->processRequest(); 195 + $response = $controller->didProcessRequest($response); 195 196 } 196 197 } catch (AphrontRedirectException $ex) { 197 198 $response = id(new AphrontRedirectResponse()) ··· 202 203 } 203 204 204 205 try { 205 - $response = $application->willSendResponse($response); 206 + $response = $application->willSendResponse($response, $controller); 206 207 $response->setRequest($request); 207 208 $response_string = $response->buildResponseString(); 208 209 } catch (Exception $ex) {
webroot/rsrc/image/app/app_people.png

This is a binary file and will not be displayed.

webroot/rsrc/image/app/app_settings.png

This is a binary file and will not be displayed.