use enabledspecs

This commit is contained in:
Harsh Mahajan
2026-03-20 18:09:57 +05:30
parent af337fdb69
commit 1499bcbbba
2 changed files with 9 additions and 8 deletions
@@ -1,5 +1,6 @@
<script lang="ts">
import { goto, invalidate } from '$app/navigation';
import { page } from '$app/state';
import { base } from '$app/paths';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import Confirm from '$lib/components/confirm.svelte';
@@ -14,7 +15,7 @@
let error: string;
async function handleDelete() {
try {
await sdk.forProject($project.region, $project.$id).webhooks.delete({
await sdk.forProject(page.params.region, $project.$id).webhooks.delete({
webhookId: $webhook.$id
});
await invalidate(Dependencies.WEBHOOKS);
@@ -24,7 +25,7 @@
message: `${$webhook.name} has been deleted`
});
trackEvent(Submit.WebhookDelete);
await goto(`${base}/project-${$project.region}-${$project.$id}/settings/webhooks`);
await goto(`${base}/project-${page.params.region}-${$project.$id}/settings/webhooks`);
} catch (e) {
error = e.message;
trackError(e, Submit.WebhookDelete);
@@ -114,10 +114,10 @@
if (specs && specs.specifications?.length) {
const enabledSpecs = specs.specifications.filter((s) => s.enabled);
const fallbackSlug = enabledSpecs[0]?.slug ?? specs.specifications[0]?.slug;
if (!specs.specifications.some((s) => s.slug === site.buildSpecification)) {
if (!enabledSpecs.some((s) => s.slug === site.buildSpecification)) {
site.buildSpecification = fallbackSlug;
}
if (!specs.specifications.some((s) => s.slug === site.runtimeSpecification)) {
if (!enabledSpecs.some((s) => s.slug === site.runtimeSpecification)) {
site.runtimeSpecification = fallbackSlug;
}
}
@@ -133,14 +133,12 @@
}
// only allow enabled specsification for it
const enabledSpecs = specs?.specifications?.filter((s) => s.enabled) ?? [];
let specToSend = enabledSpecs.some((s) => s.slug === site.buildSpecification)
const specToSend = enabledSpecs.some((s) => s.slug === site.buildSpecification)
? site.buildSpecification
: enabledSpecs[0]?.slug;
site.buildSpecification = specToSend;
let runtimeSpecToSend = enabledSpecs.some((s) => s.slug === site.runtimeSpecification)
const runtimeSpecToSend = enabledSpecs.some((s) => s.slug === site.runtimeSpecification)
? site.runtimeSpecification
: enabledSpecs[0]?.slug;
site.runtimeSpecification = runtimeSpecToSend;
try {
await sdk.forProject(page.params.region, page.params.project).sites.update({
siteId: site.$id,
@@ -163,6 +161,8 @@
buildSpecification: specToSend || undefined,
runtimeSpecification: runtimeSpecToSend || undefined
});
site.buildSpecification = specToSend;
site.runtimeSpecification = runtimeSpecToSend;
await invalidate(Dependencies.SITE);
addNotification({
message: 'Build settings have been updated',