1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-10 01:19:53 +01:00
unleash.unleash/frontend/src/component/admin/apiToken/ApiTokenDocs/ApiTokenDocs.tsx
Thomas Heartman b2c58102dd
chore(unl-204): remove uses of toast text and confetti (#8941)
As of PR #8935, we no longer support both text and title, and confetti
has been removed.

This PR:
- removes `confetti` from the toast interface
- merges `text` and `title` into `text` and updates its uses across the
codebase.
- readjusts the text where necessary.
2024-12-10 13:38:04 +00:00

84 lines
2.8 KiB
TypeScript

import { Alert, Box, IconButton, styled, Tooltip } from '@mui/material';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import CopyIcon from '@mui/icons-material/FileCopy';
import copy from 'copy-to-clipboard';
import useToast from 'hooks/useToast';
const GridContainer = styled('div')(({ theme }) => ({
display: 'grid',
gridTemplateColumns: 'auto auto 1fr',
gridAutoRows: 'min-content',
alignItems: 'center',
gap: theme.spacing(1),
marginTop: theme.spacing(1.5),
}));
const GridItem = Box;
export const ApiTokenDocs = () => {
const { uiConfig } = useUiConfig();
const { setToastData } = useToast();
const onCopyToClipboard = (url: string) => () => {
copy(url);
setToastData({
type: 'success',
text: 'Copied to clipboard',
});
};
const clientApiUrl = `${uiConfig.unleashUrl}/api/`;
const frontendApiUrl = `${uiConfig.unleashUrl}/api/frontend/`;
return (
<Alert severity='info'>
<p>
Read the{' '}
<a
href='https://docs.getunleash.io/reference/sdks'
target='_blank'
rel='noreferrer'
>
SDK overview
</a>{' '}
to connect Unleash to your application. Please note it can take
up to <strong>1 minute</strong> before a new API key is
activated.
</p>
<GridContainer>
<GridItem>
<strong>CLIENT API URL: </strong>
</GridItem>
<GridItem>
<pre style={{ display: 'inline' }}>{clientApiUrl}</pre>
</GridItem>
<GridItem>
<Tooltip title='Copy URL' arrow>
<IconButton
onClick={onCopyToClipboard(clientApiUrl)}
size='small'
>
<CopyIcon />
</IconButton>
</Tooltip>
</GridItem>
<GridItem>
<strong>FRONTEND API URL: </strong>
</GridItem>
<GridItem>
<pre style={{ display: 'inline' }}>{frontendApiUrl}</pre>
</GridItem>
<GridItem>
<Tooltip title='Copy URL' arrow>
<IconButton
onClick={onCopyToClipboard(frontendApiUrl)}
size='small'
>
<CopyIcon />
</IconButton>
</Tooltip>
</GridItem>
</GridContainer>
</Alert>
);
};