mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +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',
|
||||
3 => 'PhabricatorMarkupInterface',
|
||||
4 => 'PhabricatorDestructableInterface',
|
||||
5 => 'PhabricatorProjectInterface',
|
||||
),
|
||||
'PhabricatorRepositoryArcanistProject' =>
|
||||
array(
|
||||
|
|
|
@ -156,7 +156,10 @@ final class PhabricatorConfigWelcomeController
|
|||
$content);
|
||||
|
||||
$dashboard_href = PhabricatorEnv::getURI('/dashboard/');
|
||||
$have_dashboard = false;
|
||||
$have_dashboard = (bool)PhabricatorDashboardInstall::getDashboard(
|
||||
$viewer,
|
||||
PhabricatorApplicationHome::DASHBOARD_DEFAULT,
|
||||
'PhabricatorApplicationHome');
|
||||
if ($have_dashboard) {
|
||||
$content = pht(
|
||||
"You've installed a default dashboard to replace this welcome screen ".
|
||||
|
|
|
@ -23,17 +23,26 @@ final class PhabricatorDashboardInstallController
|
|||
$dashboard_phid = $dashboard->getPHID();
|
||||
|
||||
$object_phid = $request->getStr('objectPHID', $viewer->getPHID());
|
||||
$object = id(new PhabricatorObjectQuery())
|
||||
->setViewer($viewer)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->withPHIDs(array($object_phid))
|
||||
->executeOne();
|
||||
if (!$object) {
|
||||
return new Aphront404Response();
|
||||
switch ($object_phid) {
|
||||
case PhabricatorApplicationHome::DASHBOARD_DEFAULT:
|
||||
if (!$viewer->getIsAdmin()) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$object = id(new PhabricatorObjectQuery())
|
||||
->setViewer($viewer)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->withPHIDs(array($object_phid))
|
||||
->executeOne();
|
||||
if (!$object) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$installer_phid = $viewer->getPHID();
|
||||
|
@ -64,58 +73,67 @@ final class PhabricatorDashboardInstallController
|
|||
->setURI($this->getRedirectURI($application_class, $object_phid));
|
||||
}
|
||||
|
||||
$body = $this->getBodyContent(
|
||||
$application_class,
|
||||
$object_phid,
|
||||
$installer_phid);
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($viewer)
|
||||
->appendChild($body);
|
||||
|
||||
return $this->newDialog()
|
||||
$dialog = $this->newDialog()
|
||||
->setTitle(pht('Install Dashboard'))
|
||||
->appendChild($form->buildLayoutView())
|
||||
->addCancelButton($this->getCancelURI(
|
||||
$application_class, $object_phid))
|
||||
->addHiddenInput('objectPHID', $object_phid)
|
||||
->addCancelButton($this->getCancelURI($application_class, $object_phid))
|
||||
->addSubmitButton(pht('Install Dashboard'));
|
||||
}
|
||||
|
||||
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(
|
||||
'Are you sure you want to install this dashboard as your '.
|
||||
'home page?'));
|
||||
$body[] = phutil_tag(
|
||||
'p',
|
||||
array(),
|
||||
pht(
|
||||
'You will be re-directed to your spiffy new home page if you '.
|
||||
'choose to install this dashboard.'));
|
||||
if ($viewer->getPHID() == $object_phid) {
|
||||
if ($viewer->getIsAdmin()) {
|
||||
$dialog->setWidth(AphrontDialogView::WIDTH_FORM);
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($viewer)
|
||||
->appendRemarkupInstructions(
|
||||
pht('Choose where to install this dashboard.'))
|
||||
->appendChild(
|
||||
id(new AphrontFormRadioButtonControl())
|
||||
->setName('objectPHID')
|
||||
->setValue(PhabricatorApplicationHome::DASHBOARD_DEFAULT)
|
||||
->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 {
|
||||
$body[] = phutil_tag(
|
||||
'p',
|
||||
array(),
|
||||
$dialog->appendParagraph(
|
||||
pht(
|
||||
'Are you sure you want to install this dashboard as the home '.
|
||||
'page for %s?',
|
||||
$this->getHandle($object_phid)->getName()));
|
||||
'Install this dashboard as the home page dashboard for %s?',
|
||||
phutil_tag(
|
||||
'strong',
|
||||
array(),
|
||||
$this->getHandle($object_phid)->getName())));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Unknown dashboard application class "%s"!',
|
||||
$application_class));
|
||||
}
|
||||
return $body;
|
||||
|
||||
return $dialog;
|
||||
}
|
||||
|
||||
|
||||
private function getCancelURI($application_class, $object_phid) {
|
||||
$uri = null;
|
||||
switch ($application_class) {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
final class PhabricatorApplicationHome extends PhabricatorApplication {
|
||||
|
||||
const DASHBOARD_DEFAULT = 'dashboard:default';
|
||||
|
||||
public function getBaseURI() {
|
||||
return '/home/';
|
||||
}
|
||||
|
|
|
@ -21,6 +21,14 @@ final class PhabricatorHomeMainController
|
|||
$user,
|
||||
$user->getPHID(),
|
||||
get_class($this->getCurrentApplication()));
|
||||
|
||||
if (!$dashboard) {
|
||||
$dashboard = PhabricatorDashboardInstall::getDashboard(
|
||||
$user,
|
||||
PhabricatorApplicationHome::DASHBOARD_DEFAULT,
|
||||
get_class($this->getCurrentApplication()));
|
||||
}
|
||||
|
||||
if ($dashboard) {
|
||||
$content = id(new PhabricatorDashboardRenderingEngine())
|
||||
->setViewer($user)
|
||||
|
|
Loading…
Reference in a new issue