Skip to content

Commit

Permalink
fix: save button
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl committed Feb 5, 2025
1 parent f70a550 commit 9d9f409
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions keep-ui/shared/ui/YAMLCodeblock/ui/MonacoYAMLEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Download, Copy, Check, Save } from "lucide-react";
import { Button } from "@tremor/react";
import { LogEntry } from "@/shared/api/workflow-executions";
import { getStepStatus } from "@/shared/lib/logs-utils";
import yaml from "js-yaml";
import { useWorkflowActions } from "@/entities/workflows/model/useWorkflowActions";
import "./MonacoYAMLEditor.css";

interface Props {
Expand All @@ -19,7 +21,6 @@ interface Props {
selectedStep?: string | null;
setSelectedStep?: (step: string | null) => void;
readOnly?: boolean;
onSave?: (content: string) => Promise<void>;
}

const MonacoYAMLEditor = ({
Expand All @@ -33,9 +34,9 @@ const MonacoYAMLEditor = ({
selectedStep,
setSelectedStep,
readOnly = false,
onSave,
}: Props) => {
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
const { updateWorkflow } = useWorkflowActions();

const findStepNameForPosition = (
lineNumber: number,
Expand Down Expand Up @@ -435,11 +436,16 @@ const MonacoYAMLEditor = ({
}, [workflowRaw]);

const handleSaveWorkflow = async () => {
if (!editorRef.current || !onSave) return;
if (!editorRef.current) return;

const content = editorRef.current.getValue();
try {
await onSave(content);
const parsedYaml = yaml.load(content) as {
workflow: Record<string, unknown>;
};
// update workflow
await updateWorkflow(workflowId!, parsedYaml);

setOriginalContent(content);
setHasChanges(false);
} catch (err) {
Expand Down Expand Up @@ -497,7 +503,7 @@ const MonacoYAMLEditor = ({
style={{ height: "calc(100vh - 300px)" }}
>
<div className="absolute right-2 top-2 z-10 flex gap-2">
{!readOnly && onSave && (
{!readOnly && (
<Button
color="orange"
size="sm"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep"
version = "0.35.14"
version = "0.35.15"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
packages = [{include = "keep"}]
Expand Down

0 comments on commit 9d9f409

Please sign in to comment.