FlowFuse / FlowFuse/node-red-dashboard
Using ui-control to show/hide groups for users behaves incorrectly
- Dominant language
- HTML
- Stars
- 355
- Forks
- 82
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 24
Description
### Current Behavior
When you use the `ui-control` node to control the visibility of groups for different users, when the page is loaded, the group visibility is cached based on the last user that viewed the page. Once the page is refreshed, the correct group visibility for the current user is reflected.
Note that this behaviour only affects groups. Visibility of pages works as expected.
### Expected Behavior
The correct group visibility for the logged in user is used immediately, without needing to refresh the page.
### Steps To Reproduce
1. Configure a dashboard with an admin only page and an admin only group, (as per the guidance at https://flowfuse.com/blog/2024/04/building-an-admin-panel-in-node-red-with-dashboard-2/). For the purpose of this reproduction, assume there are two users, "alice" and "bob", and configure the dashboard so that only user "bob" can see the admin page and group.
2. Log in as bob, and the admin page and group **is** visible.
3. Now log out of bob and log in as alice. When alice's dashboard first loads, the admin page is correctly hidden but the admin group **is not** hidden.
4. Refresh alice's dashboard, and the admin group will now be hidden.
5. (Optional) Log out of alice and back in as bob, and initially the admin group will be hidden, but after a page refresh the group will be visible.
Exported flow:
```
[
{
"id": "dabf79a3db181529",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "48d47a96436f6d03",
"type": "ui-event",
"z": "dabf79a3db181529",
"ui": "e578ecf151797c4b",
"name": "",
"x": 140,
"y": 300,
"wires": [
[
"edef7ffd99d80f8f"
]
]
},
{
"id": "edef7ffd99d80f8f",
"type": "switch",
"z": "dabf79a3db181529",
"name": "Is Admin User",
"property": "admins",
"propertyType": "global",
"rules": [
{
"t": "cont",
"v": "_client.user.username",
"vt": "msg"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 340,
"y": 300,
"wires": [
[
"62b95aa3ee03236e"
],
[
"c79c41400e532d79",
"fb1ff9537b928bd7"
]
]
},
{
"id": "62b95aa3ee03236e",
"type": "change",
"z": "dabf79a3db181529",
"name": "Show Admin Pages/Groups",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"pages\":{\"show\":[\"Admin Page\"]},\"groups\":{\"show\":[\"Admin Only Section\"]}}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 730,
"y": 280,
"wires": [
[
"1393fce9f3d856de"
]
]
},
{
"id": "c79c41400e532d79",
"type": "change",
"z": "dabf79a3db181529",
"name": "Hide Admin Pages/Groups",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"pages\":{\"hide\":[\"Admin Page\"]},\"groups\":{\"hide\":[\"Admin Only Section\"]}}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 730,
"y": 340,
"wires": [
[
"1393fce9f3d856de"
]
]
},
{
"id": "1393fce9f3d856de",
"type": "ui-control",
"z": "dabf79a3db181529",
"name": "",
"ui": "e578ecf151797c4b",
"events": "all",
"x": 1080,
"y": 300,
"wires": [
[]
]
},
{
"id": "fb1ff9537b928bd7",
"type": "switch",
"z": "dabf79a3db181529",
"name": "Check if Admin Page is being directly accessed",
"property": "payload.page.name",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Admin Page",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 790,
"y": 380,
"wires": [
[
"5d271c6c75d18d60"
]
]
},
{
"id": "5d271c6c75d18d60",
"type": "change",
"z": "dabf79a3db181529",
"name": "Redirect to home page",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Home",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1120,
"y": 380,
"wires": [
[
"1393fce9f3d856de"
]
]
},
{
"id": "5fd10364677eefa9",
"type": "inject",
"z": "dabf79a3db181529",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 160,
"wires": [
[
"0911f84a460e20c4"
]
]
},
{
"id": "0911f84a460e20c4",
"type": "change",
"z": "dabf79a3db181529",
"name": "",
"rules": [
{
"t": "set",
"p": "admins",
"pt": "global",
"to": "[\"bob\"]",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 410,
"y": 160,
"wires": [
[]
]
},
{
"id": "e578ecf151797c4b",
"type": "ui-base",
"name": "My Dashboard",
"path": "/dashboard",
"includeClientData": true,
"acceptsClientConfig": [
"ui-notification",
"ui-control",
"ui-button",
"ui-dropdown",
"ui-template"
],
"showPathInSidebar": false,
"navigationStyle": "fixed",
"titleBarStyle": "default"
}
]
```
### Environment
- Dashboard version: 1.14.0
- Node-RED version: 3.1.7
- Node.js version: 18.19.1
- npm version: 10.2.4
- Platform/OS: Linux
- Browser: Edge
### Have you provided an initial effort estimate for this issue?
I am not a FlowFuse team member
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.