Skip to content

Commit

Permalink
feat: add confirm dialog for cert renewal toggle #30
Browse files Browse the repository at this point in the history
Adds a confirmation popup when toggling Let's Encrypt auto-renewal.
  • Loading branch information
0xJacky committed Apr 8, 2023
1 parent 69cdef4 commit b7560dd
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions frontend/src/views/domain/cert/IssueCert.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import {useGettext} from 'vue3-gettext'
import {computed, nextTick, ref, watch} from 'vue'
import {message} from 'ant-design-vue'
import {message, Modal} from 'ant-design-vue'
import domain from '@/api/domain'
import websocket from '@/lib/websocket'
import Template from '@/views/template/Template.vue'
Expand All @@ -15,6 +15,29 @@ const emit = defineEmits(['changeEnabled', 'callback', 'update:enabled'])
const issuing_cert = ref(false)
const modalVisible = ref(false)
const enabled = computed({
get() {
return props.enabled
},
set(value) {
emit('update:enabled', value)
}
})
function confirm() {
Modal.confirm({
title: enabled.value ? $gettext('Do you want to disable auto-cert renewal?') :
$gettext('Do you want to enable auto-cert renewal?'),
mask: false,
centered: true,
onOk() {
enabled.value = !enabled.value
}
})
}
watch(enabled, onchange)
function onchange(r: boolean) {
emit('changeEnabled', r)
change_auto_cert(r)
Expand Down Expand Up @@ -135,15 +158,6 @@ const name = computed(() => {
return props.directivesMap['server_name'][0].params.trim()
})
const enabled = computed({
get() {
return props.enabled
},
set(value) {
emit('update:enabled', value)
}
})
watch(no_server_name, () => {
emit('update:enabled', false)
onchange(false)
Expand Down Expand Up @@ -180,8 +194,8 @@ const modalClosable = ref(false)
<a-form-item :label="$gettext('Encrypt website with Let\'s Encrypt')">
<a-switch
:loading="issuing_cert"
v-model:checked="enabled"
@change="onchange"
:checked="enabled"
@change="confirm"
:disabled="no_server_name"
/>
<a-alert
Expand Down

0 comments on commit b7560dd

Please sign in to comment.