datahub/datahub-web-react/src/app/shared/admin/AdminHeaderLinks.tsx

80 lines
2.9 KiB
TypeScript
Raw Normal View History

import styled from 'styled-components';
import * as React from 'react';
import { ApiOutlined, BankOutlined, BarChartOutlined, SettingOutlined, UsergroupAddOutlined } 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 isIdentityManagementEnabled = config?.identityManagementConfig.enabled;
const isIngestionEnabled = config?.managedIngestionConfig.enabled;
const showAnalytics = (isAnalyticsEnabled && me && me.platformPrivileges.viewAnalytics) || false;
const showPolicyBuilder = (isPoliciesEnabled && me && me.platformPrivileges.managePolicies) || false;
const showIdentityManagement =
(isIdentityManagementEnabled && me && me.platformPrivileges.manageIdentities) || false;
const showSettings = true;
const showIngestion =
isIngestionEnabled && me && me.platformPrivileges.manageIngestion && me.platformPrivileges.manageSecrets;
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>
)}
{showIdentityManagement && (
<AdminLink>
<Link to="/identities">
<Button type="text">
<UsergroupAddOutlined /> Users & Groups
</Button>
</Link>
</AdminLink>
)}
{showIngestion && (
<AdminLink>
<Link to="/ingestion">
<Button type="text">
<ApiOutlined /> Ingestion
</Button>
</Link>
</AdminLink>
)}
{showSettings && (
<AdminLink>
<Link to="/settings">
<Button type="text">
<SettingOutlined /> Settings
</Button>
</Link>
</AdminLink>
)}
</>
);
}