mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-08 01:15:49 +02:00
* refactor: convert remaining js files to typescript * refactor: conditionally render remove index * refactor: dialog component to tsx * refactor: migrate some files from jsx to tsx * refactor: convert dropdown element to tsx * refactor: feature toggle list to tsx * refactor: update context name in use overrides * refactor: variant overrides to tsx refactor: remove unused strategy constraint file * fix: tsx imports * fix: update refectored components after rebase * refactor: rename report list files to tsx * fix: project health list types * refactor: addon form - add types * refactor: copy feature component types * fix: projects toggle style after tsx refactor * refactor: update ts types from openapi * fix: ts refactor changes after review * fix: header title prop * fix: update after PR comments * add test to useoverrides hook * fix conditionally render time ago * fix: toggle list empty tooltip * fix: remove unused variable * remove unused variable * fix: remove faulty snapshot
78 lines
3.0 KiB
TypeScript
78 lines
3.0 KiB
TypeScript
import { useContext } from 'react';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { Button } from '@material-ui/core';
|
|
import AccessContext from 'contexts/AccessContext';
|
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|
import PageContent from 'component/common/PageContent';
|
|
import { HeaderTitle } from 'component/common/HeaderTitle/HeaderTitle';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import {
|
|
CREATE_API_TOKEN,
|
|
READ_API_TOKEN,
|
|
} from 'component/providers/AccessProvider/permissions';
|
|
import { useStyles } from './ApiTokenPage.styles';
|
|
import { CREATE_API_TOKEN_BUTTON } from 'utils/testIds';
|
|
import { Alert } from '@material-ui/lab';
|
|
import { ApiTokenList } from 'component/admin/apiToken/ApiTokenList/ApiTokenList';
|
|
import { AdminAlert } from 'component/common/AdminAlert/AdminAlert';
|
|
|
|
export const ApiTokenPage = () => {
|
|
const styles = useStyles();
|
|
const { hasAccess } = useContext(AccessContext);
|
|
const { uiConfig } = useUiConfig();
|
|
const history = useHistory();
|
|
|
|
return (
|
|
<PageContent
|
|
headerContent={
|
|
<HeaderTitle
|
|
title="API Access"
|
|
actions={
|
|
<ConditionallyRender
|
|
condition={hasAccess(CREATE_API_TOKEN)}
|
|
show={
|
|
<Button
|
|
variant="contained"
|
|
color="primary"
|
|
onClick={() =>
|
|
history.push('/admin/api/create-token')
|
|
}
|
|
data-testid={CREATE_API_TOKEN_BUTTON}
|
|
>
|
|
New API token
|
|
</Button>
|
|
}
|
|
/>
|
|
}
|
|
/>
|
|
}
|
|
>
|
|
<Alert severity="info" className={styles.infoBoxContainer}>
|
|
<p>
|
|
Read the{' '}
|
|
<a
|
|
href="https://docs.getunleash.io/docs"
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
>
|
|
Getting started guide
|
|
</a>{' '}
|
|
to learn how to connect to the Unleash API from your
|
|
application or programmatically. Please note it can take up
|
|
to 1 minute before a new API key is activated.
|
|
</p>
|
|
<br />
|
|
<strong>API URL: </strong>{' '}
|
|
<pre style={{ display: 'inline' }}>
|
|
{uiConfig.unleashUrl}/api/
|
|
</pre>
|
|
</Alert>
|
|
<ConditionallyRender
|
|
condition={hasAccess(READ_API_TOKEN)}
|
|
show={() => <ApiTokenList />}
|
|
elseShow={() => <AdminAlert />}
|
|
/>
|
|
</PageContent>
|
|
);
|
|
};
|