Skip to content

Commit

Permalink
refactor | PRD-785 | datahub oss: migrate use of useGetAuthenticatedU… (
Browse files Browse the repository at this point in the history
#9456)

Co-authored-by: John Joyce <[email protected]>
  • Loading branch information
sumitappt and jjoyce0510 authored Dec 14, 2023
1 parent 288e458 commit b87f977
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions datahub-web-react/src/app/AdminConsole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Menu } from 'antd';
import styled from 'styled-components';
import { BankOutlined, BarChartOutlined, MenuOutlined } from '@ant-design/icons';
import Sider from 'antd/lib/layout/Sider';
import { useGetAuthenticatedUser } from './useGetAuthenticatedUser';
import { useAppConfig } from './useAppConfig';
import { ANTD_GRAY } from './entity/shared/constants';
import { useUserContext } from './context/useUserContext';

const ToggleContainer = styled.div`
background-color: ${ANTD_GRAY[4]};
Expand All @@ -32,16 +32,16 @@ const ControlSlideOut = styled(Sider)`
* Container for all views behind an authentication wall.
*/
export const AdminConsole = (): JSX.Element => {
const me = useGetAuthenticatedUser();
const me = useUserContext();

const [adminConsoleOpen, setAdminConsoleOpen] = useState(false);
const { config } = useAppConfig();

const isAnalyticsEnabled = config?.analyticsConfig.enabled;
const isPoliciesEnabled = config?.policiesConfig.enabled;

const showAnalytics = (isAnalyticsEnabled && me && me.platformPrivileges.viewAnalytics) || false;
const showPolicyBuilder = (isPoliciesEnabled && me && me.platformPrivileges.managePolicies) || false;
const showAnalytics = (isAnalyticsEnabled && me && me?.platformPrivileges?.viewAnalytics) || false;
const showPolicyBuilder = (isPoliciesEnabled && me && me?.platformPrivileges?.managePolicies) || false;
const showAdminConsole = showAnalytics || showPolicyBuilder;

const onMenuItemClick = () => {
Expand Down
6 changes: 3 additions & 3 deletions datahub-web-react/src/app/embed/EmbeddedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ 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';
import analytics from '../analytics/analytics';
import { EventType } from '../analytics';
import { useUserContext } from '../context/useUserContext';

const EmbeddedPageWrapper = styled.div`
max-height: 100%;
Expand Down Expand Up @@ -39,11 +39,11 @@ export default function EmbeddedPage({ entityType }: Props) {
});
}, [entityType, urn]);

const authenticatedUserUrn = useGetAuthenticatedUserUrn();
const { urn : authenticatedUserUrn } = useUserContext();
const { data } = useGetGrantedPrivilegesQuery({
variables: {
input: {
actorUrn: authenticatedUserUrn,
actorUrn: authenticatedUserUrn as string,
resourceSpec: { resourceType: entityType, resourceUrn: urn },
},
},
Expand Down

0 comments on commit b87f977

Please sign in to comment.