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:
parent
464979302b
commit
abcd3efa5a
5 changed files with 84 additions and 52 deletions
|
@ -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(
|
||||||
|
|
|
@ -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 ".
|
||||||
|
|
|
@ -23,17 +23,26 @@ 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());
|
||||||
$object = id(new PhabricatorObjectQuery())
|
switch ($object_phid) {
|
||||||
->setViewer($viewer)
|
case PhabricatorApplicationHome::DASHBOARD_DEFAULT:
|
||||||
->requireCapabilities(
|
if (!$viewer->getIsAdmin()) {
|
||||||
array(
|
return new Aphront404Response();
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
}
|
||||||
PhabricatorPolicyCapability::CAN_EDIT,
|
break;
|
||||||
))
|
default:
|
||||||
->withPHIDs(array($object_phid))
|
$object = id(new PhabricatorObjectQuery())
|
||||||
->executeOne();
|
->setViewer($viewer)
|
||||||
if (!$object) {
|
->requireCapabilities(
|
||||||
return new Aphront404Response();
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
|
))
|
||||||
|
->withPHIDs(array($object_phid))
|
||||||
|
->executeOne();
|
||||||
|
if (!$object) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$installer_phid = $viewer->getPHID();
|
$installer_phid = $viewer->getPHID();
|
||||||
|
@ -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,
|
|
||||||
$object_phid,
|
|
||||||
$installer_phid);
|
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
|
||||||
->setUser($viewer)
|
|
||||||
->appendChild($body);
|
|
||||||
|
|
||||||
return $this->newDialog()
|
|
||||||
->setTitle(pht('Install Dashboard'))
|
->setTitle(pht('Install Dashboard'))
|
||||||
->appendChild($form->buildLayoutView())
|
->addHiddenInput('objectPHID', $object_phid)
|
||||||
->addCancelButton($this->getCancelURI(
|
->addCancelButton($this->getCancelURI($application_class, $object_phid))
|
||||||
$application_class, $object_phid))
|
|
||||||
->addSubmitButton(pht('Install Dashboard'));
|
->addSubmitButton(pht('Install Dashboard'));
|
||||||
}
|
|
||||||
|
|
||||||
private function getBodyContent(
|
|
||||||
$application_class,
|
|
||||||
$object_phid,
|
|
||||||
$installer_phid) {
|
|
||||||
|
|
||||||
$body = array();
|
|
||||||
switch ($application_class) {
|
switch ($application_class) {
|
||||||
case 'PhabricatorApplicationHome':
|
case 'PhabricatorApplicationHome':
|
||||||
if ($installer_phid == $object_phid) {
|
if ($viewer->getPHID() == $object_phid) {
|
||||||
$body[] = phutil_tag(
|
if ($viewer->getIsAdmin()) {
|
||||||
'p',
|
$dialog->setWidth(AphrontDialogView::WIDTH_FORM);
|
||||||
array(),
|
|
||||||
pht(
|
$form = id(new AphrontFormView())
|
||||||
'Are you sure you want to install this dashboard as your '.
|
->setUser($viewer)
|
||||||
'home page?'));
|
->appendRemarkupInstructions(
|
||||||
$body[] = phutil_tag(
|
pht('Choose where to install this dashboard.'))
|
||||||
'p',
|
->appendChild(
|
||||||
array(),
|
id(new AphrontFormRadioButtonControl())
|
||||||
pht(
|
->setName('objectPHID')
|
||||||
'You will be re-directed to your spiffy new home page if you '.
|
->setValue(PhabricatorApplicationHome::DASHBOARD_DEFAULT)
|
||||||
'choose to install this dashboard.'));
|
->addButton(
|
||||||
|
PhabricatorApplicationHome::DASHBOARD_DEFAULT,
|
||||||
|
pht('Default Dashboard for All Users'),
|
||||||
|
pht(
|
||||||
|
'Install this dashboard as the global default dashboard '.
|
||||||
|
'for all users. Users can install a personal dashboard '.
|
||||||
|
'to replace it. All users who have not configured '.
|
||||||
|
'a personal dashboard will be affected by this change.'))
|
||||||
|
->addButton(
|
||||||
|
$viewer->getPHID(),
|
||||||
|
pht('Personal Home Page Dashboard'),
|
||||||
|
pht(
|
||||||
|
'Install this dashboard as your personal home page '.
|
||||||
|
'dashboard. Only you will be affected by this change.')));
|
||||||
|
|
||||||
|
$dialog->appendChild($form->buildLayoutView());
|
||||||
|
} else {
|
||||||
|
$dialog->appendParagraph(
|
||||||
|
pht('Install this dashboard on your home page?'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$body[] = phutil_tag(
|
$dialog->appendParagraph(
|
||||||
'p',
|
|
||||||
array(),
|
|
||||||
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) {
|
||||||
|
|
|
@ -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/';
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue