diff --git a/library/Icinga/Test/fixtures.sql b/library/Icinga/Test/fixtures.sql index 5470c8ada..e643cf3f7 100644 --- a/library/Icinga/Test/fixtures.sql +++ b/library/Icinga/Test/fixtures.sql @@ -32,10 +32,11 @@ CREATE TABLE `icingaweb_dashlet` ( `label` VARCHAR NOT NULL, `url` VARCHAR NOT NULL, `priority` tinyint NOT NULL, - `disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n', + `disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n', FOREIGN KEY (`dashboard_id`) REFERENCES `icingaweb_dashboard` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ); +-- TODO: Remove me once we have decoupled module dashlets (as a daemon job) from the actual dashboards loading action!! CREATE TABLE `icingaweb_module_dashlet` ( `id` binary(20) NOT NULL PRIMARY KEY, `name` VARCHAR NOT NULL, diff --git a/library/Icinga/Web/Dashboard/Common/DashboardEntries.php b/library/Icinga/Web/Dashboard/Common/DashboardEntries.php index 6592a3552..254719566 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardEntries.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardEntries.php @@ -4,9 +4,10 @@ namespace Icinga\Web\Dashboard\Common; +use Icinga\Exception\NotImplementedError; use Icinga\Exception\ProgrammingError; - use Icinga\Web\Dashboard\Dashboard; + use function ipl\Stdlib\get_php_type; trait DashboardEntries @@ -82,6 +83,7 @@ trait DashboardEntries public function createEntry(string $name, $url = null) { + throw new NotImplementedError('Not yet implemented by the concrete class!!'); } public function rewindEntries() diff --git a/library/Icinga/Web/Dashboard/Common/WidgetState.php b/library/Icinga/Web/Dashboard/Common/WidgetState.php index 40e2c6251..adc942adc 100644 --- a/library/Icinga/Web/Dashboard/Common/WidgetState.php +++ b/library/Icinga/Web/Dashboard/Common/WidgetState.php @@ -61,8 +61,8 @@ trait WidgetState /** * Get whether this widget is currently being loaded * - * This indicates which dashboard tab is currently open if this widget type is a Dashboard Pane - * or whether the Dashboard Home in the navigation bar is active/focused + * Indicates which dashboard tab is currently open if this widget is a Dashboard Pane type + * or whether the Dashboard Home is active/focused in the navigation bar * * @return bool */ diff --git a/library/Icinga/Web/Dashboard/DashboardHome.php b/library/Icinga/Web/Dashboard/DashboardHome.php index b8d0d78d9..aa675f212 100644 --- a/library/Icinga/Web/Dashboard/DashboardHome.php +++ b/library/Icinga/Web/Dashboard/DashboardHome.php @@ -4,6 +4,7 @@ namespace Icinga\Web\Dashboard; +use Icinga\Exception\AlreadyExistsException; use Icinga\Exception\Http\HttpNotFoundException; use Icinga\Exception\ProgrammingError; use Icinga\Model\Home; @@ -244,11 +245,11 @@ class DashboardHome extends BaseDashboard implements Sortable } else { // Failed to move the pane! Should have already been handled by the caller, // though I think it's better that we raise an exception here!! - throw new \LogicException(sprintf( + throw new AlreadyExistsException( 'Dashboard Pane "%s" could not be managed. Dashboard Home "%s" has Pane with the same name!', $pane->getTitle(), $this->getTitle() - )); + ); } $pane->setHome($this); diff --git a/library/Icinga/Web/Dashboard/Pane.php b/library/Icinga/Web/Dashboard/Pane.php index 7035230e6..9ef3281a2 100644 --- a/library/Icinga/Web/Dashboard/Pane.php +++ b/library/Icinga/Web/Dashboard/Pane.php @@ -5,6 +5,7 @@ namespace Icinga\Web\Dashboard; use Icinga\Application\Modules; +use Icinga\Exception\AlreadyExistsException; use Icinga\Web\Dashboard\Common\BaseDashboard; use Icinga\Exception\ProgrammingError; use Icinga\Exception\ConfigurationError; @@ -238,11 +239,11 @@ class Pane extends BaseDashboard implements Sortable } else { // Failed to move the pane! Should have already been handled by the caller, // though I think it's better that we raise an exception here!! - throw new \LogicException(sprintf( + throw new AlreadyExistsException( 'Dashlet "%s" could not be managed. Dashboard Pane "%s" has a Dashlet with the same name!', $dashlet->getTitle(), $this->getTitle() - )); + ); } $dashlet->setPane($this); diff --git a/test/php/library/Icinga/Web/Dashboard/DashletTest.php b/test/php/library/Icinga/Web/Dashboard/DashletTest.php index f60a51c0c..e65d19f06 100644 --- a/test/php/library/Icinga/Web/Dashboard/DashletTest.php +++ b/test/php/library/Icinga/Web/Dashboard/DashletTest.php @@ -4,6 +4,7 @@ namespace Tests\Icinga\Web\Dashboard; +use Icinga\Exception\AlreadyExistsException; use Icinga\Test\BaseDashboardTestCase; use Icinga\Web\Dashboard\Dashlet; use Icinga\Web\Dashboard\Pane; @@ -169,7 +170,7 @@ class DashletTest extends BaseDashboardTestCase public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError() { - $this->expectException(\LogicException::class); + $this->expectException(AlreadyExistsException::class); $default = $this->getTestHome(); $this->dashboard->manageEntry($default); diff --git a/test/php/library/Icinga/Web/Dashboard/PaneTest.php b/test/php/library/Icinga/Web/Dashboard/PaneTest.php index 6a780df62..eca67ad57 100644 --- a/test/php/library/Icinga/Web/Dashboard/PaneTest.php +++ b/test/php/library/Icinga/Web/Dashboard/PaneTest.php @@ -4,6 +4,7 @@ namespace Tests\Icinga\Web\Dashboard; +use Icinga\Exception\AlreadyExistsException; use Icinga\Exception\ProgrammingError; use Icinga\Test\BaseDashboardTestCase; use Icinga\Web\Dashboard\DashboardHome; @@ -176,7 +177,7 @@ class PaneTest extends BaseDashboardTestCase public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError() { - $this->expectException(\LogicException::class); + $this->expectException(AlreadyExistsException::class); $default = $this->getTestHome(); $home = $this->getTestHome('Second Home');