Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-09-01 18:12:43 +0300
committerJulien Veyssier <eneiluj@posteo.net>2022-09-15 19:05:52 +0300
commita3912e264a26d5ab3d042e6b47e7c75d2b123ada (patch)
tree94be27661eae4128713e824b9c1d595c1a3c437e /lib
parent79adca6b8b9b0be024899938f6e641c0379a14ed (diff)
change widget button api to support multiple button types
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/public/Dashboard/IButtonWidget.php24
-rw-r--r--lib/public/Dashboard/Model/WidgetButton.php75
4 files changed, 84 insertions, 17 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 16ca9b856c7..3f37d7cad6f 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -200,6 +200,7 @@ return array(
'OCP\\Dashboard\\IWidget' => $baseDir . '/lib/public/Dashboard/IWidget.php',
'OCP\\Dashboard\\Model\\IWidgetConfig' => $baseDir . '/lib/public/Dashboard/Model/IWidgetConfig.php',
'OCP\\Dashboard\\Model\\IWidgetRequest' => $baseDir . '/lib/public/Dashboard/Model/IWidgetRequest.php',
+ 'OCP\\Dashboard\\Model\\WidgetButton' => $baseDir . '/lib/public/Dashboard/Model/WidgetButton.php',
'OCP\\Dashboard\\Model\\WidgetItem' => $baseDir . '/lib/public/Dashboard/Model/WidgetItem.php',
'OCP\\Dashboard\\Model\\WidgetSetting' => $baseDir . '/lib/public/Dashboard/Model/WidgetSetting.php',
'OCP\\Dashboard\\Model\\WidgetSetup' => $baseDir . '/lib/public/Dashboard/Model/WidgetSetup.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index a818d684c36..aaef7c44b8f 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -233,6 +233,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Dashboard\\IWidget' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IWidget.php',
'OCP\\Dashboard\\Model\\IWidgetConfig' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/IWidgetConfig.php',
'OCP\\Dashboard\\Model\\IWidgetRequest' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/IWidgetRequest.php',
+ 'OCP\\Dashboard\\Model\\WidgetButton' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetButton.php',
'OCP\\Dashboard\\Model\\WidgetItem' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetItem.php',
'OCP\\Dashboard\\Model\\WidgetSetting' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetSetting.php',
'OCP\\Dashboard\\Model\\WidgetSetup' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetSetup.php',
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;
+ }
+}