Page MenuHomePhabricator

D9670.diff
No OneTemporary

D9670.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4876,6 +4876,7 @@
2 => 'PhabricatorFlaggableInterface',
3 => 'PhabricatorMarkupInterface',
4 => 'PhabricatorDestructableInterface',
+ 5 => 'PhabricatorProjectInterface',
),
'PhabricatorRepositoryArcanistProject' =>
array(
diff --git a/src/applications/config/controller/PhabricatorConfigWelcomeController.php b/src/applications/config/controller/PhabricatorConfigWelcomeController.php
--- a/src/applications/config/controller/PhabricatorConfigWelcomeController.php
+++ b/src/applications/config/controller/PhabricatorConfigWelcomeController.php
@@ -156,7 +156,10 @@
$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 ".
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php b/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
@@ -23,17 +23,26 @@
$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 @@
->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) {
diff --git a/src/applications/home/application/PhabricatorApplicationHome.php b/src/applications/home/application/PhabricatorApplicationHome.php
--- a/src/applications/home/application/PhabricatorApplicationHome.php
+++ b/src/applications/home/application/PhabricatorApplicationHome.php
@@ -2,6 +2,8 @@
final class PhabricatorApplicationHome extends PhabricatorApplication {
+ const DASHBOARD_DEFAULT = 'dashboard:default';
+
public function getBaseURI() {
return '/home/';
}
diff --git a/src/applications/home/controller/PhabricatorHomeMainController.php b/src/applications/home/controller/PhabricatorHomeMainController.php
--- a/src/applications/home/controller/PhabricatorHomeMainController.php
+++ b/src/applications/home/controller/PhabricatorHomeMainController.php
@@ -21,6 +21,14 @@
$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)

File Metadata

Mime Type
text/plain
Expires
Sat, May 18, 1:14 AM (2 w, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6299285
Default Alt Text
D9670.diff (7 KB)

Event Timeline