Skip to content

Commit

Permalink
Merge pull request #4100 from systeminit/brit/add-wseevents-authoring
Browse files Browse the repository at this point in the history
add wsevent when creating unlocked func copy, correctly import builti…
  • Loading branch information
britmyerss authored Jul 5, 2024
2 parents dcac307 + 1614e3b commit 24a15e7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
42 changes: 37 additions & 5 deletions lib/dal/src/func/authoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ impl FuncAuthoringClient {
let schema = SchemaVariant::schema_id_for_schema_variant_id(ctx, schema_variant_id).await?;
// is the current schema varaint already unlocked? if so, proceed
let current_schema_variant = SchemaVariant::get_by_id(ctx, schema_variant_id).await?;
if !current_schema_variant.is_locked() {
let new_func = if !current_schema_variant.is_locked() {
//already on an unlocked variant, just create unlocked copy of the func and reattach
// bindings for that schema variant
let unlocked_latest =
Expand All @@ -620,7 +620,7 @@ impl FuncAuthoringClient {
}
// ws event

Ok(new_func)
new_func
} else if current_schema_variant.is_default(ctx).await? {
let new_schema_variant =
VariantAuthoringClient::create_unlocked_variant_copy(ctx, schema_variant_id)
Expand All @@ -644,14 +644,46 @@ impl FuncAuthoringClient {
binding.port_binding_to_new_func(ctx, new_func.id).await?;
}
}
// ws event

return Ok(new_func);
new_func
} else {
return Err(FuncAuthoringError::CannotUnlockNonDefaultSchemaVariant(
schema_variant_id,
));
}
};

let bindings: Vec<si_frontend_types::FuncBinding> = FuncBinding::for_func_id(ctx, func_id)
.await?
.into_iter()
.map(|binding| binding.into())
.collect();
let new_bindings: Vec<si_frontend_types::FuncBinding> =
FuncBinding::for_func_id(ctx, new_func.id)
.await?
.into_iter()
.map(|binding| binding.into())
.collect();
WsEvent::func_bindings_updated(
ctx,
si_frontend_types::FuncBindings { bindings },
Self::compile_types_from_bindings(ctx, func_id).await?,
)
.await?
.publish_on_commit(ctx)
.await?;

WsEvent::func_bindings_updated(
ctx,
si_frontend_types::FuncBindings {
bindings: new_bindings,
},
Self::compile_types_from_bindings(ctx, new_func.id).await?,
)
.await?
.publish_on_commit(ctx)
.await?;

Ok(new_func)
}

/// Find all the latest [`SchemaVariant`]s that have bindings for the given [`FuncId`]
Expand Down
2 changes: 1 addition & 1 deletion lib/dal/src/pkg/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async fn import_change_set(
func_spec,
installed_module.clone(),
thing_map,
options.is_builtin,
options.create_unlocked,
)
.await?
};
Expand Down

0 comments on commit 24a15e7

Please sign in to comment.