filter out unknown mappers (#1559)

This commit is contained in:
Erik Jan de Wit 2021-11-22 11:32:26 +01:00 committed by GitHub
parent 119fac0916
commit bb46594d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,22 +56,30 @@ export const MapperList = ({
setAddMapperDialogOpen(!addMapperDialogOpen); setAddMapperDialogOpen(!addMapperDialogOpen);
}; };
const loader = async () => const loader = async () => {
Promise.resolve( if (!mapperList) {
(mapperList || []) return [];
.map((mapper) => { }
const mapperType = mapperTypes.filter(
(type) => type.id === mapper.protocolMapper const list = mapperList.reduce<Row[]>((rows, mapper) => {
)[0]; const mapperType = mapperTypes.find(
return { ({ id }) => id === mapper.protocolMapper
);
if (!mapperType) {
return rows;
}
return rows.concat({
...mapper, ...mapper,
category: mapperType.category, category: mapperType.category,
type: mapperType.name, type: mapperType.name,
priority: mapperType.priority, priority: mapperType.priority,
} as Row; });
}) }, []);
.sort((a, b) => a.priority - b.priority)
); return list.sort((a, b) => a.priority - b.priority);
};
const MapperLink = ({ id, name }: Row) => ( const MapperLink = ({ id, name }: Row) => (
<Link to={detailLink(id!)}>{name}</Link> <Link to={detailLink(id!)}>{name}</Link>