Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor | PRD-785 | datahub oss: migrate use of useGetAuthenticatedU… #9456

Merged
merged 2 commits into from
Dec 14, 2023
Merged
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
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
Loading