-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TELESTION-460 Dashboard layout editor (#417)
A layout editor for dashboards to make them configurable by users. Interaction can be performed using both the mouse and the keyboard. Changes are handled completely independently from the UI, allowing for both an easier way to ensure invalid states cannot occur as well as testability. During the user interaction, no actual state changes are performed. Once the interaction finishes, the changes get interpreted to the closest possible state change and "committed" to the state, where (in compliance with any business logic) the changes are applied and, thus, updates in the UI. This also allows us to implement any interactions without absolute positioning and resize observers. Instead, the native CSS grid can be used. Due to the relative complexity and clear boundaries of this subsystem, a separate folder structure which also includes a `README.md` was created. ## Screenshot ![localhost_5173_ (1).png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/O4KhC0hWe43iADdjRFxH/e8b05ef8-577b-4d5e-8bbd-8e5c350338d0.png)
- Loading branch information
Showing
26 changed files
with
2,086 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,5 +109,4 @@ jobs: | |
run: pnpm install | ||
- name: Run unit tests 🛃 | ||
run: | | ||
pnpm run build | ||
pnpm run ci:test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
frontend-react/src/lib/application/routes/dashboard-editor/dashboard-editor.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@import 'bootstrap/scss/functions'; | ||
@import 'bootstrap/scss/variables'; | ||
@import 'bootstrap/scss/mixins'; | ||
|
||
.dashboardEditor { | ||
display: grid; | ||
grid-template-areas: 'dashboard layout widget-instance'; | ||
grid-auto-columns: 1fr; | ||
grid-gap: var(--gutter); | ||
height: calc(100vh - var(--navbar-height) - var(--gutter)); | ||
|
||
> * { | ||
background: var(--bs-body-bg); | ||
color: var(--bs-body-color); | ||
border-radius: var(--bs-border-radius); | ||
|
||
overflow-y: auto; | ||
overflow-x: hidden; | ||
} | ||
|
||
.dashboard { | ||
grid-area: dashboard; | ||
} | ||
|
||
.layout { | ||
grid-area: layout; | ||
} | ||
|
||
.widgetInstance { | ||
grid-area: widget-instance; | ||
} | ||
|
||
@include media-breakpoint-down(xl) { | ||
grid-template-areas: 'dashboard layout' 'widget-instance widget-instance'; | ||
height: auto; | ||
|
||
> * { | ||
/*height: auto;*/ | ||
overflow-y: visible; | ||
} | ||
} | ||
|
||
@include media-breakpoint-down(md) { | ||
grid-template-areas: 'dashboard' 'layout' 'widget-instance'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
frontend-react/src/lib/application/routes/dashboard-editor/layout-editor/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Layout Editor | ||
|
||
Date: 2024-01-14 | ||
|
||
Designed by: | ||
|
||
- [Zuri Klaschka](https://github.com/pklaschka) | ||
|
||
The layout editor for dashboards. | ||
|
||
## Interface Definition | ||
|
||
You can find the props passed into `LayoutEditor` in | ||
the [`model/layout-editor-props.ts`](./model/layout-editor-props.ts) file. | ||
|
||
Note that apart from the current `value: LayoutEditorState`, all props are optional. | ||
|
||
However, they are required for various functions, like editing the layout, creating new widget instances, etc. | ||
|
||
## Behavior | ||
|
||
```mermaid | ||
zenuml | ||
title Layout Editor Behavior | ||
@Actor User | ||
@Boundary editor as "Layout Editor" | ||
@Entity state as "State / Parent" | ||
User->editor.beginInteraction() { | ||
while ("edits not final") { | ||
preview = User->editor.editLayout() | ||
} | ||
User->editor.endInteraction() { | ||
newState = calculateNewState() | ||
updatedState = state.update(newState) | ||
return updatedState | ||
} | ||
} | ||
``` | ||
|
||
Note that the state is not updated until the user ends the interaction. | ||
|
||
There are therefore two very distinct phases during an interaction: | ||
|
||
1. the preview phase where any changes are visualized in real-time to the user. | ||
2. the commit phase where the changes are interpolated to the closest applicable change (rounded to full grid cell | ||
units, etc.), and actually applied to the state. | ||
|
||
This means that the application to the state can be performed without any regard to the actual user interaction, and | ||
written and tested independently. | ||
|
||
## State Management | ||
|
||
The state is considered to be immutable. Updates to the state are performed using pure functions that return the new | ||
state based on the previous state and the new data. | ||
|
||
## User Interaction | ||
|
||
User interaction can be performed using both the mouse and the keyboard. | ||
|
||
## Changes | ||
|
||
n/a |
Oops, something went wrong.