From 4e04accf3a2b579edf6c8acbeb3fcb20a92d54bb Mon Sep 17 00:00:00 2001 From: axolotle Date: Sun, 19 Sep 2021 03:45:36 +0200 Subject: [PATCH] add conditional display of auto config or manual config --- app/src/i18n/locales/en.json | 3 ++- app/src/views/domain/DomainDns.vue | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index c5135659..7fedf45f 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -161,7 +161,8 @@ "domain_delete_forbidden_desc": "You cannot remove '{domain}' since it's the default domain, you need to choose another domain (or add a new one) and set it as the default domain to be able to remove this one.", "domain_dns_config": "DNS configuration", "domain_dns_longdesc": "View DNS configuration", - "domain_dns_push_failed_to_authenticate": "Failed to authenticate on registrar's API. Most probably the credentials are incorrect? (Error: {error})", + "domain_dns_push_failed_to_authenticate": "Failed to authenticate on registrar's API. Most probably the credentials are incorrect? (Error: {error})", + "domain_dns_push_managed_in_parent_domain": "The automatic DNS records feature is managed in the parent domain {parent_domain}.", "domain_dns_push_not_applicable": "The automatic DNS records feature is not applicable to domain {domain},
You should manually configure your DNS records following the documentation and the suggested configuration below.", "domain_name": "Domain name", "domain_visit": "Visit", diff --git a/app/src/views/domain/DomainDns.vue b/app/src/views/domain/DomainDns.vue index f3b53a09..1db0c743 100644 --- a/app/src/views/domain/DomainDns.vue +++ b/app/src/views/domain/DomainDns.vue @@ -3,7 +3,7 @@ :queries="queries" @queries-response="onQueriesResponse" :loading="loading" skeleton="card-info-skeleton" > - + @@ -64,7 +64,10 @@ - + {{ $t('domain_dns_conf_is_just_a_recommendation') }} @@ -91,6 +94,8 @@ export default { ['GET', `domains/${this.name}/dns/suggest`] ], loading: true, + showAutoConfigCard: true, + showManualConfigCard: false, dnsConfig: '', dnsChanges: undefined, dnsErrors: undefined, @@ -123,7 +128,7 @@ export default { ] categories.forEach(category => { const records = dnsChanges[category.action] - if (records.length > 0) { + if (records && records.length > 0) { const longestName = getLongest(records, 'name') const longestType = getLongest(records, 'type') records.forEach(record => { @@ -140,9 +145,17 @@ export default { this.loading = false }).catch(err => { if (err.name !== 'APIBadRequestError') throw err - let message = this.$t(err.data.error_key, err.data) - message = message !== err.data.error_key ? message : err.message - this.dnsErrors = [{ icon: 'ban', variant: 'danger', message }] + const key = err.data.error_key + if (key === 'domain_dns_push_managed_in_parent_domain') { + const message = this.$t(key, err.data) + this.dnsErrors = [{ icon: 'info', variant: 'info', message }] + } else if (key === 'domain_dns_push_failed_to_authenticate') { + const message = this.$t(key, err.data) + this.dnsErrors = [{ icon: 'ban', variant: 'danger', message }] + } else { + this.showManualConfigCard = true + this.showAutoConfigCard = false + } this.loading = false }) },