mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-15 17:50:48 +02:00
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->
Define and implements Project api token permissions
Assign permissions to existing roles
Adjust UI to support them
Adjust BE to implement
---------
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { Alert, Link } from '@mui/material';
|
|
import React, { ReactNode } from 'react';
|
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import { CancelButton, StyledBox, StyledForm } from './ApiTokenForm.styles';
|
|
|
|
interface IApiTokenFormProps {
|
|
handleSubmit: (e: any) => void;
|
|
handleCancel: () => void;
|
|
mode: 'Create' | 'Edit';
|
|
actions?: ReactNode;
|
|
}
|
|
|
|
const ApiTokenForm: React.FC<IApiTokenFormProps> = ({
|
|
children,
|
|
actions,
|
|
handleSubmit,
|
|
handleCancel,
|
|
}) => {
|
|
const { uiConfig } = useUiConfig();
|
|
|
|
const isUnleashCloud = Boolean(uiConfig?.flags?.UNLEASH_CLOUD);
|
|
|
|
return (
|
|
<StyledForm onSubmit={handleSubmit}>
|
|
<ConditionallyRender
|
|
condition={isUnleashCloud}
|
|
show={
|
|
<Alert severity="info" sx={{ mb: 4 }}>
|
|
Please be aware of our{' '}
|
|
<Link href="https://www.getunleash.io/fair-use-policy">
|
|
fair use policy
|
|
</Link>
|
|
.
|
|
</Alert>
|
|
}
|
|
/>
|
|
{children}
|
|
<StyledBox>
|
|
{actions}
|
|
<CancelButton onClick={handleCancel}>Cancel</CancelButton>
|
|
</StyledBox>
|
|
</StyledForm>
|
|
);
|
|
};
|
|
|
|
export default ApiTokenForm;
|