Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/decisions/2026-12-04-getfeedcounts-is-kept-for-collate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# `getFeedCounts` stays exported, in its callback form, until openmetadata-collate stops calling it

- **Status:** Accepted
- **Revisions:** v1 2026-12-04 (initial)
- **Deciders:** harsh-vador
- **Guard:** `src/utils/FeedUtilsPure.getFeedCounts.test.ts` (openmetadata-ui) calls the callback form; `reviewer` for removal
- **Related:** #39791, open-metadata/openmetadata-collate#9240, open-metadata/openmetadata-collate#9311

## Context
#39791 moved every OpenMetadata entity page to `useEntityFeedCounts`. After it, nothing in this
repository calls `getFeedCounts` in `openmetadata-ui/.../utils/FeedUtilsPure.ts`. openmetadata-collate
still does: its Observability `PipelineDetails` reloads its counts with
`getFeedCounts(EntityType.PIPELINE, fqn, callback)`. Collate compiles against this repository's
`main` through a submodule, so deleting the export, or changing its signature, breaks the Collate
build, and nothing here would warn about it.

## Decision
`getFeedCounts(entityType, entityFQN, callback)` stays exported from `utils/FeedUtilsPure.ts` with
that signature. It calls `callback` with a full `FeedCounts` built by the same fetchers the hook
uses, and shows the `server.entity-feed-fetch-error` toast on failure. The `domain` overload
removed in #39791 had no caller in either repository.

## Consequences
New OpenMetadata code uses `useEntityFeedCounts`, never `getFeedCounts`. The export goes away in two
steps:
1. openmetadata-collate#9311 moves Collate's page to the hook.
2. An OpenMetadata PR deletes `getFeedCounts` and marks this record superseded.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ jest.mock('../../../utils/useRequiredParams', () => ({
}),
}));

jest.mock('../../../utils/FeedUtilsPure', () => ({
getFeedCounts: jest.fn(),
jest.mock('../../../hooks/useEntityFeedCounts', () => ({
useEntityFeedCounts: jest.fn().mockReturnValue({
feedCount: jest.requireActual('../../../constants/entity.constants')
.FEED_COUNT_INITIAL_DATA,
getEntityFeedCount: jest.fn(),
handleFeedCount: jest.fn(),
}),
}));

jest.mock('../../../utils/TablePureUtils', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
import { Collapse, Expand } from '@openmetadata/ui-core-components/icons';

import { AxiosError } from 'axios';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { FQN_SEPARATOR_CHAR } from '../../../constants/char.constants';
import { FEED_COUNT_INITIAL_DATA } from '../../../constants/entity.constants';
import { EntityTabs, EntityType, FqnPart } from '../../../enums/entity.enum';
import { Tag } from '../../../generated/entity/classification/tag';
import { APIEndpoint } from '../../../generated/entity/data/apiEndpoint';
import { PageType } from '../../../generated/system/ui/page';
import LimitWrapper from '../../../hoc/LimitWrapper';
import { useApplicationStore } from '../../../hooks/useApplicationStore';
import { useCustomPages } from '../../../hooks/useCustomPages';
import { useEntityFeedCounts } from '../../../hooks/useEntityFeedCounts';
import { useFqn } from '../../../hooks/useFqn';
import { FeedCounts } from '../../../interface/feed.interface';
import { restoreApiEndPoint } from '../../../rest/apiEndpointsAPI';
import apiEndpointClassBase from '../../../utils/APIEndpoints/APIEndpointClassBase';
import {
Expand All @@ -38,11 +37,6 @@
getTabLabelMapFromTabs,
} from '../../../utils/CustomizePage/CustomizePageEntityTabUtils';
import { getEntityName } from '../../../utils/EntityNameUtils';
import {
fetchEntityActivityCountInto,
fetchEntityTaskCountsInto,
getFeedCounts,
} from '../../../utils/FeedUtilsPure';
import { getPartialNameFromTableFQN } from '../../../utils/FqnUtils';
import { getDerivedPermissionFlags } from '../../../utils/PermissionDerivation';
import { getEntityDetailsPath } from '../../../utils/RouterUtils';
Expand Down Expand Up @@ -81,9 +75,8 @@
const { entityFqn: decodedApiEndpointFqn } = useFqn({
type: EntityType.API_ENDPOINT,
});
const [feedCount, setFeedCount] = useState<FeedCounts>(
FEED_COUNT_INITIAL_DATA
);
const { feedCount, getEntityFeedCount, handleFeedCount } =
useEntityFeedCounts(EntityType.API_ENDPOINT, decodedApiEndpointFqn);
const { customizedPage, isLoading } = useCustomPages(PageType.APIEndpoint);
const [isTabExpanded, setIsTabExpanded] = useState(false);

Expand Down Expand Up @@ -165,7 +158,7 @@
};
await onApiEndpointUpdate(updatedApiEndpointDetails, 'owners');
},
[owners]

Check warning on line 161 in openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointDetails/APIEndpointDetails.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useCallback has missing dependencies: 'apiEndpointDetails' and 'onApiEndpointUpdate'. Either include them or remove the dependency array. If 'onApiEndpointUpdate' changes too often, find the parent component that defines it and wrap that definition in useCallback
);

const onTierUpdate = (newTier?: Tag) => {
Expand All @@ -178,33 +171,6 @@
return onApiEndpointUpdate(updatedApiEndpointDetails, 'tags');
};

const handleFeedCount = useCallback((data: FeedCounts) => {
setFeedCount(data);
}, []);

const getEntityFeedCount = () =>
getFeedCounts(
EntityType.API_ENDPOINT,
decodedApiEndpointFqn,
handleFeedCount
);

const fetchTaskCounts = useCallback(() => {
if (decodedApiEndpointFqn) {
fetchEntityTaskCountsInto(decodedApiEndpointFqn, setFeedCount);
}
}, [decodedApiEndpointFqn]);

const fetchActivityCount = useCallback(() => {
if (decodedApiEndpointFqn) {
fetchEntityActivityCountInto(
EntityType.API_ENDPOINT,
decodedApiEndpointFqn,
setFeedCount
);
}
}, [decodedApiEndpointFqn]);

// The endpoint FQN is service.collection.endpoint, so the positional
// Service+Database parts yield the collection FQN when the loaded entity
// doesn't carry its apiCollection reference.
Expand Down Expand Up @@ -250,11 +216,6 @@
};
}, [apiEndpointPermissions, deleted]);

useEffect(() => {
fetchTaskCounts();
fetchActivityCount();
}, [apiEndpointPermissions, decodedApiEndpointFqn]);

const tabs = useMemo(() => {
const tabLabelMap = getTabLabelMapFromTabs(customizedPage?.tabs);
const tabs = apiEndpointClassBase.getAPIEndpointDetailPageTabs({
Expand Down Expand Up @@ -310,7 +271,7 @@

const isExpandViewSupported = useMemo(
() => checkIfExpandViewSupported(tabs[0], activeTab, PageType.APIEndpoint),
[tabs[0], activeTab]

Check warning on line 274 in openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointDetails/APIEndpointDetails.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useMemo has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked

Check warning on line 274 in openmetadata-ui/src/main/resources/ui/src/components/APIEndpoint/APIEndpointDetails/APIEndpointDetails.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useMemo has a missing dependency: 'tabs'. Either include it or remove the dependency array
);

if (isLoading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ jest.mock('../../../utils/useRequiredParams', () => ({
}),
}));

jest.mock('../../../utils/FeedUtilsPure', () => ({
fetchEntityActivityCountInto: jest.fn(),
fetchEntityTaskCountsInto: jest.fn(),
getFeedCounts: jest.fn(),
jest.mock('../../../hooks/useEntityFeedCounts', () => ({
useEntityFeedCounts: jest.fn().mockReturnValue({
feedCount: jest.requireActual('../../../constants/entity.constants')
.FEED_COUNT_INITIAL_DATA,
getEntityFeedCount: jest.fn(),
handleFeedCount: jest.fn(),
}),
}));

jest.mock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { FEED_COUNT_INITIAL_DATA } from '../../../constants/entity.constants';
import { EntityTabs, EntityType, FqnPart } from '../../../enums/entity.enum';
import { ResourceEntity } from '../../../enums/permissions.enum';
import { ServiceCategory } from '../../../enums/service.enum';
Expand All @@ -28,9 +27,9 @@
import LimitWrapper from '../../../hoc/LimitWrapper';
import { useApplicationStore } from '../../../hooks/useApplicationStore';
import { useCustomPages } from '../../../hooks/useCustomPages';
import { useEntityFeedCounts } from '../../../hooks/useEntityFeedCounts';
import { useEntityPermissions } from '../../../hooks/useEntityPermissions/useEntityPermissions';
import { useFqn } from '../../../hooks/useFqn';
import { FeedCounts } from '../../../interface/feed.interface';
import { restoreChart } from '../../../rest/chartsAPI';
import chartDetailsClassBase from '../../../utils/ChartDetailsClassBase';
import connectionsRouterClassBase from '../../../utils/ConnectionsRouterClassBase';
Expand All @@ -41,11 +40,6 @@
getTabLabelMapFromTabs,
} from '../../../utils/CustomizePage/CustomizePageEntityTabUtils';
import { getEntityName } from '../../../utils/EntityNameUtils';
import {
fetchEntityActivityCountInto,
fetchEntityTaskCountsInto,
getFeedCounts,
} from '../../../utils/FeedUtilsPure';
import { getPartialNameFromTableFQN } from '../../../utils/FqnUtils';
import { getEntityDetailsPath } from '../../../utils/RouterUtils';
import {
Expand Down Expand Up @@ -81,14 +75,11 @@
const { customizedPage, isLoading } = useCustomPages('Chart' as PageType);
const { entityFqn: decodedChartFQN } = useFqn({ type: EntityType.CHART });

const [feedCount, setFeedCount] = useState<FeedCounts>(
FEED_COUNT_INITIAL_DATA
);
const [isTabExpanded, setIsTabExpanded] = useState(false);

const { followers = [], deleted } = useMemo(() => {
return chartDetails;
}, [chartDetails.owners, chartDetails.followers, chartDetails.deleted]);

Check warning on line 82 in openmetadata-ui/src/main/resources/ui/src/components/Chart/ChartDetails/ChartDetails.component.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useMemo has a missing dependency: 'chartDetails'. Either include it or remove the dependency array

const { isFollowing } = useMemo(() => {
return {
Expand Down Expand Up @@ -120,35 +111,10 @@
})
);
}
}, [permissionsError]);

Check warning on line 114 in openmetadata-ui/src/main/resources/ui/src/components/Chart/ChartDetails/ChartDetails.component.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useEffect has a missing dependency: 't'. Either include it or remove the dependency array

const handleFeedCount = useCallback((data: FeedCounts) => {
setFeedCount(data);
}, []);

const getEntityFeedCount = () =>
getFeedCounts(EntityType.CHART, decodedChartFQN, handleFeedCount);

const fetchTaskCounts = useCallback(() => {
if (decodedChartFQN) {
fetchEntityTaskCountsInto(decodedChartFQN, setFeedCount);
}
}, [decodedChartFQN]);

const fetchActivityCount = useCallback(() => {
if (decodedChartFQN) {
fetchEntityActivityCountInto(
EntityType.CHART,
decodedChartFQN,
setFeedCount
);
}
}, [decodedChartFQN]);

useEffect(() => {
fetchTaskCounts();
fetchActivityCount();
}, [decodedChartFQN]);
const { feedCount, getEntityFeedCount, handleFeedCount } =
useEntityFeedCounts(EntityType.CHART, decodedChartFQN);

const handleTabChange = (activeKey: string) => {
if (activeKey !== activeTab) {
Expand Down Expand Up @@ -251,7 +217,7 @@
customizedPage?.tabs,
EntityTabs.DETAILS
);
}, [

Check warning on line 220 in openmetadata-ui/src/main/resources/ui/src/components/Chart/ChartDetails/ChartDetails.component.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useMemo has missing dependencies: 'feedCount', 'fetchChart', 'getEntityFeedCount', and 'viewCustomPropertiesPermission'. Either include them or remove the dependency array
customizedPage,
feedCount.totalCount,
activeTab,
Expand Down Expand Up @@ -285,7 +251,7 @@

const isExpandViewSupported = useMemo(
() => checkIfExpandViewSupported(tabs[0], activeTab, 'Chart' as PageType),
[tabs[0], activeTab]

Check warning on line 254 in openmetadata-ui/src/main/resources/ui/src/components/Chart/ChartDetails/ChartDetails.component.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useMemo has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked

Check warning on line 254 in openmetadata-ui/src/main/resources/ui/src/components/Chart/ChartDetails/ChartDetails.component.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useMemo has a missing dependency: 'tabs'. Either include it or remove the dependency array
);

if (isLoading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ jest.mock('../../../utils/useRequiredParams', () => ({
}),
}));

jest.mock('../../../utils/FeedUtilsPure', () => ({
fetchEntityActivityCountInto: jest.fn(),
fetchEntityTaskCountsInto: jest.fn(),
getFeedCounts: jest.fn(),
jest.mock('../../../hooks/useEntityFeedCounts', () => ({
useEntityFeedCounts: jest.fn().mockReturnValue({
feedCount: jest.requireActual('../../../constants/entity.constants')
.FEED_COUNT_INITIAL_DATA,
getEntityFeedCount: jest.fn(),
handleFeedCount: jest.fn(),
}),
}));

jest.mock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { FEED_COUNT_INITIAL_DATA } from '../../../constants/entity.constants';
import { EntityTabs, EntityType, FqnPart } from '../../../enums/entity.enum';
import { ResourceEntity } from '../../../enums/permissions.enum';
import { ServiceCategory } from '../../../enums/service.enum';
Expand All @@ -28,9 +27,9 @@
import LimitWrapper from '../../../hoc/LimitWrapper';
import { useApplicationStore } from '../../../hooks/useApplicationStore';
import { useCustomPages } from '../../../hooks/useCustomPages';
import { useEntityFeedCounts } from '../../../hooks/useEntityFeedCounts';
import { useEntityPermissions } from '../../../hooks/useEntityPermissions/useEntityPermissions';
import { useFqn } from '../../../hooks/useFqn';
import { FeedCounts } from '../../../interface/feed.interface';
import { restoreDashboard } from '../../../rest/dashboardAPI';
import connectionsRouterClassBase from '../../../utils/ConnectionsRouterClassBase';
import {
Expand All @@ -41,11 +40,6 @@
} from '../../../utils/CustomizePage/CustomizePageEntityTabUtils';
import dashboardDetailsClassBase from '../../../utils/DashboardDetailsClassBase';
import { getEntityName } from '../../../utils/EntityNameUtils';
import {
fetchEntityActivityCountInto,
fetchEntityTaskCountsInto,
getFeedCounts,
} from '../../../utils/FeedUtilsPure';
import { getPartialNameFromTableFQN } from '../../../utils/FqnUtils';
import { getEntityDetailsPath } from '../../../utils/RouterUtils';
import {
Expand Down Expand Up @@ -83,9 +77,8 @@
const { entityFqn: decodedDashboardFQN } = useFqn({
type: EntityType.DASHBOARD,
});
const [feedCount, setFeedCount] = useState<FeedCounts>(
FEED_COUNT_INITIAL_DATA
);
const { feedCount, getEntityFeedCount, handleFeedCount } =
useEntityFeedCounts(EntityType.DASHBOARD, decodedDashboardFQN);
const [isTabExpanded, setIsTabExpanded] = useState(false);

const {
Expand All @@ -94,7 +87,7 @@
deleted,
} = useMemo(() => {
return dashboardDetails;
}, [

Check warning on line 90 in openmetadata-ui/src/main/resources/ui/src/components/Dashboard/DashboardDetails/DashboardDetails.component.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useMemo has a missing dependency: 'dashboardDetails'. Either include it or remove the dependency array
dashboardDetails.owners,
dashboardDetails.followers,
dashboardDetails.deleted,
Expand Down Expand Up @@ -131,36 +124,8 @@
})
);
}
}, [permissionsError]);

Check warning on line 127 in openmetadata-ui/src/main/resources/ui/src/components/Dashboard/DashboardDetails/DashboardDetails.component.tsx

View workflow job for this annotation

GitHub Actions / ui / lint

React Hook useEffect has a missing dependency: 't'. Either include it or remove the dependency array

const handleFeedCount = useCallback((data: FeedCounts) => {
setFeedCount(data);
}, []);

const getEntityFeedCount = () =>
getFeedCounts(EntityType.DASHBOARD, decodedDashboardFQN, handleFeedCount);

const fetchTaskCounts = useCallback(() => {
if (decodedDashboardFQN) {
fetchEntityTaskCountsInto(decodedDashboardFQN, setFeedCount);
}
}, [decodedDashboardFQN]);

const fetchActivityCount = useCallback(() => {
if (decodedDashboardFQN) {
fetchEntityActivityCountInto(
EntityType.DASHBOARD,
decodedDashboardFQN,
setFeedCount
);
}
}, [decodedDashboardFQN]);

useEffect(() => {
fetchTaskCounts();
fetchActivityCount();
}, [decodedDashboardFQN]);

const handleTabChange = (activeKey: string) => {
if (activeKey !== activeTab) {
navigate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ jest.mock('../../../../utils/useRequiredParams', () => ({
}),
}));

jest.mock('../../../../utils/FeedUtilsPure', () => ({
fetchEntityActivityCountInto: jest.fn(),
fetchEntityTaskCountsInto: jest.fn(),
getFeedCounts: jest.fn(),
jest.mock('../../../../hooks/useEntityFeedCounts', () => ({
useEntityFeedCounts: jest.fn().mockReturnValue({
feedCount: jest.requireActual('../../../../constants/entity.constants')
.FEED_COUNT_INITIAL_DATA,
getEntityFeedCount: jest.fn(),
handleFeedCount: jest.fn(),
}),
}));

jest.mock(
Expand Down
Loading
Loading