Removed strongly typed View Settings#974
Conversation
It is cumbersome for FE using them.
|
I agree, but the problem is that strong types (using OPModel) do camelCase -> snake_case conversion by default. I am afraid that by removing the types, already stored views will break |
So should there be some one-time backend DB conversion script to resave it in |
There was a problem hiding this comment.
This seems to have broken patching of views
[PATCH] http://localhost:3000/api/views/versions/3956a018cf9d4f64b44723bf673bc2d5?project_name=wing_it
{
"settings": {
"filter": {
"operator": "and",
"conditions": []
},
"columns": [],
"sort_by": null,
"group_by": null,
"show_grid": false,
"sort_desc": false,
"row_height": 34,
"grid_height": null,
"slicer_type": "hierarchy",
"show_products": false,
"show_empty_groups": false,
"group_sort_by_desc": false,
"featured_version_order": null,
"showEmptyGroups": false,
"rowHeight": 34
}
}{
"code": 400,
"detail": "Request validation error in [PATCH] /api/views/versions/3956a018cf9d4f64b44723bf673bc2d5",
"path": "/api/views/versions/3956a018cf9d4f64b44723bf673bc2d5",
"traceback": "viewType: field required",
"errors": [
{
"loc": [
"body",
"viewType"
],
"msg": "field required",
"type": "value_error.missing"
}
]
}|
first check if i'm right, but i think i am. then i thing the best place to do that would be here: https://github.com/ynput/ayon-backend/blob/enhancement/open_view_settings/api/views/models.py#L130 keep the existing data in the database and upon returning, check for well known keys in the json. for exampe if view type is overview and there's "sort_by", just convert to camel case. upon next save, it will be overwritten with camelCase variant and reprocessing won't be triggered again. |
|
this should bump minor version, since after updating, downgrading would cause a data loss @Innders |
Nothing has changed in the FE and I'm not sure why it should change? |
|
Added optionality to |
…enhancement/open_view_settings
There was a problem hiding this comment.
Before this change when we generated the queries the mutations would use payload.
Now they use genericViewPostModel and ``genericViewPatchModel`.
export type UpdateViewApiArg = {
viewType: string
viewId: string
projectName?: string
genericViewPatchModel: GenericViewPatchModel
}
can we please figure out a way so that the this goes back to payload
export type UpdateViewApiArg = {
viewType: string
viewId: string
projectName?: string
payload: GenericViewPatchModel
}
Tagging @filipvnencak
filipvnencak
left a comment
There was a problem hiding this comment.
With these backend tweaks the OpenAPI body comes through as payload again, so the frontend doesn't need the codegen-rename workaround in ynput/ayon-frontend#2066
Co-authored-by: Filip Vnenčák <vnencak.filip@gmail.com>
Co-authored-by: Filip Vnenčák <vnencak.filip@gmail.com>
Co-authored-by: Filip Vnenčák <vnencak.filip@gmail.com>
…enhancement/open_view_settings
…nput/ayon-backend into enhancement/open_view_settings
Co-authored-by: Filip Vnenčák <vnencak.filip@gmail.com>
This reverts commit 7a4d419.
I added tag, but I am not sure if anything actually changed, format wise. I tried to set up bunch of Views and do an upgrade and content seemed same as before. |
|
I just reproduced the problem i was expecting. It affects fields in previously strictly typed settings that contain underscores, such as overview.show_hierarchy, overview.sort_by etc. Steps to reproduce:
it only does not affect filter and columns, as they don't use underscores. possible solution: update def construct_view_model(**data: Any) -> ViewModel:
view_type = data["viewType"]
settings = data["settings"]
if view_type in ["overview", "taskProgress", "lists", "reviews", "versions"]:
patched_settings = {}
for key, val in settings.items()
if "_" in key:
patched_settings[camelize(key)] = val
else:
patched_settings[key] = val
settings = patched_settings
return GenericViewModel(view_type=view_type, settings=settings) |
Nothing is as permanent as a temporary workaround :-D |
martastain
left a comment
There was a problem hiding this comment.
Works. I love when we remove code :)


Description of changes
This PR removes strongly typed View Settings for some tabs as it was too cumbersome for frontend to be using them. Any change in FE required same change in BE.
This PR should simplify development.