Skip to content

Commit 51eb476

Browse files
committed
domain: allow downgrade
1 parent 5dc1dae commit 51eb476

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/routes/(auth)/(project)/domain/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
{#each domains as it (`${it.domain}-${it.location}`)}
5959
<tr>
6060
<td>
61-
<StatusIcon status={it.verification.ssl.pending ? 'verify' : it.status} />
61+
<StatusIcon status={it.cdn && it.verification.ssl.pending ? 'verify' : it.status} />
6262
<a href={`/domain/detail?project=${project}&domain=${it.domain}`} class="nm-link">{it.domain}</a>
6363
</td>
6464
<td>

src/routes/(auth)/(project)/domain/detail/+page.svelte

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@
178178
179179
function upgradeCdn () {
180180
modal.confirm({
181-
html: `Add CDN to "${domain.domain}" ?<br><br>This action can not roll back.`,
182-
yes: 'Upgrade to Hostname',
181+
html: `Add CDN to "${domain.domain}" ?`,
182+
yes: 'Upgrade',
183183
callback: async () => {
184184
const resp = await api.invoke('domain.create', {
185185
project,
@@ -197,6 +197,28 @@
197197
}
198198
})
199199
}
200+
201+
function downgradeCdn () {
202+
modal.confirm({
203+
html: `Remove CDN from "${domain.domain}" ?`,
204+
yes: 'Downgrade',
205+
callback: async () => {
206+
const resp = await api.invoke('domain.create', {
207+
project,
208+
location: domain.location,
209+
domain: domain.domain,
210+
wildcard: domain.wildcard,
211+
cdn: false
212+
}, fetch)
213+
if (!resp.ok) {
214+
modal.error({ error: resp.error })
215+
return
216+
}
217+
await api.invalidate('domain.get')
218+
handleReload()
219+
}
220+
})
221+
}
200222
</script>
201223

202224
<div class="nm-breadcrumb">
@@ -432,8 +454,12 @@
432454
{/if}
433455
</div>
434456

435-
{#if !domain.cdn}
436-
<hr>
457+
<hr>
458+
{#if domain.cdn}
459+
<div class="_dp-f _alit-ct _fw-w">
460+
<button class="nm-button" onclick={downgradeCdn}>Remove CDN (DDoS Protection)</button>
461+
</div>
462+
{:else}
437463
<div class="_dp-f _alit-ct _fw-w">
438464
<button class="nm-button" onclick={upgradeCdn}>Add CDN (DDoS Protection)</button>
439465
</div>

0 commit comments

Comments
 (0)