mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-09 17:12:02 +00:00
Issue 813: Unavailable entities will be removed from recent data instead of showing loader infinitely (#846)
This commit is contained in:
parent
09cc3b5dd2
commit
c655d197ac
@ -23,7 +23,10 @@ import { getTableDetailsByFQN } from '../../axiosAPIs/tableAPI';
|
|||||||
import { getTopicByFqn } from '../../axiosAPIs/topicsAPI';
|
import { getTopicByFqn } from '../../axiosAPIs/topicsAPI';
|
||||||
import { EntityType } from '../../enums/entity.enum';
|
import { EntityType } from '../../enums/entity.enum';
|
||||||
import { SearchIndex } from '../../enums/search.enum';
|
import { SearchIndex } from '../../enums/search.enum';
|
||||||
import { getRecentlyViewedData } from '../../utils/CommonUtils';
|
import {
|
||||||
|
getRecentlyViewedData,
|
||||||
|
setRecentlyViewedData,
|
||||||
|
} from '../../utils/CommonUtils';
|
||||||
import { getOwnerFromId, getTierFromTableTags } from '../../utils/TableUtils';
|
import { getOwnerFromId, getTierFromTableTags } from '../../utils/TableUtils';
|
||||||
import { getTableTags } from '../../utils/TagsUtils';
|
import { getTableTags } from '../../utils/TagsUtils';
|
||||||
import TableDataCard from '../common/table-data-card/TableDataCard';
|
import TableDataCard from '../common/table-data-card/TableDataCard';
|
||||||
@ -38,127 +41,140 @@ const RecentlyViewed: FunctionComponent = () => {
|
|||||||
const fetchRecentlyViewedEntity = async () => {
|
const fetchRecentlyViewedEntity = async () => {
|
||||||
setIsloading(true);
|
setIsloading(true);
|
||||||
const arrData: Array<FormatedTableData> = [];
|
const arrData: Array<FormatedTableData> = [];
|
||||||
|
let filteredRecentData = [...recentlyViewedData];
|
||||||
|
|
||||||
for (const oData of recentlyViewedData) {
|
for (const oData of recentlyViewedData) {
|
||||||
// for (let i = 0; i < recentlyViewedData.length; i++) {
|
// for (let i = 0; i < recentlyViewedData.length; i++) {
|
||||||
// const oData = recentlyViewedData[i];
|
// const oData = recentlyViewedData[i];
|
||||||
switch (oData.entityType) {
|
try {
|
||||||
case EntityType.DATASET: {
|
switch (oData.entityType) {
|
||||||
const res = await getTableDetailsByFQN(
|
case EntityType.DATASET: {
|
||||||
oData.fqn,
|
const res = await getTableDetailsByFQN(
|
||||||
'database, usageSummary, tags, owner,columns'
|
oData.fqn,
|
||||||
);
|
'database, usageSummary, tags, owner,columns'
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
description,
|
description,
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
columns,
|
columns,
|
||||||
owner,
|
owner,
|
||||||
usageSummary,
|
usageSummary,
|
||||||
fullyQualifiedName,
|
fullyQualifiedName,
|
||||||
tags,
|
tags,
|
||||||
} = res.data;
|
} = res.data;
|
||||||
const tableTags = getTableTags(columns || []);
|
const tableTags = getTableTags(columns || []);
|
||||||
arrData.push({
|
arrData.push({
|
||||||
description,
|
description,
|
||||||
fullyQualifiedName,
|
fullyQualifiedName,
|
||||||
id,
|
id,
|
||||||
index: SearchIndex.TABLE,
|
index: SearchIndex.TABLE,
|
||||||
name,
|
name,
|
||||||
owner: getOwnerFromId(owner?.id)?.name || '--',
|
owner: getOwnerFromId(owner?.id)?.name || '--',
|
||||||
serviceType: oData.serviceType,
|
serviceType: oData.serviceType,
|
||||||
tags: [
|
tags: [
|
||||||
getTierFromTableTags(tags),
|
getTierFromTableTags(tags),
|
||||||
...tableTags.map((tag) => tag.tagFQN),
|
...tableTags.map((tag) => tag.tagFQN),
|
||||||
].filter((tag) => tag),
|
].filter((tag) => tag),
|
||||||
tier: getTierFromTableTags(tags),
|
tier: getTierFromTableTags(tags),
|
||||||
weeklyPercentileRank: usageSummary?.weeklyStats.percentileRank || 0,
|
weeklyPercentileRank:
|
||||||
});
|
usageSummary?.weeklyStats.percentileRank || 0,
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case EntityType.TOPIC: {
|
||||||
|
const res = await getTopicByFqn(oData.fqn, 'owner, service, tags');
|
||||||
|
|
||||||
|
const { description, id, name, tags, owner, fullyQualifiedName } =
|
||||||
|
res.data;
|
||||||
|
arrData.push({
|
||||||
|
description,
|
||||||
|
fullyQualifiedName,
|
||||||
|
id,
|
||||||
|
index: SearchIndex.TOPIC,
|
||||||
|
name,
|
||||||
|
owner: getOwnerFromId(owner?.id)?.name || '--',
|
||||||
|
serviceType: oData.serviceType,
|
||||||
|
tags: (tags as Array<ColumnTags>).map((tag) => tag.tagFQN),
|
||||||
|
tier: getTierFromTableTags(tags as Array<ColumnTags>),
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EntityType.DASHBOARD: {
|
||||||
|
const res = await getDashboardByFqn(
|
||||||
|
oData.fqn,
|
||||||
|
'owner, service, tags, usageSummary'
|
||||||
|
);
|
||||||
|
|
||||||
|
const {
|
||||||
|
description,
|
||||||
|
id,
|
||||||
|
displayName,
|
||||||
|
tags,
|
||||||
|
owner,
|
||||||
|
fullyQualifiedName,
|
||||||
|
} = res.data;
|
||||||
|
arrData.push({
|
||||||
|
description,
|
||||||
|
fullyQualifiedName,
|
||||||
|
id,
|
||||||
|
index: SearchIndex.DASHBOARD,
|
||||||
|
name: displayName,
|
||||||
|
owner: getOwnerFromId(owner?.id)?.name || '--',
|
||||||
|
serviceType: oData.serviceType,
|
||||||
|
tags: (tags as Array<ColumnTags>).map((tag) => tag.tagFQN),
|
||||||
|
tier: getTierFromTableTags(tags as Array<ColumnTags>),
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EntityType.PIPELINE: {
|
||||||
|
const res = await getPipelineByFqn(
|
||||||
|
oData.fqn,
|
||||||
|
'owner, service, tags, usageSummary'
|
||||||
|
);
|
||||||
|
|
||||||
|
const {
|
||||||
|
description,
|
||||||
|
id,
|
||||||
|
displayName,
|
||||||
|
tags,
|
||||||
|
owner,
|
||||||
|
fullyQualifiedName,
|
||||||
|
} = res.data;
|
||||||
|
arrData.push({
|
||||||
|
description,
|
||||||
|
fullyQualifiedName,
|
||||||
|
id,
|
||||||
|
index: SearchIndex.PIPELINE,
|
||||||
|
name: displayName,
|
||||||
|
owner: getOwnerFromId(owner?.id)?.name || '--',
|
||||||
|
serviceType: oData.serviceType,
|
||||||
|
tags: (tags as Array<ColumnTags>).map((tag) => tag.tagFQN),
|
||||||
|
tier: getTierFromTableTags(tags as Array<ColumnTags>),
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case EntityType.TOPIC: {
|
} catch {
|
||||||
const res = await getTopicByFqn(oData.fqn, 'owner, service, tags');
|
filteredRecentData = filteredRecentData.filter(
|
||||||
|
(data) => data.fqn !== oData.fqn
|
||||||
|
);
|
||||||
|
|
||||||
const { description, id, name, tags, owner, fullyQualifiedName } =
|
continue;
|
||||||
res.data;
|
|
||||||
arrData.push({
|
|
||||||
description,
|
|
||||||
fullyQualifiedName,
|
|
||||||
id,
|
|
||||||
index: SearchIndex.TOPIC,
|
|
||||||
name,
|
|
||||||
owner: getOwnerFromId(owner?.id)?.name || '--',
|
|
||||||
serviceType: oData.serviceType,
|
|
||||||
tags: (tags as Array<ColumnTags>).map((tag) => tag.tagFQN),
|
|
||||||
tier: getTierFromTableTags(tags as Array<ColumnTags>),
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EntityType.DASHBOARD: {
|
|
||||||
const res = await getDashboardByFqn(
|
|
||||||
oData.fqn,
|
|
||||||
'owner, service, tags, usageSummary'
|
|
||||||
);
|
|
||||||
|
|
||||||
const {
|
|
||||||
description,
|
|
||||||
id,
|
|
||||||
displayName,
|
|
||||||
tags,
|
|
||||||
owner,
|
|
||||||
fullyQualifiedName,
|
|
||||||
} = res.data;
|
|
||||||
arrData.push({
|
|
||||||
description,
|
|
||||||
fullyQualifiedName,
|
|
||||||
id,
|
|
||||||
index: SearchIndex.DASHBOARD,
|
|
||||||
name: displayName,
|
|
||||||
owner: getOwnerFromId(owner?.id)?.name || '--',
|
|
||||||
serviceType: oData.serviceType,
|
|
||||||
tags: (tags as Array<ColumnTags>).map((tag) => tag.tagFQN),
|
|
||||||
tier: getTierFromTableTags(tags as Array<ColumnTags>),
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case EntityType.PIPELINE: {
|
|
||||||
const res = await getPipelineByFqn(
|
|
||||||
oData.fqn,
|
|
||||||
'owner, service, tags, usageSummary'
|
|
||||||
);
|
|
||||||
|
|
||||||
const {
|
|
||||||
description,
|
|
||||||
id,
|
|
||||||
displayName,
|
|
||||||
tags,
|
|
||||||
owner,
|
|
||||||
fullyQualifiedName,
|
|
||||||
} = res.data;
|
|
||||||
arrData.push({
|
|
||||||
description,
|
|
||||||
fullyQualifiedName,
|
|
||||||
id,
|
|
||||||
index: SearchIndex.PIPELINE,
|
|
||||||
name: displayName,
|
|
||||||
owner: getOwnerFromId(owner?.id)?.name || '--',
|
|
||||||
serviceType: oData.serviceType,
|
|
||||||
tags: (tags as Array<ColumnTags>).map((tag) => tag.tagFQN),
|
|
||||||
tier: getTierFromTableTags(tags as Array<ColumnTags>),
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (filteredRecentData.length !== recentlyViewedData.length) {
|
||||||
|
setRecentlyViewedData(filteredRecentData);
|
||||||
|
}
|
||||||
setIsloading(false);
|
setIsloading(false);
|
||||||
setData(arrData);
|
setData(arrData);
|
||||||
};
|
};
|
||||||
|
@ -160,6 +160,14 @@ export const getRecentlyViewedData = (): Array<RecentlyViewedData> => {
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setRecentlyViewedData = (
|
||||||
|
recentData: Array<RecentlyViewedData>
|
||||||
|
): void => {
|
||||||
|
reactLocalStorage.setObject(LOCALSTORAGE_RECENTLY_VIEWED, {
|
||||||
|
data: recentData,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const getHtmlForNonAdminAction = (isClaimOwner: boolean) => {
|
export const getHtmlForNonAdminAction = (isClaimOwner: boolean) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user