From 79f7fd380d443aba8005e0edd38d6ccd2b3b2507 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Sat, 30 Jul 2022 11:38:08 +0100 Subject: [PATCH] pr comments and updating group check to be more safe --- .../src/pages/builder/portal/_layout.svelte | 13 ++-- .../users/_components/AddUserModal.svelte | 61 ++++++++++++++++--- packages/server/src/utilities/global.js | 12 ++-- packages/worker/src/sdk/users/users.ts | 6 +- 4 files changed, 63 insertions(+), 29 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/_layout.svelte b/packages/builder/src/pages/builder/portal/_layout.svelte index dcebe0e2c9..17209b1786 100644 --- a/packages/builder/src/pages/builder/portal/_layout.svelte +++ b/packages/builder/src/pages/builder/portal/_layout.svelte @@ -45,14 +45,6 @@ }, ]) } - if (isEnabled(FEATURE_FLAGS.USER_GROUPS)) { - menu = menu.concat([ - { - title: "User Groups", - href: "/builder/portal/manage/groups", - }, - ]) - } if (admin) { menu = menu.concat([ @@ -61,7 +53,10 @@ href: "/builder/portal/manage/users", heading: "Manage", }, - + isEnabled(FEATURE_FLAGS.USER_GROUPS) && { + title: "User Groups", + href: "/builder/portal/manage/groups", + }, { title: "Auth", href: "/builder/portal/manage/auth" }, { title: "Email", href: "/builder/portal/manage/email" }, { diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte index 7d8d4734e8..b1e26c03e8 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte @@ -6,6 +6,7 @@ Multiselect, InputDropdown, Layout, + Icon, } from "@budibase/bbui" import { groups, auth } from "stores/portal" import { Constants } from "@budibase/frontend-core" @@ -15,7 +16,7 @@ const password = Math.random().toString(36).substring(2, 22) let disabled let userGroups = [] - + $: errors = [] $: hasGroupsLicense = $auth.user?.license.features.includes( Constants.Features.USER_GROUPS ) @@ -28,6 +29,10 @@ forceResetPassword: true, }, ] + + function removeInput(idx) { + userData = userData.filter((e, i) => i !== idx) + } function addNewInput() { userData = [ ...userData, @@ -40,9 +45,15 @@ ] } - function validateInput(email) { + function validateInput(email, index) { if (email) { - return emailValidator(email) === true ? null : emailValidator(email) + if (emailValidator(email) === true) { + errors[index] = true + return null + } else { + errors[index] = false + return emailValidator(email) + } } } @@ -56,18 +67,40 @@ confirmDisabled={disabled} cancelText="Cancel" showCloseIcon={false} + disabled={errors.some(x => x === false) || + userData.some(x => x.email === "" || x.email === null)} > {#each userData as input, index} - +
+
+ +
+
+ removeInput(index)} + /> +
+
{/each}
Add email @@ -87,6 +120,14 @@