UI Fixed Deleting the Tier tag category causes UI errors #5849 (#8703)

* UI Fixed Deleting the Tier tag category causes UI errors #5849

* fixed failing test

* updated logic for restricting system tags deletion
This commit is contained in:
Shailesh Parmar 2022-11-14 19:50:36 +05:30 committed by GitHub
parent db0215f964
commit 4faafe4235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View File

@ -254,6 +254,7 @@ jest.mock('../../utils/TagsUtils', () => ({
.mockImplementation(() => Promise.resolve({ data: mockTagsCategory })),
getTaglist: jest.fn().mockReturnValue(['tag 1', 'tag 2']),
getTagOptionsFromFQN: jest.fn().mockReturnValue([]),
isSystemTierTags: jest.fn().mockReturnValue(false),
}));
jest.mock(

View File

@ -67,7 +67,7 @@ import {
} from '../../utils/RouterUtils';
import { getErrorText } from '../../utils/StringsUtils';
import SVGIcons, { Icons } from '../../utils/SvgUtils';
import { getTagCategories } from '../../utils/TagsUtils';
import { getTagCategories, isSystemTierTags } from '../../utils/TagsUtils';
import { showErrorToast } from '../../utils/ToastUtils';
import Form from './Form';
import './TagPage.style.less';
@ -592,7 +592,10 @@ const TagsPage = () => {
<button
className="link-text"
data-testid="delete-tag"
disabled={!categoryPermissions.EditAll}
disabled={
isSystemTierTags(record.fullyQualifiedName || '') ||
!categoryPermissions.EditAll
}
onClick={() => handleActionDeleteTag(record)}>
{deleteTags.data?.id === record.id ? (
deleteTags.data?.status === 'success' ? (
@ -661,7 +664,10 @@ const TagsPage = () => {
<Button
className="tw-h-8 tw-rounded tw-ml-2"
data-testid="delete-tag-category-button"
disabled={!categoryPermissions.Delete}
disabled={
isSystemTierTags(currentCategory.name || '') ||
!categoryPermissions.Delete
}
size="small"
onClick={() => {
deleteTagHandler();

View File

@ -151,3 +151,16 @@ export const fetchTagsAndGlossaryTerms = async () => {
return tagsAndTerms;
};
export const isSystemTierTags = (tag: string) => {
const tierTags = [
'Tier',
'Tier.Tier1',
'Tier.Tier2',
'Tier.Tier3',
'Tier.Tier4',
'Tier.Tier5',
];
return tierTags.includes(tag);
};