You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
218 lines
5.9 KiB
218 lines
5.9 KiB
7 years ago
|
import PropTypes from 'prop-types';
|
||
|
import React, { Component } from 'react';
|
||
7 years ago
|
import { align, icons, sortDirections } from 'Helpers/Props';
|
||
7 years ago
|
import Button from 'Components/Link/Button';
|
||
|
import Icon from 'Components/Icon';
|
||
7 years ago
|
import FilterMenu from 'Components/Menu/FilterMenu';
|
||
|
import PageMenuButton from 'Components/Menu/PageMenuButton';
|
||
7 years ago
|
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
||
|
import ModalContent from 'Components/Modal/ModalContent';
|
||
|
import ModalHeader from 'Components/Modal/ModalHeader';
|
||
|
import ModalBody from 'Components/Modal/ModalBody';
|
||
|
import ModalFooter from 'Components/Modal/ModalFooter';
|
||
|
import Table from 'Components/Table/Table';
|
||
|
import TableBody from 'Components/Table/TableBody';
|
||
7 years ago
|
import InteractiveSearchFilterModalConnector from './InteractiveSearchFilterModalConnector';
|
||
6 years ago
|
import InteractiveSearchRow from './InteractiveSearchRow';
|
||
|
import styles from './InteractiveSearchModalContent.css';
|
||
7 years ago
|
|
||
|
const columns = [
|
||
|
{
|
||
|
name: 'protocol',
|
||
|
label: 'Source',
|
||
|
isSortable: true,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'age',
|
||
|
label: 'Age',
|
||
|
isSortable: true,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'title',
|
||
|
label: 'Title',
|
||
|
isSortable: true,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'indexer',
|
||
|
label: 'Indexer',
|
||
|
isSortable: true,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'size',
|
||
|
label: 'Size',
|
||
|
isSortable: true,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'peers',
|
||
|
label: 'Peers',
|
||
|
isSortable: true,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'qualityWeight',
|
||
|
label: 'Quality',
|
||
|
isSortable: true,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'rejections',
|
||
|
label: React.createElement(Icon, { name: icons.DANGER }),
|
||
|
isSortable: true,
|
||
|
fixedSortDirection: sortDirections.ASCENDING,
|
||
|
isVisible: true
|
||
|
},
|
||
|
{
|
||
|
name: 'releaseWeight',
|
||
|
label: React.createElement(Icon, { name: icons.DOWNLOAD }),
|
||
|
isSortable: true,
|
||
|
fixedSortDirection: sortDirections.ASCENDING,
|
||
|
isVisible: true
|
||
|
}
|
||
|
];
|
||
|
|
||
6 years ago
|
class InteractiveSearchModalContent extends Component {
|
||
7 years ago
|
|
||
|
//
|
||
|
// Render
|
||
|
|
||
|
render() {
|
||
|
const {
|
||
|
isFetching,
|
||
|
isPopulated,
|
||
|
error,
|
||
7 years ago
|
totalReleasesCount,
|
||
7 years ago
|
items,
|
||
7 years ago
|
selectedFilterKey,
|
||
|
filters,
|
||
|
customFilters,
|
||
7 years ago
|
sortKey,
|
||
|
sortDirection,
|
||
|
longDateFormat,
|
||
|
timeFormat,
|
||
|
onSortPress,
|
||
7 years ago
|
onFilterSelect,
|
||
7 years ago
|
onGrabPress,
|
||
|
onModalClose
|
||
|
} = this.props;
|
||
|
|
||
|
const hasItems = !!items.length;
|
||
|
|
||
|
return (
|
||
|
<ModalContent onModalClose={onModalClose}>
|
||
|
<ModalHeader>
|
||
|
Interactive Album Search
|
||
|
</ModalHeader>
|
||
|
|
||
|
<ModalBody>
|
||
|
{
|
||
7 years ago
|
<div>
|
||
|
<div className={styles.filterMenuContainer}>
|
||
|
<FilterMenu
|
||
|
alignMenu={align.RIGHT}
|
||
|
selectedFilterKey={selectedFilterKey}
|
||
|
filters={filters}
|
||
|
customFilters={customFilters}
|
||
|
buttonComponent={PageMenuButton}
|
||
|
filterModalConnectorComponent={InteractiveSearchFilterModalConnector}
|
||
6 years ago
|
onFilterSelect={onFilterSelect}
|
||
7 years ago
|
/>
|
||
|
</div>
|
||
|
|
||
|
{
|
||
7 years ago
|
isFetching &&
|
||
|
<LoadingIndicator />
|
||
|
}
|
||
|
|
||
|
{
|
||
|
!isFetching && !!error &&
|
||
|
<div>
|
||
|
Unable to load results for this album search. Try again later.
|
||
|
</div>
|
||
|
}
|
||
|
|
||
|
{
|
||
|
!isFetching && isPopulated && !totalReleasesCount &&
|
||
|
<div>
|
||
|
No results found.
|
||
|
</div>
|
||
|
}
|
||
|
|
||
|
{
|
||
|
!!totalReleasesCount && isPopulated && !items.length &&
|
||
|
<div>
|
||
|
All results are hidden by {filters.length > 1 ? 'filters' : 'a filter'}.
|
||
|
</div>
|
||
7 years ago
|
}
|
||
|
|
||
|
{
|
||
|
!!items.length &&
|
||
|
<Table
|
||
|
columns={columns}
|
||
|
sortKey={sortKey}
|
||
|
sortDirection={sortDirection}
|
||
|
onSortPress={onSortPress}
|
||
|
>
|
||
|
<TableBody>
|
||
|
{
|
||
|
items.map((item) => {
|
||
|
return (
|
||
6 years ago
|
<InteractiveSearchRow
|
||
7 years ago
|
key={item.guid}
|
||
|
{...item}
|
||
|
longDateFormat={longDateFormat}
|
||
|
timeFormat={timeFormat}
|
||
|
onGrabPress={onGrabPress}
|
||
|
/>
|
||
|
);
|
||
|
})
|
||
|
}
|
||
|
</TableBody>
|
||
|
</Table>
|
||
|
}
|
||
|
|
||
|
{
|
||
|
totalReleasesCount !== items.length && !!items.length &&
|
||
|
<div>
|
||
|
Some results are hidden by {filters.length > 1 ? 'filters' : 'a filter'}.
|
||
|
</div>
|
||
|
}
|
||
|
</div>
|
||
7 years ago
|
}
|
||
|
</ModalBody>
|
||
|
|
||
|
<ModalFooter>
|
||
|
<Button onPress={onModalClose}>
|
||
|
Close
|
||
|
</Button>
|
||
|
</ModalFooter>
|
||
|
</ModalContent>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
6 years ago
|
InteractiveSearchModalContent.propTypes = {
|
||
7 years ago
|
isFetching: PropTypes.bool.isRequired,
|
||
|
isPopulated: PropTypes.bool.isRequired,
|
||
|
error: PropTypes.object,
|
||
7 years ago
|
totalReleasesCount: PropTypes.number.isRequired,
|
||
7 years ago
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||
|
longDateFormat: PropTypes.string.isRequired,
|
||
|
timeFormat: PropTypes.string.isRequired,
|
||
6 years ago
|
selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||
7 years ago
|
filters: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||
|
customFilters: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||
7 years ago
|
sortKey: PropTypes.string,
|
||
|
sortDirection: PropTypes.string,
|
||
|
onSortPress: PropTypes.func.isRequired,
|
||
7 years ago
|
onFilterSelect: PropTypes.func.isRequired,
|
||
7 years ago
|
onGrabPress: PropTypes.func.isRequired,
|
||
|
onModalClose: PropTypes.func.isRequired
|
||
|
};
|
||
|
|
||
6 years ago
|
export default InteractiveSearchModalContent;
|