fix(admin): moving admin links to header (#3210)

This commit is contained in:
Gabe Lyons 2021-09-07 19:29:36 -07:00 committed by GitHub
parent 958b61a32a
commit 8aaf1d31cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 2 deletions

View File

@ -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 />} />

View File

@ -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 || ''}

View File

@ -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>

View 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>
)}
</>
);
}