0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

feat(console): add activation error for custom domain (#3994)

This commit is contained in:
Xiao Yijun 2023-06-09 10:19:01 +08:00 committed by GitHub
parent 66ba526040
commit eb4a5da9d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 3 deletions

View file

@ -21,6 +21,8 @@
.content { .content {
flex: 1; flex: 1;
overflow: hidden;
overflow-wrap: break-word;
} }
&.info { &.info {

View file

@ -0,0 +1 @@
export const customDomainSyncInterval = 10; // In seconds

View file

@ -4,3 +4,12 @@
border-top: 1px solid var(--color-divider); border-top: 1px solid var(--color-divider);
padding: _.unit(5) _.unit(6) 0; padding: _.unit(5) _.unit(6) 0;
} }
.errorNotification {
margin-bottom: _.unit(6);
.hint {
margin-top: _.unit(1);
color: var(--color-text-secondary);
}
}

View file

@ -1,5 +1,9 @@
import { type Domain, type DomainDnsRecords, type DomainDnsRecord } from '@logto/schemas'; import { type Domain, type DomainDnsRecords, type DomainDnsRecord } from '@logto/schemas';
import DynamicT from '@/components/DynamicT';
import InlineNotification from '@/components/InlineNotification';
import { customDomainSyncInterval } from '@/consts/custom-domain';
import DnsRecordsTable from './DnsRecordsTable'; import DnsRecordsTable from './DnsRecordsTable';
import Step from './Step'; import Step from './Step';
import * as styles from './index.module.scss'; import * as styles from './index.module.scss';
@ -12,7 +16,7 @@ const isSetupSslDnsRecord = ({ type, name }: DomainDnsRecord) =>
type.toUpperCase() === 'TXT' && name.includes('_acme-challenge'); type.toUpperCase() === 'TXT' && name.includes('_acme-challenge');
function ActivationProcess({ customDomain }: Props) { function ActivationProcess({ customDomain }: Props) {
const { dnsRecords, status: domainStatus } = customDomain; const { dnsRecords, status: domainStatus, errorMessage } = customDomain;
const { verifyDomainDnsRecord, setupSslDnsRecord } = dnsRecords.reduce<{ const { verifyDomainDnsRecord, setupSslDnsRecord } = dnsRecords.reduce<{
verifyDomainDnsRecord: DomainDnsRecords; verifyDomainDnsRecord: DomainDnsRecords;
@ -36,6 +40,17 @@ function ActivationProcess({ customDomain }: Props) {
return ( return (
<div className={styles.container}> <div className={styles.container}>
{errorMessage && (
<InlineNotification className={styles.errorNotification} severity="error">
{errorMessage}
<div className={styles.hint}>
<DynamicT
forKey="domain.error_hint"
interpolation={{ value: customDomainSyncInterval }}
/>
</div>
</InlineNotification>
)}
<Step <Step
step={1} step={1}
title="domain.custom.verify_domain" title="domain.custom.verify_domain"

View file

@ -4,6 +4,7 @@ import useSWR from 'swr';
import FormCard from '@/components/FormCard'; import FormCard from '@/components/FormCard';
import FormField from '@/components/FormField'; import FormField from '@/components/FormField';
import { customDomainSyncInterval } from '@/consts/custom-domain';
import useApi, { type RequestError } from '@/hooks/use-api'; import useApi, { type RequestError } from '@/hooks/use-api';
import useSwrFetcher from '@/hooks/use-swr-fetcher'; import useSwrFetcher from '@/hooks/use-swr-fetcher';
@ -16,8 +17,7 @@ function TenantDomainSettings() {
const api = useApi(); const api = useApi();
const fetcher = useSwrFetcher<Domain[]>(api); const fetcher = useSwrFetcher<Domain[]>(api);
const { data, error, mutate } = useSWR<Domain[], RequestError>('api/domains', fetcher, { const { data, error, mutate } = useSWR<Domain[], RequestError>('api/domains', fetcher, {
// Note: check the custom domain status every 10 seconds. refreshInterval: customDomainSyncInterval * 1000,
refreshInterval: 10_000,
}); });
const isLoading = !data && !error; const isLoading = !data && !error;