added disable custom domain to project settings page

main
TZGyn 1 year ago
parent b165daddb6
commit d6aadac526
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -105,7 +105,6 @@ export const actions: Actions = {
return { message: 'Custom domain enabled' } return { message: 'Custom domain enabled' }
}, },
disable_custom_domain: async (event) => { disable_custom_domain: async (event) => {
return { message: 'Disable custom domain is not available yet' }
const userId = event.locals.user.id const userId = event.locals.user.id
const existingProject = await db.query.project.findFirst({ const existingProject = await db.query.project.findFirst({
@ -120,6 +119,14 @@ export const actions: Actions = {
return fail(400, { message: 'Project not found' }) return fail(400, { message: 'Project not found' })
} }
const deleteOldCustomDomain = await deleteCustomDomain(
existingProject.custom_domain_id,
)
if (!deleteOldCustomDomain.success) {
return { message: 'Cannot delete old custom domain' }
}
await db await db
.update(projectTable) .update(projectTable)
.set({ .set({

@ -65,7 +65,7 @@
</script> </script>
<ScrollArea> <ScrollArea>
<div class="py-4 px-10 space-y-6 max-w-2xl"> <div class="max-w-2xl space-y-6 px-10 py-4">
<div> <div>
<h3 class="text-lg font-medium">Custom Domain</h3> <h3 class="text-lg font-medium">Custom Domain</h3>
<p class="text-sm text-muted-foreground"> <p class="text-sm text-muted-foreground">
@ -76,14 +76,14 @@
<Card.Root> <Card.Root>
<Card.Header> <Card.Header>
<div class="flex gap-4 items-center"> <div class="flex items-center gap-4">
<div class=""> <div class="">
{#if data.project.domain_status === 'pending'} {#if data.project.domain_status === 'pending'}
<CircleDashedIcon class="w-8 h-8 text-warning" /> <CircleDashedIcon class="h-8 w-8 text-warning" />
{:else if data.project.domain_status === 'verified'} {:else if data.project.domain_status === 'verified'}
<CircleCheckBigIcon class="w-8 h-8 text-success" /> <CircleCheckBigIcon class="h-8 w-8 text-success" />
{:else if data.project.domain_status === 'disabled'} {:else if data.project.domain_status === 'disabled'}
<CircleXIcon class="w-8 h-8 text-destructive" /> <CircleXIcon class="h-8 w-8 text-destructive" />
{/if} {/if}
</div> </div>
<div class="flex-grow"> <div class="flex-grow">
@ -96,8 +96,8 @@
<Card.Description> <Card.Description>
<Tooltip.Root> <Tooltip.Root>
<Tooltip.Trigger class="flex gap-1 items-center"> <Tooltip.Trigger class="flex items-center gap-1">
<InfoIcon class="w-4 h-4" /> <InfoIcon class="h-4 w-4" />
{#if data.project.custom_ip} {#if data.project.custom_ip}
{data.project.custom_ip} {data.project.custom_ip}
{:else if env.PUBLIC_SHORTENER_IP} {:else if env.PUBLIC_SHORTENER_IP}
@ -145,7 +145,7 @@
Are you absolutely sure? Are you absolutely sure?
</AlertDialog.Title> </AlertDialog.Title>
<Alert.Root variant="destructive"> <Alert.Root variant="destructive">
<TriangleAlertIcon class="w-4 h-4" /> <TriangleAlertIcon class="h-4 w-4" />
<Alert.Description> <Alert.Description>
Disabling custom domain is not available yet. Disabling custom domain is not available yet.
</Alert.Description> </Alert.Description>
@ -173,38 +173,38 @@
</AlertDialog.Content> </AlertDialog.Content>
</AlertDialog.Root> </AlertDialog.Root>
{:else} {:else}
<!-- <AlertDialog.Root> --> <AlertDialog.Root>
<!-- <AlertDialog.Trigger asChild let:builder> --> <AlertDialog.Trigger asChild let:builder>
<!-- <Button builders={[builder]}> --> <Button builders={[builder]}>
<!-- Disable Custom Domain --> Disable Custom Domain
<!-- </Button> --> </Button>
<!-- </AlertDialog.Trigger> --> </AlertDialog.Trigger>
<!-- <AlertDialog.Content> --> <AlertDialog.Content>
<!-- <AlertDialog.Header> --> <AlertDialog.Header>
<!-- <AlertDialog.Title> --> <AlertDialog.Title>
<!-- Are you absolutely sure? --> Are you absolutely sure?
<!-- </AlertDialog.Title> --> </AlertDialog.Title>
<!-- <AlertDialog.Description> --> <AlertDialog.Description>
<!-- Your custom domain setting will remain. --> Your custom domain setting will remain.
<!-- </AlertDialog.Description> --> </AlertDialog.Description>
<!-- </AlertDialog.Header> --> </AlertDialog.Header>
<!-- <AlertDialog.Footer> --> <AlertDialog.Footer>
<!-- <AlertDialog.Cancel>Cancel</AlertDialog.Cancel> --> <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
<!-- <AlertDialog.Action --> <AlertDialog.Action
<!-- on:click={async () => { --> on:click={async () => {
<!-- await fetch('?/disable_custom_domain', { --> await fetch('?/disable_custom_domain', {
<!-- method: 'POST', --> method: 'POST',
<!-- headers: { --> headers: {
<!-- 'Content-Type': 'multipart/form-data', --> 'Content-Type': 'multipart/form-data',
<!-- }, --> },
<!-- }) --> })
<!-- await invalidateAll() --> await invalidateAll()
<!-- }}> --> }}>
<!-- Continue --> Continue
<!-- </AlertDialog.Action> --> </AlertDialog.Action>
<!-- </AlertDialog.Footer> --> </AlertDialog.Footer>
<!-- </AlertDialog.Content> --> </AlertDialog.Content>
<!-- </AlertDialog.Root> --> </AlertDialog.Root>
{/if} {/if}
</div> </div>
</div> </div>
@ -235,10 +235,10 @@
</div> </div>
</Form.Control> </Form.Control>
<Form.Description <Form.Description
class="flex gap-2 justify-between items-center"> class="flex items-center justify-between gap-2">
<Tooltip.Root> <Tooltip.Root>
<Tooltip.Trigger class="flex gap-2 items-center"> <Tooltip.Trigger class="flex items-center gap-2">
<InfoIcon class="w-4 h-4" /> <InfoIcon class="h-4 w-4" />
Update Project Domain (leave blank to use default) Update Project Domain (leave blank to use default)
</Tooltip.Trigger> </Tooltip.Trigger>
<Tooltip.Content> <Tooltip.Content>
@ -269,7 +269,7 @@
<h3 class="text-lg font-medium">Danger Zone</h3> <h3 class="text-lg font-medium">Danger Zone</h3>
</div> </div>
<div class="rounded-lg border border-destructive"> <div class="rounded-lg border border-destructive">
<div class="flex justify-between items-center p-4"> <div class="flex items-center justify-between p-4">
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<span class="text-sm">Delete Project</span> <span class="text-sm">Delete Project</span>
<span class="text-xs text-muted-foreground"> <span class="text-xs text-muted-foreground">
@ -302,7 +302,7 @@
{...attrs} {...attrs}
bind:value={$formData.deleteShorteners} bind:value={$formData.deleteShorteners}
type="hidden" /> type="hidden" />
<div class="flex gap-2 items-center"> <div class="flex items-center gap-2">
<Checkbox <Checkbox
{...attrs} {...attrs}
id="deleteShorteners" id="deleteShorteners"
@ -314,7 +314,7 @@
</Form.Control> </Form.Control>
<Form.FieldErrors /> <Form.FieldErrors />
</Form.Field> </Form.Field>
<div class="flex gap-2 justify-end"> <div class="flex justify-end gap-2">
<Button <Button
variant="outline" variant="outline"
on:click={() => (deleteDialogOpen = false)}> on:click={() => (deleteDialogOpen = false)}>

Loading…
Cancel
Save