import PropTypes from 'prop-types'; import React, { Component } from 'react'; import FieldSet from 'Components/FieldSet'; import Icon from 'Components/Icon'; import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TableRow from 'Components/Table/TableRow'; import { icons, kinds } from 'Helpers/Props'; import titleCase from 'Utilities/String/titleCase'; import translate from 'Utilities/String/translate'; import styles from './Health.css'; function getInternalLink(source) { switch (source) { case 'IndexerRssCheck': case 'IndexerSearchCheck': case 'IndexerStatusCheck': case 'IndexerJackettAllCheck': case 'IndexerLongTermStatusCheck': return ( ); case 'DownloadClientCheck': case 'DownloadClientStatusCheck': case 'ImportMechanismCheck': case 'RemotePathMappingCheck': return ( ); case 'NotificationStatusCheck': return ( ); case 'RootFolderCheck': return ( ); case 'UpdateCheck': return ( ); default: return; } } function getTestLink(source, props) { switch (source) { case 'IndexerStatusCheck': return ( ); case 'DownloadClientCheck': case 'DownloadClientStatusCheck': return ( ); default: break; } } const columns = [ { className: styles.status, name: 'type', isVisible: true }, { name: 'message', label: translate('Message'), isVisible: true }, { name: 'actions', label: translate('Actions'), isVisible: true } ]; class Health extends Component { // // Render render() { const { isFetching, isPopulated, items } = this.props; const healthIssues = !!items.length; return (
Health { isFetching && isPopulated && } } > { isFetching && !isPopulated && } { !healthIssues &&
No issues with your configuration
} { healthIssues && { items.map((item) => { const internalLink = getInternalLink(item.source); const testLink = getTestLink(item.source, this.props); let kind = kinds.WARNING; switch (item.type.toLowerCase()) { case 'error': kind = kinds.DANGER; break; default: case 'warning': kind = kinds.WARNING; break; case 'notice': kind = kinds.INFO; break; } return ( {item.message} { internalLink } { !!testLink && testLink } ); }) }
}
); } } Health.propTypes = { isFetching: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, items: PropTypes.array.isRequired, isTestingAllDownloadClients: PropTypes.bool.isRequired, isTestingAllIndexers: PropTypes.bool.isRequired, dispatchTestAllDownloadClients: PropTypes.func.isRequired, dispatchTestAllIndexers: PropTypes.func.isRequired }; export default Health;