|
82 | 82 | }
|
83 | 83 | });
|
84 | 84 |
|
| 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 | +
|
85 | 99 | async function update() {
|
86 | 100 | let adptr = selectedFramework.adapters.find((a) => a.key === adapter);
|
87 | 101 | if (!adptr?.key && selectedFramework.adapters?.length) {
|
88 | 102 | adapter = selectedFramework.adapters[0].key as Adapter;
|
89 | 103 | adptr = selectedFramework.adapters[0];
|
| 104 | + site.adapter = adapter; |
90 | 105 | }
|
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; |
104 | 112 | try {
|
105 | 113 | await sdk
|
106 | 114 | .forProject(page.params.region, page.params.project)
|
|
0 commit comments