@budibase/frontend-core 2.6.8-alpha.3 → 2.6.8-alpha.7

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/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "2.6.8-alpha.3",
3
+ "version": "2.6.8-alpha.7",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
7
7
  "svelte": "src/index.js",
8
8
  "dependencies": {
9
- "@budibase/bbui": "2.6.8-alpha.3",
10
- "@budibase/shared-core": "2.6.8-alpha.3",
9
+ "@budibase/bbui": "2.6.8-alpha.7",
10
+ "@budibase/shared-core": "2.6.8-alpha.7",
11
11
  "dayjs": "^1.11.7",
12
12
  "lodash": "^4.17.21",
13
13
  "socket.io-client": "^4.6.1",
14
14
  "svelte": "^3.46.2"
15
15
  },
16
- "gitHead": "d3b449898b08d94ed9e286d1670292846f5c80d1"
16
+ "gitHead": "8dbc8a1e86558a8ce8cf1c2af931257eeed692eb"
17
17
  }
package/src/api/groups.js CHANGED
@@ -52,6 +52,20 @@ export const buildGroupsEndpoints = API => {
52
52
  })
53
53
  },
54
54
 
55
+ /**
56
+ * Gets a group users by the group id
57
+ */
58
+ getGroupUsers: async ({ id, bookmark }) => {
59
+ let url = `/api/global/groups/${id}/users?`
60
+ if (bookmark) {
61
+ url += `bookmark=${bookmark}`
62
+ }
63
+
64
+ return await API.get({
65
+ url,
66
+ })
67
+ },
68
+
55
69
  /**
56
70
  * Adds users to a group
57
71
  * @param groupId The group to update
@@ -362,13 +362,35 @@ export default class DataFetch {
362
362
  return
363
363
  }
364
364
  this.store.update($store => ({ ...$store, loading: true }))
365
- const { rows, info, error } = await this.getPage()
365
+ const { rows, info, error, cursor } = await this.getPage()
366
+
367
+ let { cursors } = get(this.store)
368
+ const { pageNumber } = get(this.store)
369
+
370
+ if (!rows.length && pageNumber > 0) {
371
+ // If the full page is gone but we have previous pages, navigate to the previous page
372
+ this.store.update($store => ({
373
+ ...$store,
374
+ loading: false,
375
+ cursors: cursors.slice(0, pageNumber),
376
+ }))
377
+ return await this.prevPage()
378
+ }
379
+
380
+ const currentNextCursor = cursors[pageNumber + 1]
381
+ if (currentNextCursor != cursor) {
382
+ // If the current cursor changed, all the next pages need to be updated, so we mark them as stale
383
+ cursors = cursors.slice(0, pageNumber + 1)
384
+ cursors[pageNumber + 1] = cursor
385
+ }
386
+
366
387
  this.store.update($store => ({
367
388
  ...$store,
368
389
  rows,
369
390
  info,
370
391
  loading: false,
371
392
  error,
393
+ cursors,
372
394
  }))
373
395
  }
374
396
 
@@ -0,0 +1,50 @@
1
+ import { get } from "svelte/store"
2
+ import DataFetch from "./DataFetch.js"
3
+ import { TableNames } from "../constants"
4
+
5
+ export default class GroupUserFetch extends DataFetch {
6
+ constructor(opts) {
7
+ super({
8
+ ...opts,
9
+ datasource: {
10
+ tableId: TableNames.USERS,
11
+ },
12
+ })
13
+ }
14
+
15
+ determineFeatureFlags() {
16
+ return {
17
+ supportsSearch: true,
18
+ supportsSort: false,
19
+ supportsPagination: true,
20
+ }
21
+ }
22
+
23
+ async getDefinition() {
24
+ return {
25
+ schema: {},
26
+ }
27
+ }
28
+
29
+ async getData() {
30
+ const { query, cursor } = get(this.store)
31
+ try {
32
+ const res = await this.API.getGroupUsers({
33
+ id: query.groupId,
34
+ bookmark: cursor,
35
+ })
36
+
37
+ return {
38
+ rows: res?.users || [],
39
+ hasNextPage: res?.hasNextPage || false,
40
+ cursor: res?.bookmark || null,
41
+ }
42
+ } catch (error) {
43
+ return {
44
+ rows: [],
45
+ hasNextPage: false,
46
+ error,
47
+ }
48
+ }
49
+ }
50
+ }
@@ -6,6 +6,7 @@ import NestedProviderFetch from "./NestedProviderFetch.js"
6
6
  import FieldFetch from "./FieldFetch.js"
7
7
  import JSONArrayFetch from "./JSONArrayFetch.js"
8
8
  import UserFetch from "./UserFetch.js"
9
+ import GroupUserFetch from "./GroupUserFetch.js"
9
10
 
10
11
  const DataFetchMap = {
11
12
  table: TableFetch,
@@ -13,6 +14,7 @@ const DataFetchMap = {
13
14
  query: QueryFetch,
14
15
  link: RelationshipFetch,
15
16
  user: UserFetch,
17
+ groupUser: GroupUserFetch,
16
18
 
17
19
  // Client specific datasource types
18
20
  provider: NestedProviderFetch,