@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+12 -3
+12 -3
src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
··· 10 10 $dashboard = id(new PhabricatorDashboardQuery()) 11 11 ->setViewer($viewer) 12 12 ->withIDs(array($id)) 13 + ->needPanels(true) 13 14 ->requireCapabilities( 14 15 array( 15 16 PhabricatorPolicyCapability::CAN_VIEW, ··· 33 34 ->withIDs(array($v_panel)) 34 35 ->executeOne(); 35 36 if (!$panel) { 36 - $errors[] = pht('No such panel!'); 37 + $errors[] = pht('Not a valid panel.'); 38 + $e_panel = pht('Invalid'); 39 + } 40 + 41 + $on_dashboard = $dashboard->getPanels(); 42 + $on_ids = mpull($on_dashboard, null, 'getID'); 43 + if (array_key_exists($v_panel, $on_ids)) { 44 + $p_name = $panel->getName(); 45 + $errors[] = pht('Panel "%s" already exists on dashboard.', $p_name); 37 46 $e_panel = pht('Invalid'); 38 47 } 48 + 39 49 } else { 40 50 $errors[] = pht('Select a panel to add.'); 41 51 $e_panel = pht('Required'); ··· 81 91 ->setDatasource(new PhabricatorDashboardPanelDatasource()) 82 92 ->setLimit(1) 83 93 ->setName('panel') 84 - ->setLabel(pht('Panel')) 85 - ->setValue($v_panel)); 94 + ->setLabel(pht('Panel'))); 86 95 87 96 return $this->newDialog() 88 97 ->setTitle(pht('Add Panel'))