Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions recipes/VideoGenPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,15 @@ def render_field(
value=value,
help=help_text,
)
case "string" if field.get("enum"):
return gui.selectbox(
case ("string" | "integer" | "number") as _type if field.get("enum"):
v = gui.selectbox(
label=label,
value=value,
help=help_text,
options=field["enum"],
)
pytype = {"string": str, "integer": int, "number": float}[_type]
return pytype(v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this needs some error handling like in json below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not clear on what would be the error case to handle.
because it's a selectbox, the value would always be one of the options. this is guaranteed by gui.selectbox even if we change some state with bad data on client side.
e.g. if int(v) fails, it would be because the schema from admin is incorrect. which i dont think we should handle here and just fail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll get the sentry error and then fix it from admin

case "string":
return gui.text_area(
label=label,
Expand Down