Skip to content

Commit f13a681

Browse files
authored
Merge pull request #2553 from appwrite/fix-site-settings-ux
Fix: UX of site settings
2 parents c5fd02a + 7cd90c2 commit f13a681

File tree

2 files changed

+53
-20
lines changed

2 files changed

+53
-20
lines changed

src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/store.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,25 @@ export const adapterDataList = [
6969
{
7070
framework: 'nextjs',
7171
ssr: {
72-
desc: "Ensure you don't set $ in $ file.",
73-
code: ['output', 'next.config.js'],
72+
desc: 'Set $ in $ file.',
73+
code: ["output: 'standalone'", 'next.config.js'],
7474
url: 'https://nextjs.org/docs/pages/building-your-application/deploying'
7575
},
7676
static: {
77-
desc: 'Set $ in $ file',
77+
desc: 'Set $ in $ file.',
7878
code: ["output: 'export'", 'next.config.js'],
7979
url: 'https://nextjs.org/docs/pages/building-your-application/deploying/static-exports'
8080
}
8181
},
8282
{
8383
framework: 'analog',
8484
ssr: {
85-
desc: 'Set $ in $ plugin in $',
85+
desc: 'Set $ in $ plugin in $.',
8686
code: ['ssr: true', 'analog', 'vite.config.ts'],
8787
url: 'https://analogjs.org/docs/features/server/server-side-rendering'
8888
},
8989
static: {
90-
desc: 'Set $ in $ plugin in $',
90+
desc: 'Set $ in $ plugin in $.',
9191
code: ['static: true', 'analog', 'vite.config.ts'],
9292
url: 'https://analogjs.org/docs/features/server/static-site-generation'
9393
}

src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateBuildSettings.svelte

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,34 @@
3636
frameworks.find((framework) => framework.key === site.framework)
3737
);
3838
let showFallback = $derived(adapter === Adapter.Static);
39-
let hasChanges = $derived(
39+
40+
let isUntouched = $derived(
4041
installCommand === site?.installCommand &&
4142
buildCommand === site?.buildCommand &&
4243
outputDirectory === site?.outputDirectory &&
4344
selectedFramework?.key === site?.framework &&
44-
fallback === (site?.fallbackFile || undefined) &&
45-
adapter === site?.adapter
45+
(fallback ?? '') === (site?.fallbackFile ?? '') &&
46+
(adapter ?? '') === (site?.adapter ?? '')
4647
);
4748
let frameworkAdapterData = $derived(
4849
selectedFramework.adapters.find((a) => a.key === adapter) ?? selectedFramework.adapters[0]
4950
);
5051
52+
$effect(() => {
53+
if (adapter) {
54+
const data = selectedFramework.adapters.find((a) => a.key === adapter);
55+
if (data) {
56+
installCommand = data.installCommand;
57+
buildCommand = data.buildCommand;
58+
outputDirectory = data.outputDirectory;
59+
fallback = data.fallbackFile;
60+
}
61+
}
62+
});
63+
5164
$effect(() => {
5265
if (selectedFramework?.key !== site.framework) {
53-
//Update adapter
66+
// Update adapter
5467
const singleAdapter = selectedFramework?.adapters?.length <= 1;
5568
if (singleAdapter) {
5669
const hasSSR = selectedFramework?.adapters?.some((a) => a?.key === Adapter.Ssr);
@@ -65,11 +78,13 @@
6578
}
6679
6780
//Update values
68-
const data = selectedFramework.adapters.find((a) => a.key === adapter);
81+
const data =
82+
selectedFramework.adapters.find((a) => a.key === adapter) ??
83+
selectedFramework.adapters[0];
6984
installCommand = data.installCommand;
7085
buildCommand = data.buildCommand;
7186
outputDirectory = data.outputDirectory;
72-
adapter = selectedFramework.adapters[0].key as Adapter;
87+
adapter = data.key as Adapter;
7388
fallback = data.fallbackFile;
7489
} else {
7590
adapter = site.adapter as Adapter;
@@ -157,11 +172,11 @@
157172
const data = selectedFramework.adapters.find((a) => a.key === adapter);
158173
159174
if (type === 'installCommand') {
160-
installCommand = site?.installCommand ?? data.installCommand;
175+
installCommand = data.installCommand;
161176
} else if (type === 'buildCommand') {
162-
buildCommand = site?.buildCommand ?? data.buildCommand;
177+
buildCommand = data.buildCommand;
163178
} else if (type === 'outputDirectory') {
164-
outputDirectory = site?.outputDirectory ?? data.outputDirectory;
179+
outputDirectory = data.outputDirectory;
165180
}
166181
}
167182
</script>
@@ -216,7 +231,8 @@
216231
{adapterData.ssr.desc}
217232
{/if}
218233
{#if adapterData?.ssr?.url}
219-
<Link external href={adapterData.ssr.url}>Learn more</Link>
234+
<Link variant="muted" size="m" external href={adapterData.ssr.url}
235+
>Learn more</Link>
220236
{/if}
221237
</Card.Selector>
222238
<Card.Selector
@@ -243,7 +259,11 @@
243259
{adapterData.static.desc}
244260
{/if}
245261
{#if adapterData?.static?.url}
246-
<Link external href={adapterData.static.url}>Learn more</Link>
262+
<Link
263+
variant="muted"
264+
size="m"
265+
external
266+
href={adapterData.static.url}>Learn more</Link>
247267
{/if}
248268
</Card.Selector>
249269
</Layout.Grid>
@@ -258,7 +278,11 @@
258278
placeholder={frameworkAdapterData?.installCommand ||
259279
'Enter install command'} />
260280

261-
<Button secondary size="s" on:click={() => reset('installCommand')}>
281+
<Button
282+
secondary
283+
size="s"
284+
on:click={() => reset('installCommand')}
285+
disabled={installCommand === frameworkAdapterData?.installCommand}>
262286
Reset
263287
</Button>
264288
</Layout.Stack>
@@ -269,7 +293,11 @@
269293
bind:value={buildCommand}
270294
placeholder={frameworkAdapterData?.buildCommand ||
271295
'Enter build command'} />
272-
<Button secondary size="s" on:click={() => reset('buildCommand')}>
296+
<Button
297+
secondary
298+
size="s"
299+
disabled={buildCommand === frameworkAdapterData?.buildCommand}
300+
on:click={() => reset('buildCommand')}>
273301
Reset
274302
</Button>
275303
</Layout.Stack>
@@ -280,7 +308,12 @@
280308
bind:value={outputDirectory}
281309
placeholder={frameworkAdapterData?.outputDirectory ||
282310
'Enter output directory'} />
283-
<Button secondary size="s" on:click={() => reset('outputDirectory')}>
311+
<Button
312+
secondary
313+
size="s"
314+
disabled={(outputDirectory ?? '') ===
315+
(frameworkAdapterData?.outputDirectory ?? '')}
316+
on:click={() => reset('outputDirectory')}>
284317
Reset
285318
</Button>
286319
</Layout.Stack>
@@ -305,7 +338,7 @@
305338
</svelte:fragment>
306339

307340
<svelte:fragment slot="actions">
308-
<Button disabled={hasChanges} submit>Update</Button>
341+
<Button disabled={isUntouched} submit>Update</Button>
309342
</svelte:fragment>
310343
</CardGrid>
311344
</Form>

0 commit comments

Comments
 (0)