From d9e75f00b1977da7325db14554729419f5fe02c9 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 13 Sep 2022 13:03:35 +0200 Subject: move widget options into a Option class Signed-off-by: Robin Appelman --- lib/public/Dashboard/IItemOptionWidget.php | 37 ----------------- lib/public/Dashboard/IOptionWidget.php | 37 +++++++++++++++++ lib/public/Dashboard/Model/WidgetButton.php | 6 +-- lib/public/Dashboard/Model/WidgetOptions.php | 61 ++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 40 deletions(-) delete mode 100644 lib/public/Dashboard/IItemOptionWidget.php create mode 100644 lib/public/Dashboard/IOptionWidget.php create mode 100644 lib/public/Dashboard/Model/WidgetOptions.php (limited to 'lib/public/Dashboard') diff --git a/lib/public/Dashboard/IItemOptionWidget.php b/lib/public/Dashboard/IItemOptionWidget.php deleted file mode 100644 index 9826286b041..00000000000 --- a/lib/public/Dashboard/IItemOptionWidget.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ -namespace OCP\Dashboard; - -/** - * Allow getting widget options - * - * @since 25.0.0 - */ -interface IItemOptionWidget extends IWidget { - /** - * Should the item icons be rendered round (or raw/square) by the clients? - * - * @return bool - */ - public function getItemIconsRound(): bool; -} diff --git a/lib/public/Dashboard/IOptionWidget.php b/lib/public/Dashboard/IOptionWidget.php new file mode 100644 index 00000000000..0cc129a5087 --- /dev/null +++ b/lib/public/Dashboard/IOptionWidget.php @@ -0,0 +1,37 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCP\Dashboard; + +use OCP\Dashboard\Model\WidgetOptions; + +/** + * Allow getting widget options + * + * @since 25.0.0 + */ +interface IOptionWidget extends IWidget { + /** + * Get additional options for the widget + */ + public function getWidgetOptions(): WidgetOptions; +} diff --git a/lib/public/Dashboard/Model/WidgetButton.php b/lib/public/Dashboard/Model/WidgetButton.php index c56ab232963..f3e706bf652 100644 --- a/lib/public/Dashboard/Model/WidgetButton.php +++ b/lib/public/Dashboard/Model/WidgetButton.php @@ -29,9 +29,9 @@ namespace OCP\Dashboard\Model; * @since 25.0.0 */ class WidgetButton { - const TYPE_NEW = 'new'; - const TYPE_MORE = 'more'; - const TYPE_SETUP = 'setup'; + public const TYPE_NEW = 'new'; + public const TYPE_MORE = 'more'; + public const TYPE_SETUP = 'setup'; private string $type; private string $link; diff --git a/lib/public/Dashboard/Model/WidgetOptions.php b/lib/public/Dashboard/Model/WidgetOptions.php new file mode 100644 index 00000000000..44efdbda457 --- /dev/null +++ b/lib/public/Dashboard/Model/WidgetOptions.php @@ -0,0 +1,61 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\Dashboard\Model; + +/** + * Option for displaying a widget + * + * @since 25.0.0 + */ +class WidgetOptions { + private bool $roundItemIcons; + + /** + * @param bool $roundItemIcons + * @since 25.0.0 + */ + public function __construct(bool $roundItemIcons) { + $this->roundItemIcons = $roundItemIcons; + } + + /** + * Get the default set of options + * + * @return WidgetOptions + * @since 25.0.0 + */ + public static function getDefault(): WidgetOptions { + return new WidgetOptions(false); + } + + /** + * Whether the clients should render icons for widget items as round icons + * + * @return bool + * @since 25.0.0 + */ + public function withRoundItemIcons(): bool { + return $this->roundItemIcons; + } +} -- cgit v1.2.3