clean numberOfVisibleItems prop

Signed-off-by: Virginie Ky <virginie.ky@gmail.com>
This commit is contained in:
Virginie Ky 2020-03-20 16:40:55 +01:00
parent 8d52924783
commit 59c567aa3c
2 changed files with 7 additions and 21 deletions

View File

@ -9,7 +9,7 @@ import LeftMenuHeader from '../LeftMenuHeader';
import List from './List'; import List from './List';
import Wrapper from './Wrapper'; import Wrapper from './Wrapper';
function LeftMenuList({ customLink, links, title, searchable, numberOfVisibleItems }) { function LeftMenuList({ customLink, links, title, searchable }) {
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const { formatMessage } = useGlobalContext(); const { formatMessage } = useGlobalContext();
@ -100,9 +100,7 @@ function LeftMenuList({ customLink, links, title, searchable, numberOfVisibleIte
<LeftMenuHeader {...headerProps} /> <LeftMenuHeader {...headerProps} />
</div> </div>
<div> <div>
<List numberOfVisibleItems={numberOfVisibleItems}> <List>{getList().map((link, i) => renderCompo(link, i))}</List>
{getList().map((link, i) => renderCompo(link, i))}
</List>
{Component && isValidElement(<Component />) && <Component {...componentProps} />} {Component && isValidElement(<Component />) && <Component {...componentProps} />}
</div> </div>
</Wrapper> </Wrapper>
@ -114,7 +112,6 @@ LeftMenuList.defaultProps = {
links: [], links: [],
title: null, title: null,
searchable: false, searchable: false,
numberOfVisibleItems: null,
}; };
LeftMenuList.propTypes = { LeftMenuList.propTypes = {
@ -130,7 +127,6 @@ LeftMenuList.propTypes = {
id: PropTypes.string, id: PropTypes.string,
}), }),
searchable: PropTypes.bool, searchable: PropTypes.bool,
numberOfVisibleItems: PropTypes.number,
}; };
export default LeftMenuList; export default LeftMenuList;

View File

@ -76,12 +76,8 @@ function LeftMenu({ wait }) {
const canOpenModalCreateCTorComponent = () => { const canOpenModalCreateCTorComponent = () => {
return ( return (
!Object.keys(contentTypes).some( !Object.keys(contentTypes).some(ct => contentTypes[ct].isTemporary === true) &&
ct => contentTypes[ct].isTemporary === true !Object.keys(components).some(component => components[component].isTemporary === true)
) &&
!Object.keys(components).some(
component => components[component].isTemporary === true
)
); );
}; };
@ -128,9 +124,7 @@ function LeftMenu({ wait }) {
}, },
} }
: null, : null,
links: sortedContentTypesList.filter( links: sortedContentTypesList.filter(contentType => contentType.kind === 'collectionType'),
contentType => contentType.kind === 'collectionType'
),
}, },
{ {
name: 'singleTypes', name: 'singleTypes',
@ -149,9 +143,7 @@ function LeftMenu({ wait }) {
}, },
} }
: null, : null,
links: sortedContentTypesList.filter( links: sortedContentTypesList.filter(singleType => singleType.kind === 'singleType'),
singleType => singleType.kind === 'singleType'
),
}, },
{ {
name: 'components', name: 'components',
@ -177,9 +169,7 @@ function LeftMenu({ wait }) {
return ( return (
<Wrapper className="col-md-3"> <Wrapper className="col-md-3">
{data.map(list => { {data.map(list => {
return ( return <LeftMenuList {...list} key={list.name} />;
<LeftMenuList numberOfVisibleItems={5} {...list} key={list.name} />
);
})} })}
</Wrapper> </Wrapper>
); );