-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TELESTION-462 Make widgets configurable #418
Merged
Merged
Conversation
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 was referenced Jan 21, 2024
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
pklaschka
force-pushed
the
01-14-TELESTION-460_Dashboard_layout_editor
branch
from
January 21, 2024 16:39
835d7fa
to
05e2707
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 21, 2024 16:39
881e234
to
c9a8328
Compare
pklaschka
added
🌷 enhancement
New feature or request
📚 library
labels
Jan 21, 2024
— with
Graphite App
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 21, 2024 17:06
c9a8328
to
8005af7
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
3 times, most recently
from
January 21, 2024 17:54
77238a8
to
98b46ec
Compare
This was referenced Jan 24, 2024
pklaschka
force-pushed
the
01-14-TELESTION-460_Dashboard_layout_editor
branch
from
January 24, 2024 12:06
05e2707
to
87c3688
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 24, 2024 12:06
98b46ec
to
52a2a56
Compare
pklaschka
force-pushed
the
01-14-TELESTION-460_Dashboard_layout_editor
branch
from
January 24, 2024 12:15
87c3688
to
28d9e29
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 24, 2024 12:15
52a2a56
to
7d56f8c
Compare
pklaschka
force-pushed
the
01-14-TELESTION-460_Dashboard_layout_editor
branch
from
January 24, 2024 12:33
28d9e29
to
70ec0fb
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 24, 2024 12:33
7d56f8c
to
ab9249e
Compare
pklaschka
force-pushed
the
01-14-TELESTION-460_Dashboard_layout_editor
branch
from
January 24, 2024 12:40
70ec0fb
to
61d9145
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 24, 2024 12:40
ab9249e
to
07d2c59
Compare
pklaschka
force-pushed
the
01-14-TELESTION-460_Dashboard_layout_editor
branch
from
January 26, 2024 17:34
61d9145
to
0ee0c4e
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 26, 2024 17:34
07d2c59
to
8778084
Compare
pklaschka
force-pushed
the
01-14-TELESTION-460_Dashboard_layout_editor
branch
from
January 26, 2024 18:13
0ee0c4e
to
81b92d9
Compare
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 26, 2024 18:13
8778084
to
5a72697
Compare
Base automatically changed from
01-14-TELESTION-460_Dashboard_layout_editor
to
main
January 26, 2024 18:15
fussel178
approved these changes
Jan 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🏃
Uses a context to make widgets configurable. While currently, configuration is only possible in the edit dashboard page, this context can, in the future, be used to also allow editing the configuration in other places, such as within the widget itself. For convenience, components are provided for basic confiugration fields such as textfields and checkboxes. This makes configurability as easy as this: ```tsx { ... configElement: ( <WidgetConfigWrapper> <WidgetConfigCheckboxField label={'Bool value'} name={'bool'} /> <WidgetConfigTextField label={'Test Text'} name={'text'} /> </WidgetConfigWrapper> ) } ``` It is also possible to create custom configuration fields (using `useConfigureWidgetField(name, validator)`) or even fully custom configuration UIs (using `useConfigureWidget()`). Both of these hooks return both the current configuration and a function that works the same way a `useState()`-setter works. Note that any congiuration passed into or out of the confiuration controls automatically, controlled by the context, get validated using the widget's `createConfig` function. Example of using the `useConfiugreWidgetField()` hook: ```tsx function WidgetConfigTextField(props: { label: string; name: string }) { const [value, setValue] = useConfigureWidgetField(props.name, s => z.string().parse(s) ); return ( <FormGroup className={'mb-3'}> <FormLabel>{props.label}</FormLabel> <FormControl data-name={props.name} value={value} onChange={e => setValue(e.target.value)} /> </FormGroup> ); } ``` Everything related to widget configuration can be imported from `@wuespace/telestion/widget`. Note that this also adjusts the user data to use a `Record<string, jsonSchema>` instead of a `Record<string, unknown>` as the widget instance configuration type. The `jsonSchema` implementation is taken from the zod documentation (`README.md`) wiwhere https://github.com/ggoodman is credited; thank you for this great implementation!
pklaschka
force-pushed
the
01-21-TELESTION-462_Make_widgets_configurable
branch
from
January 26, 2024 18:43
5a72697
to
c271b9e
Compare
Merge activity
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uses a context to make widgets configurable. While currently, configuration is only possible in the edit dashboard page, this context can, in the future, be used to also allow editing the configuration in other places, such as within the widget itself.
For convenience, components are provided for basic confiugration fields such as textfields and checkboxes. This makes configurability as easy as this:
It is also possible to create custom configuration fields (using
useConfigureWidgetField(name, validator)
) or even fully custom configuration UIs (usinguseConfigureWidget()
). Both of these hooks return both the current configuration and a function that works the same way auseState()
-setter works. Note that any congiuration passed into or out of the confiuration controls automatically, controlled by the context, get validated using the widget'screateConfig
function.Example of using the
useConfiugreWidgetField()
hook:Everything related to widget configuration can be imported from
@wuespace/telestion/widget
.Note that this also adjusts the user data to use a
Record<string, jsonSchema>
instead of aRecord<string, unknown>
as the widget instance configuration type. ThejsonSchema
implementation is taken from the zod documentation (README.md
) wiwhere https://github.com/ggoodman is credited; thank you for this great implementation!