2021-09-07 19:29:36 -07:00
|
|
|
import styled from 'styled-components';
|
|
|
|
|
import * as React from 'react';
|
2022-01-27 10:33:12 -08:00
|
|
|
import { ApiOutlined, BankOutlined, BarChartOutlined, SettingOutlined, UsergroupAddOutlined } from '@ant-design/icons';
|
2021-09-07 19:29:36 -07:00
|
|
|
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;
|
2021-10-07 16:14:35 -07:00
|
|
|
const isIdentityManagementEnabled = config?.identityManagementConfig.enabled;
|
2022-01-27 10:33:12 -08:00
|
|
|
const isIngestionEnabled = config?.managedIngestionConfig.enabled;
|
2021-09-07 19:29:36 -07:00
|
|
|
|
|
|
|
|
const showAnalytics = (isAnalyticsEnabled && me && me.platformPrivileges.viewAnalytics) || false;
|
|
|
|
|
const showPolicyBuilder = (isPoliciesEnabled && me && me.platformPrivileges.managePolicies) || false;
|
2021-10-07 16:14:35 -07:00
|
|
|
const showIdentityManagement =
|
|
|
|
|
(isIdentityManagementEnabled && me && me.platformPrivileges.manageIdentities) || false;
|
2021-11-22 16:33:14 -08:00
|
|
|
const showSettings = true;
|
2022-01-27 10:33:12 -08:00
|
|
|
const showIngestion =
|
|
|
|
|
isIngestionEnabled && me && me.platformPrivileges.manageIngestion && me.platformPrivileges.manageSecrets;
|
2021-09-07 19:29:36 -07:00
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
)}
|
2021-10-07 16:14:35 -07:00
|
|
|
{showIdentityManagement && (
|
|
|
|
|
<AdminLink>
|
|
|
|
|
<Link to="/identities">
|
|
|
|
|
<Button type="text">
|
|
|
|
|
<UsergroupAddOutlined /> Users & Groups
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
</AdminLink>
|
|
|
|
|
)}
|
2022-01-27 10:33:12 -08:00
|
|
|
{showIngestion && (
|
|
|
|
|
<AdminLink>
|
|
|
|
|
<Link to="/ingestion">
|
|
|
|
|
<Button type="text">
|
|
|
|
|
<ApiOutlined /> Ingestion
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
</AdminLink>
|
|
|
|
|
)}
|
2021-11-22 16:33:14 -08:00
|
|
|
{showSettings && (
|
|
|
|
|
<AdminLink>
|
|
|
|
|
<Link to="/settings">
|
|
|
|
|
<Button type="text">
|
|
|
|
|
<SettingOutlined /> Settings
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
</AdminLink>
|
|
|
|
|
)}
|
2021-09-07 19:29:36 -07:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|