diff --git a/app/components/InputSearch.js b/app/components/InputSearch.js index 526767ec0..7d594580f 100644 --- a/app/components/InputSearch.js +++ b/app/components/InputSearch.js @@ -12,6 +12,7 @@ import { searchUrl } from "utils/routeHelpers"; type Props = { history: RouterHistory, theme: Object, + source: string, placeholder?: string, collectionId?: string, }; @@ -33,7 +34,10 @@ class InputSearch extends React.Component { handleSearchInput = (ev) => { ev.preventDefault(); this.props.history.push( - searchUrl(ev.target.value, this.props.collectionId) + searchUrl(ev.target.value, { + collectionId: this.props.collectionId, + ref: this.props.source, + }) ); }; diff --git a/app/scenes/Collection.js b/app/scenes/Collection.js index a0bc5d3d7..40729510c 100644 --- a/app/scenes/Collection.js +++ b/app/scenes/Collection.js @@ -140,6 +140,7 @@ class CollectionScene extends React.Component { <> diff --git a/app/scenes/Dashboard.js b/app/scenes/Dashboard.js index 44d82d06b..b0d5d7880 100644 --- a/app/scenes/Dashboard.js +++ b/app/scenes/Dashboard.js @@ -67,7 +67,7 @@ class Dashboard extends React.Component { - + diff --git a/app/scenes/Drafts.js b/app/scenes/Drafts.js index f514f0a12..14ae4724e 100644 --- a/app/scenes/Drafts.js +++ b/app/scenes/Drafts.js @@ -37,7 +37,7 @@ class Drafts extends React.Component { - + diff --git a/app/scenes/Starred.js b/app/scenes/Starred.js index 25000f7ac..8ca71611c 100644 --- a/app/scenes/Starred.js +++ b/app/scenes/Starred.js @@ -49,7 +49,7 @@ class Starred extends React.Component { - + diff --git a/app/utils/routeHelpers.js b/app/utils/routeHelpers.js index 1d7c402a2..145bb2834 100644 --- a/app/utils/routeHelpers.js +++ b/app/utils/routeHelpers.js @@ -63,14 +63,22 @@ export function newDocumentUrl( return `/collections/${collectionId}/new?${queryString.stringify(params)}`; } -export function searchUrl(query?: string, collectionId?: string): string { - let route = "/search"; - if (query) route += `/${encodeURIComponent(query)}`; - - if (collectionId) { - route += `?collectionId=${collectionId}`; +export function searchUrl( + query?: string, + params?: { + collectionId?: string, + ref?: string, } - return route; +): string { + let search = queryString.stringify(params); + let route = "/search"; + + if (query) { + route += `/${encodeURIComponent(query)}`; + } + + search = search ? `?${search}` : ""; + return `${route}${search}`; } export function notFoundUrl(): string {