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