diff --git a/src/components/app.js b/src/components/app.js index 16c47673b..c62bd8636 100644 --- a/src/components/app.js +++ b/src/components/app.js @@ -34,7 +34,7 @@ const App = ({ loading, navbarDark, login, logout, loggedIn, username }) => ( /> import('../routes/pulse')} /> import('../routes/plugin-hub')} /> ( export default connect( state => ({ loggedIn: isLoggedIn(state), + search: state.filter, ...state.app, ...state.account }), diff --git a/src/components/external-plugin.js b/src/components/external-plugin.js index 73d947c69..840ac8fc4 100644 --- a/src/components/external-plugin.js +++ b/src/components/external-plugin.js @@ -6,6 +6,7 @@ import { numberWithCommas } from '../util' const ExternalPlugin = ({ displayName, author, + s, description, internalName, imageUrl, @@ -29,7 +30,9 @@ const ExternalPlugin = ({ {displayName}
- {author} + +const handleChange = (event, author, setPluginFilter) => { setPluginFilter({ name: event.target.value }) + if (author) { + route( + `/plugin-hub/${author}${ + event.target.value ? '?s=' + event.target.value : '' + }` + ) + } else { + route(`/plugin-hub/${event.target.value ? '?s=' + event.target.value : ''}`) + } +} +// "s" is the search param from the query parameters to filter plugins const PluginHub = ({ author, + s, externalPlugins, pluginFilter, pluginSorting, @@ -45,6 +58,16 @@ const PluginHub = ({ author ? plugin.author === author : true ) + if (s) { + if (s !== pluginFilter.name) { + setPluginFilter({ name: s }) + } + } else { + if (pluginFilter.name !== '') { + setPluginFilter({ name: '' }) + } + } + const pluginCount = externalPlugins.length const installedPluginCount = externalPlugins.filter(p => p.installed).length const totalCount = externalPlugins.reduce((a, b) => a + b.count, 0) @@ -103,7 +126,9 @@ const PluginHub = ({
handleChange(e, setPluginFilter)} + onInput={e => { + handleChange(e, author, setPluginFilter) + }} />
@@ -117,7 +142,7 @@ const PluginHub = ({
{externalPlugins.map(plugin => ( - + ))}
@@ -126,12 +151,14 @@ const PluginHub = ({ ) } -const mapStateToProps = (state, props) => ({ - ...props, - externalPlugins: getSortedExternalPlugins(state), - pluginFilter: getPluginFilter(state), - pluginSorting: getPluginSorting(state) -}) +const mapStateToProps = (state, props) => { + return { + ...props, + externalPlugins: getSortedExternalPlugins(state), + pluginFilter: getPluginFilter(state), + pluginSorting: getPluginSorting(state) + } +} const mapDispatchToProps = dispatch => bindActionCreators(