From cbb0b837c0253debaf2ea12c9bcf4e961c11b6b7 Mon Sep 17 00:00:00 2001 From: darth-coder00 <86726556+darth-coder00@users.noreply.github.com> Date: Tue, 11 Jan 2022 15:06:46 +0530 Subject: [PATCH] Fix: Misc issues for adding Tags, Teams and Service (#2149) * Fix: Misc issues for adding Tags, Teams and Service * Addressing comments --- .../AddServiceModal/AddServiceModal.tsx | 11 +- .../src/components/Modals/FormModal/index.tsx | 18 ++- .../resources/ui/src/interface/types.d.ts | 4 + .../main/resources/ui/src/pages/tags/Form.tsx | 33 +++--- .../resources/ui/src/pages/tags/index.tsx | 106 ++++++++++++++---- .../resources/ui/src/pages/teams/Form.tsx | 31 +++-- .../resources/ui/src/pages/teams/index.tsx | 63 +++++++++-- .../resources/ui/src/utils/CommonUtils.tsx | 8 ++ 8 files changed, 205 insertions(+), 69 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Modals/AddServiceModal/AddServiceModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Modals/AddServiceModal/AddServiceModal.tsx index 0233297092a..9e749e58101 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Modals/AddServiceModal/AddServiceModal.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Modals/AddServiceModal/AddServiceModal.tsx @@ -24,6 +24,7 @@ import { import { DatabaseService } from '../../../generated/entity/services/databaseService'; import { MessagingService } from '../../../generated/entity/services/messagingService'; import { PipelineService } from '../../../generated/entity/services/pipelineService'; +import { errorMsg } from '../../../utils/CommonUtils'; // import { fromISOString } from '../../../utils/ServiceUtils'; import { Button } from '../../buttons/Button/Button'; import MarkdownWithPreview from '../../common/editor/MarkdownWithPreview'; @@ -161,14 +162,6 @@ const seprateUrl = (url?: string) => { return {}; }; -const errorMsg = (value: string) => { - return ( -
- {value} -
- ); -}; - export const AddServiceModal: FunctionComponent = ({ header, serviceName, @@ -338,7 +331,7 @@ export const AddServiceModal: FunctionComponent = ({ const handleSave = () => { let setMsg: ErrorMsg = { selectService: !selectService, - name: !name, + name: !name.trim(), }; switch (serviceName) { case ServiceCategory.DATABASE_SERVICES: diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Modals/FormModal/index.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Modals/FormModal/index.tsx index 05892f570b2..39583bc436f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Modals/FormModal/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Modals/FormModal/index.tsx @@ -11,27 +11,31 @@ * limitations under the License. */ -import { Team } from 'Models'; +import { FormErrorData, Team } from 'Models'; import React, { useRef, useState } from 'react'; import { TagsCategory } from '../../../pages/tags/tagsTypes'; import { Button } from '../../buttons/Button/Button'; type FormData = TagsCategory | Team; type FormModalProp = { onCancel: () => void; - onSave: (data: TagsCategory) => void; + onChange?: (data: TagsCategory | Team) => void; + onSave: (data: TagsCategory | Team) => void; form: React.ElementType; header: string; initialData: FormData; + errorData?: FormErrorData; }; type FormRef = { fetchMarkDownData: () => string; }; const FormModal = ({ onCancel, + onChange, onSave, form: Form, header, initialData, + errorData, }: FormModalProp) => { const formRef = useRef(); const [data, setData] = useState(initialData); @@ -57,7 +61,15 @@ const FormModal = ({

-
+ { + setData(data); + onChange && onChange(data); + }} + />