Create React UI for editing validations in levelbuilder#53142
Conversation
| <br /> | ||
| NOTE: Validations are checked in the order they are listed. The first | ||
| validation set that passes is the one that is displayed, so be sure to | ||
| order your validation sets from most conditions to least. |
There was a problem hiding this comment.
This could possibly be "most stringent to least" or similar, since it might be the case that we check for one validation earlier even though it technically doesn't have more conditions than those below it?
| // height: 30px; | ||
| // width: 30px; |
There was a problem hiding this comment.
Oh good catch
| # first-order member of the properties JSON, rather than simply as a string of | ||
| # JSON belonging to a single property. | ||
| update_level_params[:level_data] = JSON.parse(level_params[:level_data]) if level_params[:level_data] | ||
| # Update level data with validatons, and remove from level properties. |
| ); | ||
| }; | ||
|
|
||
| const moveValidation = (key: string, direction: 'up' | 'down') => { |
There was a problem hiding this comment.
It might be tough given the size of a validation's UI block, but it's pretty slick when we can drag things to reorder them. The up/down arrows do seem sufficient though.
There was a problem hiding this comment.
Agreed! Wanted to just get something working so I went with the arrows, but it would be cool to pull in some React dragging library for this
breville
left a comment
There was a problem hiding this comment.
It's so awesome to see this. Great work!
This adds a React-based UI for editing validations to levelbuilder pages. This is in an effort to create a nicer UI for authoring validations (rather than hand-crafting code or JSON), and has another big benefit of being able to share front end code with other front end components. This means that we can reference other front-end types, like the list of valid validations, and shared typescript types and interfaces.
Currently, this adds a new field to music levels called "validations", but when saving the level, we merge the validations back into level data. I think we are looking to move towards storing validations on level properties directly, rather than in level data, so when that change is complete, we can tweak some of the code that copies over the validations JSON in levels_controller.
Testing Notes
I've hand tested this on some Music all the things levels, but i'm sure we'll continue to iterate on this as we start using it more.
Validations.Editor.8-2.mov