From f740e09b3d2196739c266f4d8505aaeb8d3fd566 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 21 Nov 2024 14:39:25 +0700 Subject: [PATCH] Fix create workspace region selector (#7212) Signed-off-by: Andrey Sobolev --- packages/ui/src/components/Scroller.svelte | 2 + .../src/components/CreateWorkspaceForm.svelte | 39 ++++++++++++------- .../src/components/Form.svelte | 27 +++++++------ .../src/components/SelectWorkspace.svelte | 2 +- server/account/src/utils.ts | 4 +- 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/packages/ui/src/components/Scroller.svelte b/packages/ui/src/components/Scroller.svelte index 039f07bb67..681ea58b32 100644 --- a/packages/ui/src/components/Scroller.svelte +++ b/packages/ui/src/components/Scroller.svelte @@ -50,6 +50,7 @@ export let onResize: (() => void) | undefined = undefined export let containerName: string | undefined = undefined export let containerType: 'size' | 'inline-size' | undefined = containerName !== undefined ? 'inline-size' : undefined + export let maxHeight: number | undefined = undefined export function scroll (top: number, left?: number, behavior: 'auto' | 'smooth' = 'auto') { if (divScroll) { @@ -558,6 +559,7 @@ style:--scroller-footer-height={`${(fade.multipler?.bottom ?? 0) * fz + (stickedScrollBars ? 0 : 2)}px`} style:--scroller-left-offset={`${(fade.multipler?.left ?? 0) * fz + 2}px`} style:--scroller-right-offset={`${(fade.multipler?.right ?? 0) * fz + (mask !== 'none' ? 12 : 2)}px`} + style:max-height={maxHeight !== undefined ? `${maxHeight}rem` : undefined} >
-{#if regions.length > 1} -
- ({ id: it.region, label: it.name }))} /> -
-{/if} -
+> + + {#if regions.length > 1} +
+ it.region === selectedRegion)?.name} + items={regions.map((it) => ({ id: it.region, label: getEmbeddedLabel(it.name) }))} + on:selected={(it) => { + selectedRegion = it.detail + }} + /> +
+ {/if} +
+
diff --git a/plugins/login-resources/src/components/Form.svelte b/plugins/login-resources/src/components/Form.svelte index a9ee5d1bd6..d040397339 100644 --- a/plugins/login-resources/src/components/Form.svelte +++ b/plugins/login-resources/src/components/Form.svelte @@ -21,11 +21,11 @@ import { onMount } from 'svelte' import { BottomAction } from '..' - import login from '../plugin' import { makeSequential } from '../mutex' + import login from '../plugin' + import BottomActionComponent from './BottomAction.svelte' import Providers from './Providers.svelte' import Tabs from './Tabs.svelte' - import BottomActionComponent from './BottomAction.svelte' interface Field { id?: string @@ -59,8 +59,6 @@ export let subtitle: string | undefined = undefined export let signUpDisabled = false - $: $themeStore.language && validate($themeStore.language) - const validate = makeSequential(async function validateAsync (language: string): Promise { if (ignoreInitialValidation) return true for (const field of fields) { @@ -97,7 +95,10 @@ status = OK return true }) - validate($themeStore.language) + + $: if ($themeStore.language !== undefined) { + void validate($themeStore.language) + } let inAction = false @@ -106,7 +107,7 @@ trim(field.name) } inAction = true - action.func().finally(() => { + void action.func().finally(() => { inAction = false }) } @@ -120,6 +121,7 @@ $: loginState = caption === login.string.LogIn ? 'login' : caption === login.string.SignUp ? 'signup' : 'none' +
{ - if (res) { + void validate($themeStore.language).then((res) => { + if (res != null) { performAction(action) } }) @@ -146,11 +148,14 @@ {subtitle}
{/if} -
+
+
+ +
{/if}
{#each fields as field (field.name)} -
+
- {#if secondaryButtonLabel && secondaryButtonAction} + {#if secondaryButtonLabel !== undefined && secondaryButtonAction}