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