Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/components/Editor/Context/PipelineDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import { useFlagValue } from "@/components/shared/Settings/useFlags";
import { BlockStack } from "@/components/ui/layout";
import useToastNotification from "@/hooks/useToastNotification";
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
import {
FLEX_NODES_ANNOTATION,
PIPELINE_NOTES_ANNOTATION,
PIPELINE_TAGS_ANNOTATION,
} from "@/utils/annotations";
import { SYSTEM_ANNOTATIONS } from "@/utils/annotations";
import { getComponentFileFromList } from "@/utils/componentStore";
import { USER_PIPELINES_LIST_NAME } from "@/utils/constants";
import { tracking } from "@/utils/tracking";
Expand All @@ -29,12 +25,6 @@ import { PipelineValidationList } from "./PipelineValidationList";
import RenamePipeline from "./RenamePipeline";
import { PipelineTags } from "./Tags/PipelineTags";

const EXCLUDED_ANNOTATIONS = [
PIPELINE_NOTES_ANNOTATION,
FLEX_NODES_ANNOTATION,
PIPELINE_TAGS_ANNOTATION,
];

const PipelineDetails = () => {
const notify = useToastNotification();
const { componentSpec, digest, globalValidationIssues } = useComponentSpec();
Expand Down Expand Up @@ -95,7 +85,7 @@ const PipelineDetails = () => {
];

const annotations = Object.entries(componentSpec.metadata?.annotations || {})
.filter(([key]) => !EXCLUDED_ANNOTATIONS.includes(key))
.filter(([key]) => !SYSTEM_ANNOTATIONS.includes(key))
.map(([key, value]) => ({
label: key,
value: String(value),
Expand Down
11 changes: 2 additions & 9 deletions src/components/PipelineRun/RunDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import { useBackend } from "@/providers/BackendProvider";
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
import { useExecutionData } from "@/providers/ExecutionDataProvider";
import {
FLEX_NODES_ANNOTATION,
getAnnotationValue,
getPipelineTagsFromSpec,
PIPELINE_NOTES_ANNOTATION,
PIPELINE_TAGS_ANNOTATION,
SYSTEM_ANNOTATIONS,
} from "@/utils/annotations";
import {
flattenExecutionStatusStats,
Expand All @@ -31,12 +30,6 @@ import { ActionButton } from "../shared/Buttons/ActionButton";
import { TagList } from "../shared/Tags/TagList";
import { RunNotesEditor } from "./RunNotesEditor";

const EXCLUDED_ANNOTATIONS = [
PIPELINE_NOTES_ANNOTATION,
FLEX_NODES_ANNOTATION,
PIPELINE_TAGS_ANNOTATION,
];

export const RunDetails = () => {
const { configured } = useBackend();
const { componentSpec } = useComponentSpec();
Expand Down Expand Up @@ -95,7 +88,7 @@ export const RunDetails = () => {
const tags = getPipelineTagsFromSpec(componentSpec);

const displayedAnnotations = Object.entries(pipelineAnnotations)
.filter(([key]) => !EXCLUDED_ANNOTATIONS.includes(key))
.filter(([key]) => !SYSTEM_ANNOTATIONS.includes(key))
.map(([key, value]) => ({ label: key, value: String(value) }));

const isRunCreator =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { Text } from "@/components/ui/typography";
import type { Task } from "@/models/componentSpec";
import { useAnalytics } from "@/providers/AnalyticsProvider";
import { useTaskActions } from "@/routes/v2/pages/Editor/store/actions/useTaskActions";

const TASK_COLOR_ANNOTATION = "tangleml.com/editor/task-color";
import { TASK_COLOR_ANNOTATION } from "@/utils/annotations";

export const BatchTaskColor = observer(function BatchTaskColor({
tasks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useTaskActions } from "@/routes/v2/pages/Editor/store/actions/useTaskAc
import { useEditorSession } from "@/routes/v2/pages/Editor/store/EditorSessionContext";
import { MenuTriggerButton } from "@/routes/v2/shared/components/MenuTriggerButton";
import { useSharedStores } from "@/routes/v2/shared/store/SharedStoreContext";
import { EDITOR_POSITION_ANNOTATION } from "@/utils/annotations";
import { componentMetadata } from "@/utils/componentTracking";
import { getErrorMessage } from "@/utils/string";
import { tracking } from "@/utils/tracking";
Expand Down Expand Up @@ -62,7 +63,7 @@ export const NodeMenu = observer(function NodeMenu() {
const handleDuplicate = () => {
if (!task) return;
track("v2.pipeline_editor.node_menu.duplicate_task.click");
const position = task.annotations.get("editor.position") ?? {
const position = task.annotations.get(EDITOR_POSITION_ANNOTATION) ?? {
x: 0,
y: 0,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useSpec } from "@/routes/v2/shared/providers/SpecContext";
import { useSharedStores } from "@/routes/v2/shared/store/SharedStoreContext";
import {
PIPELINE_NOTES_ANNOTATION,
PIPELINE_TAGS_ANNOTATION,
SYSTEM_ANNOTATIONS,
} from "@/utils/annotations";

import { InputsBlock } from "./components/InputsBlock";
Expand All @@ -25,15 +25,6 @@ import { PipelineDetailsHeader } from "./components/PipelineDetailsHeader";
import { PipelineDetailsTextField } from "./components/PipelineDetailsTextField";
import { TagsBlock } from "./components/TagsBlock";

const SYSTEM_PIPELINE_ANNOTATIONS = [
"notes",
PIPELINE_TAGS_ANNOTATION,
"flex-nodes",
"tangleml.com/editor/edge-conduits",
"sdk",
"editor.flow-direction",
];

export const PipelineDetailsContent = observer(
function PipelineDetailsContent() {
const { track } = useAnalytics();
Expand Down Expand Up @@ -133,7 +124,7 @@ export const PipelineDetailsContent = observer(
<Separator />
<AnnotationsBlock
annotations={pipelineSpec.annotations}
systemAnnotationKeys={SYSTEM_PIPELINE_ANNOTATIONS}
systemAnnotationKeys={SYSTEM_ANNOTATIONS}
/>
</BlockStack>
</PipelineDetailsCollapsibleSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
} from "@/models/componentSpec/annotations";
import { getConduits } from "@/routes/v2/shared/nodes/ConduitNode/conduit.utils";
import type { UndoGroupable } from "@/routes/v2/shared/nodes/types";
import { EDGE_CONDUITS_ANNOTATION } from "@/utils/annotations";

const DEFAULT_COLORS = [
"#6366f1",
Expand Down Expand Up @@ -37,7 +38,7 @@ function pickColor(existing: EdgeConduit[]): string {
export { getConduits } from "@/routes/v2/shared/nodes/ConduitNode/conduit.utils";

function setConduits(spec: ComponentSpec, conduits: EdgeConduit[]) {
spec.setMetadata("tangleml.com/editor/edge-conduits", conduits);
spec.setMetadata(EDGE_CONDUITS_ANNOTATION, conduits);
}

export function addGuideline(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import {
IncrementingIdGenerator,
} from "@/models/componentSpec";
import type { UndoGroupable } from "@/routes/v2/shared/nodes/types";

const FLEX_NODES_KEY = "flex-nodes" as const;
import { FLEX_NODES_ANNOTATION } from "@/utils/annotations";

const idGen = new IncrementingIdGenerator();

export function getFlexNodes(spec: ComponentSpec): FlexNodeData[] {
return spec.annotations.get(FLEX_NODES_KEY);
return spec.annotations.get(FLEX_NODES_ANNOTATION);
}

export function setFlexNodes(
Expand All @@ -25,7 +24,7 @@ export function setFlexNodes(
nodes: FlexNodeData[],
) {
undo.withGroup("Update flex nodes", () => {
spec.annotations.set(FLEX_NODES_KEY, nodes);
spec.annotations.set(FLEX_NODES_ANNOTATION, nodes);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
snapshotInput,
} from "@/routes/v2/shared/nodes/IONode/inputManifestBase";
import type { NodeTypeManifest } from "@/routes/v2/shared/nodes/types";
import { EDITOR_POSITION_ANNOTATION } from "@/utils/annotations";
import { deepClone } from "@/utils/deepClone";

import { InputDetails } from "./context/InputDetails";
Expand Down Expand Up @@ -49,7 +50,7 @@ export const inputManifest: NodeTypeManifest = {
optional: snapshot.data.optional,
annotations: Annotations.from([
...snapshot.data.annotations,
{ key: "editor.position", value: position },
{ key: EDITOR_POSITION_ANNOTATION, value: position },
]),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
snapshotOutput,
} from "@/routes/v2/shared/nodes/IONode/outputManifestBase";
import type { NodeTypeManifest } from "@/routes/v2/shared/nodes/types";
import { EDITOR_POSITION_ANNOTATION } from "@/utils/annotations";
import { deepClone } from "@/utils/deepClone";

import { OutputDetails } from "./context/OutputDetails";
Expand Down Expand Up @@ -47,7 +48,7 @@ export const outputManifest: NodeTypeManifest = {
description: snapshot.data.description,
annotations: Annotations.from([
...snapshot.data.annotations,
{ key: "editor.position", value: position },
{ key: EDITOR_POSITION_ANNOTATION, value: position },
]),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useTaskActions } from "@/routes/v2/pages/Editor/store/actions/useTaskAc
import { useEditorSession } from "@/routes/v2/pages/Editor/store/EditorSessionContext";
import { useSpec } from "@/routes/v2/shared/providers/SpecContext";
import { useSharedStores } from "@/routes/v2/shared/store/SharedStoreContext";
import { EDITOR_COLLAPSED_ANNOTATION } from "@/utils/annotations";
import { SYSTEM_ANNOTATIONS, ZINDEX_ANNOTATION } from "@/utils/annotations";
import { tracking } from "@/utils/tracking";

import { getTaskYamlText } from "./components/actions/getTaskYamlText";
Expand All @@ -26,13 +26,6 @@ import { TaskActionsBar } from "./components/TaskActionsBar";
import { TaskArgumentsEditor } from "./components/TaskArgumentsEditor";
import { useTask } from "./hooks/useTask";

const SYSTEM_TASK_ANNOTATIONS = [
"editor.position",
"tangleml.com/editor/task-color",
"tangleml.com/editor/edge-conduits",
EDITOR_COLLAPSED_ANNOTATION,
];

interface TaskDetailsProps {
entityId: string;
}
Expand Down Expand Up @@ -83,7 +76,7 @@ export const TaskDetails = observer(function TaskDetails({

const handleZIndexChange = (newZIndex: number) => {
undo.withGroup("Update task z-index", () => {
task.annotations.set("zIndex", newZIndex);
task.annotations.set(ZINDEX_ANNOTATION, newZIndex);
});
};

Expand Down Expand Up @@ -227,7 +220,7 @@ export const TaskDetails = observer(function TaskDetails({
>
<AnnotationsBlock
annotations={task.annotations}
systemAnnotationKeys={SYSTEM_TASK_ANNOTATIONS}
systemAnnotationKeys={SYSTEM_ANNOTATIONS}
/>
</TabsContent>
</Tabs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { Heading, Paragraph } from "@/components/ui/typography";
import type { Task } from "@/models/componentSpec";
import { useAnalytics } from "@/providers/AnalyticsProvider";
import type { AnnotationConfig, Annotations } from "@/types/annotations";
import { EDITOR_COLLAPSED_ANNOTATION } from "@/utils/annotations";
import {
EDITOR_COLLAPSED_ANNOTATION,
TASK_COLOR_ANNOTATION,
} from "@/utils/annotations";
import { ISO8601_DURATION_ZERO_DAYS } from "@/utils/constants";

import { useTaskConfigActions } from "./useTaskConfigActions";
Expand Down Expand Up @@ -130,7 +133,7 @@ export const ConfigurationSection = observer(function ConfigurationSection({
track("v2.pipeline_editor.task_details.collapse_node.toggle");
};

const taskColor = task.annotations.get("tangleml.com/editor/task-color");
const taskColor = task.annotations.get(TASK_COLOR_ANNOTATION);
const isCollapsed =
task.annotations.get(EDITOR_COLLAPSED_ANNOTATION) === "true";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useToastNotification from "@/hooks/useToastNotification";
import { useTask } from "@/routes/v2/pages/Editor/nodes/TaskNode/context/TaskDetails/hooks/useTask";
import { useTaskActions } from "@/routes/v2/pages/Editor/store/actions/useTaskActions";
import { useSpec } from "@/routes/v2/shared/providers/SpecContext";
import { EDITOR_POSITION_ANNOTATION } from "@/utils/annotations";
import { getErrorMessage } from "@/utils/string";

interface DuplicateTaskButtonProps {
Expand All @@ -20,7 +21,7 @@ export function DuplicateTaskButton({ entityId }: DuplicateTaskButtonProps) {
const { mutate, isPending } = useMutation({
mutationFn: async () => {
if (!spec || !task) throw new Error("No spec or task available");
const position = task.annotations.get("editor.position") ?? {
const position = task.annotations.get(EDITOR_POSITION_ANNOTATION) ?? {
x: 0,
y: 0,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Task } from "@/models/componentSpec";
import type { UndoGroupable } from "@/routes/v2/shared/nodes/types";
import type { AnnotationConfig } from "@/types/annotations";
import { EDITOR_COLLAPSED_ANNOTATION } from "@/utils/annotations";
import {
EDITOR_COLLAPSED_ANNOTATION,
TASK_COLOR_ANNOTATION,
} from "@/utils/annotations";
import { ISO8601_DURATION_ZERO_DAYS } from "@/utils/constants";

const TASK_COLOR_ANNOTATION = "tangleml.com/editor/task-color";

export function toggleCacheDisable(
undo: UndoGroupable,
task: Task,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "@/routes/v2/shared/nodes/TaskNode/taskManifestBase";
import type { NodeTypeManifest } from "@/routes/v2/shared/nodes/types";
import { hydrateComponentReference } from "@/services/componentService";
import { EDITOR_POSITION_ANNOTATION } from "@/utils/annotations";
import type { TaskSpec } from "@/utils/componentSpec";
import { deepClone } from "@/utils/deepClone";

Expand Down Expand Up @@ -51,7 +52,7 @@ export const taskManifest: NodeTypeManifest = {
const uniqueName = generateUniqueTaskName(spec, snapshot.name);
const annotations = Annotations.from([
...snapshot.data.annotations,
{ key: "editor.position", value: position },
{ key: EDITOR_POSITION_ANNOTATION, value: position },
]);

const clonedComponentRef = deepClone(snapshot.data.componentRef);
Expand Down
7 changes: 4 additions & 3 deletions src/routes/v2/pages/Editor/store/actions/io.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@/routes/v2/pages/Editor/store/nameUtils";
import type { UndoGroupable } from "@/routes/v2/shared/nodes/types";
import type { ParentContext } from "@/routes/v2/shared/store/navigationStore";
import { EDITOR_POSITION_ANNOTATION } from "@/utils/annotations";

import {
propagateInputDelete,
Expand All @@ -33,7 +34,7 @@ export function addInput(
$id: idGen.next("input"),
name: inputName,
});
input.annotations.set("editor.position", {
input.annotations.set(EDITOR_POSITION_ANNOTATION, {
x: position.x,
y: position.y,
});
Expand All @@ -54,7 +55,7 @@ export function addOutput(
$id: idGen.next("output"),
name: outputName,
});
output.annotations.set("editor.position", {
output.annotations.set(EDITOR_POSITION_ANNOTATION, {
x: position.x,
y: position.y,
});
Expand Down Expand Up @@ -242,7 +243,7 @@ export function createInputAndConnect(
if (targetTaskIds.length === 0) return;

const firstTask = spec.tasks.find((t) => targetTaskIds.includes(t.$id));
const taskPos = firstTask?.annotations.get("editor.position") ?? {
const taskPos = firstTask?.annotations.get(EDITOR_POSITION_ANNOTATION) ?? {
x: 0,
y: 0,
};
Expand Down
12 changes: 9 additions & 3 deletions src/routes/v2/pages/Editor/store/actions/pipeline.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import {
} from "@/models/componentSpec";
import { generateUniqueTaskName } from "@/routes/v2/pages/Editor/store/nameUtils";
import type { UndoGroupable } from "@/routes/v2/shared/nodes/types";
import { PIPELINE_NOTES_ANNOTATION } from "@/utils/annotations";
import { PIPELINE_TAGS_ANNOTATION } from "@/utils/annotations";
import {
EDITOR_POSITION_ANNOTATION,
PIPELINE_NOTES_ANNOTATION,
PIPELINE_TAGS_ANNOTATION,
} from "@/utils/annotations";

import { idGen } from "./utils";

Expand Down Expand Up @@ -87,7 +90,10 @@ export function createSubgraph(

if (!result) return null;

result.replacementTask.annotations.set("editor.position", position);
result.replacementTask.annotations.set(
EDITOR_POSITION_ANNOTATION,
position,
);
return result;
});

Expand Down
Loading
Loading