Review main Merged

83143[FEATURE] Introduce tree node labels

Benjamin Kott CR +2 V +2 Hard +276 −17 updated 03/01/24, 11:03

Commit message

We've upgraded the backend tree component by extending tree nodes to
incorporate labels, offering enhanced functionality and additional
information.

Before the implementation of labels, developers and integrators
relied on `pageTree.backgroundColor.<pageid>` for visual cues.
However, these background colors lacked accessibility and meaningful
context, catering only to users with perfect eyesight and excluding
those dependent on screen readers or contrast modes.

With labels, we now cater to all editors. These labels not only offer
customizable color markings for tree nodes but also require an
associated label for improved accessibility.

Each node can support multiple labels, sorted by priority, with the
highest priority label taking precedence over others. Users can
assign a label to a node via tsconfig, noting that only one label
can be set through this method.

```
options.pageTree.label.<pageid> {
    label = Campaign A
    color = #ff8700
}
```

The labels can also be added by using the event
`\TYPO3\CMS\Backend\Controller\Event\AfterPageTreeItemsPreparedEvent`.

```
$items = $event->getItems();
foreach ($items as &$item) {
    $item['labels'][] = new Label(
        label: 'Campaign B',
        color: #00658f,
        priority: 1,
    );
}
```

Please note that only the marker for the label with the highest priority
is rendered. All additional labels will only be added to the title of
the node.

Review

  • Code review CR +2 Done
    • Benjamin Kott +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
  • Verified V +2 Done
    • Benjamin Kott +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 1

Files 21

Show 1 more file

Review log 3949

Show 1824 earlier messages
  1. Benjamin Kott uploaded patch set 1 02/26/24, 15:23

  2. core-ci voted on patch set 1 V -1 02/26/24, 15:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53625

  3. Benjamin Kott uploaded patch set 2 V -1 02/27/24, 11:20

  4. core-ci voted on patch set 2 V -1 02/27/24, 11:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53633

  5. Benjamin Kott uploaded patch set 3 V -1 02/27/24, 11:42

  6. core-ci voted on patch set 3 V +1 02/27/24, 11:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53635

  7. Benjamin Kott uploaded patch set 4 V +1 02/27/24, 13:08

  8. core-ci voted on patch set 4 V +1 02/27/24, 13:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53640

  9. Benni Mack commented on patch set 4 02/27/24, 13:42

    nice job!
  10. Markus Klein voted on patch set 4 CR +1 02/27/24, 13:59

  11. Markus Klein commented on patch set 4 02/27/24, 14:01

    Deprecation-103211-DeprecatePageTreebackgroundColor.rst:30

    not sure about the spelling here, is it "TSconfig" maybe make clear here, that this is *user* TSconfig here.
  12. Jasmina Ließmann commented on patch set 4 02/27/24, 16:43

    Deprecation-103211-DeprecatePageTreebackgroundColor.rst:30 Reply

    Good catch. Yes, it has to be called "TSconfig".
  13. Jasmina Ließmann commented on patch set 5 CR +1 V +1 02/27/24, 19:36

    Published edit on patch set 4.
  14. Jasmina Ließmann commented on patch set 5 02/27/24, 19:36

    Deprecation-103211-DeprecatePageTreebackgroundColor.rst:30 Reply

    Done
  15. core-ci voted on patch set 5 V -1 02/27/24, 19:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53662

  16. Jasmina Ließmann commented on patch set 6 V -1 02/27/24, 19:43

    Published edit on patch set 5.
  17. core-ci voted on patch set 6 V +1 02/27/24, 19:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53663

  18. Markus Klein voted on patch set 6 CR +1 02/27/24, 20:10

  19. Oli Bartsch commented on patch set 6 02/28/24, 21:02

    TreeController.php:391

    Correct to add the deprecated label in any case? Because if the old and the new way are used for the same page, the color is taken from the new config while the label contains the old "Color: #XXXXXX" part.

    Label.php:23

    Do we want to name this "TreeNodeLabel" as it's called in JS? Otherwise it IMO sounds strange to have the DTO Label in the Namespace \Label.

    Feature-103211-IntroduceTreeNodeLabels.rst:38

    Any reason for not allowing to define the priority here?

    Feature-103211-IntroduceTreeNodeLabels.rst:55

    Using the example above (setting priority=0 in the listener) the label from TSconfig will be used as it is defined beforehand, even if it uses the same priority. Maybe we should adjust the example or add the information that in case labels with the same priority exists, the first one is used.
  20. Simon Schaufelberger commented on patch set 6 02/28/24, 23:46

    Would it be a good idea to add an example to the styleguide (create a page with a label)?
  21. Benjamin Kott commented on patch set 6 02/29/24, 07:28

    Reply

    Not sure about this, we also did not do this for status information.

    TreeController.php:391 Reply

    This is the replacement for the old part, it was removed in the original tree rebuild patch and is now added as a migration to this again. It was dropped in the original patch without notice, this patch now handles and deprecates it. Since it is only deprecated, I think it´s best to keep both available ... for now.

    Label.php:23 Reply

    We did not do this with for example the StatusInformation, not sure if we now need to do it here.

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    Yes, you can only set 1 label here, no need to have a priority.

    Feature-103211-IntroduceTreeNodeLabels.rst:55 Reply

    For me, it is just an example. We can change the priority to 1 here if you feel more comfortable about it.
  22. Benjamin Kott commented on patch set 7 CR +1 V +1 02/29/24, 07:45

    Published edit on patch set 6.
  23. Benjamin Kott commented on patch set 7 02/29/24, 07:46

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    Done
  24. Benjamin Kott commented on patch set 7 02/29/24, 07:47

    TreeController.php:391 Reply

    Done

    Label.php:23 Reply

    Done

    Feature-103211-IntroduceTreeNodeLabels.rst:55 Reply

    Done
  1. Benjamin Kott commented on patch set 7 02/29/24, 07:47

    Reply

    Done
  2. core-ci voted on patch set 7 V +1 02/29/24, 07:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53701

  3. Jasmina Ließmann commented on patch set 7 02/29/24, 08:15

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    What if a node has multiple labels, for example one defined by TSconfig and one defined by Event. 1 / Will those defined by Event always have a higher priority because those defined by TSconfig cannot have a priority? 2 / Case: I want to reorder labels set automatically by extensions via Event and prioritize my custom label that I created via TSconfig. Would a rearrangement only be possible via Event?
  4. Benjamin Franzke commented on patch set 7 02/29/24, 08:27

    tree.ts:918

    We should explicitly use `backgroundColor` to ensure no one tries to embed images or other combined `background` options.
  5. Benjamin Kott uploaded patch set 8 V +1 02/29/24, 08:50

  6. Benjamin Kott commented on patch set 8 02/29/24, 08:52

    tree.ts:918 Reply

    good catch
  7. core-ci voted on patch set 8 V +1 02/29/24, 08:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53705

  8. Simon Schaufelberger commented on patch set 8 02/29/24, 09:01

    Reply

    at least it would make testing easier and also show the capability that TYPO3 can do sweet things like that.
  9. Benjamin Kott commented on patch set 8 02/29/24, 09:07

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    1. No, the default priority is 0. If you want to set a higher priority you need to set it. 2. You have full control over the entries with your event.
  10. Benjamin Kott commented on patch set 8 02/29/24, 09:09

    Reply

    I agree, but I would prefer a style guide for the components - instead of records being generated. Iirc Jasmina is looking currently into something.
  11. Andreas Kienast commented on patch set 8 CR -1 02/29/24, 09:35

    on it
  12. Andreas Kienast uploaded patch set 9 CR -1 V +1 02/29/24, 09:38

  13. Andreas Kienast voted on patch set 9 CR +1 V +1 02/29/24, 09:38

  14. core-ci voted on patch set 9 V +1 02/29/24, 09:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53708

  15. Markus Klein voted on patch set 9 CR +1 02/29/24, 09:48

  16. Benjamin Franzke uploaded patch set 10 CR +1 V +1 02/29/24, 15:56

  17. core-ci voted on patch set 10 V +1 02/29/24, 16:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53730

  18. Oli Bartsch commented on patch set 10 02/29/24, 20:34

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    > 1. No, the default priority is 0. If you want to set a higher priority you need to set it. But you can't using just TSconfig. Not all integrators are able to write PHP - use the Event. This means one extension defines a Label and by extension loading order, the extension is loaded beforehand and therefore wins. That's why I highly recommend to allow setting the priority also via TSconfig.
  19. Oli Bartsch commented on patch set 10 02/29/24, 20:37

    Label.php:23 Reply

    There the namespace is \Status while the class name is StatusInformation. This sounds fine. However, having namespace \Label with class name Label sounds as mentioned a bit strange. Especially because using TreeNodeLabel would make the actual intension much more clear.
  20. Jasmina Ließmann commented on patch set 10 02/29/24, 23:32

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    I support that. In my day-to-day business as an integrator, I don't write Events.
  21. Benjamin Kott commented on patch set 10 03/01/24, 06:31

    Label.php:23 Reply

    But isn´t that what the namespace is for?

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    It is not helpful to assign multiple labels and sort them without any logic attached. It´s the same reason why you only can create 1. label through tsconfig. while being able to create multiple ones through PHP. The label gets inherited automatically when no label is set to child nodes. They are not merged, so there is also no need to set a priority. If a label is added to a node with PHP. A label is only inherited when there is no label set for the current node. There is no priority you need to handle.
  22. Benni Mack commented on patch set 10 03/01/24, 07:32

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    I also think that configuring priorities is not necessarily needed for TSconfig, as it makes it quite complicated.
  23. Oli Bartsch commented on patch set 10 CR +1 V +1 03/01/24, 11:02

    Label.php:23 Reply

    Done

    Feature-103211-IntroduceTreeNodeLabels.rst:38 Reply

    Done
  24. Benjamin Kott voted on patch set 10 CR +2 V +2 03/01/24, 11:03

  25. Benjamin Kott merged patch set 11 03/01/24, 11:03