node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

Implement Unique IDs for UI Elements, shows just the Labels to the User

Open andrea-tomassi opened this issue 6 months ago • 10 comments

Description

image

Summary: To improve code maintainability and avoid inconsistencies, it is proposed that all UI elements (such as Pages, Groups, and thus Menu items) in Node-RED Dashboard 2.0 should have unique IDs or codes. These IDs should be used for routing, authorization, and business logic instead of visible text labels.

Description: Currently, Node-RED Dashboard 2.0 uses visible text labels for UI elements such as Page Names in routing, authorization, and business logic. This approach can lead to several issues:

  • Inconsistencies and poor code maintenance: Renaming a UI element requires a complete refactor of the authorization logic, which can be cumbersome and error-prone.
  • Positional approach limitations: Using positional references for UI elements can lead to similar maintenance challenges.

Proposed Solution:

  • Each UI element (Page, Group etc.) should have a unique ID or code.
  • The ID should be randomly generated upon creation but can be overwritten by the user to provide a meaningful logical key.

Separation of Labels and IDs:

  • The visible name of the UI element should be treated as a label and should not be used in routing, authorization, or business logic.
  • Deep references to UI elements (e.g., programmatic UI-Control to show/hide components based on authenticated user) should leverage IDs, not names.

Benefits:

  • Improved Maintainability: Changes to visible labels will not require refactoring of the underlying logic, reducing the risk of errors and simplifying maintenance.
  • Consistency: Using unique IDs ensures that references to UI elements remain consistent, even if the visible labels are changed.
  • Flexibility: Users can assign meaningful logical keys to IDs, making the system more intuitive and easier to manage. Naming convention (E.G. complex keys with prefixes and suffixes) could help in complex scenario without affecting the visible label.

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

andrea-tomassi avatar Aug 04 '24 10:08 andrea-tomassi