mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
Merge branch 'main' into feat/search-projects
This commit is contained in:
commit
286b8b8604
@ -19,7 +19,8 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
searchIcon: {
|
searchIcon: {
|
||||||
marginRight: '8px',
|
marginRight: 8,
|
||||||
|
color: theme.palette.grey[600],
|
||||||
},
|
},
|
||||||
inputRoot: {
|
inputRoot: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
@ -22,6 +22,10 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
title: {
|
title: {
|
||||||
fontSize: '1rem',
|
fontSize: '1rem',
|
||||||
fontWeight: 'normal',
|
fontWeight: 'normal',
|
||||||
|
display: 'unset',
|
||||||
|
[theme.breakpoints.down(600)]: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
iconButton: {
|
iconButton: {
|
||||||
marginRight: '1rem',
|
marginRight: '1rem',
|
||||||
@ -37,4 +41,17 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
link: {
|
link: {
|
||||||
textDecoration: 'none',
|
textDecoration: 'none',
|
||||||
},
|
},
|
||||||
|
actionsContainer: {
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
search: {
|
||||||
|
border: `1px solid ${theme.palette.grey[300]}`,
|
||||||
|
height: 35,
|
||||||
|
marginRight: '2rem',
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
@ -1,36 +1,46 @@
|
|||||||
import { useContext } from 'react';
|
import { useContext, useMemo, useState } from 'react';
|
||||||
import { IconButton } from '@material-ui/core';
|
import { IconButton } from '@material-ui/core';
|
||||||
import { Add } from '@material-ui/icons';
|
import { Add } from '@material-ui/icons';
|
||||||
import FilterListIcon from '@material-ui/icons/FilterList';
|
import FilterListIcon from '@material-ui/icons/FilterList';
|
||||||
import { useParams } from 'react-router';
|
import { useParams } from 'react-router';
|
||||||
import { Link, useHistory } from 'react-router-dom';
|
import { Link, useHistory } from 'react-router-dom';
|
||||||
import AccessContext from '../../../../contexts/AccessContext';
|
import AccessContext from 'contexts/AccessContext';
|
||||||
import { IFeatureToggleListItem } from '../../../../interfaces/featureToggle';
|
import { SearchField } from 'component/common/SearchField/SearchField';
|
||||||
import { getCreateTogglePath } from '../../../../utils/route-path-helpers';
|
import ConditionallyRender from 'component/common/ConditionallyRender';
|
||||||
import ConditionallyRender from '../../../common/ConditionallyRender';
|
import { PROJECTFILTERING } from 'component/common/flags';
|
||||||
import { PROJECTFILTERING } from '../../../common/flags';
|
import HeaderTitle from 'component/common/HeaderTitle';
|
||||||
import HeaderTitle from '../../../common/HeaderTitle';
|
import PageContent from 'component/common/PageContent';
|
||||||
import PageContent from '../../../common/PageContent';
|
import ResponsiveButton from 'component/common/ResponsiveButton/ResponsiveButton';
|
||||||
import ResponsiveButton from '../../../common/ResponsiveButton/ResponsiveButton';
|
import FeatureToggleListNew from 'component/feature/FeatureToggleListNew/FeatureToggleListNew';
|
||||||
import FeatureToggleListNew from '../../../feature/FeatureToggleListNew/FeatureToggleListNew';
|
import { IFeatureToggleListItem } from 'interfaces/featureToggle';
|
||||||
|
import { getCreateTogglePath } from 'utils/route-path-helpers';
|
||||||
import { useStyles } from './ProjectFeatureToggles.styles';
|
import { useStyles } from './ProjectFeatureToggles.styles';
|
||||||
import { CREATE_FEATURE } from '../../../providers/AccessProvider/permissions';
|
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
||||||
import useUiConfig from '../../../../hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
interface IProjectFeatureToggles {
|
interface IProjectFeatureTogglesProps {
|
||||||
features: IFeatureToggleListItem[];
|
features: IFeatureToggleListItem[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProjectFeatureToggles = ({
|
export const ProjectFeatureToggles = ({
|
||||||
features,
|
features,
|
||||||
loading,
|
loading,
|
||||||
}: IProjectFeatureToggles) => {
|
}: IProjectFeatureTogglesProps) => {
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { hasAccess } = useContext(AccessContext);
|
const { hasAccess } = useContext(AccessContext);
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
|
const [filter, setFilter] = useState('');
|
||||||
|
|
||||||
|
const filteredFeatures = useMemo(() => {
|
||||||
|
const regExp = new RegExp(filter, 'i');
|
||||||
|
return filter
|
||||||
|
? features.filter(feature => regExp.test(feature.name))
|
||||||
|
: features;
|
||||||
|
}, [features, filter]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContent
|
<PageContent
|
||||||
@ -39,9 +49,16 @@ const ProjectFeatureToggles = ({
|
|||||||
headerContent={
|
headerContent={
|
||||||
<HeaderTitle
|
<HeaderTitle
|
||||||
className={styles.title}
|
className={styles.title}
|
||||||
title={`Feature toggles (${features.length})`}
|
title={`Feature toggles (${filteredFeatures.length})`}
|
||||||
actions={
|
actions={
|
||||||
<>
|
<div className={styles.actionsContainer}>
|
||||||
|
<SearchField
|
||||||
|
initialValue={filter}
|
||||||
|
updateValue={setFilter}
|
||||||
|
className={classnames(styles.search, {
|
||||||
|
skeleton: loading,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={PROJECTFILTERING}
|
condition={PROJECTFILTERING}
|
||||||
show={
|
show={
|
||||||
@ -69,19 +86,20 @@ const ProjectFeatureToggles = ({
|
|||||||
Icon={Add}
|
Icon={Add}
|
||||||
projectId={id}
|
projectId={id}
|
||||||
permission={CREATE_FEATURE}
|
permission={CREATE_FEATURE}
|
||||||
|
className={styles.button}
|
||||||
>
|
>
|
||||||
New feature toggle
|
New feature toggle
|
||||||
</ResponsiveButton>
|
</ResponsiveButton>
|
||||||
</>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={features?.length > 0}
|
condition={filteredFeatures.length > 0}
|
||||||
show={
|
show={
|
||||||
<FeatureToggleListNew
|
<FeatureToggleListNew
|
||||||
features={features}
|
features={filteredFeatures}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
projectId={id}
|
projectId={id}
|
||||||
/>
|
/>
|
||||||
@ -112,5 +130,3 @@ const ProjectFeatureToggles = ({
|
|||||||
</PageContent>
|
</PageContent>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProjectFeatureToggles;
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import useProject from '../../../hooks/api/getters/useProject/useProject';
|
import useProject from '../../../hooks/api/getters/useProject/useProject';
|
||||||
import ProjectFeatureToggles from './ProjectFeatureToggles/ProjectFeatureToggles';
|
import { ProjectFeatureToggles } from './ProjectFeatureToggles/ProjectFeatureToggles';
|
||||||
import ProjectInfo from './ProjectInfo/ProjectInfo';
|
import ProjectInfo from './ProjectInfo/ProjectInfo';
|
||||||
import { useStyles } from './Project.styles';
|
import { useStyles } from './Project.styles';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user