mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Don't allow duplicate panels on dashboards
Summary: Fixes T10145. I went with "don't add two panels", since panels are easy to create, I expect this to be a reasonable limit until we have better use cases. Test Plan: Try to add the same panel twice, get error. Add panel normally fine, move panels fine, edit panels fine. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T10145 Differential Revision: https://secure.phabricator.com/D17351
This commit is contained in:
parent
128a9d13fc
commit
5556f0e45a
1 changed files with 12 additions and 3 deletions
|
@ -10,6 +10,7 @@ final class PhabricatorDashboardAddPanelController
|
|||
$dashboard = id(new PhabricatorDashboardQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->needPanels(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
|
@ -33,9 +34,18 @@ final class PhabricatorDashboardAddPanelController
|
|||
->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 @@ final class PhabricatorDashboardAddPanelController
|
|||
->setDatasource(new PhabricatorDashboardPanelDatasource())
|
||||
->setLimit(1)
|
||||
->setName('panel')
|
||||
->setLabel(pht('Panel'))
|
||||
->setValue($v_panel));
|
||||
->setLabel(pht('Panel')));
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Add Panel'))
|
||||
|
|
Loading…
Reference in a new issue