Skip to content

Commit

Permalink
Merge pull request #5160 from systeminit/fix/BUG-700-func-updated-eve…
Browse files Browse the repository at this point in the history
…nts-when-installing

BUG-700: adding WsEvent::FuncUpdated to component created endpoints
  • Loading branch information
jobelenus authored Dec 18, 2024
2 parents 9796322 + 815e7d6 commit fe0059a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/dal/src/diagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::{
use telemetry::prelude::*;
use thiserror::Error;

use crate::FuncError;
use crate::{
attribute::{
prototype::argument::{AttributePrototypeArgumentError, AttributePrototypeArgumentId},
Expand Down Expand Up @@ -76,6 +77,8 @@ pub enum DiagramError {
DiagramObjectNotFoundForView(ViewId),
#[error("edge not found")]
EdgeNotFound,
#[error("func error: {0}")]
Func(#[from] FuncError),
#[error("geometry can't represent: {0}")]
GeometryCannotRepresentNodeWeight(NodeWeightDiscriminants),
#[error("geometry not found: {0}")]
Expand Down
6 changes: 4 additions & 2 deletions lib/sdf-server/src/service/diagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use dal::{
slow_rt::SlowRuntimeError,
socket::{input::InputSocketError, output::OutputSocketError},
workspace_snapshot::WorkspaceSnapshotError,
ChangeSetError, SchemaError, SchemaId, SchemaVariantId, StandardModelError, TransactionsError,
WsEventError,
ChangeSetError, FuncError, SchemaError, SchemaId, SchemaVariantId, StandardModelError,
TransactionsError, WsEventError,
};
use std::num::{ParseFloatError, ParseIntError};
use telemetry::prelude::*;
Expand Down Expand Up @@ -75,6 +75,8 @@ pub enum DiagramError {
EdgeNotFound,
#[error("frame socket not found for schema variant id: {0}")]
FrameSocketNotFound(SchemaVariantId),
#[error("func error: {0}")]
Func(#[from] FuncError),
#[error("invalid header name {0}")]
Hyper(#[from] hyper::http::Error),
#[error("InferredConnectionGraph error: {0}")]
Expand Down
10 changes: 9 additions & 1 deletion lib/sdf-server/src/service/diagram/create_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use axum::{
};
use serde::{Deserialize, Serialize};

use dal::diagram::view::View;
use dal::{
change_status::ChangeStatus, component::frame::Frame, generate_name, ChangeSet, Component,
ComponentId, Schema, SchemaId, SchemaVariant, SchemaVariantId, Visibility, WsEvent,
};
use dal::{diagram::view::View, Func};
use si_events::audit_log::AuditLogKind;
use si_frontend_types::SchemaVariant as FrontendVariant;

Expand Down Expand Up @@ -94,6 +94,14 @@ pub async fn create_component(
.await?
.publish_on_commit(&ctx)
.await?;
for func_id in front_end_variant.func_ids.iter() {
let func = Func::get_by_id_or_error(&ctx, *func_id).await?;
let front_end_func = func.into_frontend_type(&ctx).await?;
WsEvent::func_updated(&ctx, front_end_func, None)
.await?
.publish_on_commit(&ctx)
.await?;
}

(variant_id, Some(front_end_variant))
}
Expand Down
6 changes: 4 additions & 2 deletions lib/sdf-server/src/service/v2/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use dal::{
pkg::PkgError,
slow_rt::SlowRuntimeError,
workspace_snapshot::graph::WorkspaceSnapshotGraphError,
ChangeSetError, ComponentError, SchemaError, SchemaId, SchemaVariantError, TransactionsError,
WorkspaceSnapshotError, WsEventError,
ChangeSetError, ComponentError, FuncError, SchemaError, SchemaId, SchemaVariantError,
TransactionsError, WorkspaceSnapshotError, WsEventError,
};
use thiserror::Error;
use tokio::task::JoinError;
Expand Down Expand Up @@ -46,6 +46,8 @@ pub enum ViewError {
DalDiagram(#[from] dal::diagram::DiagramError),
#[error("frame error: {0}")]
Frame(#[from] FrameError),
#[error("func error: {0}")]
Func(#[from] FuncError),
#[error("inferred connection graph error: {0}")]
InferredConnectionGraph(#[from] InferredConnectionGraphError),
#[error("invalid request: {0}")]
Expand Down
9 changes: 9 additions & 0 deletions lib/sdf-server/src/service/v2/view/create_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use axum::{
Json,
};
use dal::diagram::geometry::Geometry;
use dal::Func;
use serde::{Deserialize, Serialize};

use dal::diagram::view::ViewId;
Expand Down Expand Up @@ -120,6 +121,14 @@ pub async fn create_component(
.await?
.publish_on_commit(&ctx)
.await?;
for func_id in front_end_variant.func_ids.iter() {
let func = Func::get_by_id_or_error(&ctx, *func_id).await?;
let front_end_func = func.into_frontend_type(&ctx).await?;
WsEvent::func_updated(&ctx, front_end_func, None)
.await?
.publish_on_commit(&ctx)
.await?;
}

(
variant_id,
Expand Down

0 comments on commit fe0059a

Please sign in to comment.