Skip to content

Commit

Permalink
Merge pull request #4099 from systeminit/victor/bug-446-only-unlock-f…
Browse files Browse the repository at this point in the history
…unc-for-single-variant-by-default

fix: Don't unlock all variants for func automatically
  • Loading branch information
vbustamante authored Jul 5, 2024
2 parents 4ddca7d + f3b9bee commit 656ab88
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/web/src/components/FuncEditor/FuncDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 8 additions & 1 deletion app/web/src/store/func/funcs.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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<SchemaVariantId>,
}
#[derive(Deserialize, Serialize, Debug)]
Expand All @@ -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<GetRequest>,
Path((_workspace_pk, change_set_id, func_id)): Path<(WorkspacePk, ChangeSetId, FuncId)>,
Json(request): Json<UnlockFuncRequest>,
) -> FuncAPIResult<impl IntoResponse> {
let mut ctx = builder
.build(access_builder.build(change_set_id.into()))
Expand Down

0 comments on commit 656ab88

Please sign in to comment.