Skip to content

Commit 4167528

Browse files
committed
fix: added resource limits validation to show only available resouces
1 parent 21bee30 commit 4167528

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,33 @@
8282
}
8383
});
8484
85+
$effect(() => {
86+
if (selectedFramework) {
87+
if (!selectedFramework.adapters.some((a) => a.key === adapter)) {
88+
adapter = selectedFramework.adapters[0].key as Adapter;
89+
site.adapter = adapter;
90+
}
91+
if (specs && specs.specifications?.length) {
92+
if (!specs.specifications.some((s) => s.slug === site.specification)) {
93+
site.specification = specs.specifications[0].slug;
94+
}
95+
}
96+
}
97+
});
98+
8599
async function update() {
86100
let adptr = selectedFramework.adapters.find((a) => a.key === adapter);
87101
if (!adptr?.key && selectedFramework.adapters?.length) {
88102
adapter = selectedFramework.adapters[0].key as Adapter;
89103
adptr = selectedFramework.adapters[0];
104+
site.adapter = adapter;
90105
}
91-
let specToSend = site?.specification;
92-
if (!specToSend && specs && specs.specifications?.length) {
93-
specToSend = specs.specifications[0].slug;
94-
site.specification = specToSend;
95-
}
96-
if (
97-
specs &&
98-
specs.specifications?.length &&
99-
!specs.specifications.some((s) => s.slug === specToSend)
100-
) {
101-
specToSend = specs.specifications[0].slug;
102-
site.specification = specToSend;
103-
}
106+
// only allow enabled specsification for it
107+
const enabledSpecs = specs?.specifications?.filter((s) => s.enabled) ?? [];
108+
let specToSend = enabledSpecs.some((s) => s.slug === site.specification)
109+
? site.specification
110+
: enabledSpecs[0]?.slug;
111+
site.specification = specToSend;
104112
try {
105113
await sdk
106114
.forProject(page.params.region, page.params.project)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
value: spec.slug,
6666
disabled: !spec.enabled
6767
}));
68+
69+
$: {
70+
const enabledSpecs = specs?.specifications?.filter((s) => s.enabled) ?? [];
71+
if (!enabledSpecs.some((s) => s.slug === specification)) {
72+
specification = enabledSpecs[0]?.slug;
73+
site.specification = specification;
74+
}
75+
}
6876
</script>
6977

7078
<Form onSubmit={updateLogging}>

0 commit comments

Comments
 (0)