mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-21 13:47:39 +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
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import classnames from 'classnames';
|
|
import { Link } from 'react-router-dom';
|
|
import { Button, IconButton, Tooltip } from '@material-ui/core';
|
|
import useMediaQuery from '@material-ui/core/useMediaQuery';
|
|
import { Add } from '@material-ui/icons';
|
|
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">
|
|
<IconButton
|
|
component={Link}
|
|
to={createFeature.path}
|
|
data-testid={NAVIGATE_TO_CREATE_FEATURE}
|
|
disabled={!createFeature.access}
|
|
>
|
|
<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>
|
|
}
|
|
/>
|
|
);
|
|
};
|