•  
      request #31111 Remove global states in the artifact modal
    Infos
    #31111
    Joris MASSON (jmasson)
    2024-10-08 17:26
    2023-03-02 11:03
    32715
    Details
    Remove global states in the artifact modal

    This is not part of request #18391 but revealed by it.
    During the long ongoing work to get rid of AngularJS, we have introduced a couple of global "state" modules whose purpose was to share data between "distant" UI components. There are a couple scenarii where such state modules are used:

    1. Text fields (and New comment) components need to know whether file upload is even possible (i.e. whether there is a file field in the current tracker; if there is none, file upload is not possible).
    2. Text fields (and New comment) components need to communicate with File field component to attach uploaded image drop to the file field.
    3. The footer of the modal shows a file upload quota. This still depends on an HTTP call to the temporary_files endpoint. However, since request #28830, those endpoints have been replaced by TUS protocol. Calling them is no longer necessary, so we should instead show the max upload file size, which is known by File field component.
    4. Submitting the modal is disabled while an image drop in a Text field is uploading.

    All of the above scenarii relied on a global state module. Global state can be dangerous because it is a Singleton pattern, it is hard to replace it (for example in tests), and it can be re-used in situations when it is not wanted. For example, with two modals on the same page, they would share some state via the global modules, which is likely a problem. We have introduced a listener/observer pattern that has succesfully replaced the previous field dependency system. We should reuse events for those scenarii and remove global state.

    Trackers
    Empty
    Empty
    • [ ] enhancement
    • [x] internal improvement
    Empty
    Stage
    Joris MASSON (jmasson)
    Closed
    2024-10-08
    Attachments
    Empty
    References

    Follow-ups