- Are you sure to delete {targetName}?
+ Are you sure to delete {obj.getName()}?
Please enter Confirm to confirm deletion:
diff --git a/frontend/plugins/kubepanel/src/pages/kubepanel/components/action-button/update-editor-modal.tsx b/frontend/plugins/kubepanel/src/pages/kubepanel/components/action-button/update-editor-modal.tsx
index 9a66de24e25..a81c227eb3d 100644
--- a/frontend/plugins/kubepanel/src/pages/kubepanel/components/action-button/update-editor-modal.tsx
+++ b/frontend/plugins/kubepanel/src/pages/kubepanel/components/action-button/update-editor-modal.tsx
@@ -1,15 +1,15 @@
+import { updateResource } from '@/api/kubernetes';
import { KubeObject } from '@/k8slens/kube-object';
-import { ApiResp } from '@/services/kubernet';
+import { buildErrorResponse } from '@/services/backend/response';
import { dumpKubeObject } from '@/utils/yaml';
import { Editor } from '@monaco-editor/react';
import { Button, Modal, message } from 'antd';
import { editor } from 'monaco-editor';
-import { useEffect, useRef, useState } from 'react';
+import { useRef } from 'react';
interface Props {
obj?: K;
open: boolean;
- onUpdate: (data: string) => Promise;
onCancel: () => void;
onOk: () => void;
}
@@ -17,33 +17,15 @@ interface Props {
const UpdateEditorModal = ({
obj,
open,
- onUpdate,
onCancel,
onOk
}: Props) => {
if (!obj) return null;
- const [clickedUpdate, setClickedUpdate] = useState(false);
const [msgApi, contextHolder] = message.useMessage();
+ const msgKey = 'updatedMsg';
const editorRef = useRef();
- useEffect(() => {
- if (!clickedUpdate || !editorRef.current) return;
- const updateRequest = async () => {
- const resp = await onUpdate(editorRef.current!.getValue());
- if (resp.code === 200) {
- msgApi.success('Successfully updated');
- onOk();
- } else {
- msgApi.error(`Failed to update: ${resp.data.message}`);
- }
-
- setClickedUpdate(false);
- };
-
- updateRequest();
- }, [clickedUpdate]);
-
const editorValue = dumpKubeObject(obj);
return (
@@ -53,8 +35,38 @@ const UpdateEditorModal = ({
title={{`${obj.kind}: ${obj.getName()}`}
}
open={open}
onCancel={onCancel}
+ destroyOnClose
footer={[
-