forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui) Add new embedded profile to be displayed in extension (datah…
- Loading branch information
1 parent
bfa8561
commit e1bca87
Showing
56 changed files
with
1,526 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { useParams } from 'react-router'; | ||
import styled from 'styled-components/macro'; | ||
import { useGetGrantedPrivilegesQuery } from '../../graphql/policy.generated'; | ||
import { EntityType } from '../../types.generated'; | ||
import { UnauthorizedPage } from '../authorization/UnauthorizedPage'; | ||
import { VIEW_ENTITY_PAGE } from '../entity/shared/constants'; | ||
import { decodeUrn } from '../entity/shared/utils'; | ||
import CompactContext from '../shared/CompactContext'; | ||
import { useEntityRegistry } from '../useEntityRegistry'; | ||
import { useGetAuthenticatedUserUrn } from '../useGetAuthenticatedUser'; | ||
|
||
const EmbeddedPageWrapper = styled.div` | ||
max-height: 100%; | ||
overflow: auto; | ||
padding: 16px; | ||
`; | ||
|
||
interface RouteParams { | ||
urn: string; | ||
} | ||
|
||
interface Props { | ||
entityType: EntityType; | ||
} | ||
|
||
export default function EmbeddedPage({ entityType }: Props) { | ||
const entityRegistry = useEntityRegistry(); | ||
const { urn: encodedUrn } = useParams<RouteParams>(); | ||
const urn = decodeUrn(encodedUrn); | ||
|
||
const authenticatedUserUrn = useGetAuthenticatedUserUrn(); | ||
const { data } = useGetGrantedPrivilegesQuery({ | ||
variables: { | ||
input: { | ||
actorUrn: authenticatedUserUrn, | ||
resourceSpec: { resourceType: entityType, resourceUrn: urn }, | ||
}, | ||
}, | ||
fetchPolicy: 'cache-first', | ||
}); | ||
|
||
const privileges = data?.getGrantedPrivileges?.privileges || []; | ||
const canViewEntityPage = privileges.find((privilege) => privilege === VIEW_ENTITY_PAGE); | ||
|
||
return ( | ||
<CompactContext.Provider value> | ||
{data && !canViewEntityPage && <UnauthorizedPage />} | ||
{data && canViewEntityPage && ( | ||
<EmbeddedPageWrapper>{entityRegistry.renderEmbeddedProfile(entityType, urn)}</EmbeddedPageWrapper> | ||
)} | ||
</CompactContext.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.