|
23 | 23 | import { page } from '$app/state';
|
24 | 24 | import Card from '../card.svelte';
|
25 | 25 | import SkeletonRepoList from './skeletonRepoList.svelte';
|
26 |
| - import { untrack } from 'svelte'; |
| 26 | + import { onMount, untrack } from 'svelte'; |
27 | 27 |
|
28 | 28 | let {
|
29 | 29 | action = $bindable('select'),
|
|
46 | 46 | let search = $state('');
|
47 | 47 | let selectedInstallation = $state(null);
|
48 | 48 | let isLoadingRepositories = $state(null);
|
| 49 | + let installationsMap = $state(null); |
| 50 | +
|
| 51 | + onMount(() => { |
| 52 | + loadInstallations(); |
| 53 | + }); |
49 | 54 |
|
50 | 55 | async function loadInstallations() {
|
51 | 56 | if (installationList) {
|
|
59 | 64 | )
|
60 | 65 | );
|
61 | 66 | }
|
62 |
| - return installationList.installations; |
| 67 | + installationsMap = installationList.installations; |
63 | 68 | } else {
|
64 | 69 | const { installations } = await sdk
|
65 | 70 | .forProject(page.params.region, page.params.project)
|
|
70 | 75 | }
|
71 | 76 | installation.set(installations.find((entry) => entry.$id === selectedInstallation));
|
72 | 77 | }
|
73 |
| - return installations; |
| 78 | + installationsMap = installations; |
74 | 79 | }
|
75 | 80 | }
|
76 | 81 |
|
|
123 | 128 | {#if hasInstallations}
|
124 | 129 | <Layout.Stack>
|
125 | 130 | <Layout.Stack gap="s">
|
126 |
| - {#await loadInstallations()} |
| 131 | + {#if !installationsMap} |
127 | 132 | <Layout.Stack direction="row">
|
128 | 133 | <InputSelect
|
129 | 134 | disabled
|
|
137 | 142 | value={null} />
|
138 | 143 | <InputSearch placeholder="Search repositories" disabled />
|
139 | 144 | </Layout.Stack>
|
140 |
| - {:then installations} |
| 145 | + {:else} |
141 | 146 | <Layout.Stack direction={$isSmallViewport ? 'column' : 'row'}>
|
142 | 147 | <InputSelect
|
143 | 148 | id="installation"
|
144 | 149 | options={[
|
145 |
| - ...installations.map((entry) => { |
| 150 | + ...installationsMap.map((entry) => { |
146 | 151 | return {
|
147 | 152 | label: entry.organization,
|
148 | 153 | value: entry.$id
|
|
160 | 165 | }
|
161 | 166 | search = '';
|
162 | 167 | installation.set(
|
163 |
| - installations.find((entry) => entry.$id === selectedInstallation) |
| 168 | + installationsMap.find((entry) => entry.$id === selectedInstallation) |
164 | 169 | );
|
165 | 170 |
|
166 | 171 | isLoadingRepositories = true;
|
|
174 | 179 | bind:value={search}
|
175 | 180 | disabled={!search && !$repositories?.repositories?.length} />
|
176 | 181 | </Layout.Stack>
|
177 |
| - {/await} |
| 182 | + {/if} |
178 | 183 | </Layout.Stack>
|
179 | 184 | {#if selectedInstallation}
|
180 | 185 | <!-- manual installation change -->
|
|
0 commit comments