Repository navigation
Public interfaces for dashboard app - #10222
Conversation
| @@ -0,0 +1,53 @@ | |||
| <?php | |||
|
|
|||
| /** | ||
| * @return string | ||
| */ | ||
| public function getId(); |
There was a problem hiding this comment.
NC14 is >php 7.0. So you can use return types
There was a problem hiding this comment.
can I use : void ? (php 7.1)
| @@ -0,0 +1,53 @@ | |||
| <?php | |||
There was a problem hiding this comment.
strict typing since we are >7.0 anyway
|
@rullzer: please have a look to the asked edit |
| * | ||
| * @param string $widgetId | ||
| */ | ||
| public function __construct(string $widgetId); |
There was a problem hiding this comment.
I wouldn't add the constructor to the interfaces.
Just call setWidgetId instead
|
@daita You will also need to adjust the following xsd files to make the dashboard section valid in the appinfo.xml: https://github.com/nextcloud/server/blob/master/resources/app-info-shipped.xsd And the app store needs those updates as well. |
|
Just a general thing, when we add new sections to the appinfo.xml like for this case, does this break apps that also support versions previous to 14? The app store only has one version-independent file to validate the appinfo, so that should work fine, but does the server also checks for a valid appinfo at some point? |
|
Yes the app check-code checks it, but additional stuff is not a problem as far as I know. |
| interface IDashboardWidget { | ||
|
|
||
| /** | ||
| * @return string |
There was a problem hiding this comment.
Missing @since 14.0.0 on the methods and the interface.
| @@ -0,0 +1,79 @@ | |||
| <?php declare(strict_types=1); | |||
There was a problem hiding this comment.
Put the declare() on a new line.
|
It's a bit late for that ... freeze was on Friday ... at least for the server PR. And also it was never brought up to be needed for 14. :/ |
|
No need to rush in the dashboard, no? We can merge it very early for 15, and then properly work on adding endpoints to the different apps and have the Dashboard app use those, like any other app. |
|
Well, you know. After working on something else for months and finally having few days to do something fun. But I get it; @nickvergessen already told me last week that I should not waste my time on it. So, no rush. |
|
So, ready for NC15. @nickvergessen : Added also a IDashboardManager that can be called with Automatic DI so there is no more API, just call the right method from the dashboardManager, that will check if app is installed or not. |
| * @throws DashboardAppNotAvailableException | ||
| */ | ||
| public function createGlobalEvent(string $widgetId, array $payload, string $uniqueId = '' | ||
| ) { |
| maxOccurs="unbounded"/> | ||
| maxOccurs="unbounded"/> | ||
| </xs:sequence> | ||
| </xs:complexType> |
There was a problem hiding this comment.
this needs to go to the appstore too
There was a problem hiding this comment.
More general why is this needed here? I don't see it being used yet.
ChristophWurst
left a comment
There was a problem hiding this comment.
Some nitpicks. Please also make sure you have a line break at the end of each file (as github shows here) to be consistent with our other source files.
Thanks!
| /** | ||
| * @since 15.0.0 | ||
| * | ||
| * @return array |
There was a problem hiding this comment.
Please add more documentation to these methods. What are they supposed to return? array is very generic 😉
| /** | ||
| * @since 15.0.0 | ||
| * | ||
| * @return array |
| * | ||
| * @param string $widgetId | ||
| */ | ||
| public function __construct(string $widgetId); |
There was a problem hiding this comment.
the interface determines the constructor interface? This doesn't seem right 🙈
| /** | ||
| * @since 15.0.0 | ||
| * | ||
| * @param string $request |
There was a problem hiding this comment.
what kind of request is this string?
| * @param string $userId | ||
| * @param string $widgetId | ||
| */ | ||
| public function __construct(string $widgetId, string $userId); |
There was a problem hiding this comment.
Please remove this. Same issue as above.
There was a problem hiding this comment.
saw that ... removed.
| <xs:sequence> | ||
| <xs:element name="widget" type="php-class" minOccurs="1" | ||
| maxOccurs="unbounded"/> | ||
| maxOccurs="unbounded"/> |
| <xs:sequence> | ||
| <xs:element name="widget" type="php-class" minOccurs="1" | ||
| maxOccurs="unbounded"/> | ||
| maxOccurs="unbounded"/> |
| } | ||
|
|
||
| try { | ||
| return \OC::$server->query($service); |
There was a problem hiding this comment.
you can inject IServerContainer in your constructor. Then you can also better unit test this.
|
🏓 Would be great to go on with this one, as it is a blocker to work on the dev of widgets for 15. |
| * 'content' => (string) path to the HTML Template of the widget, | ||
| * 'function' => (string) JavaScript function to be called when | ||
| * loading the widget on the dashboard | ||
| * ]; |
There was a problem hiding this comment.
A template object would be nice, because it is automatically properly typed and has then proper autocompletion as well. 😉
There was a problem hiding this comment.
moved to objects in various spot, pushed. Will comment during the day.
| * ] | ||
| * | ||
| * 'push' contains the JS function to be called on push event: | ||
| * 'push' => (string) JavaScript function to be called on push event |
There was a problem hiding this comment.
A settings object would be nice instead of a multidimensional array. 🤔
MorrisJobke
left a comment
There was a problem hiding this comment.
Beside the comments it looks good 👍
This comment has been minimized.
This comment has been minimized.
| */ | ||
| public function getWidgetConfig(string $widgetId, string $userId): IWidgetConfig { | ||
| /** @var \OCA\Dashboard\Service\WidgetsService $widgetsService */ | ||
| $widgetsService = $this->getService('\OCA\Dashboard\Service\WidgetsService'); |
There was a problem hiding this comment.
please use the ::class syntax, this makes finding class usages and refactoring later a lot easier 👍
There was a problem hiding this comment.
Would require another try-catch in here of course, in case the dashboard app is not here.
There was a problem hiding this comment.
Why would it? ::class is simply replaced by the FQCN (string) by the interpreter.
There was a problem hiding this comment.
I thought this would invoke autoloading and therefor throw? 🤷
There was a problem hiding this comment.
The thing is that I am not sure the app is available at this point, and calling the ::class does not clean enough
There was a problem hiding this comment.
$ php -a
Interactive shell
php > echo Joas::class;
Joas
| */ | ||
| public function createUsersEvent(string $widgetId, array $users, array $payload, string $uniqueId = '') { | ||
| /** @var \OCA\Dashboard\Service\EventsService $eventsService */ | ||
| $eventsService = $this->getService('\OCA\Dashboard\Service\EventsService'); |
| */ | ||
| public function createGroupsEvent(string $widgetId, array $groups, array $payload, string $uniqueId = '') { | ||
| /** @var \OCA\Dashboard\Service\EventsService $eventsService */ | ||
| $eventsService = $this->getService('\OCA\Dashboard\Service\EventsService'); |
| */ | ||
| public function createGlobalEvent(string $widgetId, array $payload, string $uniqueId = '') { | ||
| /** @var \OCA\Dashboard\Service\EventsService $eventsService */ | ||
| $eventsService = $this->getService('\OCA\Dashboard\Service\EventsService'); |
| /** | ||
| * @since 15.0.0 | ||
| * | ||
| * @param string $request |
| public function getInitFunction(): string; | ||
|
|
||
| /** | ||
| * JavaScript function to be called when loading the widget on the |
There was a problem hiding this comment.
how will that function be invoked? Does it have to exist globally?
There was a problem hiding this comment.
it does not have to exist globally, it is called by the app
| * | ||
| * @return array | ||
| */ | ||
| public function getCss(): array { |
There was a problem hiding this comment.
how will this CSS be loaded? Is this property the actual CSS contents or just the URL?
rullzer
left a comment
There was a problem hiding this comment.
I don't see a reason for much of this implementation to be in the server. Like the actual implementation of a lot of those classes can just be in the dashboard app itself right?
| * | ||
| * @param string $type | ||
| */ | ||
| public function __construct($type = '') { |
| maxOccurs="unbounded"/> | ||
| maxOccurs="unbounded"/> | ||
| </xs:sequence> | ||
| </xs:complexType> |
There was a problem hiding this comment.
More general why is this needed here? I don't see it being used yet.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ChristophWurst
left a comment
There was a problem hiding this comment.
Looks a lot better 👍
Let's move the implementations to the dashboard app. I don't think they should be in the server as they aren't even used directly.
Nitpick: @see WidgetSetting is a bit misleading. Not sure what it should tell me. It's also a bit misplaced in the interfaces because that would point to the private implementation. All usage should be documented in the public interfaces though 😉
| * | ||
| * @package OC\Dashboard\Model | ||
| */ | ||
| class WidgetSetting implements JsonSerializable { |
There was a problem hiding this comment.
I think this implementation can be safely move to the dashboard app
| * | ||
| * @package OC\Dashboard\Model | ||
| */ | ||
| class WidgetSetup implements JsonSerializable { |
There was a problem hiding this comment.
I think this implementation can be safely move to the dashboard app
| * | ||
| * @package OC\Dashboard\Model | ||
| */ | ||
| class WidgetTemplate implements JsonSerializable { |
There was a problem hiding this comment.
I think this implementation can be safely move to the dashboard app
|
WidgetSettings is not used outside the private namespace. Hence it must not be used by apps.
|
If a construct (class/interface) is used by an app, it has to be a public API. There are
|
|
After a bit of discussion I think I've finally understood how the different components will be used. I created a little diagram that outlines where certain classes/interfaces live: This works for @daita and clearly separates what should be in server/dashboard and other apps. This removes and dependency from server on the dashboard app. The implementation part in server (esp the private part) is minimal. The three classes for setup, settings and template were deliberately moved to OCP as classes as they are simple models (or better data transfer objects). |
Yes makes sense. |
ChristophWurst
left a comment
There was a problem hiding this comment.
Wasn't the plan to have WidgetSettings, WidgetSetup and WidgetTemplate in OCP? They're in the private namespace right now.
ChristophWurst
left a comment
There was a problem hiding this comment.
Looks good now!
You probably have to run ./build/autoloaderchecker.sh to make CI happy.
Also, please make squash this and make this a single commit change 😉
3689505 to
323c330
Compare
ChristophWurst
left a comment
There was a problem hiding this comment.
Please remove additional files and rerun autoloader command
| 'OCP\\Dashboard\\IDashboardManager' => $baseDir . '/lib/public/Dashboard/IDashboardManager.php', | ||
| 'OCP\\Dashboard\\IDashboardWidget' => $baseDir . '/lib/public/Dashboard/IDashboardWidget.php', | ||
| 'OCP\\Dashboard\\Model\\IWidgetConfig' => $baseDir . '/lib/public/Dashboard/Model/IWidgetConfig.php', | ||
| 'OCP\\Dashboard\\Model\\IWidgetRequest' => $baseDir . '/lib/public/Dashboard/Model/IWidgetRequest.php', |
ChristophWurst
left a comment
There was a problem hiding this comment.
Nvm the last review, I was confused by the interface names it seems
0880b33 to
b98fa11
Compare
Signed-off-by: Maxence Lange <[email protected]> Merge remote-tracking branch 'origin/interface-dashboard' into interface-dashboard Signed-off-by: Maxence Lange <[email protected]> moving data object to OCP Signed-off-by: Maxence Lange <[email protected]> update autoload files Signed-off-by: Maxence Lange <[email protected]> +@SInCE Signed-off-by: Maxence Lange <[email protected]>
b98fa11 to
dfd4782
Compare

No description provided.