From 33b77e4abf9ea9abf1ad8f62880f0f140a015008 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 20 Feb 2018 17:06:09 -0800 Subject: [PATCH] (stable) Make dashboard arrange actions (move, add, remove) work again after read locking from "chaos reduction" Summary: See PHI385. Ref T13054. Ref T13083. The dashboard "arrange" operations (add, remove, move) rely on doing `$dashboard->setThing(...)` and then applying transactions. This no longer works after the read locking change from T13054. To make this function again, just add an explicit `save()` after layout adjustment. This should be more nuanced eventually, but all arrange operations are nonfunctional in a corrupting way at HEAD of `master`/`stable`, so stop the bleeding first. Test Plan: - Created new empty and template dashboards. - Moved panels. - Added new and existing panels. - Removed panels. Maniphest Tasks: T13083, T13054 Differential Revision: https://secure.phabricator.com/D19123 --- .../dashboard/storage/PhabricatorDashboard.php | 8 ++++++++ .../typeahead/PhabricatorDashboardPanelDatasource.php | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/applications/dashboard/storage/PhabricatorDashboard.php b/src/applications/dashboard/storage/PhabricatorDashboard.php index b79fded93f..2e673de19c 100644 --- a/src/applications/dashboard/storage/PhabricatorDashboard.php +++ b/src/applications/dashboard/storage/PhabricatorDashboard.php @@ -74,7 +74,15 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO public function setLayoutConfigFromObject( PhabricatorDashboardLayoutConfig $object) { + $this->setLayoutConfig($object->toDictionary()); + + // See PHI385. Dashboard panel mutations rely on changes to the Dashboard + // object persisting when transactions are applied, but this assumption is + // no longer valid after T13054. For now, just save the dashboard + // explicitly. + $this->save(); + return $this; } diff --git a/src/applications/dashboard/typeahead/PhabricatorDashboardPanelDatasource.php b/src/applications/dashboard/typeahead/PhabricatorDashboardPanelDatasource.php index d534d32adc..8bbdb1a5e5 100644 --- a/src/applications/dashboard/typeahead/PhabricatorDashboardPanelDatasource.php +++ b/src/applications/dashboard/typeahead/PhabricatorDashboardPanelDatasource.php @@ -34,8 +34,10 @@ final class PhabricatorDashboardPanelDatasource $impl = $panel->getImplementation(); if ($impl) { $type_text = $impl->getPanelTypeName(); + $icon = $impl->getIcon(); } else { $type_text = nonempty($panel->getPanelType(), pht('Unknown Type')); + $icon = 'fa-question'; } $id = $panel->getID(); $monogram = $panel->getMonogram(); @@ -44,7 +46,7 @@ final class PhabricatorDashboardPanelDatasource $result = id(new PhabricatorTypeaheadResult()) ->setName($monogram.' '.$panel->getName()) ->setPHID($id) - ->setIcon($impl->getIcon()) + ->setIcon($icon) ->addAttribute($type_text); if (!empty($properties['class'])) {