mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-25 09:28:23 +00:00
Fix #5471 Creating a tag with an illegal character prevents utilizing the tagging system until manually removed (#5854)
This commit is contained in:
parent
e7f57d90c3
commit
111106312d
@ -24,6 +24,7 @@ type FormModalProp = {
|
||||
header: string;
|
||||
initialData: FormData;
|
||||
errorData?: FormErrorData;
|
||||
isSaveButtonDisabled?: boolean;
|
||||
};
|
||||
type FormRef = {
|
||||
fetchMarkDownData: () => string;
|
||||
@ -36,6 +37,7 @@ const FormModal = ({
|
||||
header,
|
||||
initialData,
|
||||
errorData,
|
||||
isSaveButtonDisabled,
|
||||
}: FormModalProp) => {
|
||||
const formRef = useRef<FormRef>();
|
||||
const [data, setData] = useState<FormData>(initialData);
|
||||
@ -81,6 +83,7 @@ const FormModal = ({
|
||||
</Button>
|
||||
<Button
|
||||
data-testid="saveButton"
|
||||
disabled={isSaveButtonDisabled}
|
||||
size="regular"
|
||||
theme="primary"
|
||||
type="submit"
|
||||
|
@ -19,3 +19,6 @@ export const FQN_REGEX = new RegExp(
|
||||
`("${FQN_SEPARATOR_CHAR}*?"|[^"${FQN_SEPARATOR_CHAR}\\s]+)(?=\\s*.|\\s*$)`,
|
||||
'g'
|
||||
);
|
||||
|
||||
export const delimiterRegex = /[\\[\]\\()\\;\\,\\|\\{}\\``\\/\\<>\\^]/g;
|
||||
export const nameWithSpace = /\s/g;
|
||||
|
@ -15,7 +15,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { Card } from 'antd';
|
||||
import { AxiosError, AxiosResponse } from 'axios';
|
||||
import classNames from 'classnames';
|
||||
import { isUndefined, toLower } from 'lodash';
|
||||
import { isEmpty, isUndefined, toLower } from 'lodash';
|
||||
import { FormErrorData, LoadingState } from 'Models';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
@ -43,6 +43,7 @@ import ConfirmationModal from '../../components/Modals/ConfirmationModal/Confirm
|
||||
import FormModal from '../../components/Modals/FormModal';
|
||||
import { ModalWithMarkdownEditor } from '../../components/Modals/ModalWithMarkdownEditor/ModalWithMarkdownEditor';
|
||||
import { TITLE_FOR_NON_ADMIN_ACTION } from '../../constants/constants';
|
||||
import { delimiterRegex, nameWithSpace } from '../../constants/regex.constants';
|
||||
import {
|
||||
CreateTagCategory,
|
||||
TagCategoryType,
|
||||
@ -149,8 +150,10 @@ const TagsPage = () => {
|
||||
const errData: { [key: string]: string } = {};
|
||||
if (!data.name.trim()) {
|
||||
errData['name'] = 'Name is required';
|
||||
} else if (/\s/g.test(data.name)) {
|
||||
} else if (nameWithSpace.test(data.name)) {
|
||||
errData['name'] = 'Name with space is not allowed';
|
||||
} else if (delimiterRegex.test(data.name)) {
|
||||
errData['name'] = 'Name with delimiters are not allowed';
|
||||
} else if (
|
||||
!isUndefined(
|
||||
categories.find((item) => toLower(item.name) === toLower(data.name))
|
||||
@ -308,8 +311,10 @@ const TagsPage = () => {
|
||||
const errData: { [key: string]: string } = {};
|
||||
if (!data.name.trim()) {
|
||||
errData['name'] = 'Name is required';
|
||||
} else if (/\s/g.test(data.name)) {
|
||||
} else if (nameWithSpace.test(data.name)) {
|
||||
errData['name'] = 'Name with space is not allowed';
|
||||
} else if (delimiterRegex.test(data.name)) {
|
||||
errData['name'] = 'Name with delimiters are not allowed';
|
||||
} else if (
|
||||
!isUndefined(
|
||||
currentCategory?.children?.find(
|
||||
@ -713,10 +718,12 @@ const TagsPage = () => {
|
||||
description: '',
|
||||
categoryType: TagCategoryType.Descriptive,
|
||||
}}
|
||||
isSaveButtonDisabled={!isEmpty(errorDataCategory)}
|
||||
onCancel={() => setIsAddingCategory(false)}
|
||||
onChange={(data) =>
|
||||
onNewCategoryChange(data as TagCategory)
|
||||
}
|
||||
onChange={(data) => {
|
||||
setErrorDataCategory({});
|
||||
onNewCategoryChange(data as TagCategory);
|
||||
}}
|
||||
onSave={(data) => createCategory(data as TagCategory)}
|
||||
/>
|
||||
)}
|
||||
@ -732,8 +739,12 @@ const TagsPage = () => {
|
||||
description: '',
|
||||
categoryType: '',
|
||||
}}
|
||||
isSaveButtonDisabled={!isEmpty(errorDataTag)}
|
||||
onCancel={() => setIsAddingTag(false)}
|
||||
onChange={(data) => onNewTagChange(data as TagCategory)}
|
||||
onChange={(data) => {
|
||||
setErrorDataTag({});
|
||||
onNewTagChange(data as TagCategory);
|
||||
}}
|
||||
onSave={(data) => createPrimaryTag(data as TagCategory)}
|
||||
/>
|
||||
)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user