mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-03 22:23:37 +00:00
fix(react): Fix authenticated user profile (#2128)
This commit is contained in:
parent
2a184dd3d5
commit
1b96cd8c26
@ -8,6 +8,7 @@ import { useEntityRegistry } from '../useEntityRegistry';
|
||||
import { useGetAutoCompleteResultsLazyQuery } from '../../graphql/search.generated';
|
||||
import { navigateToSearchUrl } from './utils/navigateToSearchUrl';
|
||||
import { EntityType } from '../../types.generated';
|
||||
import { useGetAuthenticatedUser } from '../useGetAuthenticatedUser';
|
||||
|
||||
const ALL_ENTITIES_SEARCH_TYPE_NAME = 'All Entities';
|
||||
|
||||
@ -29,6 +30,9 @@ export const SearchablePage = ({ selectedType, initialQuery, children }: Props)
|
||||
|
||||
const entityRegistry = useEntityRegistry();
|
||||
const searchTypes = entityRegistry.getSearchEntityTypes();
|
||||
|
||||
const { data: userData } = useGetAuthenticatedUser();
|
||||
|
||||
const searchTypeNames = [
|
||||
ALL_ENTITIES_SEARCH_TYPE_NAME,
|
||||
...searchTypes.map((entityType) => entityRegistry.getCollectionName(entityType)),
|
||||
@ -78,7 +82,8 @@ export const SearchablePage = ({ selectedType, initialQuery, children }: Props)
|
||||
}
|
||||
onSearch={search}
|
||||
onQueryChange={autoComplete}
|
||||
authenticatedUserUrn="urn:li:corpuser:0"
|
||||
authenticatedUserUrn={userData?.corpUser?.urn || ''}
|
||||
authenticatedUserPictureLink={userData?.corpUser?.editableInfo?.pictureLink || ''}
|
||||
/>
|
||||
<div style={{ marginTop: 64 }}>{children}</div>
|
||||
</Layout>
|
||||
|
||||
8
datahub-web-react/src/app/useGetAuthenticatedUser.tsx
Normal file
8
datahub-web-react/src/app/useGetAuthenticatedUser.tsx
Normal file
@ -0,0 +1,8 @@
|
||||
import { useGetUserQuery } from '../graphql/user.generated';
|
||||
|
||||
/**
|
||||
* Fetch a CorpUser object corresponding to the currently authenticated user.
|
||||
*/
|
||||
export function useGetAuthenticatedUser() {
|
||||
return useGetUserQuery({ variables: { urn: localStorage.getItem('userUrn') as string } });
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user