diff --git a/frontend/src/History/Details/HistoryDetails.js b/frontend/src/History/Details/HistoryDetails.js index f2d8857f9..9d2fea5d1 100644 --- a/frontend/src/History/Details/HistoryDetails.js +++ b/frontend/src/History/Details/HistoryDetails.js @@ -63,6 +63,32 @@ function HistoryDetails(props) { ); } + if (eventType === 'releaseGrabbed') { + const { + source + } = data; + + return ( + + { + !!indexer && + + } + + { + !!data && + + } + + ); + } + return ( { + const { + indexer, + data + } = this.props; + + let categories = []; + + if (data.categories) { + categories = data.categories.split(',').map((item) => { + return parseInt(item); + }); + } + + console.log(categories); + + this.props.onSearchPress(data.query, indexer.id, categories); + } + onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); } @@ -115,7 +134,11 @@ class HistoryRow extends Component { key={name} className={styles.indexer} > - {`${data.elapsedTime}ms`} + { + data.elapsedTime ? + `${data.elapsedTime}ms` : + null + } ); } @@ -146,9 +169,19 @@ class HistoryRow extends Component { key={name} className={styles.details} > + { + eventType === 'indexerQuery' ? + : + null + } ); @@ -186,7 +219,8 @@ HistoryRow.propTypes = { columns: PropTypes.arrayOf(PropTypes.object).isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, - onMarkAsFailedPress: PropTypes.func.isRequired + onMarkAsFailedPress: PropTypes.func.isRequired, + onSearchPress: PropTypes.func.isRequired }; export default HistoryRow; diff --git a/frontend/src/History/HistoryRowConnector.js b/frontend/src/History/HistoryRowConnector.js index d31f482ab..473d6dc20 100644 --- a/frontend/src/History/HistoryRowConnector.js +++ b/frontend/src/History/HistoryRowConnector.js @@ -1,8 +1,10 @@ +import { push } from 'connected-react-router'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { fetchHistory, markAsFailed } from 'Store/Actions/historyActions'; +import { setSearchDefault } from 'Store/Actions/releaseActions'; import createIndexerSelector from 'Store/Selectors/createIndexerSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import HistoryRow from './HistoryRow'; @@ -23,7 +25,9 @@ function createMapStateToProps() { const mapDispatchToProps = { fetchHistory, - markAsFailed + markAsFailed, + setSearchDefault, + push }; class HistoryRowConnector extends Component { @@ -44,6 +48,11 @@ class HistoryRowConnector extends Component { // // Listeners + onSearchPress = (term, indexerId, categories) => { + this.props.setSearchDefault({ searchQuery: term, searchIndexerIds: [indexerId], searchCategories: categories }); + this.props.push(`${window.Prowlarr.urlBase}search`); + } + onMarkAsFailedPress = () => { this.props.markAsFailed({ id: this.props.id }); } @@ -56,6 +65,7 @@ class HistoryRowConnector extends Component { ); } @@ -67,7 +77,9 @@ HistoryRowConnector.propTypes = { isMarkingAsFailed: PropTypes.bool, markAsFailedError: PropTypes.object, fetchHistory: PropTypes.func.isRequired, - markAsFailed: PropTypes.func.isRequired + markAsFailed: PropTypes.func.isRequired, + setSearchDefault: PropTypes.func.isRequired, + push: PropTypes.func.isRequired }; export default connect(createMapStateToProps, mapDispatchToProps)(HistoryRowConnector); diff --git a/frontend/src/Search/SearchFooter.css b/frontend/src/Search/SearchFooter.css index 0dbb98cb3..83eb700cd 100644 --- a/frontend/src/Search/SearchFooter.css +++ b/frontend/src/Search/SearchFooter.css @@ -24,18 +24,10 @@ flex-grow: 1; } -.organizeSelectedButton, -.tagsButton { +.searchButton { composes: button from '~Components/Link/SpinnerButton.css'; - margin-right: 10px; - height: 35px; -} - -.deleteSelectedButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - margin-left: 50px; + margin-left: 25px; height: 35px; } diff --git a/frontend/src/Search/SearchFooter.js b/frontend/src/Search/SearchFooter.js index a14a8aff4..0fcdf1f27 100644 --- a/frontend/src/Search/SearchFooter.js +++ b/frontend/src/Search/SearchFooter.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import IndexersSelectInputConnector from 'Components/Form/IndexersSelectInputConnector'; @@ -16,36 +17,75 @@ class SearchFooter extends Component { constructor(props, context) { super(props, context); + const { + defaultIndexerIds, + defaultCategories, + defaultSearchQuery + } = props; + this.state = { searchingReleases: false, - searchQuery: '', - indexerIds: [], - categories: [] + searchQuery: defaultSearchQuery, + searchIndexerIds: defaultIndexerIds, + searchCategories: defaultCategories }; } + componentDidMount() { + const { + searchIndexerIds, + searchCategories, + searchQuery + } = this.state; + + if (searchQuery !== '' || searchCategories !== [] || searchIndexerIds !== []) { + this.onSearchPress(); + } + } + componentDidUpdate(prevProps) { const { isFetching, + defaultIndexerIds, + defaultCategories, + defaultSearchQuery, searchError } = this.props; + const { + searchIndexerIds, + searchCategories, + searchQuery + } = this.state; + + const newState = {}; + + if (searchIndexerIds !== defaultIndexerIds) { + newState.searchIndexerIds = defaultIndexerIds; + } + + if (searchCategories !== defaultCategories) { + newState.searchCategories = defaultCategories; + } + + if (searchQuery !== defaultSearchQuery) { + newState.searchQuery = defaultSearchQuery; + } + if (prevProps.isFetching && !isFetching && !searchError) { - this.setState({ - searchingReleases: false - }); + newState.searchingReleases = false; + } + + if (!_.isEmpty(newState)) { + this.setState(newState); } } // // Listeners - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - } - onSearchPress = () => { - this.props.onSearchPress(this.state.searchQuery, this.state.indexerIds, this.state.categories); + this.props.onSearchPress(this.state.searchQuery, this.state.searchIndexerIds, this.state.searchCategories); } // @@ -54,13 +94,14 @@ class SearchFooter extends Component { render() { const { isFetching, - hasIndexers + hasIndexers, + onInputChange } = this.props; const { searchQuery, - indexerIds, - categories + searchIndexerIds, + searchCategories } = this.state; return ( @@ -75,7 +116,7 @@ class SearchFooter extends Component { name='searchQuery' value={searchQuery} isDisabled={isFetching} - onChange={this.onInputChange} + onChange={onInputChange} /> @@ -86,10 +127,10 @@ class SearchFooter extends Component { /> @@ -100,19 +141,24 @@ class SearchFooter extends Component { />
+ +
state.releases, + (releases) => { + const { + searchQuery: defaultSearchQuery, + searchIndexerIds: defaultIndexerIds, + searchCategories: defaultCategories + } = releases.defaults; + + return { + defaultSearchQuery, + defaultIndexerIds, + defaultCategories + }; + } + ); +} + +const mapDispatchToProps = { + setSearchDefault +}; + +class SearchFooterConnector extends Component { + + // + // Listeners + + onInputChange = ({ name, value }) => { + console.log(name, value); + this.props.setSearchDefault({ [name]: value }); + } + + // + // Render + + render() { + return ( + + ); + } +} + +SearchFooterConnector.propTypes = { + setSearchDefault: PropTypes.func.isRequired +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(SearchFooterConnector); diff --git a/frontend/src/Search/SearchIndex.js b/frontend/src/Search/SearchIndex.js index 6133ea202..ff460f910 100644 --- a/frontend/src/Search/SearchIndex.js +++ b/frontend/src/Search/SearchIndex.js @@ -21,7 +21,7 @@ import translate from 'Utilities/String/translate'; import SearchIndexFilterMenu from './Menus/SearchIndexFilterMenu'; import SearchIndexSortMenu from './Menus/SearchIndexSortMenu'; import NoSearchResults from './NoSearchResults'; -import SearchFooter from './SearchFooter.js'; +import SearchFooterConnector from './SearchFooterConnector'; import SearchIndexTableConnector from './Table/SearchIndexTableConnector'; import styles from './SearchIndex.css'; @@ -290,7 +290,7 @@ class SearchIndex extends Component { }
-