mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-04 11:17:02 +02:00
* refactor: add missing event arg type * refactor: fix project card popup position * refactor: add tooltip arrows * refactor: update snapshot * refactor: add missing tooltips * refactor: use a custom Autocomplete size in AutocompleteBox
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import classnames from 'classnames';
|
|
import { Link } from 'react-router-dom';
|
|
import { Button, IconButton, Tooltip } from '@mui/material';
|
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
import { Add } from '@mui/icons-material';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import { NAVIGATE_TO_CREATE_FEATURE } from 'utils/testIds';
|
|
import { IFeaturesFilter } from 'hooks/useFeaturesFilter';
|
|
import { useCreateFeaturePath } from 'component/feature/CreateFeatureButton/useCreateFeaturePath';
|
|
|
|
interface ICreateFeatureButtonProps {
|
|
loading: boolean;
|
|
filter: IFeaturesFilter;
|
|
}
|
|
|
|
export const CreateFeatureButton = ({
|
|
loading,
|
|
filter,
|
|
}: ICreateFeatureButtonProps) => {
|
|
const smallScreen = useMediaQuery('(max-width:800px)');
|
|
const createFeature = useCreateFeaturePath(filter);
|
|
|
|
if (!createFeature) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ConditionallyRender
|
|
condition={smallScreen}
|
|
show={
|
|
<Tooltip title="Create feature toggle" arrow>
|
|
<IconButton
|
|
component={Link}
|
|
to={createFeature.path}
|
|
data-testid={NAVIGATE_TO_CREATE_FEATURE}
|
|
disabled={!createFeature.access}
|
|
size="large"
|
|
>
|
|
<Add />
|
|
</IconButton>
|
|
</Tooltip>
|
|
}
|
|
elseShow={
|
|
<Button
|
|
to={createFeature.path}
|
|
color="primary"
|
|
variant="contained"
|
|
component={Link}
|
|
data-testid={NAVIGATE_TO_CREATE_FEATURE}
|
|
disabled={!createFeature.access}
|
|
className={classnames({ skeleton: loading })}
|
|
>
|
|
New feature toggle
|
|
</Button>
|
|
}
|
|
/>
|
|
);
|
|
};
|