fix: filter out existing workspace members from instance emails select

Also fixes "Add new userss" typo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Guilhem
2026-02-16 10:25:15 +00:00
co-authored by Claude Opus 4.6
parent 077eb91c0f
commit fb0f0031d9
2 changed files with 15 additions and 10 deletions
+14 -10
View File
@@ -14,6 +14,8 @@
const dispatch = createEventDispatcher()
let { workspaceEmails = [] }: { workspaceEmails?: string[] } = $props()
let email: string | undefined = $state()
let username: string | undefined = $state()
@@ -32,15 +34,22 @@
}
getAutomateUsernameCreationSetting()
let instanceEmails: { label: string; value: string }[] | undefined = $state(undefined)
let allInstanceEmails: string[] | undefined = $state(undefined)
let instanceEmails = $derived.by(() => {
if (!allInstanceEmails) return undefined
const workspaceSet = new Set(workspaceEmails)
return allInstanceEmails
.filter((e) => !workspaceSet.has(e))
.map((e) => ({ label: e, value: e }))
})
async function loadInstanceEmails() {
if (isCloudHosted()) return
try {
const emails = await UserService.listInstanceEmails()
instanceEmails = emails.map((e) => ({ label: e, value: e }))
allInstanceEmails = await UserService.listInstanceEmails()
} catch {
instanceEmails = undefined
allInstanceEmails = undefined
}
}
loadInstanceEmails()
@@ -110,12 +119,7 @@
disablePortal={true}
/>
{:else}
<input
type="email"
onkeyup={handleKeyUp}
placeholder="email"
bind:value={email}
/>
<input type="email" onkeyup={handleKeyUp} placeholder="email" bind:value={email} />
{/if}
{#if !automateUsernameCreation}
@@ -724,6 +724,7 @@
{/if}
<AddUser
workspaceEmails={users?.map((u) => u.email) ?? []}
on:new={() => {
listUsers()
listInvites()