feat: Add tracking of search source in UI
This commit is contained in:
parent
40d52e9a78
commit
6f1f855083
@ -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<Props> {
|
||||
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,
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -140,6 +140,7 @@ class CollectionScene extends React.Component<Props> {
|
||||
<>
|
||||
<Action>
|
||||
<InputSearch
|
||||
source="collection"
|
||||
placeholder="Search in collection…"
|
||||
collectionId={match.params.id}
|
||||
/>
|
||||
|
@ -67,7 +67,7 @@ class Dashboard extends React.Component<Props> {
|
||||
</Switch>
|
||||
<Actions align="center" justify="flex-end">
|
||||
<Action>
|
||||
<InputSearch />
|
||||
<InputSearch source="dashboard" />
|
||||
</Action>
|
||||
<Action>
|
||||
<NewDocumentMenu />
|
||||
|
@ -37,7 +37,7 @@ class Drafts extends React.Component<Props> {
|
||||
|
||||
<Actions align="center" justify="flex-end">
|
||||
<Action>
|
||||
<InputSearch />
|
||||
<InputSearch source="drafts" />
|
||||
</Action>
|
||||
<Action>
|
||||
<NewDocumentMenu />
|
||||
|
@ -49,7 +49,7 @@ class Starred extends React.Component<Props> {
|
||||
|
||||
<Actions align="center" justify="flex-end">
|
||||
<Action>
|
||||
<InputSearch />
|
||||
<InputSearch source="starred" />
|
||||
</Action>
|
||||
<Action>
|
||||
<NewDocumentMenu />
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user