feat: Add tracking of search source in UI
This commit is contained in:
@ -12,6 +12,7 @@ import { searchUrl } from "utils/routeHelpers";
|
|||||||
type Props = {
|
type Props = {
|
||||||
history: RouterHistory,
|
history: RouterHistory,
|
||||||
theme: Object,
|
theme: Object,
|
||||||
|
source: string,
|
||||||
placeholder?: string,
|
placeholder?: string,
|
||||||
collectionId?: string,
|
collectionId?: string,
|
||||||
};
|
};
|
||||||
@ -33,7 +34,10 @@ class InputSearch extends React.Component<Props> {
|
|||||||
handleSearchInput = (ev) => {
|
handleSearchInput = (ev) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this.props.history.push(
|
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>
|
<Action>
|
||||||
<InputSearch
|
<InputSearch
|
||||||
|
source="collection"
|
||||||
placeholder="Search in collection…"
|
placeholder="Search in collection…"
|
||||||
collectionId={match.params.id}
|
collectionId={match.params.id}
|
||||||
/>
|
/>
|
||||||
|
@ -67,7 +67,7 @@ class Dashboard extends React.Component<Props> {
|
|||||||
</Switch>
|
</Switch>
|
||||||
<Actions align="center" justify="flex-end">
|
<Actions align="center" justify="flex-end">
|
||||||
<Action>
|
<Action>
|
||||||
<InputSearch />
|
<InputSearch source="dashboard" />
|
||||||
</Action>
|
</Action>
|
||||||
<Action>
|
<Action>
|
||||||
<NewDocumentMenu />
|
<NewDocumentMenu />
|
||||||
|
@ -37,7 +37,7 @@ class Drafts extends React.Component<Props> {
|
|||||||
|
|
||||||
<Actions align="center" justify="flex-end">
|
<Actions align="center" justify="flex-end">
|
||||||
<Action>
|
<Action>
|
||||||
<InputSearch />
|
<InputSearch source="drafts" />
|
||||||
</Action>
|
</Action>
|
||||||
<Action>
|
<Action>
|
||||||
<NewDocumentMenu />
|
<NewDocumentMenu />
|
||||||
|
@ -49,7 +49,7 @@ class Starred extends React.Component<Props> {
|
|||||||
|
|
||||||
<Actions align="center" justify="flex-end">
|
<Actions align="center" justify="flex-end">
|
||||||
<Action>
|
<Action>
|
||||||
<InputSearch />
|
<InputSearch source="starred" />
|
||||||
</Action>
|
</Action>
|
||||||
<Action>
|
<Action>
|
||||||
<NewDocumentMenu />
|
<NewDocumentMenu />
|
||||||
|
@ -63,14 +63,22 @@ export function newDocumentUrl(
|
|||||||
return `/collections/${collectionId}/new?${queryString.stringify(params)}`;
|
return `/collections/${collectionId}/new?${queryString.stringify(params)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function searchUrl(query?: string, collectionId?: string): string {
|
export function searchUrl(
|
||||||
let route = "/search";
|
query?: string,
|
||||||
if (query) route += `/${encodeURIComponent(query)}`;
|
params?: {
|
||||||
|
collectionId?: string,
|
||||||
if (collectionId) {
|
ref?: string,
|
||||||
route += `?collectionId=${collectionId}`;
|
|
||||||
}
|
}
|
||||||
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 {
|
export function notFoundUrl(): string {
|
||||||
|
Reference in New Issue
Block a user