Files
windmill/frontend/src/lib/components/InstanceGroupEditor.svelte
T
310f37a682 feat: migrate to svelte5 + vite6 (#4813)
* runs on svelte 5

* Line component from svelte-chartjs

* Replaced all svelte-chartjs occurrences with custom wrapper

* Fix props mistake

* Fix illegal table structures

* self-closing-tags fix

* aria labels

* Fixed trivial warnings and errors

* @tanstack/svelte-table fix

* upgrade to vite 6

* svelte-kit sync before running svelte-check

* Remove on:clear which is actually on:removeAll and already handled by on:change

* fix worker tags not displaying in Autoscaling

* Try to fix svelte-kit sync not working during CI

* remove warnings

* Fix add flow page crashing

* access worldStore before assignment fix

* fix infinite recursions in App Editor

* Replaced JSON.stringify with proper deepEqual

* component mount api changed (no longer classes)

* fix ci errors

* Fix infinite loops in background runnable panel

* factored effect on deep equal logic in onObjChange

* fix "Add" not working in AgGrid Table

* Replaced legacy component.$set api

* Fix multiselect infinite value reaction

* Fix flow input fields resetting when opening their edit tab

* fix date input resetting when typing year

* Remove !p-0 affecting subgrid dotted borders

* fix missing debounceTemplate causing hundreds of updates

* Fix AgGrid action refreshes and disppearing

* resolve getItems generating random ids every rerun

* fix cannot access items before init

* fix sort lambda arguments being undefined

* Revert "Remove !p-0 affecting subgrid dotted borders"

This reverts commit c62809bb45d682a48376b071680645ed4e1c601b.

* fix input not updating in decision tree editor

* Update frontend/src/lib/components/schema/EditableSchemaWrapper.svelte

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Re-added padding affecting subgrid dotted borders (#5479)

* remove !p-0 in preset components

* removed extra padding on accordion tabs subgrid

* Fix non-reactive SchemaForm

* dirty fix for the oneOf bug

* Fix warnings and update svelte-exmarkdown for svelte 5

* fix dnd not working

* don't mount component like objects

---------

Co-authored-by: Diego Imbert <diegoimbert@protonmail.com>
Co-authored-by: Diego Imbert <70353967+diegoimbert@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-04-02 21:33:50 +00:00

122 lines
2.9 KiB
Svelte

<script lang="ts">
import { GroupService, type InstanceGroup } from '$lib/gen'
import { createEventDispatcher } from 'svelte'
import autosize from '$lib/autosize'
import { Button } from './common'
import Skeleton from './common/skeleton/Skeleton.svelte'
import TableCustom from './TableCustom.svelte'
import { sendUserToast } from '$lib/toast'
import { Loader2 } from 'lucide-svelte'
export let name: string
let email = ''
let instance_group: InstanceGroup | undefined
let members: { member_email: string }[] | undefined = undefined
const dispatch = createEventDispatcher()
$: {
load()
}
async function load() {
return Promise.all([loadInstanceGroup()])
}
async function loadInstanceGroup(): Promise<void> {
instance_group = await GroupService.getInstanceGroup({ name })
members = instance_group?.emails
? instance_group.emails.map((x) => {
return { member_email: x }
})
: []
}
</script>
<div class="flex flex-col gap-6">
<h1>{name}</h1>
{#if instance_group !== undefined}
<div class="flex flex-col gap-1">
<textarea
rows="2"
use:autosize
bind:value={instance_group.summary}
placeholder="Summary of the group"
></textarea>
<div class="flex justify-end">
<Button
size="xs"
on:click={async () => {
await GroupService.updateInstanceGroup({
name,
requestBody: { new_summary: instance_group?.summary ?? '' }
})
dispatch('update')
sendUserToast('New summary saved')
}}>Save Summary</Button
>
</div>
</div>
<h2
>Members ({#if members?.length != undefined}{members?.length ?? 0}{:else}<Loader2
class="animate-spin"
size={10}
/>{/if})</h2
>
<div class="flex items-start">
<input type="text" placeholder="john@acme.com" bind:value={email} />
<Button
variant="contained"
color="blue"
size="sm"
btnClasses="!ml-4"
on:click={async () => {
await GroupService.addUserToInstanceGroup({
name,
requestBody: { email: email }
})
dispatch('update')
sendUserToast('User added')
loadInstanceGroup()
}}
>
Add member
</Button>
</div>
{#if members}
<TableCustom>
<tr slot="header-row">
<th>user</th>
<th></th>
</tr>
<tbody slot="body">
{#each members as { member_email }}<tr>
<td>{member_email}</td>
<td>
<button
class="ml-2 text-red-500"
on:click={async () => {
await GroupService.removeUserFromInstanceGroup({
name,
requestBody: { email: member_email }
})
dispatch('update')
sendUserToast('User removed')
loadInstanceGroup()
}}>remove</button
>
</td>
</tr>{/each}
</tbody>
</TableCustom>
{:else}
<div class="flex flex-col">
{#each new Array(6) as _}
<Skeleton layout={[[2], 0.7]} />
{/each}
</div>
{/if}
{/if}
</div>