exported deleteUserModal as component
This commit is contained in:
parent
835c4e390d
commit
2d12970c58
|
@ -17,7 +17,6 @@
|
||||||
Popover,
|
Popover,
|
||||||
Select,
|
Select,
|
||||||
Modal,
|
Modal,
|
||||||
ModalContent,
|
|
||||||
notifications,
|
notifications,
|
||||||
StatusLight,
|
StatusLight,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
|
@ -29,10 +28,11 @@
|
||||||
import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte"
|
import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte"
|
||||||
import { RoleUtils } from "@budibase/frontend-core"
|
import { RoleUtils } from "@budibase/frontend-core"
|
||||||
import UserGroupPicker from "components/settings/UserGroupPicker.svelte"
|
import UserGroupPicker from "components/settings/UserGroupPicker.svelte"
|
||||||
|
import DeleteUserModal from "./_components/DeleteUserModal.svelte"
|
||||||
|
|
||||||
export let userId
|
export let userId
|
||||||
|
|
||||||
let deleteUserModal
|
let deleteModal
|
||||||
let resetPasswordModal
|
let resetPasswordModal
|
||||||
let popoverAnchor
|
let popoverAnchor
|
||||||
let searchTerm = ""
|
let searchTerm = ""
|
||||||
|
@ -83,15 +83,6 @@
|
||||||
: "appUser"
|
: "appUser"
|
||||||
|
|
||||||
const userFetch = fetchData(`/api/global/users/${userId}`)
|
const userFetch = fetchData(`/api/global/users/${userId}`)
|
||||||
async function deleteUser() {
|
|
||||||
try {
|
|
||||||
await users.delete(userId)
|
|
||||||
notifications.success(`User ${$userFetch?.data?.email} deleted.`)
|
|
||||||
$goto("./")
|
|
||||||
} catch (error) {
|
|
||||||
notifications.error("Error deleting user")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getHighestRole(roles) {
|
function getHighestRole(roles) {
|
||||||
let highestRole
|
let highestRole
|
||||||
|
@ -207,9 +198,7 @@
|
||||||
<MenuItem on:click={resetPasswordModal.show} icon="Refresh"
|
<MenuItem on:click={resetPasswordModal.show} icon="Refresh"
|
||||||
>Force Password Reset</MenuItem
|
>Force Password Reset</MenuItem
|
||||||
>
|
>
|
||||||
<MenuItem on:click={deleteUserModal.show} icon="Delete"
|
<MenuItem on:click={deleteModal.show} icon="Delete">Delete</MenuItem>
|
||||||
>Delete</MenuItem
|
|
||||||
>
|
|
||||||
</ActionMenu>
|
</ActionMenu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -331,19 +320,8 @@
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<Modal bind:this={deleteUserModal}>
|
<Modal bind:this={deleteModal}>
|
||||||
<ModalContent
|
<DeleteUserModal user={$userFetch.data} />
|
||||||
warning
|
|
||||||
onConfirm={deleteUser}
|
|
||||||
title="Delete User"
|
|
||||||
confirmText="Delete user"
|
|
||||||
cancelText="Cancel"
|
|
||||||
showCloseIcon={false}
|
|
||||||
>
|
|
||||||
<Body>
|
|
||||||
Are you sure you want to delete <strong>{$userFetch?.data?.email}</strong>
|
|
||||||
</Body>
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal bind:this={resetPasswordModal}>
|
<Modal bind:this={resetPasswordModal}>
|
||||||
<ForceResetPasswordModal
|
<ForceResetPasswordModal
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<script>
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
|
import { Body, ModalContent, notifications } from "@budibase/bbui"
|
||||||
|
|
||||||
|
import { users } from "stores/portal"
|
||||||
|
|
||||||
|
export let user
|
||||||
|
|
||||||
|
async function deleteUser() {
|
||||||
|
try {
|
||||||
|
await users.delete(user._id)
|
||||||
|
notifications.success(`User ${user?.email} deleted.`)
|
||||||
|
$goto("./")
|
||||||
|
} catch (error) {
|
||||||
|
notifications.error("Error deleting user")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ModalContent
|
||||||
|
warning
|
||||||
|
onConfirm={deleteUser}
|
||||||
|
title="Delete User"
|
||||||
|
confirmText="Delete user"
|
||||||
|
cancelText="Cancel"
|
||||||
|
showCloseIcon={false}
|
||||||
|
>
|
||||||
|
<Body>
|
||||||
|
Are you sure you want to delete <strong>{user?.email}</strong>
|
||||||
|
</Body>
|
||||||
|
</ModalContent>
|
Loading…
Reference in New Issue