diff --git a/package-lock.json b/package-lock.json index 49cb142..f004367 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@ant-design/icons": "5.6.0", "@monaco-editor/react": "4.6.0", "@originjs/vite-plugin-federation": "1.3.6", - "@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.20", + "@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.21", "@readme/openapi-parser": "4.0.0", "@reduxjs/toolkit": "2.2.5", "@tanstack/react-query": "5.62.2", @@ -2752,9 +2752,9 @@ } }, "node_modules/@prorobotech/openapi-k8s-toolkit": { - "version": "0.0.1-alpha.20", - "resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.20.tgz", - "integrity": "sha512-sooiZUyFwOpc0iUX+uNGy9Qr1iwJkjvn286dkCAyuWbLjhWPXUMi5hiJ1Y0DdtdeZV31zHIx+bVFJ1jBhw1YsQ==", + "version": "0.0.1-alpha.21", + "resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.21.tgz", + "integrity": "sha512-1uXnvf5s82VyuJTnNwmliQtIOtIMmd20/xwXHN4uh0BP8Y6dOCpUP5tGUlo7zhbvm6Gh2uZhYhSFqqxZPw11Kw==", "license": "MIT", "dependencies": { "@monaco-editor/react": "4.6.0", diff --git a/package.json b/package.json index 6446401..f6245df 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@ant-design/icons": "5.6.0", "@monaco-editor/react": "4.6.0", "@originjs/vite-plugin-federation": "1.3.6", - "@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.20", + "@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.21", "@readme/openapi-parser": "4.0.0", "@reduxjs/toolkit": "2.2.5", "@tanstack/react-query": "5.62.2", diff --git a/src/App.tsx b/src/App.tsx index 5e3e969..02321fc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,6 +29,7 @@ import { FormApiPage, FormCrdPage, FactoryPage, + FactoryAdminPage, } from 'pages' import { getBasePrefix } from 'utils/getBaseprefix' import { colorsLight, colorsDark, sizes } from 'constants/colors' @@ -127,6 +128,7 @@ export const App: FC = ({ isFederation, forcedTheme }) => { element={} /> } /> + } /> ) diff --git a/src/pages/FactoryAdminPage/AddComponentModal.tsx b/src/pages/FactoryAdminPage/AddComponentModal.tsx new file mode 100644 index 0000000..f2d7616 --- /dev/null +++ b/src/pages/FactoryAdminPage/AddComponentModal.tsx @@ -0,0 +1,52 @@ +import React, { useState } from 'react' +import { Modal, Button, Form, Select } from 'antd' +import { ComponentType } from './types' + +export const componentTypes: ComponentType[] = [ + 'antdText', + 'antdCard', + 'antdFlex', + 'antdRow', + 'antdCol', + 'partsOfUrl', + 'multiQuery', + 'parsedText', +] + +interface AddComponentModalProps { + onAdd: (type: ComponentType) => void + title?: string +} + +export const AddComponentModal: React.FC = ({ onAdd, title = 'Add Component' }) => { + const [visible, setVisible] = useState(false) + const [form] = Form.useForm() + + const handleSubmit = (values: { type: ComponentType }) => { + onAdd(values.type) + setVisible(false) + form.resetFields() + } + + return ( + <> + + setVisible(false)} footer={null}> +
+ + + + +
+
+ + ) +} diff --git a/src/pages/FactoryAdminPage/AntdCardForm.tsx b/src/pages/FactoryAdminPage/AntdCardForm.tsx new file mode 100644 index 0000000..7e97207 --- /dev/null +++ b/src/pages/FactoryAdminPage/AntdCardForm.tsx @@ -0,0 +1,73 @@ +/* eslint-disable no-console */ +/* eslint-disable no-param-reassign */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import React, { useEffect } from 'react' +import { Form, Input, Select, Button, Switch } from 'antd' + +const { TextArea } = Input +const { Option } = Select + +interface AntdCardFormProps { + initialValues: any // This would be `TDynamicComponentsAppTypeMap['antdCard']` + onSave: (data: any) => void +} + +export const AntdCardForm: React.FC = ({ initialValues, onSave }) => { + const [form] = Form.useForm() + + useEffect(() => { + form.setFieldsValue(initialValues) + }, [initialValues, form]) + + const handleSubmit = (values: any) => { + try { + if (values.style) { + values.style = JSON.parse(values.style) + } + } catch (e) { + console.log('Invalid JSON for style', e) + return + } + + onSave(values) + } + + return ( +
+ + + + + + + + + + + + + + + + + +