Page MenuHomePhabricator

D17351.diff
No OneTemporary

D17351.diff

diff --git a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
@@ -10,6 +10,7 @@
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($id))
+ ->needPanels(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -33,9 +34,18 @@
->withIDs(array($v_panel))
->executeOne();
if (!$panel) {
- $errors[] = pht('No such panel!');
+ $errors[] = pht('Not a valid panel.');
$e_panel = pht('Invalid');
}
+
+ $on_dashboard = $dashboard->getPanels();
+ $on_ids = mpull($on_dashboard, null, 'getID');
+ if (array_key_exists($v_panel, $on_ids)) {
+ $p_name = $panel->getName();
+ $errors[] = pht('Panel "%s" already exists on dashboard.', $p_name);
+ $e_panel = pht('Invalid');
+ }
+
} else {
$errors[] = pht('Select a panel to add.');
$e_panel = pht('Required');
@@ -81,8 +91,7 @@
->setDatasource(new PhabricatorDashboardPanelDatasource())
->setLimit(1)
->setName('panel')
- ->setLabel(pht('Panel'))
- ->setValue($v_panel));
+ ->setLabel(pht('Panel')));
return $this->newDialog()
->setTitle(pht('Add Panel'))

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 2:35 AM (7 h, 20 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6773278
Default Alt Text
D17351.diff (1 KB)

Event Timeline