1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

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
This commit is contained in:
epriestley 2014-06-23 15:14:38 -07:00
parent 464979302b
commit abcd3efa5a
5 changed files with 84 additions and 52 deletions

View file

@ -4876,6 +4876,7 @@ phutil_register_library_map(array(
2 => 'PhabricatorFlaggableInterface', 2 => 'PhabricatorFlaggableInterface',
3 => 'PhabricatorMarkupInterface', 3 => 'PhabricatorMarkupInterface',
4 => 'PhabricatorDestructableInterface', 4 => 'PhabricatorDestructableInterface',
5 => 'PhabricatorProjectInterface',
), ),
'PhabricatorRepositoryArcanistProject' => 'PhabricatorRepositoryArcanistProject' =>
array( array(

View file

@ -156,7 +156,10 @@ final class PhabricatorConfigWelcomeController
$content); $content);
$dashboard_href = PhabricatorEnv::getURI('/dashboard/'); $dashboard_href = PhabricatorEnv::getURI('/dashboard/');
$have_dashboard = false; $have_dashboard = (bool)PhabricatorDashboardInstall::getDashboard(
$viewer,
PhabricatorApplicationHome::DASHBOARD_DEFAULT,
'PhabricatorApplicationHome');
if ($have_dashboard) { if ($have_dashboard) {
$content = pht( $content = pht(
"You've installed a default dashboard to replace this welcome screen ". "You've installed a default dashboard to replace this welcome screen ".

View file

@ -23,6 +23,13 @@ final class PhabricatorDashboardInstallController
$dashboard_phid = $dashboard->getPHID(); $dashboard_phid = $dashboard->getPHID();
$object_phid = $request->getStr('objectPHID', $viewer->getPHID()); $object_phid = $request->getStr('objectPHID', $viewer->getPHID());
switch ($object_phid) {
case PhabricatorApplicationHome::DASHBOARD_DEFAULT:
if (!$viewer->getIsAdmin()) {
return new Aphront404Response();
}
break;
default:
$object = id(new PhabricatorObjectQuery()) $object = id(new PhabricatorObjectQuery())
->setViewer($viewer) ->setViewer($viewer)
->requireCapabilities( ->requireCapabilities(
@ -35,6 +42,8 @@ final class PhabricatorDashboardInstallController
if (!$object) { if (!$object) {
return new Aphront404Response(); return new Aphront404Response();
} }
break;
}
$installer_phid = $viewer->getPHID(); $installer_phid = $viewer->getPHID();
$application_class = $request->getStr( $application_class = $request->getStr(
@ -64,58 +73,67 @@ final class PhabricatorDashboardInstallController
->setURI($this->getRedirectURI($application_class, $object_phid)); ->setURI($this->getRedirectURI($application_class, $object_phid));
} }
$body = $this->getBodyContent( $dialog = $this->newDialog()
$application_class, ->setTitle(pht('Install Dashboard'))
$object_phid, ->addHiddenInput('objectPHID', $object_phid)
$installer_phid); ->addCancelButton($this->getCancelURI($application_class, $object_phid))
->addSubmitButton(pht('Install Dashboard'));
switch ($application_class) {
case 'PhabricatorApplicationHome':
if ($viewer->getPHID() == $object_phid) {
if ($viewer->getIsAdmin()) {
$dialog->setWidth(AphrontDialogView::WIDTH_FORM);
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($viewer) ->setUser($viewer)
->appendChild($body); ->appendRemarkupInstructions(
pht('Choose where to install this dashboard.'))
return $this->newDialog() ->appendChild(
->setTitle(pht('Install Dashboard')) id(new AphrontFormRadioButtonControl())
->appendChild($form->buildLayoutView()) ->setName('objectPHID')
->addCancelButton($this->getCancelURI( ->setValue(PhabricatorApplicationHome::DASHBOARD_DEFAULT)
$application_class, $object_phid)) ->addButton(
->addSubmitButton(pht('Install Dashboard')); PhabricatorApplicationHome::DASHBOARD_DEFAULT,
} pht('Default Dashboard for All Users'),
private function getBodyContent(
$application_class,
$object_phid,
$installer_phid) {
$body = array();
switch ($application_class) {
case 'PhabricatorApplicationHome':
if ($installer_phid == $object_phid) {
$body[] = phutil_tag(
'p',
array(),
pht( pht(
'Are you sure you want to install this dashboard as your '. 'Install this dashboard as the global default dashboard '.
'home page?')); 'for all users. Users can install a personal dashboard '.
$body[] = phutil_tag( 'to replace it. All users who have not configured '.
'p', 'a personal dashboard will be affected by this change.'))
array(), ->addButton(
$viewer->getPHID(),
pht('Personal Home Page Dashboard'),
pht( pht(
'You will be re-directed to your spiffy new home page if you '. 'Install this dashboard as your personal home page '.
'choose to install this dashboard.')); 'dashboard. Only you will be affected by this change.')));
$dialog->appendChild($form->buildLayoutView());
} else { } else {
$body[] = phutil_tag( $dialog->appendParagraph(
'p', pht('Install this dashboard on your home page?'));
array(), }
} else {
$dialog->appendParagraph(
pht( pht(
'Are you sure you want to install this dashboard as the home '. 'Install this dashboard as the home page dashboard for %s?',
'page for %s?', phutil_tag(
$this->getHandle($object_phid)->getName())); 'strong',
array(),
$this->getHandle($object_phid)->getName())));
} }
break; break;
default:
throw new Exception(
pht(
'Unknown dashboard application class "%s"!',
$application_class));
} }
return $body;
return $dialog;
} }
private function getCancelURI($application_class, $object_phid) { private function getCancelURI($application_class, $object_phid) {
$uri = null; $uri = null;
switch ($application_class) { switch ($application_class) {

View file

@ -2,6 +2,8 @@
final class PhabricatorApplicationHome extends PhabricatorApplication { final class PhabricatorApplicationHome extends PhabricatorApplication {
const DASHBOARD_DEFAULT = 'dashboard:default';
public function getBaseURI() { public function getBaseURI() {
return '/home/'; return '/home/';
} }

View file

@ -21,6 +21,14 @@ final class PhabricatorHomeMainController
$user, $user,
$user->getPHID(), $user->getPHID(),
get_class($this->getCurrentApplication())); get_class($this->getCurrentApplication()));
if (!$dashboard) {
$dashboard = PhabricatorDashboardInstall::getDashboard(
$user,
PhabricatorApplicationHome::DASHBOARD_DEFAULT,
get_class($this->getCurrentApplication()));
}
if ($dashboard) { if ($dashboard) {
$content = id(new PhabricatorDashboardRenderingEngine()) $content = id(new PhabricatorDashboardRenderingEngine())
->setViewer($user) ->setViewer($user)