Fix #3784: Part 1 - fixing Explore and Glossary page (#3786)

This commit is contained in:
darth-coder00 2022-03-31 23:04:51 +05:30 committed by GitHub
parent 0ee2c48cf2
commit c50f71b478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 44 additions and 31 deletions

View File

@ -21,6 +21,7 @@ import React, { FunctionComponent, useEffect, useState } from 'react';
import appState from '../../AppState'; import appState from '../../AppState';
import { useAuthContext } from '../../auth-provider/AuthProvider'; import { useAuthContext } from '../../auth-provider/AuthProvider';
import { getCategory } from '../../axiosAPIs/tagAPI'; import { getCategory } from '../../axiosAPIs/tagAPI';
import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants';
import { Operation } from '../../generated/entity/policies/accessControl/rule'; import { Operation } from '../../generated/entity/policies/accessControl/rule';
import { useAuth } from '../../hooks/authHooks'; import { useAuth } from '../../hooks/authHooks';
import { getUserTeams } from '../../utils/CommonUtils'; import { getUserTeams } from '../../utils/CommonUtils';
@ -193,7 +194,7 @@ const ManageTab: FunctionComponent<Props> = ({
if (res.data) { if (res.data) {
const tierData = res.data.children.map( const tierData = res.data.children.map(
(tier: { name: string; description: string }) => ({ (tier: { name: string; description: string }) => ({
id: `Tier.${tier.name}`, id: `Tier${FQN_SEPARATOR_CHAR}${tier.name}`,
title: tier.name, title: tier.name,
description: tier.description.substring( description: tier.description.substring(
0, 0,

View File

@ -45,15 +45,15 @@ jest.mock('../../hooks/authHooks', () => ({
const mockTierData = { const mockTierData = {
children: [ children: [
{ {
fullyQualifiedName: 'Tier.Tier1', fullyQualifiedName: 'Tier:Tier1',
description: 'description for card 1', description: 'description for card 1',
}, },
{ {
fullyQualifiedName: 'Tier.Tier2', fullyQualifiedName: 'Tier:Tier2',
description: 'description for card 2', description: 'description for card 2',
}, },
{ {
fullyQualifiedName: 'Tier.Tier3', fullyQualifiedName: 'Tier:Tier3',
description: 'description for card 3', description: 'description for card 3',
}, },
], ],

View File

@ -35,7 +35,7 @@ const followHandler = jest.fn();
const versionHandler = jest.fn(); const versionHandler = jest.fn();
const onThreadLinkSelect = jest.fn(); const onThreadLinkSelect = jest.fn();
const mockTier = { const mockTier = {
tagFQN: 'Tier.Tier1', tagFQN: 'Tier:Tier1',
description: '', description: '',
source: 'Tag', source: 'Tag',
labelType: 'Manual', labelType: 'Manual',

View File

@ -27,7 +27,7 @@ const FilterContainer: FunctionComponent<FilterContainerProp> = ({
isDisabled = false, isDisabled = false,
}: FilterContainerProp) => { }: FilterContainerProp) => {
const getFilterName = (name = '') => { const getFilterName = (name = '') => {
const formattedName = name.startsWith('Tier.Tier') const formattedName = name.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`)
? name.split(FQN_SEPARATOR_CHAR)[1] ? name.split(FQN_SEPARATOR_CHAR)[1]
: name; : name;

View File

@ -34,13 +34,13 @@ const TableDataCardBody: FunctionComponent<Props> = ({
}: Props) => { }: Props) => {
const getTagValue = (tag: string | TagLabel): string | TagLabel => { const getTagValue = (tag: string | TagLabel): string | TagLabel => {
if (isString(tag)) { if (isString(tag)) {
return tag.startsWith('Tier.Tier') return tag.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`)
? tag.split(FQN_SEPARATOR_CHAR)[1] ? tag.split(FQN_SEPARATOR_CHAR)[1]
: tag; : tag;
} else { } else {
return { return {
...tag, ...tag,
tagFQN: tag.tagFQN.startsWith('Tier.Tier') tagFQN: tag.tagFQN.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`)
? tag.tagFQN.split(FQN_SEPARATOR_CHAR)[1] ? tag.tagFQN.split(FQN_SEPARATOR_CHAR)[1]
: tag.tagFQN, : tag.tagFQN,
}; };

View File

@ -28,10 +28,10 @@ const tagList = [
]; ];
const tagListWithTier = [ const tagListWithTier = [
{ fqn: 'Tier.Tier1', source: 'Tag' }, { fqn: 'Tier:Tier1', source: 'Tag' },
{ fqn: 'Data.Tier1Data', source: 'Tag' }, { fqn: 'Data:Tier1Data', source: 'Tag' },
{ fqn: 'Tier.Tier2', source: 'Glossary' }, { fqn: 'Tier:Tier2', source: 'Glossary' },
{ fqn: 'Count.Tier2Count', source: 'Glossary' }, { fqn: 'Count:Tier2Count', source: 'Glossary' },
]; ];
const onCancel = jest.fn(); const onCancel = jest.fn();
const onSelectionChange = jest.fn(); const onSelectionChange = jest.fn();

View File

@ -16,6 +16,7 @@ import classNames from 'classnames';
import { isNull } from 'lodash'; import { isNull } from 'lodash';
import { EntityTags, TagOption } from 'Models'; import { EntityTags, TagOption } from 'Models';
import React, { FunctionComponent, useEffect, useRef, useState } from 'react'; import React, { FunctionComponent, useEffect, useRef, useState } from 'react';
import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants';
import { Source } from '../../generated/type/tagLabel'; import { Source } from '../../generated/type/tagLabel';
import { withLoader } from '../../hoc/withLoader'; import { withLoader } from '../../hoc/withLoader';
import { Button } from '../buttons/Button/Button'; import { Button } from '../buttons/Button/Button';
@ -76,7 +77,7 @@ const TagsContainer: FunctionComponent<TagsContainerProps> = ({
.filter((tag) => { .filter((tag) => {
return !tags.some((selectedTag) => selectedTag.tagFQN === tag.fqn); return !tags.some((selectedTag) => selectedTag.tagFQN === tag.fqn);
}) })
.filter((tag) => !tag.fqn?.startsWith('Tier.Tier')) // To filter out Tier tags .filter((tag) => !tag.fqn?.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`)) // To filter out Tier tags
.map((tag) => { .map((tag) => {
return { return {
name: tag.fqn, name: tag.fqn,

View File

@ -11,6 +11,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { FQN_SEPARATOR_CHAR } from './char.constants';
export const FOLLOWERS_VIEW_CAP = 20; export const FOLLOWERS_VIEW_CAP = 20;
export const JSON_TAB_SIZE = 2; export const JSON_TAB_SIZE = 2;
export const PAGE_SIZE = 10; export const PAGE_SIZE = 10;
@ -59,11 +61,11 @@ export const ONLY_NUMBER_REGEX = /^[0-9\b]+$/;
/* eslint-disable @typescript-eslint/camelcase */ /* eslint-disable @typescript-eslint/camelcase */
export const tiers = [ export const tiers = [
{ key: 'Tier.Tier1', doc_count: 0 }, { key: `Tier${FQN_SEPARATOR_CHAR}Tier1`, doc_count: 0 },
{ key: 'Tier.Tier2', doc_count: 0 }, { key: `Tier${FQN_SEPARATOR_CHAR}Tier2`, doc_count: 0 },
{ key: 'Tier.Tier3', doc_count: 0 }, { key: `Tier${FQN_SEPARATOR_CHAR}Tier3`, doc_count: 0 },
{ key: 'Tier.Tier4', doc_count: 0 }, { key: `Tier${FQN_SEPARATOR_CHAR}Tier4`, doc_count: 0 },
{ key: 'Tier.Tier5', doc_count: 0 }, { key: `Tier${FQN_SEPARATOR_CHAR}Tier5`, doc_count: 0 },
]; ];
export const versionTypes = [ export const versionTypes = [

View File

@ -11,6 +11,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { FQN_SEPARATOR_CHAR } from './char.constants';
/* eslint-disable */ /* eslint-disable */
export const mockFeedData = [ export const mockFeedData = [
@ -3746,7 +3748,7 @@ export const mockSearchData = {
'User.CreditCardNumber', 'User.CreditCardNumber',
], ],
fqdn: 'bigquery.shopify.fact_sale', fqdn: 'bigquery.shopify.fact_sale',
tier: 'Tier.Tier1', tier: `Tier${FQN_SEPARATOR_CHAR}Tier1`,
schema_description: null, schema_description: null,
owner: '', owner: '',
followers: [], followers: [],
@ -3787,7 +3789,7 @@ export const mockSearchData = {
sum_other_doc_count: 0, sum_other_doc_count: 0,
buckets: [ buckets: [
{ {
key: 'Tier.Tier1', key: `Tier${FQN_SEPARATOR_CHAR}Tier1`,
doc_count: 1, doc_count: 1,
}, },
], ],
@ -3894,7 +3896,7 @@ export const mockSearchData = {
sum_other_doc_count: 0, sum_other_doc_count: 0,
buckets: [ buckets: [
{ {
key: 'Tier.Tier1', key: `Tier${FQN_SEPARATOR_CHAR}Tier1`,
doc_count: 1, doc_count: 1,
}, },
], ],
@ -4001,7 +4003,7 @@ export const mockSearchData = {
sum_other_doc_count: 0, sum_other_doc_count: 0,
buckets: [ buckets: [
{ {
key: 'Tier.Tier1', key: `Tier${FQN_SEPARATOR_CHAR}Tier1`,
doc_count: 1, doc_count: 1,
}, },
], ],
@ -4108,7 +4110,7 @@ export const mockSearchData = {
sum_other_doc_count: 0, sum_other_doc_count: 0,
buckets: [ buckets: [
{ {
key: 'Tier.Tier1', key: `Tier${FQN_SEPARATOR_CHAR}Tier1`,
doc_count: 1, doc_count: 1,
}, },
], ],

View File

@ -662,7 +662,9 @@ const DatabaseDetails: FunctionComponent = () => {
sizeCap={-1} sizeCap={-1}
tags={(table.tags || []).map((tag) => ({ tags={(table.tags || []).map((tag) => ({
...tag, ...tag,
tagFQN: tag.tagFQN?.startsWith('Tier.Tier') tagFQN: tag.tagFQN?.startsWith(
`Tier${FQN_SEPARATOR_CHAR}Tier`
)
? tag.tagFQN.split(FQN_SEPARATOR_CHAR)[1] ? tag.tagFQN.split(FQN_SEPARATOR_CHAR)[1]
: tag.tagFQN, : tag.tagFQN,
}))} }))}

View File

@ -127,7 +127,7 @@ const createGlossaryTermNode = (
leafFqn: string, leafFqn: string,
name: string name: string
): GlossaryTermTreeNode => { ): GlossaryTermTreeNode => {
const arrFQN = leafFqn.split(`${name}.`); const arrFQN = leafFqn.split(`${name}${FQN_SEPARATOR_CHAR}`);
const childName = arrFQN[1]?.split(FQN_SEPARATOR_CHAR)[0]; const childName = arrFQN[1]?.split(FQN_SEPARATOR_CHAR)[0];
return !childName return !childName
@ -239,7 +239,9 @@ export const getActionsList = () => {
*/ */
export const getHierarchicalKeysByFQN = (fqn: string) => { export const getHierarchicalKeysByFQN = (fqn: string) => {
const keys = fqn.split(FQN_SEPARATOR_CHAR).reduce((prev, curr) => { const keys = fqn.split(FQN_SEPARATOR_CHAR).reduce((prev, curr) => {
const currFqn = prev.length ? `${prev[prev.length - 1]}.${curr}` : curr; const currFqn = prev.length
? `${prev[prev.length - 1]}${FQN_SEPARATOR_CHAR}${curr}`
: curr;
return [...prev, currFqn]; return [...prev, currFqn];
}, [] as string[]); }, [] as string[]);

View File

@ -18,6 +18,7 @@ import { EntityTags, TableDetail } from 'Models';
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import AppState from '../AppState'; import AppState from '../AppState';
import PopOver from '../components/common/popover/PopOver'; import PopOver from '../components/common/popover/PopOver';
import { FQN_SEPARATOR_CHAR } from '../constants/char.constants';
import { import {
getDashboardDetailsPath, getDashboardDetailsPath,
getDatabaseDetailsPath, getDatabaseDetailsPath,
@ -74,7 +75,7 @@ export const getTierFromTableTags = (
): EntityTags['tagFQN'] => { ): EntityTags['tagFQN'] => {
const tierTag = tags.find( const tierTag = tags.find(
(item) => (item) =>
item.tagFQN.startsWith('Tier.Tier') && item.tagFQN.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`) &&
!isNaN(parseInt(item.tagFQN.substring(9).trim())) !isNaN(parseInt(item.tagFQN.substring(9).trim()))
); );
@ -84,7 +85,7 @@ export const getTierFromTableTags = (
export const getTierTags = (tags: Array<TagLabel>) => { export const getTierTags = (tags: Array<TagLabel>) => {
const tierTag = tags.find( const tierTag = tags.find(
(item) => (item) =>
item.tagFQN.startsWith('Tier.Tier') && item.tagFQN.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`) &&
!isNaN(parseInt(item.tagFQN.substring(9).trim())) !isNaN(parseInt(item.tagFQN.substring(9).trim()))
); );
@ -96,7 +97,7 @@ export const getTagsWithoutTier = (
): Array<EntityTags> => { ): Array<EntityTags> => {
return tags.filter( return tags.filter(
(item) => (item) =>
!item.tagFQN.startsWith('Tier.Tier') || !item.tagFQN.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`) ||
isNaN(parseInt(item.tagFQN.substring(9).trim())) isNaN(parseInt(item.tagFQN.substring(9).trim()))
); );
}; };
@ -104,7 +105,8 @@ export const getTagsWithoutTier = (
export const getTierFromSearchTableTags = (tags: Array<string>): string => { export const getTierFromSearchTableTags = (tags: Array<string>): string => {
const tierTag = tags.find( const tierTag = tags.find(
(item) => (item) =>
item.startsWith('Tier.Tier') && !isNaN(parseInt(item.substring(9).trim())) item.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`) &&
!isNaN(parseInt(item.substring(9).trim()))
); );
return tierTag || ''; return tierTag || '';
@ -115,7 +117,8 @@ export const getSearchTableTagsWithoutTier = (
): Array<string> => { ): Array<string> => {
return tags.filter( return tags.filter(
(item) => (item) =>
!item.startsWith('Tier.Tier') || isNaN(parseInt(item.substring(9).trim())) !item.startsWith(`Tier${FQN_SEPARATOR_CHAR}Tier`) ||
isNaN(parseInt(item.substring(9).trim()))
); );
}; };