Fix issue-4216 Remove Associated Tags field from tags page (#4308)

This commit is contained in:
Shailesh Parmar 2022-04-21 13:51:10 +05:30 committed by GitHub
parent 9ccfd4f7cd
commit 1bf12f729b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 100 deletions

View File

@ -425,17 +425,12 @@ describe('Test TagsPage page', () => {
const name = await findByTestId(container, 'heading-name'); const name = await findByTestId(container, 'heading-name');
const description = await findByTestId(container, 'heading-description'); const description = await findByTestId(container, 'heading-description');
const actions = await findByTestId(container, 'heading-actions'); const actions = await findByTestId(container, 'heading-actions');
const associatedTags = await findByTestId(
container,
'heading-associated-tags'
);
const tableBody = await findByTestId(container, 'table-body'); const tableBody = await findByTestId(container, 'table-body');
expect(table).toBeInTheDocument(); expect(table).toBeInTheDocument();
expect(actions).toBeInTheDocument(); expect(actions).toBeInTheDocument();
expect(name).toBeInTheDocument(); expect(name).toBeInTheDocument();
expect(description).toBeInTheDocument(); expect(description).toBeInTheDocument();
expect(associatedTags).toBeInTheDocument();
expect(tableBody).toBeInTheDocument(); expect(tableBody).toBeInTheDocument();
}); });

View File

@ -15,8 +15,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { AxiosError, AxiosResponse } from 'axios'; import { AxiosError, AxiosResponse } from 'axios';
import classNames from 'classnames'; import classNames from 'classnames';
import { isUndefined, toLower } from 'lodash'; import { isUndefined, toLower } from 'lodash';
import { EntityTags, FormErrorData, LoadingState } from 'Models'; import { FormErrorData, LoadingState } from 'Models';
import React, { useCallback, useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; import { useAuthContext } from '../../authentication/auth-provider/AuthProvider';
import { import {
@ -39,8 +39,6 @@ import Loader from '../../components/Loader/Loader';
import ConfirmationModal from '../../components/Modals/ConfirmationModal/ConfirmationModal'; import ConfirmationModal from '../../components/Modals/ConfirmationModal/ConfirmationModal';
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 TagsContainer from '../../components/tags-container/tags-container';
import Tags from '../../components/tags/tags';
import { import {
getExplorePathWithSearch, getExplorePathWithSearch,
TITLE_FOR_NON_ADMIN_ACTION, TITLE_FOR_NON_ADMIN_ACTION,
@ -61,11 +59,7 @@ import {
} from '../../utils/CommonUtils'; } from '../../utils/CommonUtils';
import { getErrorText } from '../../utils/StringsUtils'; import { getErrorText } from '../../utils/StringsUtils';
import SVGIcons from '../../utils/SvgUtils'; import SVGIcons from '../../utils/SvgUtils';
import { import { getTagCategories } from '../../utils/TagsUtils';
getTagCategories,
getTaglist,
getTagOptionsFromFQN,
} from '../../utils/TagsUtils';
import { showErrorToast } from '../../utils/ToastUtils'; import { showErrorToast } from '../../utils/ToastUtils';
import Form from './Form'; import Form from './Form';
@ -101,14 +95,6 @@ const TagsPage = () => {
state: false, state: false,
}); });
const getTags = useCallback(() => {
const filteredTags = getTaglist(categories).filter(
(tag) => editTag?.fullyQualifiedName !== tag
);
return getTagOptionsFromFQN(filteredTags);
}, [currentCategory, editTag]);
const fetchCategories = () => { const fetchCategories = () => {
setIsLoading(true); setIsLoading(true);
getTagCategories('usageCount') getTagCategories('usageCount')
@ -393,32 +379,6 @@ const TagsPage = () => {
}); });
}; };
const handleTagSelection = (tags?: Array<EntityTags>) => {
const newTags = tags?.map((tag) => tag.tagFQN);
if (newTags && editTag) {
updateTag(currentCategory?.name, editTag?.name, {
description: editTag?.description,
name: editTag?.name,
associatedTags: newTags,
})
.then((res: AxiosResponse) => {
if (res.data) {
fetchCurrentCategory(currentCategory?.name as string, true);
} else {
throw jsonData['api-error-messages']['unexpected-server-response'];
}
})
.catch((err: AxiosError) => {
showErrorToast(
err,
jsonData['api-error-messages']['update-tags-error']
);
});
}
setEditTag(undefined);
};
const getUsageCountLink = (tagFQN: string) => { const getUsageCountLink = (tagFQN: string) => {
if (tagFQN.startsWith('Tier')) { if (tagFQN.startsWith('Tier')) {
return `${getExplorePathWithSearch()}?tier=${tagFQN}`; return `${getExplorePathWithSearch()}?tier=${tagFQN}`;
@ -575,11 +535,6 @@ const TagsPage = () => {
data-testid="heading-description"> data-testid="heading-description">
Description Description
</th> </th>
<th
className="tableHead-cell tw-w-60"
data-testid="heading-associated-tags">
Associated tags
</th>
<th <th
className="tableHead-cell tw-w-10" className="tableHead-cell tw-w-10"
data-testid="heading-actions"> data-testid="heading-actions">
@ -655,53 +610,6 @@ const TagsPage = () => {
)} )}
</div> </div>
</td> </td>
<td
className="tw-group tableBody-cell"
onClick={() => {
setEditTag(tag);
}}>
<NonAdminAction
permission={Operation.UpdateTags}
position="left"
title={TITLE_FOR_NON_ADMIN_ACTION}
trigger="click">
<TagsContainer
editable={
editTag?.name === tag.name && !isEditTag
}
selectedTags={
tag.associatedTags?.map((tag) => ({
tagFQN: tag,
})) || []
}
tagList={getTags()}
onCancel={() => {
handleTagSelection();
}}
onSelectionChange={(tags) => {
handleTagSelection(tags);
}}>
{tag.associatedTags?.length ? (
<button className="tw-opacity-0 tw-ml-1 group-hover:tw-opacity-100 focus:tw-outline-none">
<SVGIcons
alt="edit"
icon="icon-edit"
title="Edit"
width="10px"
/>
</button>
) : (
<span className="tw-opacity-60 group-hover:tw-opacity-100 tw-text-grey-muted group-hover:tw-text-primary">
<Tags
startWith="+ "
tag="Add tag"
type="outlined"
/>
</span>
)}
</TagsContainer>
</NonAdminAction>
</td>
<td className="tableBody-cell"> <td className="tableBody-cell">
<div className="tw-text-center"> <div className="tw-text-center">
<NonAdminAction <NonAdminAction