@stoker-platform/web-app 0.5.176 → 0.5.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/Collection.tsx +7 -6
- package/src/Filters.tsx +6 -3
- package/src/Form.tsx +6 -3
- package/src/PermissionPicker.tsx +6 -3
- package/src/SearchAllResults.tsx +18 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @stoker-platform/web-app
|
|
2
2
|
|
|
3
|
+
## 0.5.178
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: fix filters button showing when no filters to show
|
|
8
|
+
|
|
9
|
+
## 0.5.177
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix: always use local search for serverReadOnly collections
|
|
14
|
+
|
|
3
15
|
## 0.5.176
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
package/src/Collection.tsx
CHANGED
|
@@ -1298,7 +1298,7 @@ function Collection({
|
|
|
1298
1298
|
})
|
|
1299
1299
|
}
|
|
1300
1300
|
return excluded
|
|
1301
|
-
}, [isPreloadCacheEnabled, cardsConfig, statusField, tab])
|
|
1301
|
+
}, [isPreloadCacheEnabled, cardsConfig, statusField, tab, filters])
|
|
1302
1302
|
|
|
1303
1303
|
const filtersActive = useMemo(() => {
|
|
1304
1304
|
return (
|
|
@@ -1335,12 +1335,13 @@ function Collection({
|
|
|
1335
1335
|
if (!field) return false
|
|
1336
1336
|
|
|
1337
1337
|
if (filter.roles && !filter.roles.includes(userRole)) return false
|
|
1338
|
+
if (relationList && relationList.field === filter.field) return false
|
|
1338
1339
|
|
|
1339
1340
|
if (filter.type === "relation") {
|
|
1340
1341
|
if (!isRelationField(field)) return false
|
|
1341
1342
|
const relationCollection = schema.collections[field.collection]
|
|
1342
|
-
if (!relationCollection
|
|
1343
|
-
const collectionPermissions = permissions
|
|
1343
|
+
if (!relationCollection?.fullTextSearch) return false
|
|
1344
|
+
const collectionPermissions = permissions.collections?.[relationCollection.labels.collection]
|
|
1344
1345
|
const fullCollectionAccess = collectionPermissions && collectionAccess("Read", collectionPermissions)
|
|
1345
1346
|
const dependencyAccess = hasDependencyAccess(relationCollection, schema, permissions)
|
|
1346
1347
|
if (!fullCollectionAccess && dependencyAccess.length === 0) return false
|
|
@@ -1572,7 +1573,7 @@ function Collection({
|
|
|
1572
1573
|
pushConstraint(softDelete.archivedField, "==", false)
|
|
1573
1574
|
}
|
|
1574
1575
|
|
|
1575
|
-
if (fullTextSearch && !isPreloadCacheEnabled && query) {
|
|
1576
|
+
if (fullTextSearch && !isPreloadCacheEnabled && !isServerReadOnly && query) {
|
|
1576
1577
|
const disjunctions = getFilterDisjunctions(collection)
|
|
1577
1578
|
const hitsPerPage =
|
|
1578
1579
|
disjunctions === 0 ? 10 : Math.min(10, Math.max(1, Math.floor(30 / disjunctions)))
|
|
@@ -1599,7 +1600,7 @@ function Collection({
|
|
|
1599
1600
|
| [string, WhereFilterOp, unknown][]
|
|
1600
1601
|
| QueryConstraint[],
|
|
1601
1602
|
only: isPreloadCacheEnabled ? "cache" : undefined,
|
|
1602
|
-
pagination: isPreloadCacheEnabled ? undefined : { number: 10 },
|
|
1603
|
+
pagination: isPreloadCacheEnabled || (isServerReadOnly && query) ? undefined : { number: 10 },
|
|
1603
1604
|
noEmbeddingFields: true,
|
|
1604
1605
|
})
|
|
1605
1606
|
|
|
@@ -1611,7 +1612,7 @@ function Collection({
|
|
|
1611
1612
|
return !array?.includes(parentId)
|
|
1612
1613
|
})
|
|
1613
1614
|
|
|
1614
|
-
if (isPreloadCacheEnabled && query) {
|
|
1615
|
+
if ((isPreloadCacheEnabled || isServerReadOnly) && query) {
|
|
1615
1616
|
const searchResults = localFullTextSearch(collection, query, filtered)
|
|
1616
1617
|
const objectIds = searchResults.map((result) => result.id)
|
|
1617
1618
|
setSelectableData(filtered.filter((doc) => objectIds.includes(doc.id)).slice(0, 10))
|
package/src/Filters.tsx
CHANGED
|
@@ -275,7 +275,7 @@ export function Filters({ collection, excluded, relationList }: FiltersProps) {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
let searchObjectIDs: string[] | undefined
|
|
278
|
-
if (fullTextSearch && !isCollectionPreloadCacheEnabled && query) {
|
|
278
|
+
if (fullTextSearch && !isCollectionPreloadCacheEnabled && !isCollectionServerReadOnly && query) {
|
|
279
279
|
const disjunctions = getFilterDisjunctions(collectionSchema)
|
|
280
280
|
const hitsPerPage = disjunctions === 0 ? 10 : Math.min(10, Math.max(1, Math.floor(30 / disjunctions)))
|
|
281
281
|
const objectIDs = await performFullTextSearch(collectionSchema, query, hitsPerPage, constraints)
|
|
@@ -308,13 +308,16 @@ export function Filters({ collection, excluded, relationList }: FiltersProps) {
|
|
|
308
308
|
getSome([collection], {
|
|
309
309
|
constraints: newConstraints as QueryConstraint[] | [string, WhereFilterOp, unknown][],
|
|
310
310
|
only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
|
|
311
|
-
pagination:
|
|
311
|
+
pagination:
|
|
312
|
+
isCollectionPreloadCacheEnabled || (isCollectionServerReadOnly && query)
|
|
313
|
+
? undefined
|
|
314
|
+
: { number: 10 },
|
|
312
315
|
noEmbeddingFields: true,
|
|
313
316
|
}).then((data) => {
|
|
314
317
|
clearTimeout(pickerDebounceTimeout.current)
|
|
315
318
|
|
|
316
319
|
const numberOfResults = isCollectionPreloadCacheEnabled && isMobile ? 20 : 10
|
|
317
|
-
if (isCollectionPreloadCacheEnabled && query) {
|
|
320
|
+
if ((isCollectionPreloadCacheEnabled || isCollectionServerReadOnly) && query) {
|
|
318
321
|
const searchResults = localFullTextSearch(collectionSchema, query, data.records)
|
|
319
322
|
const recordsById = new Map(data.records.map((doc) => [doc.id, doc]))
|
|
320
323
|
const ordered = searchResults
|
package/src/Form.tsx
CHANGED
|
@@ -1974,7 +1974,7 @@ function RelationField({
|
|
|
1974
1974
|
}
|
|
1975
1975
|
|
|
1976
1976
|
let searchObjectIDs: string[] | undefined
|
|
1977
|
-
if (fullTextSearch && !isCollectionPreloadCacheEnabled && query) {
|
|
1977
|
+
if (fullTextSearch && !isCollectionPreloadCacheEnabled && !isCollectionServerReadOnly && query) {
|
|
1978
1978
|
const disjunctions = getFilterDisjunctions(relationCollection)
|
|
1979
1979
|
const hitsPerPage = disjunctions === 0 ? 10 : Math.min(10, Math.max(1, Math.floor(30 / disjunctions)))
|
|
1980
1980
|
const objectIDs = await performFullTextSearch(relationCollection, query, hitsPerPage, constraints)
|
|
@@ -2020,13 +2020,16 @@ function RelationField({
|
|
|
2020
2020
|
getSome([labels.collection], {
|
|
2021
2021
|
constraints: newConstraints,
|
|
2022
2022
|
only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
|
|
2023
|
-
pagination:
|
|
2023
|
+
pagination:
|
|
2024
|
+
isCollectionPreloadCacheEnabled || (isCollectionServerReadOnly && query)
|
|
2025
|
+
? undefined
|
|
2026
|
+
: { number: 10 },
|
|
2024
2027
|
noEmbeddingFields: true,
|
|
2025
2028
|
}).then((data) => {
|
|
2026
2029
|
clearTimeout(pickerDebounceTimeout.current)
|
|
2027
2030
|
|
|
2028
2031
|
const numberOfResults = isCollectionPreloadCacheEnabled && isMobile ? 20 : 10
|
|
2029
|
-
if (isCollectionPreloadCacheEnabled && query) {
|
|
2032
|
+
if ((isCollectionPreloadCacheEnabled || isCollectionServerReadOnly) && query) {
|
|
2030
2033
|
const searchResults = localFullTextSearch(relationCollection, query, data.records, (result) => {
|
|
2031
2034
|
if (!fieldCustomization.admin?.filterResults) return true
|
|
2032
2035
|
return !!fieldCustomization.admin?.filterResults?.(result, collection, record)
|
package/src/PermissionPicker.tsx
CHANGED
|
@@ -109,7 +109,7 @@ export const PermissionPicker = ({
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
let searchObjectIDs: string[] | undefined
|
|
112
|
-
if (fullTextSearch && !isCollectionPreloadCacheEnabled && query) {
|
|
112
|
+
if (fullTextSearch && !isCollectionPreloadCacheEnabled && !isCollectionServerReadOnly && query) {
|
|
113
113
|
const disjunctions = getFilterDisjunctions(collection)
|
|
114
114
|
const hitsPerPage = disjunctions === 0 ? 10 : Math.min(10, Math.max(1, Math.floor(30 / disjunctions)))
|
|
115
115
|
const objectIDs = await performFullTextSearch(collection, query, hitsPerPage, constraints)
|
|
@@ -136,13 +136,16 @@ export const PermissionPicker = ({
|
|
|
136
136
|
getSome([labels.collection], {
|
|
137
137
|
constraints: newConstraints,
|
|
138
138
|
only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
|
|
139
|
-
pagination:
|
|
139
|
+
pagination:
|
|
140
|
+
isCollectionPreloadCacheEnabled || (isCollectionServerReadOnly && query)
|
|
141
|
+
? undefined
|
|
142
|
+
: { number: 10 },
|
|
140
143
|
noEmbeddingFields: true,
|
|
141
144
|
}).then((data) => {
|
|
142
145
|
clearTimeout(pickerDebounceTimeout.current)
|
|
143
146
|
|
|
144
147
|
const numberOfResults = isCollectionPreloadCacheEnabled && isMobile ? 20 : 10
|
|
145
|
-
if (isCollectionPreloadCacheEnabled && query) {
|
|
148
|
+
if ((isCollectionPreloadCacheEnabled || isCollectionServerReadOnly) && query) {
|
|
146
149
|
const searchResults = localFullTextSearch(collection, query, data.records)
|
|
147
150
|
const recordsById = new Map(data.records.map((doc) => [doc.id, doc]))
|
|
148
151
|
const ordered = searchResults
|
package/src/SearchAllResults.tsx
CHANGED
|
@@ -58,7 +58,7 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
|
|
|
58
58
|
],
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (fullTextSearch && !isPreloadCacheEnabled) {
|
|
61
|
+
if (fullTextSearch && !isPreloadCacheEnabled && !isServerReadOnly) {
|
|
62
62
|
const disjunctions = getFilterDisjunctions(collection)
|
|
63
63
|
const hitsPerPage = disjunctions === 0 ? 5 : Math.min(5, Math.max(1, Math.floor(30 / disjunctions)))
|
|
64
64
|
const algoliaConstraints: [string, "==" | "in", unknown][] = []
|
|
@@ -67,11 +67,7 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
|
|
|
67
67
|
}
|
|
68
68
|
const objectIDs = await performFullTextSearch(collection, search, hitsPerPage, algoliaConstraints)
|
|
69
69
|
if (objectIDs.length > 0) {
|
|
70
|
-
|
|
71
|
-
query.queries[0].constraints = [["id", "in", objectIDs]]
|
|
72
|
-
} else {
|
|
73
|
-
query.queries[0].constraints = [where("id", "in", objectIDs)]
|
|
74
|
-
}
|
|
70
|
+
query.queries[0].constraints = [where("id", "in", objectIDs)]
|
|
75
71
|
} else if (search) {
|
|
76
72
|
setResults([])
|
|
77
73
|
setLoading(false)
|
|
@@ -105,7 +101,7 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
|
|
|
105
101
|
setResults(searchRecords.slice(0, MAX_RESULTS))
|
|
106
102
|
setLoading(false)
|
|
107
103
|
} else {
|
|
108
|
-
setResults(loadedDocs)
|
|
104
|
+
setResults(loadedDocs.slice(0, MAX_RESULTS))
|
|
109
105
|
setLoading(false)
|
|
110
106
|
}
|
|
111
107
|
|
|
@@ -151,13 +147,23 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
|
|
|
151
147
|
}
|
|
152
148
|
|
|
153
149
|
const getServerData = async () => {
|
|
150
|
+
const serverConstraints: [string, WhereFilterOp, unknown][] = []
|
|
151
|
+
if (softDelete?.archivedField) {
|
|
152
|
+
serverConstraints.push([softDelete.archivedField, "==", false])
|
|
153
|
+
}
|
|
154
154
|
const data = await getSome([labels.collection], {
|
|
155
|
-
constraints:
|
|
156
|
-
pagination: {
|
|
157
|
-
number: MAX_RESULTS,
|
|
158
|
-
},
|
|
155
|
+
constraints: serverConstraints,
|
|
156
|
+
pagination: search && fullTextSearch ? undefined : { number: MAX_RESULTS },
|
|
159
157
|
})
|
|
160
|
-
|
|
158
|
+
let records = data.records
|
|
159
|
+
if (search && fullTextSearch) {
|
|
160
|
+
const searchResults = localFullTextSearch(collection, search, records)
|
|
161
|
+
const recordsById = new Map(records.map((record) => [record.id, record]))
|
|
162
|
+
records = searchResults
|
|
163
|
+
.map((result) => recordsById.get(result.id))
|
|
164
|
+
.filter((record): record is StokerRecord => record !== undefined)
|
|
165
|
+
}
|
|
166
|
+
setResults(records.slice(0, MAX_RESULTS))
|
|
161
167
|
setLoading(false)
|
|
162
168
|
resolve()
|
|
163
169
|
}
|