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

Allow administrators to set a dashboard as a global default

Summary:
Ref T4883.

- When an administrator installs a dashbord, give them the option to install it as a global default.
- On the home page, if a user does not have a dashboard installed, check for a global default.
- On the Admin NUX/Welcome page, check for a global dashboard.

Test Plan:
- Installed a global dashboard, checked homepage, saw it.
- Installed a personal dashboard over it.
- Checked non-admin flow.
- Checked Admin NUX page for quest completion.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T4883

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

+84 -52
+1
src/__phutil_library_map__.php
··· 4876 4876 2 => 'PhabricatorFlaggableInterface', 4877 4877 3 => 'PhabricatorMarkupInterface', 4878 4878 4 => 'PhabricatorDestructableInterface', 4879 + 5 => 'PhabricatorProjectInterface', 4879 4880 ), 4880 4881 'PhabricatorRepositoryArcanistProject' => 4881 4882 array(
+4 -1
src/applications/config/controller/PhabricatorConfigWelcomeController.php
··· 156 156 $content); 157 157 158 158 $dashboard_href = PhabricatorEnv::getURI('/dashboard/'); 159 - $have_dashboard = false; 159 + $have_dashboard = (bool)PhabricatorDashboardInstall::getDashboard( 160 + $viewer, 161 + PhabricatorApplicationHome::DASHBOARD_DEFAULT, 162 + 'PhabricatorApplicationHome'); 160 163 if ($have_dashboard) { 161 164 $content = pht( 162 165 "You've installed a default dashboard to replace this welcome screen ".
+69 -51
src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
··· 23 23 $dashboard_phid = $dashboard->getPHID(); 24 24 25 25 $object_phid = $request->getStr('objectPHID', $viewer->getPHID()); 26 - $object = id(new PhabricatorObjectQuery()) 27 - ->setViewer($viewer) 28 - ->requireCapabilities( 29 - array( 30 - PhabricatorPolicyCapability::CAN_VIEW, 31 - PhabricatorPolicyCapability::CAN_EDIT, 32 - )) 33 - ->withPHIDs(array($object_phid)) 34 - ->executeOne(); 35 - if (!$object) { 36 - return new Aphront404Response(); 26 + switch ($object_phid) { 27 + case PhabricatorApplicationHome::DASHBOARD_DEFAULT: 28 + if (!$viewer->getIsAdmin()) { 29 + return new Aphront404Response(); 30 + } 31 + break; 32 + default: 33 + $object = id(new PhabricatorObjectQuery()) 34 + ->setViewer($viewer) 35 + ->requireCapabilities( 36 + array( 37 + PhabricatorPolicyCapability::CAN_VIEW, 38 + PhabricatorPolicyCapability::CAN_EDIT, 39 + )) 40 + ->withPHIDs(array($object_phid)) 41 + ->executeOne(); 42 + if (!$object) { 43 + return new Aphront404Response(); 44 + } 45 + break; 37 46 } 38 47 39 48 $installer_phid = $viewer->getPHID(); ··· 64 73 ->setURI($this->getRedirectURI($application_class, $object_phid)); 65 74 } 66 75 67 - $body = $this->getBodyContent( 68 - $application_class, 69 - $object_phid, 70 - $installer_phid); 71 - 72 - $form = id(new AphrontFormView()) 73 - ->setUser($viewer) 74 - ->appendChild($body); 75 - 76 - return $this->newDialog() 76 + $dialog = $this->newDialog() 77 77 ->setTitle(pht('Install Dashboard')) 78 - ->appendChild($form->buildLayoutView()) 79 - ->addCancelButton($this->getCancelURI( 80 - $application_class, $object_phid)) 78 + ->addHiddenInput('objectPHID', $object_phid) 79 + ->addCancelButton($this->getCancelURI($application_class, $object_phid)) 81 80 ->addSubmitButton(pht('Install Dashboard')); 82 - } 83 - 84 - private function getBodyContent( 85 - $application_class, 86 - $object_phid, 87 - $installer_phid) { 88 81 89 - $body = array(); 90 82 switch ($application_class) { 91 83 case 'PhabricatorApplicationHome': 92 - if ($installer_phid == $object_phid) { 93 - $body[] = phutil_tag( 94 - 'p', 95 - array(), 96 - pht( 97 - 'Are you sure you want to install this dashboard as your '. 98 - 'home page?')); 99 - $body[] = phutil_tag( 100 - 'p', 101 - array(), 102 - pht( 103 - 'You will be re-directed to your spiffy new home page if you '. 104 - 'choose to install this dashboard.')); 84 + if ($viewer->getPHID() == $object_phid) { 85 + if ($viewer->getIsAdmin()) { 86 + $dialog->setWidth(AphrontDialogView::WIDTH_FORM); 87 + 88 + $form = id(new AphrontFormView()) 89 + ->setUser($viewer) 90 + ->appendRemarkupInstructions( 91 + pht('Choose where to install this dashboard.')) 92 + ->appendChild( 93 + id(new AphrontFormRadioButtonControl()) 94 + ->setName('objectPHID') 95 + ->setValue(PhabricatorApplicationHome::DASHBOARD_DEFAULT) 96 + ->addButton( 97 + PhabricatorApplicationHome::DASHBOARD_DEFAULT, 98 + pht('Default Dashboard for All Users'), 99 + pht( 100 + 'Install this dashboard as the global default dashboard '. 101 + 'for all users. Users can install a personal dashboard '. 102 + 'to replace it. All users who have not configured '. 103 + 'a personal dashboard will be affected by this change.')) 104 + ->addButton( 105 + $viewer->getPHID(), 106 + pht('Personal Home Page Dashboard'), 107 + pht( 108 + 'Install this dashboard as your personal home page '. 109 + 'dashboard. Only you will be affected by this change.'))); 110 + 111 + $dialog->appendChild($form->buildLayoutView()); 112 + } else { 113 + $dialog->appendParagraph( 114 + pht('Install this dashboard on your home page?')); 115 + } 105 116 } else { 106 - $body[] = phutil_tag( 107 - 'p', 108 - array(), 117 + $dialog->appendParagraph( 109 118 pht( 110 - 'Are you sure you want to install this dashboard as the home '. 111 - 'page for %s?', 112 - $this->getHandle($object_phid)->getName())); 119 + 'Install this dashboard as the home page dashboard for %s?', 120 + phutil_tag( 121 + 'strong', 122 + array(), 123 + $this->getHandle($object_phid)->getName()))); 113 124 } 114 125 break; 126 + default: 127 + throw new Exception( 128 + pht( 129 + 'Unknown dashboard application class "%s"!', 130 + $application_class)); 115 131 } 116 - return $body; 132 + 133 + return $dialog; 117 134 } 135 + 118 136 119 137 private function getCancelURI($application_class, $object_phid) { 120 138 $uri = null;
+2
src/applications/home/application/PhabricatorApplicationHome.php
··· 2 2 3 3 final class PhabricatorApplicationHome extends PhabricatorApplication { 4 4 5 + const DASHBOARD_DEFAULT = 'dashboard:default'; 6 + 5 7 public function getBaseURI() { 6 8 return '/home/'; 7 9 }
+8
src/applications/home/controller/PhabricatorHomeMainController.php
··· 21 21 $user, 22 22 $user->getPHID(), 23 23 get_class($this->getCurrentApplication())); 24 + 25 + if (!$dashboard) { 26 + $dashboard = PhabricatorDashboardInstall::getDashboard( 27 + $user, 28 + PhabricatorApplicationHome::DASHBOARD_DEFAULT, 29 + get_class($this->getCurrentApplication())); 30 + } 31 + 24 32 if ($dashboard) { 25 33 $content = id(new PhabricatorDashboardRenderingEngine()) 26 34 ->setViewer($user)