aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-06-26 16:01:52 +0200
committerJulius Härtl <jus@bitgrid.net>2020-07-15 09:28:11 +0200
commit31a14945296047cbdd17a90c223527f4e1ad951b (patch)
tree6706b4de9b4d5422dd27991ded50a60a74400f65
parent879b7569952b8ee4a18e90310f94866bda6fce42 (diff)
downloadnextcloud-server-31a14945296047cbdd17a90c223527f4e1ad951b.tar.gz
nextcloud-server-31a14945296047cbdd17a90c223527f4e1ad951b.zip
Add load method for apps to bootstrap their panels
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--lib/private/Dashboard/Manager.php13
-rw-r--r--lib/public/Dashboard/IPanel.php18
2 files changed, 24 insertions, 7 deletions
diff --git a/lib/private/Dashboard/Manager.php b/lib/private/Dashboard/Manager.php
index f9c857f831f..c9185e0b832 100644
--- a/lib/private/Dashboard/Manager.php
+++ b/lib/private/Dashboard/Manager.php
@@ -23,11 +23,13 @@
namespace OC\Dashboard;
+use InvalidArgumentException;
use OCP\AppFramework\QueryException;
use OCP\Dashboard\IManager;
use OCP\Dashboard\IPanel;
use OCP\ILogger;
use OCP\IServerContainer;
+use Throwable;
class Manager implements IManager {
@@ -46,7 +48,7 @@ class Manager implements IManager {
private function registerPanel(IPanel $panel): void {
if (array_key_exists($panel->getId(), $this->panels)) {
- throw new \InvalidArgumentException('Dashboard panel with this id has already been registered');
+ throw new InvalidArgumentException('Dashboard panel with this id has already been registered');
}
$this->panels[$panel->getId()] = $panel;
@@ -88,6 +90,15 @@ class Manager implements IManager {
'level' => ILogger::FATAL,
]);
}
+
+ try {
+ $panel->load();
+ } catch (Throwable $e) {
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'Error during dashboard panel loading: ' . $e->getMessage(),
+ 'level' => ILogger::FATAL,
+ ]);
+ }
}
$this->lazyPanels = [];
}
diff --git a/lib/public/Dashboard/IPanel.php b/lib/public/Dashboard/IPanel.php
index d7e7b157964..78c7d09c009 100644
--- a/lib/public/Dashboard/IPanel.php
+++ b/lib/public/Dashboard/IPanel.php
@@ -32,32 +32,38 @@ namespace OCP\Dashboard;
interface IPanel {
/**
- * @return string
+ * @return string Unique id that identifies the panel, e.g. the app id
* @since 20.0.0
*/
public function getId(): string;
/**
- * @return string
+ * @return string User facing title of the panel
* @since 20.0.0
*/
public function getTitle(): string;
/**
- * @return int
+ * @return int Initial order for panel sorting
* @since 20.0.0
*/
public function getOrder(): int;
/**
- * @return string
+ * @return string css class that displays an icon next to the panel title
* @since 20.0.0
*/
public function getIconClass(): string;
/**
- * @return string The absolute url to the apps own view
+ * @return string|null The absolute url to the apps own view
* @since 20.0.0
*/
- public function getUrl(): string;
+ public function getUrl(): ?string;
+
+ /**
+ * Execute panel bootstrap code like loading scripts and providing initial state
+ * @since 20.0.0
+ */
+ public function load(): void;
}