diff options
author | Robin Appelman <robin@icewind.nl> | 2022-09-01 17:12:43 +0200 |
---|---|---|
committer | Julien Veyssier <eneiluj@posteo.net> | 2022-09-15 18:05:52 +0200 |
commit | a3912e264a26d5ab3d042e6b47e7c75d2b123ada (patch) | |
tree | 94be27661eae4128713e824b9c1d595c1a3c437e /lib/public | |
parent | 79adca6b8b9b0be024899938f6e641c0379a14ed (diff) | |
download | nextcloud-server-a3912e264a26d5ab3d042e6b47e7c75d2b123ada.tar.gz nextcloud-server-a3912e264a26d5ab3d042e6b47e7c75d2b123ada.zip |
change widget button api to support multiple button types
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/Dashboard/IButtonWidget.php | 24 | ||||
-rw-r--r-- | lib/public/Dashboard/Model/WidgetButton.php | 75 |
2 files changed, 82 insertions, 17 deletions
diff --git a/lib/public/Dashboard/IButtonWidget.php b/lib/public/Dashboard/IButtonWidget.php index cc0297fe7bc..5745c368c96 100644 --- a/lib/public/Dashboard/IButtonWidget.php +++ b/lib/public/Dashboard/IButtonWidget.php @@ -22,6 +22,8 @@ declare(strict_types=1); */ namespace OCP\Dashboard; +use OCP\Dashboard\Model\WidgetButton; + /** * Adds a button to the dashboard api representation * @@ -29,23 +31,11 @@ namespace OCP\Dashboard; */ interface IButtonWidget extends IWidget { /** - * Get the absolute url for the button target - * - * @return string - */ - public function getButtonUrl(): string; - - /** - * Get the absolute url for the button icon - * - * @return string - */ - public function getButtonIconUrl(): ?string; - - /** - * Get the text to show in the button + * Get the buttons to show on the widget * - * @return string + * @param string $userId + * @return WidgetButton[] + * @since 25.0.0 */ - public function getButtonText(): string; + public function getWidgetButtons(string $userId): array; } diff --git a/lib/public/Dashboard/Model/WidgetButton.php b/lib/public/Dashboard/Model/WidgetButton.php new file mode 100644 index 00000000000..c56ab232963 --- /dev/null +++ b/lib/public/Dashboard/Model/WidgetButton.php @@ -0,0 +1,75 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Dashboard\Model; + +/** + * Button for a dashboard widget + * + * @since 25.0.0 + */ +class WidgetButton { + const TYPE_NEW = 'new'; + const TYPE_MORE = 'more'; + const TYPE_SETUP = 'setup'; + + private string $type; + private string $link; + private string $text; + + public function __construct(string $type, string $link, string $text) { + $this->type = $type; + $this->link = $link; + $this->text = $text; + } + + /** + * Get the button type, either "new", "more" or "setup" + * + * @return string + * @since 25.0.0 + */ + public function getType(): string { + return $this->type; + } + + /** + * Get the absolute url the buttons links to + * + * @return string + * @since 25.0.0 + */ + public function getLink(): string { + return $this->link; + } + + /** + * Get the translated text for the button + * + * @return string + * @since 25.0.0 + */ + public function getText(): string { + return $this->text; + } +} |