From 3561b0e7ec12abfaa5ff0ce2b41fe91cba52c91f Mon Sep 17 00:00:00 2001 From: JuanPabloDiaz Date: Wed, 21 Aug 2024 21:28:18 -0400 Subject: [PATCH] Add ability to edit schema description closes #39 --- .../modals/EditSchemaDescriptionModal.tsx | 60 +++++++++++ src/hooks/schemas.tsx | 41 +++++++ src/pages/SchemaDetails.tsx | 101 ++++++++++++------ 3 files changed, 169 insertions(+), 33 deletions(-) create mode 100644 src/components/modals/EditSchemaDescriptionModal.tsx diff --git a/src/components/modals/EditSchemaDescriptionModal.tsx b/src/components/modals/EditSchemaDescriptionModal.tsx new file mode 100644 index 0000000..d219cec --- /dev/null +++ b/src/components/modals/EditSchemaDescriptionModal.tsx @@ -0,0 +1,60 @@ +import { Button, Form, Modal, Typography } from 'antd'; +import React, { useCallback, useRef } from 'react'; +import TextArea from 'antd/es/input/TextArea'; +import { UpdateSchemaMutationParams } from '../../hooks/schemas'; + +interface EditSchemaDescriptionModalProps { + open: boolean; + schema: UpdateSchemaMutationParams; + closeModal: () => void; + onSubmit: (comment: UpdateSchemaMutationParams) => void; + loading: boolean; +} + +export function EditSchemaDescriptionModal({ + open, + schema, + closeModal, + onSubmit, + loading, +}: EditSchemaDescriptionModalProps) { + const submitRef = useRef(null); + + const handleSubmit = useCallback(() => { + submitRef.current?.click(); + }, []); + + return ( + Edit description} + okText="Save" + cancelText="Cancel" + open={open} + destroyOnClose + onCancel={closeModal} + onOk={handleSubmit} + okButtonProps={{ loading: loading }} + > + + Schema description + + + layout="vertical" + onFinish={(values) => { + onSubmit(values); + }} + name="Edit description form" + initialValues={{ comment: schema.comment }} + > + +