Allow passing no query to the search API.
This commit is contained in:
parent
7e37420c97
commit
7f3d88265e
|
@ -40,7 +40,7 @@ export const buildTableEndpoints = API => ({
|
|||
sortType,
|
||||
paginate,
|
||||
}) => {
|
||||
if (!tableId || !query) {
|
||||
if (!tableId) {
|
||||
return {
|
||||
rows: [],
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ export const buildTableEndpoints = API => ({
|
|||
return await API.post({
|
||||
url: `/api/${tableId}/search`,
|
||||
body: {
|
||||
query,
|
||||
...(query ? { query } : {}),
|
||||
bookmark,
|
||||
limit,
|
||||
sort,
|
||||
|
|
|
@ -32,7 +32,7 @@ export default class UserFetch extends DataFetch {
|
|||
const { cursor, query } = get(this.store)
|
||||
let finalQuery
|
||||
// convert old format to new one - we now allow use of the lucene format
|
||||
const { appId, paginated, ...rest } = query
|
||||
const { appId, paginated, ...rest } = query || {}
|
||||
|
||||
finalQuery = utils.isSupportedUserSearch(rest)
|
||||
? query
|
||||
|
|
|
@ -64,7 +64,7 @@ export default class ViewV2Fetch extends DataFetch {
|
|||
try {
|
||||
const res = await this.API.viewV2.fetch({
|
||||
viewId: datasource.id,
|
||||
query,
|
||||
...(query ? { query } : {}),
|
||||
paginate,
|
||||
limit,
|
||||
bookmark: cursor,
|
||||
|
|
|
@ -574,7 +574,12 @@ export const buildQueryLegacy = (
|
|||
export const buildQuery = (
|
||||
filter?: SearchFilterGroup | SearchFilter[]
|
||||
): SearchFilters | undefined => {
|
||||
const parsedFilter: SearchFilterGroup = processSearchFilters(filter)
|
||||
const parsedFilter: SearchFilterGroup | undefined =
|
||||
processSearchFilters(filter)
|
||||
|
||||
if (!parsedFilter) {
|
||||
return
|
||||
}
|
||||
|
||||
const operatorMap: { [key in FilterGroupLogicalOperator]: LogicalOperator } =
|
||||
{
|
||||
|
|
|
@ -97,17 +97,17 @@ export function trimOtherProps(object: any, allowedProps: string[]) {
|
|||
*/
|
||||
export const processSearchFilters = (
|
||||
filters: SearchFilter[] | SearchFilterGroup | undefined
|
||||
): SearchFilterGroup => {
|
||||
): SearchFilterGroup | undefined => {
|
||||
if (!filters) {
|
||||
return
|
||||
}
|
||||
|
||||
// Base search config.
|
||||
const defaultCfg: SearchFilterGroup = {
|
||||
logicalOperator: FilterGroupLogicalOperator.ALL,
|
||||
groups: [],
|
||||
}
|
||||
|
||||
if (!filters) {
|
||||
return defaultCfg
|
||||
}
|
||||
|
||||
const filterWhitelistKeys = [
|
||||
"field",
|
||||
"operator",
|
||||
|
@ -182,7 +182,7 @@ export const processSearchFilters = (
|
|||
|
||||
return migratedSetting
|
||||
} else if (!filters?.groups) {
|
||||
return defaultCfg
|
||||
return
|
||||
}
|
||||
return filters
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue