Don't perform DB updates when the home/pane hasn't been changed

This commit is contained in:
Yonas Habteab 2022-06-13 09:06:55 +02:00
parent 89cbc9f644
commit 51370a9e37
2 changed files with 11 additions and 7 deletions

View File

@ -41,6 +41,10 @@ class HomeForm extends BaseDashboardForm
{
if ($this->isUpdating()) {
$home = $this->dashboard->getActiveHome();
if ($home->getTitle() === $this->getPopulatedValue('title')) {
return;
}
$home->setTitle($this->getPopulatedValue('title'));
$this->dashboard->manageEntry($home);

View File

@ -88,12 +88,18 @@ class PaneForm extends BaseDashboardForm
if ($this->isUpdating()) {
$orgHome = $dashboard->getEntry($this->requestUrl->getParam('home'));
$orgPane = $orgHome->getEntry($this->getValue('org_name'));
$currentPane = clone $orgHome->getEntry($this->getValue('org_name'));
$currentPane = clone $orgPane;
$currentPane
->setHome($currentHome)
->setTitle($this->getValue('title'));
$diff = array_filter(array_diff_assoc($currentPane->toArray(), $orgPane->toArray()));
if (empty($diff)) {
return;
}
if ($orgHome->getName() !== $currentHome->getName() && $currentHome->hasEntry($currentPane->getName())) {
Notification::error(sprintf(
t('Failed to move dashboard "%s": Dashbaord pane already exists within the "%s" dashboard home'),
@ -104,12 +110,6 @@ class PaneForm extends BaseDashboardForm
return;
}
if ($currentHome->getName() === $orgHome->getName()) {
// There is no dashboard home diff so clear all the dashboard pane
// of the org home
$orgHome->setEntries([]);
}
$conn->beginTransaction();
try {