From cc7df474c91eff86a94b33125abc4ca03db3c744 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 May 2023 09:24:53 +0100 Subject: [PATCH] Standardise usage of user avatars and colours across the entire platform --- packages/bbui/src/Avatar/Avatar.svelte | 18 ++- .../builder/src/builderStore/store/users.js | 6 +- .../src/components/common/AppLockModal.svelte | 143 ------------------ .../src/components/start/AppRow.svelte | 29 ++-- .../_components/UserAvatars.svelte | 33 ++-- .../builder/app/[application]/_layout.svelte | 12 +- .../src/pages/builder/apps/index.svelte | 11 +- .../portal/_components/UserDropdown.svelte | 5 +- .../auditLogs/_components/UserRenderer.svelte | 13 +- .../portal/overview/[appId]/_layout.svelte | 2 - .../backups/_components/UserRenderer.svelte | 9 +- .../portal/overview/[appId]/overview.svelte | 15 +- .../portal/users/users/[userId].svelte | 19 +-- .../src/components/UserAvatar.svelte | 58 +++++++ .../src/components/grid/layout/Avatar.svelte | 24 --- .../components/grid/layout/UserAvatars.svelte | 16 +- .../src/components/grid/stores/users.js | 20 ++- .../frontend-core/src/components/index.js | 1 + packages/server/src/websockets/builder.ts | 22 ++- packages/server/src/websockets/grid.ts | 9 +- packages/server/src/websockets/websocket.ts | 26 +--- packages/shared-core/src/helpers/helpers.ts | 59 ++++++++ 22 files changed, 254 insertions(+), 296 deletions(-) delete mode 100644 packages/builder/src/components/common/AppLockModal.svelte create mode 100644 packages/frontend-core/src/components/UserAvatar.svelte delete mode 100644 packages/frontend-core/src/components/grid/layout/Avatar.svelte diff --git a/packages/bbui/src/Avatar/Avatar.svelte b/packages/bbui/src/Avatar/Avatar.svelte index 1e4cefd8ce..0faf50f55a 100644 --- a/packages/bbui/src/Avatar/Avatar.svelte +++ b/packages/bbui/src/Avatar/Avatar.svelte @@ -13,10 +13,12 @@ export let url = "" export let disabled = false export let initials = "JD" + export let color = null const DefaultColor = "#3aab87" - $: color = getColor(initials) + $: avatarColor = color || getColor(initials) + $: style = getStyle(size, avatarColor) const getColor = initials => { if (!initials?.length) { @@ -26,6 +28,12 @@ const hue = ((code % 26) / 26) * 360 return `hsl(${hue}, 50%, 50%)` } + + const getStyle = (sizeKey, color) => { + const size = `var(${sizes.get(sizeKey)})` + const fontSize = `calc(${size} / 2)` + return `width:${size}; height:${size}; font-size:${fontSize}; background:${color};` + } {#if url} @@ -37,13 +45,7 @@ style="width: var({sizes.get(size)}); height: var({sizes.get(size)});" /> {:else} -
+
{initials || ""}
{/if} diff --git a/packages/builder/src/builderStore/store/users.js b/packages/builder/src/builderStore/store/users.js index 6de2adc90a..18f343c884 100644 --- a/packages/builder/src/builderStore/store/users.js +++ b/packages/builder/src/builderStore/store/users.js @@ -9,11 +9,11 @@ export const getUserStore = () => { const updateUser = user => { const $users = get(store) - if (!$users.some(x => x.id === user.id)) { + if (!$users.some(x => x.sessionId === user.sessionId)) { store.set([...$users, user]) } else { store.update(state => { - const index = state.findIndex(x => x.id === user.id) + const index = state.findIndex(x => x.sessionId === user.sessionId) state[index] = user return state.slice() }) @@ -22,7 +22,7 @@ export const getUserStore = () => { const removeUser = user => { store.update(state => { - return state.filter(x => x.id !== user.id) + return state.filter(x => x.sessionId !== user.sessionId) }) } diff --git a/packages/builder/src/components/common/AppLockModal.svelte b/packages/builder/src/components/common/AppLockModal.svelte deleted file mode 100644 index df491ead38..0000000000 --- a/packages/builder/src/components/common/AppLockModal.svelte +++ /dev/null @@ -1,143 +0,0 @@ - - -{#if lockedBy} -
- { - e.stopPropagation() - appLockModal.show() - }} - /> -
-{/if} - - - - - - Apps are locked to prevent work being lost from overlapping changes - between your team. - - {#if lockedByYou && getExpiryDuration(app) > 0} - - {processStringSync( - "This lock will expire in {{ duration time 'millisecond' }} from now.", - { - time: getExpiryDuration(app), - } - )} - - {/if} -
- - - {#if lockedByYou} - - {/if} - -
-
-
-
- - diff --git a/packages/builder/src/components/start/AppRow.svelte b/packages/builder/src/components/start/AppRow.svelte index 162958473e..0c011e89be 100644 --- a/packages/builder/src/components/start/AppRow.svelte +++ b/packages/builder/src/components/start/AppRow.svelte @@ -1,13 +1,16 @@
- {#each users as user} -
- {user.email[0]} -
+ {#each uniqueUsers as user} + {/each}
@@ -15,19 +25,4 @@ display: flex; gap: 4px; } - .avatar { - width: 24px; - height: 24px; - display: grid; - place-items: center; - color: white; - border-radius: 50%; - font-size: 12px; - font-weight: 700; - text-transform: uppercase; - line-height: 0; - } - .avatar:hover { - cursor: pointer; - } diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index 409f3e071b..4da0da44f9 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -218,7 +218,9 @@
{:then _} - +
+ +
{:catch error}

Something went wrong: {error.message}

{/await} @@ -254,6 +256,7 @@ box-sizing: border-box; align-items: stretch; border-bottom: var(--border-light); + z-index: 2; } .topleftnav { @@ -294,4 +297,11 @@ flex-direction: row; gap: 8px; } + + .body { + flex: 1 1 auto; + z-index: 1; + display: flex; + flex-direction: column; + } diff --git a/packages/builder/src/pages/builder/apps/index.svelte b/packages/builder/src/pages/builder/apps/index.svelte index 4b77671345..1806d51b69 100644 --- a/packages/builder/src/pages/builder/apps/index.svelte +++ b/packages/builder/src/pages/builder/apps/index.svelte @@ -5,7 +5,6 @@ Divider, ActionMenu, MenuItem, - Avatar, Page, Icon, Body, @@ -22,6 +21,8 @@ import { processStringSync } from "@budibase/string-templates" import Spaceman from "assets/bb-space-man.svg" import Logo from "assets/bb-emblem.svg" + import { UserAvatar } from "@budibase/frontend-core" + import { helpers } from "@budibase/shared-core" let loaded = false let userInfoModal @@ -96,11 +97,7 @@
- +
userInfoModal.show()}> @@ -125,7 +122,7 @@
- Hey {$auth.user.firstName || $auth.user.email} + Hey {helpers.getUserLabel($auth.user)} Welcome to the {$organisation.company} portal. Below you'll find the diff --git a/packages/builder/src/pages/builder/portal/_components/UserDropdown.svelte b/packages/builder/src/pages/builder/portal/_components/UserDropdown.svelte index 935d69812f..9faae70aa9 100644 --- a/packages/builder/src/pages/builder/portal/_components/UserDropdown.svelte +++ b/packages/builder/src/pages/builder/portal/_components/UserDropdown.svelte @@ -1,11 +1,12 @@ {#if row?.user?.email} @@ -19,7 +14,7 @@ on:focus={() => (showTooltip = true)} on:mouseleave={() => (showTooltip = false)} > - +
{#if showTooltip}
diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/_layout.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/_layout.svelte index cc244852d8..8ee469a914 100644 --- a/packages/builder/src/pages/builder/portal/overview/[appId]/_layout.svelte +++ b/packages/builder/src/pages/builder/portal/overview/[appId]/_layout.svelte @@ -24,7 +24,6 @@ import { AppStatus } from "constants" import analytics, { Events, EventSource } from "analytics" import { store } from "builderStore" - import AppLockModal from "components/common/AppLockModal.svelte" import EditableIcon from "components/common/EditableIcon.svelte" import { API } from "api" import ConfirmDialog from "components/common/ConfirmDialog.svelte" @@ -128,7 +127,6 @@ />
-