Skip to content

Commit

Permalink
fix: add request tags and desc for glossary and terms (#14071)
Browse files Browse the repository at this point in the history
* fix: add request tags and desc for glossary and terms

* fix: breadcrumbs

* fix: add request tags cypress
  • Loading branch information
karanh37 authored Nov 23, 2023
1 parent 631145d commit 312b038
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ import {
SEARCH_ENTITY_TABLE,
} from '../../constants/constants';

const name = `test_dataconsumer${uuid()}`;

const CREDENTIALS = {
firstName: 'Cypress',
lastName: 'UserDC',
email: `test_dataconsumer${uuid()}@openmetadata.org`,
email: `${name}@openmetadata.org`,
password: 'User@OMD123',
username: 'CypressUserDC',
};
Expand Down Expand Up @@ -278,9 +280,7 @@ const updateTags = (inTerm) => {
'/api/v1/search/query?q=*&index=tag_search_index&from=0&size=*&query_filter=*',
'tags'
);
cy.get(
'[data-testid="tags-input-container"] [data-testid="add-tag"]'
).click();
cy.get('[data-testid="tags-container"] [data-testid="add-tag"]').click();

verifyResponseStatusCode('@tags', 200);

Expand All @@ -294,7 +294,7 @@ const updateTags = (inTerm) => {

cy.get('[data-testid="saveAssociatedTag"]').scrollIntoView().click();
const container = inTerm
? '[data-testid="tags-input-container"]'
? '[data-testid="tags-container"]'
: '[data-testid="glossary-details"]';
cy.wait(1000);
cy.get(container).scrollIntoView().contains('Personal').should('be.visible');
Expand Down Expand Up @@ -636,7 +636,7 @@ describe('Glossary page should work properly', () => {

// Remove Tag
cy.get(
'[data-testid="tags-input-container"] [data-testid="edit-button"]'
'[data-testid="tags-container"] [data-testid="edit-button"]'
).click();

cy.get('[data-testid="remove-tags"]').should('be.visible').click();
Expand Down Expand Up @@ -768,6 +768,64 @@ describe('Glossary page should work properly', () => {
voteGlossary();
});

it('Request Tags workflow for Glossary', function () {
cy.get('[data-testid="glossary-left-panel"]')
.contains(NEW_GLOSSARY_1.name)
.click();

interceptURL(
'GET',
`/api/v1/search/query?q=*%20AND%20disabled:false&index=tag_search_index*`,
'suggestTag'
);
interceptURL('POST', '/api/v1/feed', 'taskCreated');
interceptURL('PUT', '/api/v1/feed/tasks/*/resolve', 'taskResolve');

cy.get('[data-testid="request-entity-tags"]').should('exist').click();

// set assignees for task
cy.get(
'[data-testid="select-assignee"] > .ant-select-selector > .ant-select-selection-overflow'
)
.click()
.type(name);
cy.get(`[data-testid="assignee-option-${name}"]`).click();
cy.clickOutside();

cy.get('[data-testid="tag-selector"]')
.click()
.type('{backspace}')
.type('{backspace}')
.type('Personal');

verifyResponseStatusCode('@suggestTag', 200);
cy.get(
'.ant-select-dropdown [data-testid="tag-PersonalData.Personal"]'
).click();
cy.clickOutside();

cy.get('[data-testid="submit-tag-request"]').click();
verifyResponseStatusCode('@taskCreated', 201);

// Accept the tag suggestion which is created
cy.get('.ant-btn-compact-first-item').contains('Accept Suggestion').click();

verifyResponseStatusCode('@taskResolve', 200);

cy.reload();

cy.get('[data-testid="glossary-left-panel"]')
.contains(NEW_GLOSSARY_1.name)
.click();

checkDisplayName(NEW_GLOSSARY_1.name);

// Verify Tags which is added at the time of creating glossary
cy.get('[data-testid="tags-container"]')
.contains('Personal')
.should('be.visible');
});

it('Assets Tab should work properly', () => {
selectActiveGlossary(NEW_GLOSSARY.name);
const glossary = NEW_GLOSSARY.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const GlossaryDetails = ({
onAddGlossaryTerm,
onEditGlossaryTerm,
isVersionView,
onThreadLinkSelect,
}: GlossaryDetailsProps) => {
const { t } = useTranslation();
const history = useHistory();
Expand Down Expand Up @@ -131,15 +132,19 @@ const GlossaryDetails = ({
<Space className="w-full" direction="vertical" size={24}>
<DescriptionV1
description={description}
entityFqn={glossary.fullyQualifiedName}
entityName={glossary.displayName ?? glossary.name}
entityType={EntityType.GLOSSARY}
hasEditAccess={permissions.EditDescription || permissions.EditAll}
isEdit={isDescriptionEditable}
showCommentsIcon={false}
owner={glossary?.owner}
showActions={!glossary.deleted}
onCancel={() => setIsDescriptionEditable(false)}
onDescriptionEdit={() => setIsDescriptionEditable(true)}
onDescriptionUpdate={onDescriptionUpdate}
onThreadLinkSelect={onThreadLinkSelect}
/>

<GlossaryTermTab
isGlossary
childGlossaryTerms={glossaryTerms}
Expand All @@ -158,6 +163,7 @@ const GlossaryDetails = ({
isVersionView={isVersionView}
permissions={permissions}
selectedData={glossary}
onThreadLinkSelect={onThreadLinkSelect}
onUpdate={updateGlossary}
/>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ export type GlossaryDetailsProps = {
refreshGlossaryTerms: () => void;
onAddGlossaryTerm: (glossaryTerm: GlossaryTerm | undefined) => void;
onEditGlossaryTerm: (glossaryTerm: GlossaryTerm) => void;
onThreadLinkSelect: (value: string) => void;
};
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const mockProps = {
onAddGlossaryTerm: jest.fn(),
onEditGlossaryTerm: jest.fn(),
updateVote: jest.fn(),
onThreadLinkSelect: jest.fn(),
};

describe('Test Glossary-details component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { UserSelectableList } from '../../../components/common/UserSelectableLis
import { UserTeamSelectableList } from '../../../components/common/UserTeamSelectableList/UserTeamSelectableList.component';
import { OperationPermission } from '../../../components/PermissionProvider/PermissionProvider.interface';
import TagButton from '../../../components/TagButton/TagButton.component';
import TagsInput from '../../../components/TagsInput/TagsInput.component';
import {
DE_ACTIVE_COLOR,
getTeamAndUserDetailsPath,
Expand All @@ -31,7 +30,7 @@ import {
} from '../../../constants/constants';
import { EntityField } from '../../../constants/Feeds.constants';
import { EntityType } from '../../../enums/entity.enum';
import { Glossary } from '../../../generated/entity/data/glossary';
import { Glossary, TagSource } from '../../../generated/entity/data/glossary';
import {
GlossaryTerm,
TagLabel,
Expand All @@ -47,6 +46,8 @@ import {
getEntityVersionTags,
} from '../../../utils/EntityVersionUtils';
import { DomainLabel } from '../../common/DomainLabel/DomainLabel.component';
import TagsContainerV2 from '../../Tag/TagsContainerV2/TagsContainerV2';
import { DisplayType } from '../../Tag/TagsViewer/TagsViewer.interface';
import GlossaryReviewers from './GlossaryReviewers';

type Props = {
Expand All @@ -55,6 +56,7 @@ type Props = {
selectedData: Glossary | GlossaryTerm;
isGlossary: boolean;
onUpdate: (data: GlossaryTerm | Glossary) => void;
onThreadLinkSelect: (value: string) => void;
};

const GlossaryDetailsRightPanel = ({
Expand All @@ -63,6 +65,7 @@ const GlossaryDetailsRightPanel = ({
isGlossary,
onUpdate,
isVersionView,
onThreadLinkSelect,
}: Props) => {
const hasEditReviewerAccess = useMemo(() => {
return permissions.EditAll || permissions.EditReviewers;
Expand Down Expand Up @@ -307,11 +310,15 @@ const GlossaryDetailsRightPanel = ({
<Col span="24">
<div data-testid="glossary-tags-name">
{isGlossary && (
<TagsInput
editable={permissions.EditAll || permissions.EditTags}
isVersionView={isVersionView}
tags={tags}
onTagsUpdate={handleTagsUpdate}
<TagsContainerV2
displayType={DisplayType.READ_MORE}
entityFqn={selectedData.fullyQualifiedName}
entityType={EntityType.GLOSSARY}
permission={permissions.EditAll || permissions.EditTags}
selectedTags={tags ?? []}
tagType={TagSource.Classification}
onSelectionChange={handleTagsUpdate}
onThreadLinkSelect={onThreadLinkSelect}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('GlossaryDetailsRightPanel', () => {
isGlossary
permissions={mockPermissions}
selectedData={mockedGlossaries[0]}
onThreadLinkSelect={jest.fn()}
onUpdate={jest.fn()}
/>
</BrowserRouter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const GlossaryTermsV1 = ({
updateVote,
refreshActiveGlossaryTerm,
isVersionView,
onThreadLinkSelect,
}: GlossaryTermsV1Props) => {
const {
fqn: glossaryFqn,
Expand Down Expand Up @@ -130,6 +131,7 @@ const GlossaryTermsV1 = ({
isVersionView={isVersionView}
permissions={permissions}
selectedData={glossaryTerm}
onThreadLinkSelect={onThreadLinkSelect}
onUpdate={(data) => handleGlossaryTermUpdate(data as GlossaryTerm)}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export interface GlossaryTermsV1Props {
onEditGlossaryTerm: (glossaryTerm: GlossaryTerm) => void;
updateVote?: (data: VotingDataProps) => Promise<void>;
refreshActiveGlossaryTerm?: () => void;
onThreadLinkSelect: (value: string) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const mockProps = {
refreshActiveGlossaryTerm: jest.fn(),
onAddGlossaryTerm: jest.fn(),
onEditGlossaryTerm: jest.fn(),
onThreadLinkSelect: jest.fn(),
};

describe('Test Glossary-term component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ import { EntityType } from '../../../../enums/entity.enum';
import { Glossary } from '../../../../generated/entity/data/glossary';
import { GlossaryTerm } from '../../../../generated/entity/data/glossaryTerm';
import { ChangeDescription } from '../../../../generated/entity/type';
import { TagLabel } from '../../../../generated/type/tagLabel';
import { TagLabel, TagSource } from '../../../../generated/type/tagLabel';
import { getEntityName } from '../../../../utils/EntityUtils';
import {
getEntityVersionByField,
getEntityVersionTags,
} from '../../../../utils/EntityVersionUtils';
import DescriptionV1 from '../../../common/EntityDescription/DescriptionV1';
import { OperationPermission } from '../../../PermissionProvider/PermissionProvider.interface';
import TagsInput from '../../../TagsInput/TagsInput.component';
import TagsContainerV2 from '../../../Tag/TagsContainerV2/TagsContainerV2';
import { DisplayType } from '../../../Tag/TagsViewer/TagsViewer.interface';
import GlossaryDetailsRightPanel from '../../GlossaryDetailsRightPanel/GlossaryDetailsRightPanel.component';
import GlossaryTermReferences from './GlossaryTermReferences';
import GlossaryTermSynonyms from './GlossaryTermSynonyms';
Expand All @@ -37,6 +38,7 @@ type Props = {
onUpdate: (data: GlossaryTerm | Glossary) => Promise<void>;
isGlossary: boolean;
isVersionView?: boolean;
onThreadLinkSelect: (value: string) => void;
};

const GlossaryOverviewTab = ({
Expand All @@ -45,6 +47,7 @@ const GlossaryOverviewTab = ({
onUpdate,
isGlossary,
isVersionView,
onThreadLinkSelect,
}: Props) => {
const [isDescriptionEditable, setIsDescriptionEditable] =
useState<boolean>(false);
Expand Down Expand Up @@ -110,14 +113,17 @@ const GlossaryOverviewTab = ({
<Col span={24}>
<DescriptionV1
description={glossaryDescription}
entityFqn={selectedData.fullyQualifiedName}
entityName={getEntityName(selectedData)}
entityType={EntityType.GLOSSARY}
entityType={EntityType.GLOSSARY_TERM}
hasEditAccess={permissions.EditDescription || permissions.EditAll}
isEdit={isDescriptionEditable}
showCommentsIcon={false}
owner={selectedData?.owner}
showActions={!selectedData.deleted}
onCancel={() => setIsDescriptionEditable(false)}
onDescriptionEdit={() => setIsDescriptionEditable(true)}
onDescriptionUpdate={onDescriptionUpdate}
onThreadLinkSelect={onThreadLinkSelect}
/>
</Col>
<Col span={24}>
Expand Down Expand Up @@ -153,11 +159,15 @@ const GlossaryOverviewTab = ({

<Col span={12}>
<Space className="w-full" direction="vertical">
<TagsInput
editable={hasEditTagsPermissions}
isVersionView={isVersionView}
tags={tags}
onTagsUpdate={handleTagsUpdate}
<TagsContainerV2
displayType={DisplayType.READ_MORE}
entityFqn={selectedData.fullyQualifiedName}
entityType={EntityType.GLOSSARY_TERM}
permission={hasEditTagsPermissions}
selectedTags={tags ?? []}
tagType={TagSource.Classification}
onSelectionChange={handleTagsUpdate}
onThreadLinkSelect={onThreadLinkSelect}
/>
</Space>
</Col>
Expand All @@ -171,6 +181,7 @@ const GlossaryOverviewTab = ({
isVersionView={isVersionView}
permissions={permissions}
selectedData={selectedData}
onThreadLinkSelect={onThreadLinkSelect}
onUpdate={onUpdate}
/>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('GlossaryOverviewTab', () => {
isGlossary={isGlossary}
permissions={permissions}
selectedData={selectedData}
onThreadLinkSelect={jest.fn()}
onUpdate={onUpdate}
/>
</BrowserRouter>
Expand Down
Loading

0 comments on commit 312b038

Please sign in to comment.