Skip to main content

jellyflow_core/ops/mutation/planner/
sticky_notes.rs

1use crate::core::StickyNoteId;
2use crate::ops::{GraphOp, GraphTransaction};
3
4use super::GraphMutationPlanner;
5use crate::ops::mutation::GraphMutationError;
6use crate::ops::mutation::collect::bindings_for_sticky_note;
7
8impl GraphMutationPlanner<'_> {
9    pub fn remove_sticky_note_op(&self, id: StickyNoteId) -> Result<GraphOp, GraphMutationError> {
10        let note = self
11            .graph
12            .sticky_notes
13            .get(&id)
14            .cloned()
15            .ok_or(GraphMutationError::MissingStickyNote(id))?;
16
17        Ok(GraphOp::RemoveStickyNote {
18            id,
19            note,
20            bindings: bindings_for_sticky_note(self.graph, id),
21        })
22    }
23
24    pub fn remove_sticky_note_tx(
25        &self,
26        id: StickyNoteId,
27        label: impl Into<String>,
28    ) -> Result<GraphTransaction, GraphMutationError> {
29        Ok(GraphTransaction::new()
30            .with_label(label)
31            .with_ops([self.remove_sticky_note_op(id)?]))
32    }
33}