Commit bc95278
refactor(dashboard): immutable state updates, drag-drop hook, and granular contexts (#497)
* refactor(dashboard): immutable state updates, drag-drop hook, and granular contexts
Split the monolithic ApplicationsContext tuple into three purpose-built
contexts (AppListContext, DashboardContext, CurrentAppContext) so
components subscribe only to the state they read, and rework the
dashboard layout around them:
- extract drag-and-drop monitoring into a useDashboardDragDrop hook and
the context menu into a DrawerContextMenu component; DashboardDrawer
now updates dashboard state immutably (no in-place mutation of groups)
- rewrite hooks/application.tsx around the granular contexts
(useAppList, useDashboard, useApplicationId, useCurrentApplication)
and drop useApplicationTitle/useApplicationType
- memoize NavigationProvider and OIDCConfigurationProvider values
- ProfileButton loses the dead About entry; ThemeToggleButton,
Import/ExportButton, ApplicationDialog and ApplicationSelector are
adapted to the new contexts
- contexts/index.ts now exports the granular contexts explicitly
(ApplicationsContext is gone); Dashboard stories/tests updated
* refactor(dashboard): resolve drag-drop groups inside the state updater
useDashboardDragDrop no longer takes userDashboard or mirrors it in a
ref. reorderSections receives the source/destination group titles from
the drop event and looks the groups up inside the setUserDashboard
functional updater, where React hands it the freshest state. This drops
the ref, its sync effect, and the userDashboard parameter, and removes
the (practically unreachable) window where a drop could read a stale
dashboard between a state commit and the ref update. The destination
index is copied into a local so the updater stays pure under StrictMode.
Draft addressing review comment C6.1 — kept as its own commit for review.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 6cd3e80 commit bc95278
20 files changed
Lines changed: 535 additions & 467 deletions
File tree
- packages/diracx-web-components
- src
- components
- DashboardLayout
- contexts
- hooks
- types
- stories
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 11 | + | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
| |||
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
45 | | - | |
46 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| |||
154 | 152 | | |
155 | 153 | | |
156 | 154 | | |
157 | | - | |
| 155 | + | |
| 156 | + | |
158 | 157 | | |
159 | 158 | | |
160 | 159 | | |
| |||
0 commit comments