Skip to content

Commit 69a290d

Browse files
Masterchen09esteban
authored andcommitted
fix(ui): fix useGetUserGroupUrns when user urn is empty (#13359)
1 parent 02c669a commit 69a290d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

datahub-web-react/src/app/entityV2/user/useGetUserGroupUrns.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { useGetUserGroupsUrnsQuery } from '@src/graphql/user.generated';
22

33
const NUM_GROUP_URNS_TO_FETCH = 100;
44

5-
export default function useGetUserGroupUrns(userUrn: string) {
5+
export default function useGetUserGroupUrns(userUrn?: string) {
66
const { data, loading } = useGetUserGroupsUrnsQuery({
7-
variables: { urn: userUrn, start: 0, count: NUM_GROUP_URNS_TO_FETCH },
7+
variables: { urn: userUrn || '', start: 0, count: NUM_GROUP_URNS_TO_FETCH },
88
fetchPolicy: 'cache-first',
9+
skip: !userUrn,
910
});
1011

1112
const groupUrns: string[] =

datahub-web-react/src/app/homeV2/reference/sections/assets/AssetsYouOwn.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const AssetsYouOwn = ({ hideIfEmpty, trackClickInSection }: ReferenceSect
1818
const { user } = userContext;
1919
const [entityCount, setEntityCount] = useState(DEFAULT_MAX_ENTITIES_TO_SHOW);
2020
const [showModal, setShowModal] = useState(false);
21-
const { groupUrns } = useGetUserGroupUrns(user?.urn || '');
21+
const { groupUrns } = useGetUserGroupUrns(user?.urn);
2222
const { entities, loading } = useGetAssetsYouOwn(user);
2323

2424
if (hideIfEmpty && entities.length === 0) {

datahub-web-react/src/app/homeV2/reference/sections/assets/useGetAssetsYouOwn.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import { CorpUser } from '@types';
88
const MAX_ASSETS_TO_FETCH = 50;
99

1010
export const useGetAssetsYouOwn = (user?: CorpUser | null, count = MAX_ASSETS_TO_FETCH) => {
11-
const userUrn = user?.urn || '';
12-
const { groupUrns, loading: groupDataLoading } = useGetUserGroupUrns(userUrn);
11+
const { groupUrns, loading: groupDataLoading } = useGetUserGroupUrns(user?.urn);
1312

1413
const { loading, data, error } = useGetSearchResultsForMultipleQuery({
1514
variables: {
@@ -21,16 +20,16 @@ export const useGetAssetsYouOwn = (user?: CorpUser | null, count = MAX_ASSETS_TO
2120
filters: [
2221
{
2322
field: OWNERS_FILTER_NAME,
24-
value: userUrn,
25-
values: [userUrn, ...groupUrns],
23+
value: user?.urn,
24+
values: [user?.urn || '', ...groupUrns],
2625
},
2726
],
2827
searchFlags: {
2928
skipCache: true,
3029
},
3130
},
3231
},
33-
skip: !userUrn || groupDataLoading,
32+
skip: !user?.urn || groupDataLoading,
3433
fetchPolicy: 'cache-first',
3534
});
3635

0 commit comments

Comments
 (0)