diff --git a/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/index.tsx b/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/index.tsx index 1a4a0743..980f6d6d 100644 --- a/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/index.tsx +++ b/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/index.tsx @@ -258,6 +258,14 @@ const WorkloadPage = () => { label: 'Daemonset', value: WorkloadKind.Daemonset, }, + { + label: 'Cronjob', + value: WorkloadKind.Cronjob, + }, + { + label: 'Job', + value: WorkloadKind.Job, + }, ]} /> @@ -315,6 +323,7 @@ const WorkloadPage = () => { mode={editorState.mode} workloadContent={editorState.content} open={showModal} + kind={filter.kind} onOk={async (ret) => { const msg = editorState.mode === 'edit' diff --git a/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/new-workload-editor-modal.tsx b/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/new-workload-editor-modal.tsx index 5a5c587f..517a08c7 100644 --- a/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/new-workload-editor-modal.tsx +++ b/ui/apps/dashboard/src/pages/multicloud-resource-manage/workload/new-workload-editor-modal.tsx @@ -1,26 +1,28 @@ import i18nInstance from '@/utils/i18n'; import { FC, useEffect, useState } from 'react'; -import { Modal } from 'antd'; +import { Form, Modal, Select } from 'antd'; import Editor from '@monaco-editor/react'; -import { parse, stringify } from 'yaml'; +import { parse } from 'yaml'; import _ from 'lodash'; -import { PutResource } from '@/services/unstructured'; -import { CreateDeployment } from '@/services/workload'; -import { IResponse } from '@/services/base.ts'; +import { CreateResource, PutResource } from '@/services/unstructured'; +import { IResponse, WorkloadKind } from '@/services/base.ts'; export interface NewWorkloadEditorModalProps { mode: 'create' | 'edit'; open: boolean; + kind: WorkloadKind; workloadContent?: string; onOk: (ret: IResponse) => Promise; onCancel: () => Promise | void; } + const NewWorkloadEditorModal: FC = (props) => { - const { mode, open, workloadContent = '', onOk, onCancel } = props; + const { mode, open, workloadContent = '', onOk, onCancel, kind } = props; const [content, setContent] = useState(workloadContent); useEffect(() => { console.log('workloadContent', workloadContent); setContent(workloadContent); }, [workloadContent]); + function handleEditorChange(value: string | undefined) { setContent(value || ''); } @@ -40,15 +42,15 @@ const NewWorkloadEditorModal: FC = (props) => { const namespace = _.get(yamlObject, 'metadata.namespace'); const name = _.get(yamlObject, 'metadata.name'); if (mode === 'create') { - if (kind.toLowerCase() === 'deployment') { - const ret = await CreateDeployment({ - namespace, - name, - content: stringify(yamlObject), - }); - await onOk(ret); - setContent(''); - } + const ret = await CreateResource({ + kind, + name, + namespace, + content: yamlObject, + }); + console.log('ret', ret); + await onOk(ret); + setContent(''); } else { const ret = await PutResource({ kind, @@ -68,14 +70,46 @@ const NewWorkloadEditorModal: FC = (props) => { setContent(''); }} > + +