mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Fixed: If no categories are passed in, flag up a unknown error (#311)
* If no categories are passed in, flag up a unknown error * Pass back in default props to deal with undefined issues
This commit is contained in:
@@ -1,10 +1,22 @@
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Label from 'Components/Label';
|
import Label from 'Components/Label';
|
||||||
|
import { kinds, tooltipPositions } from 'Helpers/Props';
|
||||||
|
import Tooltip from '../../Components/Tooltip/Tooltip';
|
||||||
|
|
||||||
function CategoryLabel({ categories = [] }) {
|
function CategoryLabel({ categories }) {
|
||||||
const sortedCategories = categories.filter((cat) => cat.name !== undefined).sort((c) => c.id);
|
const sortedCategories = categories.filter((cat) => cat.name !== undefined).sort((c) => c.id);
|
||||||
|
|
||||||
|
if (categories?.length === 0) {
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
anchor={<Label kind={kinds.DANGER}>Unknown</Label>}
|
||||||
|
tooltip="Please report this issue to the GitHub as this shouldn't be happening"
|
||||||
|
position={tooltipPositions.LEFT}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{
|
{
|
||||||
@@ -20,8 +32,12 @@ function CategoryLabel({ categories = [] }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CategoryLabel.defaultProps = {
|
||||||
|
categories: []
|
||||||
|
};
|
||||||
|
|
||||||
CategoryLabel.propTypes = {
|
CategoryLabel.propTypes = {
|
||||||
categories: PropTypes.arrayOf(PropTypes.object)
|
categories: PropTypes.arrayOf(PropTypes.object).isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CategoryLabel;
|
export default CategoryLabel;
|
||||||
|
Reference in New Issue
Block a user