From aae52ae434acbac7c89074cc90460520095b712c Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Tue, 22 Feb 2022 17:17:07 +0100 Subject: [PATCH] Merge both create user modals for easy switch between the two --- .../FilterEditor/FilterDrawer.svelte | 2 +- .../users/_components/AddUserModal.svelte | 63 ++++++++++++---- .../_components/BasicOnboardingModal.svelte | 74 ------------------- .../builder/portal/manage/users/index.svelte | 11 +-- 4 files changed, 51 insertions(+), 99 deletions(-) delete mode 100644 packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte index bca78f6cbb..1441d3834b 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte @@ -90,7 +90,7 @@ -
+
{#if !filters?.length} 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 0255784a7b..b95c9b98ea 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 @@ -12,13 +12,38 @@ import { users } from "stores/portal" import analytics, { Events } from "analytics" - export let disabled - + const password = Math.random().toString(36).substring(2, 22) const options = ["Email onboarding", "Basic onboarding"] - let selected = options[0] - let builder, admin - const [email, error, touched] = createValidationStore("", emailValidator) + let disabled + let builder + let admin + let selected = "Email onboarding" + + $: basic = selected === "Basic onboarding" + + function addUser() { + if (basic) { + createUser() + } else { + createUserFlow() + } + } + + async function createUser() { + try { + await users.create({ + email: $email, + password, + builder, + admin, + forceResetPassword: true, + }) + notifications.success("Successfully created user") + } catch (error) { + notifications.error("Error creating user") + } + } async function createUserFlow() { try { @@ -32,7 +57,7 @@ - + + {#if basic} + + + {:else} + + {/if}
diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte deleted file mode 100644 index 29e2d56ed0..0000000000 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte +++ /dev/null @@ -1,74 +0,0 @@ - - - - - Below you will find the user’s username and password. The password will not - be accessible from this point. Please save the credentials. - - - -
-
- - -
-
- - -
-
-
- - diff --git a/packages/builder/src/pages/builder/portal/manage/users/index.svelte b/packages/builder/src/pages/builder/portal/manage/users/index.svelte index 1160cc109b..f74a6c80a3 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/index.svelte @@ -15,7 +15,6 @@ } from "@budibase/bbui" import TagsRenderer from "./_components/TagsTableRenderer.svelte" import AddUserModal from "./_components/AddUserModal.svelte" - import BasicOnboardingModal from "./_components/BasicOnboardingModal.svelte" import { users } from "stores/portal" import { onMount } from "svelte" @@ -30,7 +29,6 @@ } let search - let email $: filteredUsers = $users .filter(user => user.email.includes(search || "")) .map(user => ({ @@ -41,12 +39,6 @@ })) let createUserModal - let basicOnboardingModal - - function openBasicOnboardingModal() { - createUserModal.hide() - basicOnboardingModal.show() - } onMount(async () => { try { @@ -91,9 +83,8 @@ - + -