From 149aa07409ef7cd17098a28510e515530b173f13 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sat, 20 Apr 2019 19:18:26 +0200 Subject: DrawerResults → SearchResults + SearchResultsContainer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/compose/components/search_results.js | 72 ++++++++++++++++++++ .../compose/containers/search_results_container.js | 8 +++ .../flavours/glitch/features/compose/index.js | 13 +--- .../glitch/features/compose/results/index.js | 78 ---------------------- 4 files changed, 82 insertions(+), 89 deletions(-) create mode 100644 app/javascript/flavours/glitch/features/compose/components/search_results.js create mode 100644 app/javascript/flavours/glitch/features/compose/containers/search_results_container.js delete mode 100644 app/javascript/flavours/glitch/features/compose/results/index.js (limited to 'app/javascript/flavours/glitch') diff --git a/app/javascript/flavours/glitch/features/compose/components/search_results.js b/app/javascript/flavours/glitch/features/compose/components/search_results.js new file mode 100644 index 000000000..3d29675b4 --- /dev/null +++ b/app/javascript/flavours/glitch/features/compose/components/search_results.js @@ -0,0 +1,72 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; +import AccountContainer from 'flavours/glitch/containers/account_container'; +import StatusContainer from 'flavours/glitch/containers/status_container'; +import ImmutablePureComponent from 'react-immutable-pure-component'; +import Hashtag from 'flavours/glitch/components/hashtag'; +import Icon from 'flavours/glitch/components/icon'; + +export default @injectIntl +class SearchResults extends ImmutablePureComponent { + + static propTypes = { + results: ImmutablePropTypes.map.isRequired, + intl: PropTypes.object.isRequired, + }; + + render() { + const { intl, results } = this.props; + + let accounts, statuses, hashtags; + let count = 0; + + if (results.get('accounts') && results.get('accounts').size > 0) { + count += results.get('accounts').size; + accounts = ( +
+
+ + {results.get('accounts').map(accountId => )} +
+ ); + } + + if (results.get('statuses') && results.get('statuses').size > 0) { + count += results.get('statuses').size; + statuses = ( +
+
+ + {results.get('statuses').map(statusId => )} +
+ ); + } + + if (results.get('hashtags') && results.get('hashtags').size > 0) { + count += results.get('hashtags').size; + hashtags = ( +
+
+ + {results.get('hashtags').map(hashtag => )} +
+ ); + } + + // The result. + return ( +
+
+ + +
+ + {accounts} + {statuses} + {hashtags} +
+ ); + }; +} diff --git a/app/javascript/flavours/glitch/features/compose/containers/search_results_container.js b/app/javascript/flavours/glitch/features/compose/containers/search_results_container.js new file mode 100644 index 000000000..16d95d417 --- /dev/null +++ b/app/javascript/flavours/glitch/features/compose/containers/search_results_container.js @@ -0,0 +1,8 @@ +import { connect } from 'react-redux'; +import SearchResults from '../components/search_results'; + +const mapStateToProps = state => ({ + results: state.getIn(['search', 'results']), +}); + +export default connect(mapStateToProps)(SearchResults); diff --git a/app/javascript/flavours/glitch/features/compose/index.js b/app/javascript/flavours/glitch/features/compose/index.js index 6dc786c8b..0865a7ff9 100644 --- a/app/javascript/flavours/glitch/features/compose/index.js +++ b/app/javascript/flavours/glitch/features/compose/index.js @@ -14,8 +14,8 @@ import { cycleElefriendCompose } from 'flavours/glitch/actions/compose'; import Composer from 'flavours/glitch/features/composer'; import DrawerAccount from './account'; import DrawerHeader from './header'; -import DrawerResults from './results'; import SearchContainer from './containers/search_container'; +import SearchResultsContainer from './containers/search_results_container'; import spring from 'react-motion/lib/spring'; // Utils. @@ -32,9 +32,6 @@ const mapStateToProps = (state, ownProps) => ({ account: state.getIn(['accounts', me]), columns: state.getIn(['settings', 'columns']), elefriend: state.getIn(['compose', 'elefriend']), - results: state.getIn(['search', 'results']), - searchHidden: state.getIn(['search', 'hidden']), - submitted: state.getIn(['search', 'submitted']), showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : ownProps.isSearchPage, unreadNotifications: state.getIn(['notifications', 'unread']), showNotificationsBadge: state.getIn(['local_settings', 'notifications', 'tab_badge']), @@ -65,10 +62,7 @@ class Compose extends React.PureComponent { // State props. account: ImmutablePropTypes.map, columns: ImmutablePropTypes.list, - results: ImmutablePropTypes.map, elefriend: PropTypes.number, - searchHidden: PropTypes.bool, - submitted: PropTypes.bool, unreadNotifications: PropTypes.number, showNotificationsBadge: PropTypes.bool, @@ -87,9 +81,6 @@ class Compose extends React.PureComponent { multiColumn, onClickElefriend, onOpenSettings, - results, - searchHidden, - submitted, isSearchPage, unreadNotifications, showNotificationsBadge, @@ -124,7 +115,7 @@ class Compose extends React.PureComponent { {({ x }) => (
- +
)}
diff --git a/app/javascript/flavours/glitch/features/compose/results/index.js b/app/javascript/flavours/glitch/features/compose/results/index.js deleted file mode 100644 index 162d14913..000000000 --- a/app/javascript/flavours/glitch/features/compose/results/index.js +++ /dev/null @@ -1,78 +0,0 @@ -// Package imports. -import PropTypes from 'prop-types'; -import React from 'react'; -import ImmutablePureComponent from 'react-immutable-pure-component'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; -import { Link } from 'react-router-dom'; - -// Components. -import Icon from 'flavours/glitch/components/icon'; -import AccountContainer from 'flavours/glitch/containers/account_container'; -import StatusContainer from 'flavours/glitch/containers/status_container'; -import Hashtag from 'flavours/glitch/components/hashtag'; - -// Messages. -// The component. -export default @injectIntl -class DrawerResults extends ImmutablePureComponent { - - static propTypes = { - results: ImmutablePropTypes.map.isRequired, - intl: PropTypes.object.isRequired, - }; - - render() { - const { intl, results } = this.props; - - let accounts, statuses, hashtags; - let count = 0; - - if (results.get('accounts') && results.get('accounts').size > 0) { - count += results.get('accounts').size; - accounts = ( -
-
- - {results.get('accounts').map(accountId => )} -
- ); - } - - if (results.get('statuses') && results.get('statuses').size > 0) { - count += results.get('statuses').size; - statuses = ( -
-
- - {results.get('statuses').map(statusId => )} -
- ); - } - - if (results.get('hashtags') && results.get('hashtags').size > 0) { - count += results.get('hashtags').size; - hashtags = ( -
-
- - {results.get('hashtags').map(hashtag => )} -
- ); - } - - // The result. - return ( -
-
- - -
- - {accounts} - {statuses} - {hashtags} -
- ); - }; -} -- cgit