mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 00:05:27 +00:00
* fix: correct $props generic syntax in Svelte 5 components Replace incorrect `$props<T>()` syntax with correct `let x: T = $props()` syntax to ensure proper TypeScript typing instead of falling back to `any` types. This affects 11 Svelte 5 components throughout the frontend codebase. Fixes #5974 Co-authored-by: Diego Imbert <diegoimbert@users.noreply.github.com> * fix claude pr --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Diego Imbert <diegoimbert@users.noreply.github.com> Co-authored-by: Diego Imbert <diego@windmill.dev> Co-authored-by: Diego Imbert <70353967+diegoimbert@users.noreply.github.com>
86 lines
1.8 KiB
Svelte
86 lines
1.8 KiB
Svelte
<script lang="ts">
|
|
import { workspaceStore } from '$lib/stores'
|
|
import Button from '../common/button/Button.svelte'
|
|
import { sendUserToast } from '$lib/toast'
|
|
import { WorkspaceService } from '$lib/gen'
|
|
import Modal from '../common/modal/Modal.svelte'
|
|
import { Pen } from 'lucide-svelte'
|
|
import { untrack } from 'svelte'
|
|
|
|
let { open = false }: { open?: boolean } = $props()
|
|
|
|
let newName = $state('')
|
|
let currentName = $state('')
|
|
|
|
$effect(() => {
|
|
if ($workspaceStore) {
|
|
untrack(() => getWorkspaceName())
|
|
}
|
|
})
|
|
|
|
async function getWorkspaceName() {
|
|
currentName = await WorkspaceService.getWorkspaceName({ workspace: $workspaceStore! })
|
|
}
|
|
|
|
async function renameWorkspace() {
|
|
open = false
|
|
await WorkspaceService.changeWorkspaceName({
|
|
workspace: $workspaceStore!,
|
|
requestBody: {
|
|
new_name: newName
|
|
}
|
|
})
|
|
|
|
sendUserToast(`Changed workspace name to ${newName}`)
|
|
newName = ''
|
|
getWorkspaceName()
|
|
}
|
|
</script>
|
|
|
|
<div>
|
|
<p class="font-semibold text-sm">Workspace name</p>
|
|
<div class="flex flex-row gap-0.5 items-center">
|
|
<p class="text-sm text-secondary">{currentName}</p>
|
|
<Button
|
|
on:click={() => {
|
|
open = true
|
|
}}
|
|
size="xs"
|
|
spacingSize="xs2"
|
|
color="light"
|
|
iconOnly
|
|
startIcon={{
|
|
icon: Pen
|
|
}}
|
|
/>
|
|
</div>
|
|
|
|
<p class="italic text-xs"> Displayable name </p>
|
|
</div>
|
|
|
|
<Modal bind:open title="Change workspace name">
|
|
<div class="flex flex-col gap-4 mt-4">
|
|
{#if currentName}
|
|
<p class="text-secondary text-sm"
|
|
>Current name <br /> <span class="font-bold">{currentName}</span></p
|
|
>
|
|
{/if}
|
|
<label class="block">
|
|
<span class="text-secondary text-sm">New name</span>
|
|
<input type="text" bind:value={newName} />
|
|
</label>
|
|
</div>
|
|
|
|
<svelte:fragment slot="actions">
|
|
<Button
|
|
size="sm"
|
|
disabled={!newName}
|
|
on:click={() => {
|
|
renameWorkspace()
|
|
}}
|
|
>
|
|
Save
|
|
</Button>
|
|
</svelte:fragment>
|
|
</Modal>
|