Review main Abandoned

69254[FEATURE] Configurable dashboard widgets

Richard Haeser CR 0 V 0 Hard +609 −173 updated 11/09/21, 19:36

Commit message

For some widgets it is useful to have some settings for the user. By
configuring the widget, the user can decide which data is shown in
the widget. That is why it is now possible to decide if a registered
option is available for a user to change.

To make one or more options available, you need to change the Widget
Registration and implement the :php:`ConfigurableWidgetInterface`
for your widget class. If you need the options set in the
dataprovider as well, you also need to implement a :php:`setOptions`
method in your dataprovider.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 27

Show 7 more files

Review log 1724

  1. Richard Haeser uploaded patch set 1 05/24/21, 17:25

  2. core-ci voted on patch set 1 V +1 05/24/21, 17:33 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/11801

  3. Richard Haeser uploaded patch set 2 05/24/21, 20:05

  4. core-ci voted on patch set 2 V +1 05/24/21, 20:15 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/11804

  5. Richard Haeser uploaded patch set 3 05/25/21, 13:45

  6. core-ci voted on patch set 3 V +1 05/25/21, 13:56 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/11832

  7. Richard Haeser updated the commit message in patch set 4 05/25/21, 14:48

  8. Richard Haeser commented on patch set 4 05/25/21, 14:48

    This change is ready for review.
  9. Richard Haeser updated the commit message in patch set 5 05/25/21, 14:49

  10. core-ci voted on patch set 4 V +1 05/25/21, 14:58 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/11835

  11. core-ci voted on patch set 5 V +1 05/25/21, 15:02 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/11836

  12. Oli Bartsch commented on patch set 5 05/25/21, 16:48

    Hi, thanks for continuing the work on the dashboard. I had a short look and would appreciate talking to you about this patch in the next few days. I already added some comments, mainly regarding the JavaScript part.

    WidgetContentCollector.ts:69 Unresolved

    Why do we insert all options - hidden - into the DOM, instead of fetching them when needed (accessing the corresponding modal)?

    WidgetSettings.ts:14

    Please don't introduce new jQuery dependencies.

    WidgetSettings.ts:21 Unresolved

    This should ideally be a custom element

    WidgetSettings.ts:34 Unresolved

    As noted above. I personally don't like parsing the DOM here. I would prefer to fetch the setting via XHR here and add it as modal content then.

    WidgetSettings.ts:68 Unresolved

    We could use the trigger property of the buttons directly to distinguish between the actions.

    WidgetSettings.ts:84

    For the sake of consistency, let's set the active state to the "cancel" button.

    WidgetSettings.ts:93

    I can't find the 'delete' button in this modal. Do I overlook something?

    ConfigurableWidgetInterface.php:21

    This seems to be a copy&paste error.

    RssWidget.php:138

    When removing this again, we should update the RST about the refresh option, since we mentioned this method there.

    Main.html:50 Unresolved

    Anchor tags without a target are bad - UX wise. Please see my comment regarding a custom element in the TS.

    WidgetSettingsForm.html:13

    Do we need a default case? Adding an unknown type would still display the title but no options. Besides that, I'm not sure if we should instead try to create a more generic solution, not limiting devs to these types.

    WidgetSettingsForm.html:14

    So I can only have one checkbox? Though about some filter, which requires to allow checking multiple options. Something like Include content types: [] text [x] image [x] text&image [] divider
  13. Daniel Siepmann commented on patch set 5 05/25/21, 19:50

    Feature-94190-ConfigurableWidgets.rst:3

    Headline Markup should be as long as the headline itself.

    Feature-94190-ConfigurableWidgets.rst:23

    The indentation should be increased by 1 whitespace, to match `c` of `code-block`.

    Feature-94190-ConfigurableWidgets.rst:30

    Would it make sense to allow override of widget title somehow? E.g. in case you add this widget three times, once for each available option. You won't be able to recognize which widget shows which option. It would be cool to have the options available within title somehow. Not sure how a solution could look like. What do you think?

    Feature-94190-ConfigurableWidgets.rst:36

    Doesn't matter to much, but I guess 365?

    Feature-94190-ConfigurableWidgets.rst:46

    I guess there is a reason not to have "input"? Most probably because it is complex to validate? Maybe we should add a small hint so people know why it is missing.

    Feature-94190-ConfigurableWidgets.rst:49

    I guess that's also true for checkbox, beside select and radio? We should mention how checkbox is configured.

    Feature-94190-ConfigurableWidgets.rst:70

    Can we add further info, e.g. the full signature? That way developers and docs maintainers will know which parameters are provided and which type should be returned, e.g.: `public function setOptions(array $options): void`
  14. Oli Bartsch commented on patch set 5 05/26/21, 09:50

    WidgetAjaxController.php:154

    Could be merged into parent.

    Dashboard.php:130

    We should check for the interface here instead.

    AbstractConfigurableWidget.php:62

    Could be static.

    AbstractConfigurableWidget.php:64

    Could be merged into parent.

    AbstractConfigurableWidget.php:102

    Could be merged into parent. Maybe also think about using a ConfigurableDataProviderInterface.

    ConfigurableWidgetInterface.php:29

    Let's add a `: void;`.

    NumberWithIconWidget.php:65

    Same as above. This could also be handled by a dedicated interface, so it's clear for extension authors which methods are required.

    NumberOfFailedLoginsDataProvider.php:38

    Why do we remove the type hint here? If this should be nullable, `?int $secondsBack = null` should be fine.

    NumberOfFailedLoginsDataProvider.php:41

    $secondsBack ??= $this->getSecondsBack($period); should be fine.

    NumberOfFailedLoginsDataProvider.php:70

    : void

    SysLogErrorsDataProvider.php:50

    Why do we remove the type hint here? If this should be nullable, `?int $days = null` should be fine.

    SysLogErrorsDataProvider.php:50

    $days !== null

    SysLogErrorsDataProvider.php:75

    : void

    SysLogErrorsDataProvider.php:106

    This will trigger a warning (PHP 8) in case 'daysToShow' is not defined.

    TypeOfUsersChartDataProvider.php:76

    Where is this option defined? In case this key does not exists, this will trigger a warning (PHP 8)
  15. Richard Haeser uploaded patch set 6 06/08/21, 11:45

  16. Richard Haeser commented on patch set 6 CR -1 06/08/21, 11:45

    Work In Progress

    WidgetSettings.ts:14 Reply

    AFAIK the Modal is still relying on jQuery. I minimised the usage of jQuery though within the script. If you see something that can be replaced, please let me know!

    WidgetSettings.ts:84 Reply

    Done

    WidgetSettings.ts:93 Reply

    Done

    Feature-94190-ConfigurableWidgets.rst:3 Reply

    Done

    Feature-94190-ConfigurableWidgets.rst:23 Reply

    Done

    Feature-94190-ConfigurableWidgets.rst:30 Reply Unresolved

    The "problem" is, that this title is also used in for example the widget selector. So at least there should be some sort of fallback. For the NumberWithIcon widget, I added this already (see typo3/sysext/dashboard/Classes/Widgets/NumberWithIconWidget.php:64). There the title is really part of the widget, so more obvious to give the option. Not sure if we should do it for all the widgets as it will only be shown on the dashboard itself and not in the widget selector (you don't know the settings at that moment). What would you think? Maybe something for a follow-up when devs want this feature?

    Feature-94190-ConfigurableWidgets.rst:36 Reply

    Done

    Feature-94190-ConfigurableWidgets.rst:46 Reply

    Well, validation indeed and therefor also from a MVP point-of-view, I would like to start with those two options as this will help in the majority of the settings. I couldn't imagine a lot of widgets needing a free text input (besides a weather widget where you can give your location)

    Feature-94190-ConfigurableWidgets.rst:49 Reply Unresolved

    A checkbox is just a simple bool and has nothing to do with the options, but I agree we should mention this somewhere. Suggestions where to add this?

    Feature-94190-ConfigurableWidgets.rst:70 Reply

    Done
  17. core-ci voted on patch set 6 V +1 06/08/21, 11:53 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12213

  18. Oli Bartsch commented on patch set 6 06/08/21, 16:17

    WidgetSettings.ts:14 Reply Unresolved

    Yes, the modal is internally still relying on JQuery. Importing JQuery is however not required for using the Modal component in custom elements. See e.g. https://github.com/TYPO3/TYPO3.CMS/blob/7aad9f6dea9246a1cc64f1b076e106605db3e04c/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/FormEngine/Element/MfaInfoElement.ts where the modal is also used, but without any JQuery import. Actually the JQuery import is currently only necessary for line 49. Since this is not related to the Modal, I assume this can be done in pure JavaScript.
  19. Richard Haeser uploaded patch set 7 06/14/21, 12:38

  20. Richard Haeser commented on patch set 6 06/14/21, 12:38

    Still WIP

    WidgetAjaxController.php:154 Reply

    Done

    Dashboard.php:130 Reply Unresolved

    I'm not a fan of this code as well, but when we introduce a new interface here, 3rd party extensions need to have two different widgets if they want to support v10 as well as v11. But maybe we should just take that for granted and do it the right way.

    AbstractConfigurableWidget.php:62 Reply

    Done

    AbstractConfigurableWidget.php:64 Reply

    Done

    AbstractConfigurableWidget.php:102 Reply

    Done

    ConfigurableWidgetInterface.php:21 Reply

    Done

    ConfigurableWidgetInterface.php:29 Reply

    Done

    NumberWithIconWidget.php:65 Reply Unresolved

    See earlier reply. Checking on an interface will make the Widget classes incompatible with v10. So if we are ok with that, we can do it the right way.

    NumberOfFailedLoginsDataProvider.php:38 Reply

    Done

    NumberOfFailedLoginsDataProvider.php:41 Reply

    Done

    NumberOfFailedLoginsDataProvider.php:70 Reply

    Done

    SysLogErrorsDataProvider.php:50 Reply

    Done

    SysLogErrorsDataProvider.php:50 Reply

    Done

    SysLogErrorsDataProvider.php:75 Reply

    Done

    SysLogErrorsDataProvider.php:106 Reply

    Done

    TypeOfUsersChartDataProvider.php:76 Reply

    Done

    RssWidget.php:138 Reply

    yeah, this is moved to the abstract now. Will update the RST file of feature 93210.

    WidgetSettingsForm.html:13 Reply Unresolved

    Creating a more generic solution is something I tried before but all the things I tried ended up in a way to complicated setup while you only need specific types for widgets. So I would like to keep it as simple as possible. I think having a default type would only be good to show that the field is wrongly configured. What do you think?

    WidgetSettingsForm.html:14 Reply Unresolved

    Good point. Will check and fix this
  21. Richard Haeser voted on patch set 7 CR -1 06/14/21, 12:39

  22. core-ci voted on patch set 7 V +1 06/14/21, 12:52 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12409

  23. Christian Kuhn commented on patch set 7 11/09/21, 19:36

    Hey. I hope it's ok to abandon this WIP patch for now: Not too much happened for a while and we can easily resurrect the patch when work continues for the sake of a more clean review system.
  24. Christian Kuhn abandoned the change 11/09/21, 19:36