@budibase/frontend-core 3.9.4 → 3.10.0
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 +2 -2
- package/src/api/features.ts +19 -0
- package/src/api/index.ts +2 -0
- package/src/api/types.ts +2 -0
- package/src/components/UserAvatar.svelte +7 -6
- package/src/components/UserAvatars.svelte +22 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"shortid": "2.2.15",
|
|
18
18
|
"socket.io-client": "^4.7.5"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "35c16326f7215671d405cd811b28e78f5be70d07"
|
|
21
21
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OverrideFeatureFlagRequest } from "@budibase/types"
|
|
2
|
+
import { BaseAPIClient } from "./types"
|
|
3
|
+
|
|
4
|
+
export interface FeatureFlagEndpoints {
|
|
5
|
+
overrideFeatureFlags: (flags: Record<string, boolean>) => Promise<void>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const buildFeatureFlagEndpoints = (
|
|
9
|
+
API: BaseAPIClient
|
|
10
|
+
): FeatureFlagEndpoints => ({
|
|
11
|
+
overrideFeatureFlags: async flags => {
|
|
12
|
+
const body: OverrideFeatureFlagRequest = { flags }
|
|
13
|
+
return await API.patch({
|
|
14
|
+
url: "/api/features",
|
|
15
|
+
body,
|
|
16
|
+
parseResponse: () => {},
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
})
|
package/src/api/index.ts
CHANGED
|
@@ -46,6 +46,7 @@ import { buildLogsEndpoints } from "./logs"
|
|
|
46
46
|
import { buildMigrationEndpoints } from "./migrations"
|
|
47
47
|
import { buildRowActionEndpoints } from "./rowActions"
|
|
48
48
|
import { buildOAuth2Endpoints } from "./oauth2"
|
|
49
|
+
import { buildFeatureFlagEndpoints } from "./features"
|
|
49
50
|
|
|
50
51
|
export type { APIClient } from "./types"
|
|
51
52
|
|
|
@@ -289,6 +290,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
|
|
|
289
290
|
...buildAuditLogEndpoints(API),
|
|
290
291
|
...buildLogsEndpoints(API),
|
|
291
292
|
...buildMigrationEndpoints(API),
|
|
293
|
+
...buildFeatureFlagEndpoints(API),
|
|
292
294
|
viewV2: buildViewV2Endpoints(API),
|
|
293
295
|
rowActions: buildRowActionEndpoints(API),
|
|
294
296
|
oauth2: buildOAuth2Endpoints(API),
|
package/src/api/types.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ConfigEndpoints } from "./configs"
|
|
|
10
10
|
import { DatasourceEndpoints } from "./datasources"
|
|
11
11
|
import { EnvironmentVariableEndpoints } from "./environmentVariables"
|
|
12
12
|
import { EventEndpoints } from "./events"
|
|
13
|
+
import { FeatureFlagEndpoints } from "./features"
|
|
13
14
|
import { FlagEndpoints } from "./flags"
|
|
14
15
|
import { GroupEndpoints } from "./groups"
|
|
15
16
|
import { LayoutEndpoints } from "./layouts"
|
|
@@ -133,6 +134,7 @@ export type APIClient = BaseAPIClient &
|
|
|
133
134
|
TableEndpoints &
|
|
134
135
|
TemplateEndpoints &
|
|
135
136
|
UserEndpoints &
|
|
137
|
+
FeatureFlagEndpoints &
|
|
136
138
|
ViewEndpoints & {
|
|
137
139
|
rowActions: RowActionEndpoints
|
|
138
140
|
viewV2: ViewV2Endpoints
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { Avatar, AbsTooltip, TooltipPosition } from "@budibase/bbui"
|
|
3
3
|
import { helpers } from "@budibase/shared-core"
|
|
4
|
+
import type { User } from "@budibase/types"
|
|
4
5
|
|
|
5
|
-
export let user
|
|
6
|
-
export let size = "S"
|
|
7
|
-
export let tooltipPosition = TooltipPosition.Top
|
|
8
|
-
export let showTooltip = true
|
|
6
|
+
export let user: User
|
|
7
|
+
export let size: "XS" | "S" | "M" = "S"
|
|
8
|
+
export let tooltipPosition: TooltipPosition = TooltipPosition.Top
|
|
9
|
+
export let showTooltip: boolean = true
|
|
9
10
|
</script>
|
|
10
11
|
|
|
11
12
|
{#if user}
|
|
12
13
|
<AbsTooltip
|
|
13
|
-
text={showTooltip ? helpers.getUserLabel(user) :
|
|
14
|
+
text={showTooltip ? helpers.getUserLabel(user) : ""}
|
|
14
15
|
position={tooltipPosition}
|
|
15
16
|
color={helpers.getUserColor(user)}
|
|
16
17
|
>
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { UserAvatar } from "@budibase/frontend-core"
|
|
3
3
|
import { TooltipPosition, Avatar } from "@budibase/bbui"
|
|
4
|
+
import type { UIUser } from "@budibase/types"
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
export let order = "ltr"
|
|
7
|
-
export let size = "S"
|
|
8
|
-
export let tooltipPosition = TooltipPosition.Top
|
|
6
|
+
type OrderType = "ltr" | "rtl"
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
export let users: UIUser[] = []
|
|
9
|
+
export let order: OrderType = "ltr"
|
|
10
|
+
export let size: "XS" | "S" = "S"
|
|
11
|
+
export let tooltipPosition: TooltipPosition = TooltipPosition.Top
|
|
12
|
+
|
|
13
|
+
$: uniqueUsers = unique(users)
|
|
11
14
|
$: avatars = getAvatars(uniqueUsers, order)
|
|
12
15
|
|
|
13
|
-
const unique = users => {
|
|
14
|
-
|
|
15
|
-
users
|
|
16
|
+
const unique = (users: UIUser[]) => {
|
|
17
|
+
const uniqueUsers: Record<string, UIUser> = {}
|
|
18
|
+
users.forEach(user => {
|
|
16
19
|
uniqueUsers[user.email] = user
|
|
17
20
|
})
|
|
18
21
|
return Object.values(uniqueUsers)
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
type Overflow = { _id: "overflow"; label: string }
|
|
25
|
+
const getAvatars = (users: UIUser[], order: OrderType) => {
|
|
26
|
+
const avatars: (Overflow | UIUser)[] = users.slice(0, 3)
|
|
23
27
|
if (users.length > 3) {
|
|
24
|
-
const overflow = {
|
|
28
|
+
const overflow: Overflow = {
|
|
25
29
|
_id: "overflow",
|
|
26
30
|
label: `+${users.length - 3}`,
|
|
27
31
|
}
|
|
@@ -31,17 +35,22 @@
|
|
|
31
35
|
avatars.unshift(overflow)
|
|
32
36
|
}
|
|
33
37
|
}
|
|
38
|
+
|
|
34
39
|
return avatars.map((user, idx) => ({
|
|
35
40
|
...user,
|
|
36
41
|
zIndex: order === "ltr" ? idx : uniqueUsers.length - idx,
|
|
37
42
|
}))
|
|
38
43
|
}
|
|
44
|
+
|
|
45
|
+
function isUser(value: Overflow | UIUser): value is UIUser {
|
|
46
|
+
return value._id !== "overflow"
|
|
47
|
+
}
|
|
39
48
|
</script>
|
|
40
49
|
|
|
41
50
|
<div class="avatars">
|
|
42
51
|
{#each avatars as user}
|
|
43
52
|
<span style="z-index:{user.zIndex};">
|
|
44
|
-
{#if user
|
|
53
|
+
{#if !isUser(user)}
|
|
45
54
|
<Avatar
|
|
46
55
|
{size}
|
|
47
56
|
initials={user.label}
|