Skip to content

Commit 353432f

Browse files
fix push button disabled when adding the first instance
1 parent 102c86f commit 353432f

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

frontend/src/components/Instances/InstancesPushModal.svelte

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,19 @@ with "Instance Name" for cross platform data share.
3939
let selectedInstanceId = $state<number | null>(null);
4040
let entityType = $state<EntityType>('experiment');
4141
42-
async function refreshInstances(): Promise<void> {
42+
async function refreshInstances(previousIds?: Set<number>): Promise<void> {
4343
loading = true;
4444
try {
4545
instances = await ListElabftwInstances(profileUuid);
46+
if (previousIds) {
47+
const created = instances.find(instance => !previousIds.has(instance.id));
48+
if (created) {
49+
selectedInstanceId = created.id;
50+
return;
51+
}
52+
}
53+
if (selectedInstanceId !== null && instances.some(instance => instance.id === selectedInstanceId)) return;
54+
selectedInstanceId = instances.length === 1 ? instances[0].id : null;
4655
} catch (e: unknown) {
4756
onAlert({type: 'error', message: errorMessage(e)});
4857
} finally {
@@ -51,10 +60,7 @@ with "Instance Name" for cross platform data share.
5160
}
5261
5362
async function createInstanceFromModal(): Promise<void> {
54-
const previousIds = new Set(
55-
instances.map(instance => instance.id),
56-
);
57-
63+
const previousIds = new Set(instances.map(instance => instance.id));
5864
await refreshInstances(previousIds);
5965
showCreateForm = false;
6066
}
@@ -101,8 +107,8 @@ with "Instance Name" for cross platform data share.
101107
<div class='grid gap-1'>
102108
{#if instances.length === 1}
103109
<div>
104-
<span class='description'>Instance</span>
105-
<p>{instances[0].siteUrl}</p>
110+
<h1>Instance</h1>
111+
<p class='text-white'>{instances[0].siteUrl}</p>
106112
</div>
107113
{:else}
108114
<div>

0 commit comments

Comments
 (0)