From d022679b7dcbce3cec98e6a1fd0879e3c0d92523 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 5 Jan 2023 18:20:49 -0800 Subject: [PATCH] Refactor Series index to use react-window --- .../ImportSeries/Import/ImportSeries.js | 25 +- frontend/src/App/AppRoutes.js | 4 +- frontend/src/App/ModelBase.ts | 5 + .../src/Components/Form/FormInputGroup.js | 6 +- frontend/src/Components/Form/FormLabel.js | 26 +- frontend/src/Components/Link/IconButton.js | 2 + .../src/Components/Link/SpinnerIconButton.js | 2 + frontend/src/Components/Menu/SortMenu.js | 5 +- frontend/src/Components/Menu/ViewMenu.js | 5 +- .../src/Components/Page/PageContentBody.js | 61 -- .../src/Components/Page/PageContentBody.tsx | 51 ++ .../Page/Toolbar/PageToolbarButton.js | 3 +- frontend/src/Components/Scroller/Scroller.js | 95 --- frontend/src/Components/Scroller/Scroller.tsx | 90 +++ frontend/src/Components/Table/Column.ts | 10 + frontend/src/Components/withScrollPosition.js | 30 - .../src/Components/withScrollPosition.tsx | 25 + frontend/src/Helpers/Hooks/useMeasure.ts | 21 + frontend/src/Helpers/Props/ScrollDirection.ts | 8 + frontend/src/Helpers/Props/SortDirection.ts | 6 + .../src/Series/Delete/DeleteSeriesModal.js | 1 + .../Series/Delete/DeleteSeriesModalContent.js | 1 - frontend/src/Series/Edit/EditSeriesModal.js | 1 + .../Series/Edit/EditSeriesModalConnector.js | 1 + ...ilterMenu.js => SeriesIndexFilterMenu.tsx} | 13 +- ...dexSortMenu.js => SeriesIndexSortMenu.tsx} | 14 +- ...dexViewMenu.js => SeriesIndexViewMenu.tsx} | 25 +- .../SeriesIndexOverviewOptionsModal.js | 25 - .../SeriesIndexOverviewOptionsModal.tsx | 25 + .../SeriesIndexOverviewOptionsModalContent.js | 305 ---------- ...SeriesIndexOverviewOptionsModalContent.tsx | 193 ++++++ ...dexOverviewOptionsModalContentConnector.js | 23 - .../Index/Overview/SeriesIndexOverview.js | 281 --------- .../Index/Overview/SeriesIndexOverview.tsx | 240 ++++++++ .../Index/Overview/SeriesIndexOverviewInfo.js | 265 --------- .../Overview/SeriesIndexOverviewInfo.tsx | 243 ++++++++ .../Overview/SeriesIndexOverviewInfoRow.js | 35 -- .../Overview/SeriesIndexOverviewInfoRow.tsx | 23 + .../Index/Overview/SeriesIndexOverviews.js | 275 --------- .../Index/Overview/SeriesIndexOverviews.tsx | 203 +++++++ .../Overview/SeriesIndexOverviewsConnector.js | 25 - .../Index/Overview/selectOverviewOptions.ts | 8 + .../Options/SeriesIndexPosterOptionsModal.js | 25 - .../Options/SeriesIndexPosterOptionsModal.tsx | 21 + .../SeriesIndexPosterOptionsModalContent.js | 213 ------- .../SeriesIndexPosterOptionsModalContent.tsx | 138 +++++ ...IndexPosterOptionsModalContentConnector.js | 23 - .../Series/Index/Posters/SeriesIndexPoster.js | 291 --------- .../Index/Posters/SeriesIndexPoster.tsx | 230 +++++++ .../Index/Posters/SeriesIndexPosterInfo.js | 125 ---- .../Index/Posters/SeriesIndexPosterInfo.tsx | 94 +++ .../Index/Posters/SeriesIndexPosters.css | 3 - .../Index/Posters/SeriesIndexPosters.js | 333 ----------- .../Index/Posters/SeriesIndexPosters.tsx | 282 +++++++++ .../Posters/SeriesIndexPostersConnector.js | 24 - .../Index/Posters/selectPosterOptions.ts | 8 + ...gressBar.js => SeriesIndexProgressBar.tsx} | 27 +- frontend/src/Series/Index/SeriesIndex.js | 370 ------------ frontend/src/Series/Index/SeriesIndex.tsx | 306 ++++++++++ .../src/Series/Index/SeriesIndexConnector.js | 105 ---- .../Series/Index/SeriesIndexFilterModal.tsx | 48 ++ .../Index/SeriesIndexFilterModalConnector.js | 24 - .../src/Series/Index/SeriesIndexFooter.js | 158 ----- .../src/Series/Index/SeriesIndexFooter.tsx | 155 +++++ .../Index/SeriesIndexFooterConnector.js | 46 -- .../Series/Index/SeriesIndexItemConnector.js | 134 ----- .../Index/Table/SeriesIndexActionsCell.js | 102 ---- .../Series/Index/Table/SeriesIndexHeader.js | 86 --- .../Index/Table/SeriesIndexHeaderConnector.js | 13 - .../src/Series/Index/Table/SeriesIndexRow.js | 563 ------------------ .../src/Series/Index/Table/SeriesIndexRow.tsx | 445 ++++++++++++++ .../Series/Index/Table/SeriesIndexTable.css | 6 +- .../Series/Index/Table/SeriesIndexTable.js | 127 ---- .../Series/Index/Table/SeriesIndexTable.tsx | 205 +++++++ .../Index/Table/SeriesIndexTableConnector.js | 29 - ...xHeader.css => SeriesIndexTableHeader.css} | 0 .../Index/Table/SeriesIndexTableHeader.tsx | 99 +++ .../Index/Table/SeriesIndexTableOptions.js | 100 ---- .../Index/Table/SeriesIndexTableOptions.tsx | 61 ++ .../Table/SeriesIndexTableOptionsConnector.js | 14 - ...riesStatusCell.js => SeriesStatusCell.tsx} | 30 +- ...owableColumns.js => hasGrowableColumns.ts} | 12 +- .../Series/Index/Table/selectTableOptions.ts | 8 + .../Index/createSeriesIndexItemSelector.ts | 51 ++ frontend/src/Series/Series.ts | 75 +++ frontend/src/Series/SeriesBanner.js | 4 + frontend/src/Series/SeriesPoster.js | 4 + .../createSeriesQualityProfileSelector.js | 4 +- .../Store/Selectors/createSeriesSelector.js | 18 +- .../Array/getIndexOfFirstCharacter.js | 4 +- package.json | 4 + yarn.lock | 37 ++ 92 files changed, 3527 insertions(+), 4462 deletions(-) create mode 100644 frontend/src/App/ModelBase.ts delete mode 100644 frontend/src/Components/Page/PageContentBody.js create mode 100644 frontend/src/Components/Page/PageContentBody.tsx delete mode 100644 frontend/src/Components/Scroller/Scroller.js create mode 100644 frontend/src/Components/Scroller/Scroller.tsx create mode 100644 frontend/src/Components/Table/Column.ts delete mode 100644 frontend/src/Components/withScrollPosition.js create mode 100644 frontend/src/Components/withScrollPosition.tsx create mode 100644 frontend/src/Helpers/Hooks/useMeasure.ts create mode 100644 frontend/src/Helpers/Props/ScrollDirection.ts create mode 100644 frontend/src/Helpers/Props/SortDirection.ts rename frontend/src/Series/Index/Menus/{SeriesIndexFilterMenu.js => SeriesIndexFilterMenu.tsx} (76%) rename frontend/src/Series/Index/Menus/{SeriesIndexSortMenu.js => SeriesIndexSortMenu.tsx} (94%) rename frontend/src/Series/Index/Menus/{SeriesIndexViewMenu.js => SeriesIndexViewMenu.tsx} (64%) delete mode 100644 frontend/src/Series/Index/Overview/Options/SeriesIndexOverviewOptionsModal.js create mode 100644 frontend/src/Series/Index/Overview/Options/SeriesIndexOverviewOptionsModal.tsx delete mode 100644 frontend/src/Series/Index/Overview/Options/SeriesIndexOverviewOptionsModalContent.js create mode 100644 frontend/src/Series/Index/Overview/Options/SeriesIndexOverviewOptionsModalContent.tsx delete mode 100644 frontend/src/Series/Index/Overview/Options/SeriesIndexOverviewOptionsModalContentConnector.js delete mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverview.js create mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverview.tsx delete mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverviewInfo.js create mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverviewInfo.tsx delete mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverviewInfoRow.js create mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverviewInfoRow.tsx delete mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverviews.js create mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverviews.tsx delete mode 100644 frontend/src/Series/Index/Overview/SeriesIndexOverviewsConnector.js create mode 100644 frontend/src/Series/Index/Overview/selectOverviewOptions.ts delete mode 100644 frontend/src/Series/Index/Posters/Options/SeriesIndexPosterOptionsModal.js create mode 100644 frontend/src/Series/Index/Posters/Options/SeriesIndexPosterOptionsModal.tsx delete mode 100644 frontend/src/Series/Index/Posters/Options/SeriesIndexPosterOptionsModalContent.js create mode 100644 frontend/src/Series/Index/Posters/Options/SeriesIndexPosterOptionsModalContent.tsx delete mode 100644 frontend/src/Series/Index/Posters/Options/SeriesIndexPosterOptionsModalContentConnector.js delete mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPoster.js create mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPoster.tsx delete mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.js create mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.tsx delete mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPosters.css delete mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPosters.js create mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPosters.tsx delete mode 100644 frontend/src/Series/Index/Posters/SeriesIndexPostersConnector.js create mode 100644 frontend/src/Series/Index/Posters/selectPosterOptions.ts rename frontend/src/Series/Index/ProgressBar/{SeriesIndexProgressBar.js => SeriesIndexProgressBar.tsx} (62%) delete mode 100644 frontend/src/Series/Index/SeriesIndex.js create mode 100644 frontend/src/Series/Index/SeriesIndex.tsx delete mode 100644 frontend/src/Series/Index/SeriesIndexConnector.js create mode 100644 frontend/src/Series/Index/SeriesIndexFilterModal.tsx delete mode 100644 frontend/src/Series/Index/SeriesIndexFilterModalConnector.js delete mode 100644 frontend/src/Series/Index/SeriesIndexFooter.js create mode 100644 frontend/src/Series/Index/SeriesIndexFooter.tsx delete mode 100644 frontend/src/Series/Index/SeriesIndexFooterConnector.js delete mode 100644 frontend/src/Series/Index/SeriesIndexItemConnector.js delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexActionsCell.js delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexHeader.js delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexHeaderConnector.js delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexRow.js create mode 100644 frontend/src/Series/Index/Table/SeriesIndexRow.tsx delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexTable.js create mode 100644 frontend/src/Series/Index/Table/SeriesIndexTable.tsx delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexTableConnector.js rename frontend/src/Series/Index/Table/{SeriesIndexHeader.css => SeriesIndexTableHeader.css} (100%) create mode 100644 frontend/src/Series/Index/Table/SeriesIndexTableHeader.tsx delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexTableOptions.js create mode 100644 frontend/src/Series/Index/Table/SeriesIndexTableOptions.tsx delete mode 100644 frontend/src/Series/Index/Table/SeriesIndexTableOptionsConnector.js rename frontend/src/Series/Index/Table/{SeriesStatusCell.js => SeriesStatusCell.tsx} (65%) rename frontend/src/Series/Index/Table/{hasGrowableColumns.js => hasGrowableColumns.ts} (52%) create mode 100644 frontend/src/Series/Index/Table/selectTableOptions.ts create mode 100644 frontend/src/Series/Index/createSeriesIndexItemSelector.ts create mode 100644 frontend/src/Series/Series.ts diff --git a/frontend/src/AddSeries/ImportSeries/Import/ImportSeries.js b/frontend/src/AddSeries/ImportSeries/Import/ImportSeries.js index 8580d47af..6482ed2af 100644 --- a/frontend/src/AddSeries/ImportSeries/Import/ImportSeries.js +++ b/frontend/src/AddSeries/ImportSeries/Import/ImportSeries.js @@ -17,6 +17,8 @@ class ImportSeries extends Component { constructor(props, context) { super(props, context); + this.scrollerRef = React.createRef(); + this.state = { allSelected: false, allUnselected: false, @@ -25,13 +27,6 @@ class ImportSeries extends Component { }; } - // - // Control - - setScrollerRef = (ref) => { - this.setState({ scroller: ref }); - }; - // // Listeners @@ -70,10 +65,6 @@ class ImportSeries extends Component { this.props.onImportPress(this.getSelectedIds()); }; - onScroll = ({ scrollTop }) => { - this.setState({ scrollTop }); - }; - // // Render @@ -90,16 +81,12 @@ class ImportSeries extends Component { const { allSelected, allUnselected, - selectedState, - scroller + selectedState } = this.state; return ( - + { rootFoldersFetching ? : null } @@ -126,14 +113,14 @@ class ImportSeries extends Component { !rootFoldersFetching && rootFoldersPopulated && !!unmappedFolders.length && - scroller ? + this.scrollerRef.current ? { diff --git a/frontend/src/App/ModelBase.ts b/frontend/src/App/ModelBase.ts new file mode 100644 index 000000000..187b12fb2 --- /dev/null +++ b/frontend/src/App/ModelBase.ts @@ -0,0 +1,5 @@ +interface ModelBase { + id: number; +} + +export default ModelBase; diff --git a/frontend/src/Components/Form/FormInputGroup.js b/frontend/src/Components/Form/FormInputGroup.js index 94780aba2..666d75c9a 100644 --- a/frontend/src/Components/Form/FormInputGroup.js +++ b/frontend/src/Components/Form/FormInputGroup.js @@ -256,6 +256,9 @@ FormInputGroup.propTypes = { className: PropTypes.string.isRequired, containerClassName: PropTypes.string.isRequired, inputClassName: PropTypes.string, + name: PropTypes.string.isRequired, + value: PropTypes.any, + values: PropTypes.arrayOf(PropTypes.any), type: PropTypes.string.isRequired, unit: PropTypes.string, buttons: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]), @@ -265,7 +268,8 @@ FormInputGroup.propTypes = { helpLink: PropTypes.string, pending: PropTypes.bool, errors: PropTypes.arrayOf(PropTypes.object), - warnings: PropTypes.arrayOf(PropTypes.object) + warnings: PropTypes.arrayOf(PropTypes.object), + onChange: PropTypes.func.isRequired }; FormInputGroup.defaultProps = { diff --git a/frontend/src/Components/Form/FormLabel.js b/frontend/src/Components/Form/FormLabel.js index d419039b3..d4a4bcffc 100644 --- a/frontend/src/Components/Form/FormLabel.js +++ b/frontend/src/Components/Form/FormLabel.js @@ -4,16 +4,18 @@ import React from 'react'; import { sizes } from 'Helpers/Props'; import styles from './FormLabel.css'; -function FormLabel({ - children, - className, - errorClassName, - size, - name, - hasError, - isAdvanced, - ...otherProps -}) { +function FormLabel(props) { + const { + children, + className, + errorClassName, + size, + name, + hasError, + isAdvanced, + ...otherProps + } = props; + return (