fixed #1395 - preselect current user in access instructions modal (#1405)

This commit is contained in:
Eugene 2025-07-03 23:46:01 +02:00 committed by GitHub
parent 90b0aaf137
commit 7e217d5f89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { api, type Role, type Target, type User } from 'admin/lib/api'
import { api, type Role, type Target } from 'admin/lib/api'
import AsyncButton from 'common/AsyncButton.svelte'
import ConnectionInstructions from 'common/ConnectionInstructions.svelte'
import { TargetKind } from 'gateway/lib/api'
@ -20,7 +20,7 @@
let { params }: Props = $props()
let error: string|undefined = $state()
let selectedUser: User|undefined = $state()
let selectedUsername: string|undefined = $state($serverInfo?.username)
let target: Target | undefined = $state()
let roleIsAllowed: Record<string, any> = $state({})
let connectionsInstructionsModalOpen = $state(false)
@ -86,9 +86,9 @@
<Loadable promise={api.getUsers()}>
{#snippet children(users)}
<FormGroup floating label="Select a user">
<select bind:value={selectedUser} class="form-control">
{#each users as user}
<option value={user}>
<select bind:value={selectedUsername} class="form-control">
{#each users as user (user.id)}
<option value={user.username}>
{user.username}
</option>
{/each}
@ -100,7 +100,7 @@
<ConnectionInstructions
targetName={target.name}
username={selectedUser?.username}
username={selectedUsername}
targetKind={{
Ssh: TargetKind.Ssh,
WebAdmin: TargetKind.WebAdmin,
@ -208,7 +208,7 @@
<Loadable promise={loadRoles()}>
{#snippet children(roles)}
<div class="list-group list-group-flush mb-3">
{#each roles as role}
{#each roles as role (role.id)}
<label
for="role-{role.id}"
class="list-group-item list-group-item-action d-flex align-items-center"