From f3b9beeed49b33d2c02e989c5c9b30041d007df5 Mon Sep 17 00:00:00 2001 From: Victor Bustamante Date: Fri, 5 Jul 2024 16:08:44 -0300 Subject: [PATCH] fix: Don't unlock all variants for func automatically Signed-off-by: Victor Bustamante --- app/web/src/components/FuncEditor/FuncDetails.vue | 5 ++++- app/web/src/store/func/funcs.store.ts | 9 ++++++++- .../src/server/service/v2/func/create_unlocked_copy.rs | 7 ++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/web/src/components/FuncEditor/FuncDetails.vue b/app/web/src/components/FuncEditor/FuncDetails.vue index c40581ee1a..d5a3790bcc 100644 --- a/app/web/src/components/FuncEditor/FuncDetails.vue +++ b/app/web/src/components/FuncEditor/FuncDetails.vue @@ -322,7 +322,10 @@ const updateFunc = () => { const unlock = async () => { if (editingFunc.value?.funcId) { - const resp = await funcStore.CREATE_UNLOCKED_COPY(editingFunc.value.funcId); + const resp = await funcStore.CREATE_UNLOCKED_COPY( + editingFunc.value.funcId, + assetStore.selectedVariantId, + ); if (resp.result.success) { await assetStore.setFuncSelection(resp.result.data.summary.funcId); } diff --git a/app/web/src/store/func/funcs.store.ts b/app/web/src/store/func/funcs.store.ts index 08569b2829..e38906dfb8 100644 --- a/app/web/src/store/func/funcs.store.ts +++ b/app/web/src/store/func/funcs.store.ts @@ -23,6 +23,7 @@ import { trackEvent } from "@/utils/tracking"; import keyedDebouncer from "@/utils/keyedDebouncer"; import { useWorkspacesStore } from "@/store/workspaces.store"; import { useAssetStore } from "@/store/asset.store"; +import { SchemaVariantId } from "@/api/sdf/dal/schema"; import { useChangeSetsStore } from "../change_sets.store"; import { useRealtimeStore } from "../realtime/realtime.store"; import { useComponentsStore } from "../components.store"; @@ -201,10 +202,16 @@ export const useFuncStore = () => { }, }); }, - async CREATE_UNLOCKED_COPY(funcId: FuncId) { + async CREATE_UNLOCKED_COPY( + funcId: FuncId, + schemaVariantId?: SchemaVariantId, + ) { return new ApiRequest<{ summary: FuncSummary; code: FuncCode }>({ method: "post", url: `${API_PREFIX}/${funcId}/create_unlocked_copy`, + params: { + schemaVariantId, + }, onSuccess: (response) => { this.funcsById[response.summary.funcId] = response.summary; this.funcCodeById[response.code.funcId] = response.code; diff --git a/lib/sdf-server/src/server/service/v2/func/create_unlocked_copy.rs b/lib/sdf-server/src/server/service/v2/func/create_unlocked_copy.rs index 4f3ba3a3e6..2ca6b3eb87 100644 --- a/lib/sdf-server/src/server/service/v2/func/create_unlocked_copy.rs +++ b/lib/sdf-server/src/server/service/v2/func/create_unlocked_copy.rs @@ -1,6 +1,7 @@ use axum::{ - extract::{OriginalUri, Path, Query}, + extract::{OriginalUri, Path}, response::IntoResponse, + Json, }; use dal::{ func::authoring::FuncAuthoringClient, ChangeSet, ChangeSetId, FuncId, SchemaVariantId, @@ -19,7 +20,7 @@ use super::{get_code_response, get_types, FuncAPIResult}; #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct GetRequest { +pub struct UnlockFuncRequest { pub schema_variant_id: Option, } #[derive(Deserialize, Serialize, Debug)] @@ -34,8 +35,8 @@ pub async fn create_unlocked_copy( AccessBuilder(access_builder): AccessBuilder, PosthogClient(posthog_client): PosthogClient, OriginalUri(original_uri): OriginalUri, - Query(request): Query, Path((_workspace_pk, change_set_id, func_id)): Path<(WorkspacePk, ChangeSetId, FuncId)>, + Json(request): Json, ) -> FuncAPIResult { let mut ctx = builder .build(access_builder.build(change_set_id.into()))