1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-26 22:56:23 -04:00

New: Table options in page toolbar in addition to table header

This commit is contained in:
Mark McDowall
2019-01-09 18:57:18 -08:00
parent 21a92b62fd
commit 3b565d8bb1
9 changed files with 126 additions and 53 deletions
+25 -5
View File
@@ -7,20 +7,22 @@ import LoadingIndicator from 'Components/Loading/LoadingIndicator';
import PageContent from 'Components/Page/PageContent';
import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector';
import PageJumpBar from 'Components/Page/PageJumpBar';
import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper';
import PageToolbar from 'Components/Page/Toolbar/PageToolbar';
import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator';
import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection';
import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton';
import NoSeries from 'Series/NoSeries';
import SeriesIndexTableConnector from './Table/SeriesIndexTableConnector';
import SeriesIndexTableOptionsConnector from './Table/SeriesIndexTableOptionsConnector';
import SeriesIndexPosterOptionsModal from './Posters/Options/SeriesIndexPosterOptionsModal';
import SeriesIndexPostersConnector from './Posters/SeriesIndexPostersConnector';
import SeriesIndexOverviewOptionsModal from './Overview/Options/SeriesIndexOverviewOptionsModal';
import SeriesIndexOverviewsConnector from './Overview/SeriesIndexOverviewsConnector';
import SeriesIndexFooter from './SeriesIndexFooter';
import SeriesIndexFilterMenu from './Menus/SeriesIndexFilterMenu';
import SeriesIndexSortMenu from './Menus/SeriesIndexSortMenu';
import SeriesIndexViewMenu from './Menus/SeriesIndexViewMenu';
import SeriesIndexFooter from './SeriesIndexFooter';
import styles from './SeriesIndex.css';
function getViewComponent(view) {
@@ -172,6 +174,7 @@ class SeriesIndex extends Component {
error,
totalItems,
items,
columns,
selectedFilterKey,
filters,
customFilters,
@@ -229,25 +232,41 @@ class SeriesIndex extends Component {
alignContent={align.RIGHT}
collapseButtons={false}
>
{
view === 'table' ?
<TableOptionsModalWrapper
{...otherProps}
columns={columns}
optionsComponent={SeriesIndexTableOptionsConnector}
>
<PageToolbarButton
label="Options"
iconName={icons.TABLE}
/>
</TableOptionsModalWrapper> :
null
}
{
view === 'posters' &&
view === 'posters' ?
<PageToolbarButton
label="Options"
iconName={icons.POSTER}
isDisabled={hasNoSeries}
onPress={this.onPosterOptionsPress}
/>
/> :
null
}
{
view === 'overview' &&
view === 'overview' ?
<PageToolbarButton
label="Options"
iconName={icons.OVERVIEW}
isDisabled={hasNoSeries}
onPress={this.onOverviewOptionsPress}
/>
/> :
null
}
{
@@ -348,6 +367,7 @@ SeriesIndex.propTypes = {
error: PropTypes.object,
totalItems: PropTypes.number.isRequired,
items: PropTypes.arrayOf(PropTypes.object).isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired,
customFilters: PropTypes.arrayOf(PropTypes.object).isRequired,
@@ -8,7 +8,7 @@ import createCommandExecutingSelector from 'Store/Selectors/createCommandExecuti
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
import { fetchSeries } from 'Store/Actions/seriesActions';
import scrollPositions from 'Store/scrollPositions';
import { setSeriesSort, setSeriesFilter, setSeriesView } from 'Store/Actions/seriesIndexActions';
import { setSeriesSort, setSeriesFilter, setSeriesView, setSeriesTableOption } from 'Store/Actions/seriesIndexActions';
import { executeCommand } from 'Store/Actions/commandActions';
import * as commandNames from 'Commands/commandNames';
import withScrollPosition from 'Components/withScrollPosition';
@@ -59,13 +59,41 @@ function createMapStateToProps() {
);
}
const mapDispatchToProps = {
fetchSeries,
setSeriesSort,
setSeriesFilter,
setSeriesView,
executeCommand
};
function createMapDispatchToProps(dispatch, props) {
return {
dispatchFetchSeries() {
dispatch(fetchSeries);
},
onTableOptionChange(payload) {
dispatch(setSeriesTableOption(payload));
},
onSortSelect(sortKey) {
dispatch(setSeriesSort({ sortKey }));
},
onFilterSelect(selectedFilterKey) {
dispatch(setSeriesFilter({ selectedFilterKey }));
},
dispatchSetSeriesView(view) {
dispatch(setSeriesView({ view }));
},
onRefreshSeriesPress() {
dispatch(executeCommand({
name: commandNames.REFRESH_SERIES
}));
},
onRssSyncPress() {
dispatch(executeCommand({
name: commandNames.RSS_SYNC
}));
}
};
}
class SeriesIndexConnector extends Component {
@@ -87,24 +115,16 @@ class SeriesIndexConnector extends Component {
}
componentDidMount() {
this.props.fetchSeries();
this.props.dispatchFetchSeries();
}
//
// Listeners
onSortSelect = (sortKey) => {
this.props.setSeriesSort({ sortKey });
}
onFilterSelect = (selectedFilterKey) => {
this.props.setSeriesFilter({ selectedFilterKey });
}
onViewSelect = (view) => {
// Reset the scroll position before changing the view
this.setState({ scrollTop: 0 }, () => {
this.props.setSeriesView({ view });
this.props.dispatchSetSeriesView({ view });
});
}
@@ -116,18 +136,6 @@ class SeriesIndexConnector extends Component {
});
}
onRefreshSeriesPress = () => {
this.props.executeCommand({
name: commandNames.REFRESH_SERIES
});
}
onRssSyncPress = () => {
this.props.executeCommand({
name: commandNames.RSS_SYNC
});
}
//
// Render
@@ -136,12 +144,8 @@ class SeriesIndexConnector extends Component {
<SeriesIndex
{...this.props}
scrollTop={this.state.scrollTop}
onSortSelect={this.onSortSelect}
onFilterSelect={this.onFilterSelect}
onViewSelect={this.onViewSelect}
onScroll={this.onScroll}
onRefreshSeriesPress={this.onRefreshSeriesPress}
onRssSyncPress={this.onRssSyncPress}
/>
);
}
@@ -151,14 +155,10 @@ SeriesIndexConnector.propTypes = {
isSmallScreen: PropTypes.bool.isRequired,
view: PropTypes.string.isRequired,
scrollTop: PropTypes.number.isRequired,
fetchSeries: PropTypes.func.isRequired,
setSeriesSort: PropTypes.func.isRequired,
setSeriesFilter: PropTypes.func.isRequired,
setSeriesView: PropTypes.func.isRequired,
executeCommand: PropTypes.func.isRequired
dispatchFetchSeries: PropTypes.func.isRequired
};
export default withScrollPosition(
connect(createMapStateToProps, mapDispatchToProps)(SeriesIndexConnector),
connect(createMapStateToProps, createMapDispatchToProps)(SeriesIndexConnector),
'seriesIndex'
);