mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
feat: link to frontend api url (#7770)
This commit is contained in:
parent
0118f88964
commit
c7ececc429
@ -1,8 +1,33 @@
|
||||
import { Alert } from '@mui/material';
|
||||
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',
|
||||
title: 'Copied to clipboard',
|
||||
});
|
||||
};
|
||||
|
||||
const clientApiUrl = `${uiConfig.unleashUrl}/api/`;
|
||||
const frontendApiUrl = `${uiConfig.unleashUrl}/api/frontend`;
|
||||
|
||||
return (
|
||||
<Alert severity='info'>
|
||||
@ -19,9 +44,40 @@ export const ApiTokenDocs = () => {
|
||||
up to <strong>1 minute</strong> before a new API key is
|
||||
activated.
|
||||
</p>
|
||||
<br />
|
||||
<strong>API URL: </strong>{' '}
|
||||
<pre style={{ display: 'inline' }}>{uiConfig.unleashUrl}/api/</pre>
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user