mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-24 16:38:19 +00:00
fix(admin): moving admin links to header (#3210)
This commit is contained in:
parent
958b61a32a
commit
8aaf1d31cf
@ -10,7 +10,6 @@ import { SearchPage } from './search/SearchPage';
|
||||
import { AnalyticsPage } from './analyticsDashboard/components/AnalyticsPage';
|
||||
import { PoliciesPage } from './policy/PoliciesPage';
|
||||
import AppConfigProvider from '../AppConfigProvider';
|
||||
import { AdminConsole } from './AdminConsole';
|
||||
|
||||
/**
|
||||
* Container for all views behind an authentication wall.
|
||||
@ -20,7 +19,6 @@ export const ProtectedRoutes = (): JSX.Element => {
|
||||
return (
|
||||
<AppConfigProvider>
|
||||
<Layout style={{ height: '100%', width: '100%' }}>
|
||||
<AdminConsole />
|
||||
<Layout>
|
||||
<Switch>
|
||||
<Route exact path="/" render={() => <HomePage />} />
|
||||
|
||||
@ -12,6 +12,7 @@ import { GetSearchResultsQuery, useGetAutoCompleteAllResultsLazyQuery } from '..
|
||||
import { useGetAllEntitySearchResults } from '../../utils/customGraphQL/useGetAllEntitySearchResults';
|
||||
import { EntityType } from '../../types.generated';
|
||||
import analytics, { EventType } from '../analytics';
|
||||
import { AdminHeaderLinks } from '../shared/admin/AdminHeaderLinks';
|
||||
|
||||
const Background = styled.div`
|
||||
width: 100%;
|
||||
@ -211,6 +212,7 @@ export const HomePageHeader = () => {
|
||||
)}
|
||||
</WelcomeText>
|
||||
<NavGroup>
|
||||
<AdminHeaderLinks />
|
||||
<ManageAccount
|
||||
urn={user?.urn || ''}
|
||||
pictureLink={user?.editableInfo?.pictureLink || ''}
|
||||
|
||||
@ -8,6 +8,7 @@ import { ManageAccount } from '../shared/ManageAccount';
|
||||
import { AutoCompleteResultForEntity, EntityType } from '../../types.generated';
|
||||
import EntityRegistry from '../entity/EntityRegistry';
|
||||
import { ANTD_GRAY } from '../entity/shared/constants';
|
||||
import { AdminHeaderLinks } from '../shared/admin/AdminHeaderLinks';
|
||||
|
||||
const { Header } = Layout;
|
||||
|
||||
@ -90,6 +91,7 @@ export const SearchHeader = ({
|
||||
/>
|
||||
</LogoSearchContainer>
|
||||
<NavGroup>
|
||||
<AdminHeaderLinks />
|
||||
<ManageAccount urn={authenticatedUserUrn} pictureLink={authenticatedUserPictureLink || ''} />
|
||||
</NavGroup>
|
||||
</Header>
|
||||
|
||||
46
datahub-web-react/src/app/shared/admin/AdminHeaderLinks.tsx
Normal file
46
datahub-web-react/src/app/shared/admin/AdminHeaderLinks.tsx
Normal file
@ -0,0 +1,46 @@
|
||||
import styled from 'styled-components';
|
||||
import * as React from 'react';
|
||||
import { BankOutlined, BarChartOutlined } from '@ant-design/icons';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Button } from 'antd';
|
||||
|
||||
import { useAppConfig } from '../../useAppConfig';
|
||||
import { useGetAuthenticatedUser } from '../../useGetAuthenticatedUser';
|
||||
|
||||
const AdminLink = styled.span`
|
||||
margin-right: 4px;
|
||||
`;
|
||||
|
||||
export function AdminHeaderLinks() {
|
||||
const me = useGetAuthenticatedUser();
|
||||
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;
|
||||
|
||||
return (
|
||||
<>
|
||||
{showAnalytics && (
|
||||
<AdminLink>
|
||||
<Link to="/analytics">
|
||||
<Button type="text">
|
||||
<BarChartOutlined /> Analytics
|
||||
</Button>
|
||||
</Link>
|
||||
</AdminLink>
|
||||
)}
|
||||
{showPolicyBuilder && (
|
||||
<AdminLink>
|
||||
<Link to="/policies">
|
||||
<Button type="text">
|
||||
<BankOutlined /> Policies
|
||||
</Button>
|
||||
</Link>
|
||||
</AdminLink>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user