From 2ac675b09f94832aeba60060731eaed251ea60c0 Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 20 Jun 2024 18:24:24 +0100 Subject: [PATCH 1/2] fix(dal, sdf): Ensure we can save changes to variant details without regenerating We should ensure we don't need to regenerate the variant to save changes to it's details --- lib/dal/src/schema/variant/authoring.rs | 36 +++++++++++++++++-- .../schema/variant/authoring/save_variant.rs | 3 ++ .../server/service/variant/save_variant.rs | 3 ++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/dal/src/schema/variant/authoring.rs b/lib/dal/src/schema/variant/authoring.rs index e9b06a0117..b03978c3d0 100644 --- a/lib/dal/src/schema/variant/authoring.rs +++ b/lib/dal/src/schema/variant/authoring.rs @@ -562,25 +562,55 @@ impl VariantAuthoringClient { pub async fn save_variant_content( ctx: &DalContext, current_schema_variant_id: SchemaVariantId, - name: impl Into, + content_name: impl Into, menu_name: Option, link: Option, code: impl Into, description: Option, + category: impl Into, + component_type: ComponentType, + color: impl Into, ) -> VariantAuthoringResult<()> { let current_schema_variant = SchemaVariant::get_by_id(ctx, current_schema_variant_id).await?; + let current_schema = current_schema_variant.schema(ctx).await?; + let asset_func_id = current_schema_variant.asset_func_id.ok_or( VariantAuthoringError::SchemaVariantAssetNotFound(current_schema_variant_id), )?; - let code_base64 = general_purpose::STANDARD_NO_PAD.encode(code.into()); + let name: String = content_name.into(); + let name = &name; + + current_schema + .modify(ctx, |s| { + s.name = name.to_string(); + Ok(()) + }) + .await?; + + let variant_description = description.clone(); + let variant_link = link.clone(); + let variant_display_name = menu_name.clone(); + + current_schema_variant + .modify(ctx, |sv| { + sv.description = variant_description; + sv.link = variant_link; + sv.category.clone_from(&category.into()); + sv.component_type = component_type; + sv.color.clone_from(&color.into()); + sv.display_name = variant_display_name; + Ok(()) + }) + .await?; + let code_base64 = general_purpose::STANDARD_NO_PAD.encode(code.into()); let current_func = Func::get_by_id_or_error(ctx, asset_func_id).await?; current_func .modify(ctx, |func| { - func.name = name.into(); + func.name = name.to_string(); func.backend_kind = FuncBackendKind::JsSchemaVariantDefinition; func.backend_response_type = FuncBackendResponseType::SchemaVariantDefinition; func.display_name = menu_name diff --git a/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs b/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs index 680db98823..c399a4b62a 100644 --- a/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs +++ b/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs @@ -82,6 +82,9 @@ async fn save_variant(ctx: &mut DalContext) { link.clone(), updated_func_content.clone(), updated_description.clone(), + category.clone(), + variant.component_type(), + color.clone(), ) .await .expect("Unable to save the func"); diff --git a/lib/sdf-server/src/server/service/variant/save_variant.rs b/lib/sdf-server/src/server/service/variant/save_variant.rs index 342e57ed49..6650490971 100644 --- a/lib/sdf-server/src/server/service/variant/save_variant.rs +++ b/lib/sdf-server/src/server/service/variant/save_variant.rs @@ -49,6 +49,9 @@ pub async fn save_variant( request.link.clone(), request.code.clone(), request.description.clone(), + request.category.clone(), + request.component_type, + request.color, ) .await?; From c33b4f100303a9d5300bab67ce0845bfe641c9e2 Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 20 Jun 2024 18:27:44 +0100 Subject: [PATCH 2/2] fix(web): Ensure we show progress of regenerating a schema variant --- app/web/src/store/asset.store.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/web/src/store/asset.store.ts b/app/web/src/store/asset.store.ts index 2d4e74ec47..676e04a630 100644 --- a/app/web/src/store/asset.store.ts +++ b/app/web/src/store/asset.store.ts @@ -455,6 +455,7 @@ export const useAssetStore = () => { return new ApiRequest({ method: "post", url: "/variant/update_variant", + keyRequestStatusBy: assetId, params: { ...visibility, ..._.omit(asset, ["hasComponents", "createdAt", "updatedAt"]),