Skip to content

Commit d65f170

Browse files
committed
UI/UX: error messages, hover states, light cleanup
error: uses the error thrown by the domains resolver hover: clipboards and verification time are shown by default instead of being hidden by hover cleanup: clearer dnsRecord subcomponent
1 parent 06608b1 commit d65f170

File tree

3 files changed

+70
-65
lines changed

3 files changed

+70
-65
lines changed

api/resolvers/domain.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export default {
4444
verification: {
4545
dns: {
4646
state: 'PENDING',
47-
cname: 'stacker.news',
48-
txt: randomBytes(32).toString('base64')
47+
cname: 'stacker.news'
4948
},
5049
ssl: {
5150
state: 'WAITING',
@@ -63,6 +62,13 @@ export default {
6362
},
6463
create: {
6564
...initializeDomain,
65+
verification: {
66+
...initializeDomain.verification,
67+
dns: {
68+
...initializeDomain.verification.dns,
69+
txt: randomBytes(32).toString('base64')
70+
}
71+
},
6672
sub: {
6773
connect: { name: subName }
6874
}

components/item.module.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,6 @@ a.link:visited {
259259
fill: var(--theme-grey);
260260
width: 1rem;
261261
height: 1rem;
262-
opacity: 0;
263-
transition: opacity 0.1s ease, fill 0.1s ease;
264-
}
265-
266-
.record:hover .clipboard {
267-
opacity: 1;
268262
}
269263

270264
.clipboard:hover {

components/territory-domains.js

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Badge } from 'react-bootstrap'
22
import { Form, Input, SubmitButton, CopyButton } from './form'
33
import { useMutation, useQuery } from '@apollo/client'
44
import { customDomainSchema } from '@/lib/validate'
5-
import ActionTooltip from './action-tooltip'
65
import { useToast } from '@/components/toast'
76
import { NORMAL_POLL_INTERVAL, SSR } from '@/lib/constants'
87
import { GET_CUSTOM_DOMAIN, SET_CUSTOM_DOMAIN } from '@/fragments/domains'
@@ -97,24 +96,27 @@ const DomainLabel = ({ customDomain, polling }) => {
9796
<div className='d-flex align-items-center gap-2'>
9897
<span>custom domain</span>
9998
{domain && (
100-
<ActionTooltip overlayText={lastVerifiedAt ? new Date(lastVerifiedAt).toLocaleString() : ''}>
101-
<div className='d-flex align-items-center gap-2'>
102-
{status !== 'HOLD'
103-
? (
104-
<>
105-
{getStatusBadge(verification?.dns?.state)}
106-
{getSSLStatusBadge(verification?.ssl?.state)}
107-
</>
108-
)
109-
: (<Badge bg='secondary'>HOLD</Badge>)}
110-
{status === 'HOLD' && (
111-
<SubmitButton variant='link' className='p-0'>
112-
<RefreshLine className={styles.refresh} style={{ width: '1rem', height: '1rem' }} />
113-
</SubmitButton>
114-
)}
115-
{polling && <Moon className='spin fill-grey' style={{ width: '1rem', height: '1rem' }} />}
116-
</div>
117-
</ActionTooltip>
99+
<div className='d-flex align-items-center gap-2'>
100+
{status !== 'HOLD'
101+
? (
102+
<>
103+
{getStatusBadge(verification?.dns?.state)}
104+
{getSSLStatusBadge(verification?.ssl?.state)}
105+
</>
106+
)
107+
: (<Badge bg='secondary'>HOLD</Badge>)}
108+
{status === 'HOLD' && (
109+
<SubmitButton variant='link' className='p-0'>
110+
<RefreshLine className={styles.refresh} style={{ width: '1rem', height: '1rem' }} />
111+
</SubmitButton>
112+
)}
113+
{polling && <Moon className='spin fill-grey' style={{ width: '1rem', height: '1rem' }} />}
114+
</div>
115+
)}
116+
{lastVerifiedAt && status !== 'ACTIVE' && (
117+
<span className='text-muted'>
118+
<small>last verified {new Date(lastVerifiedAt).toLocaleString()}</small>
119+
</span>
118120
)}
119121
</div>
120122
)
@@ -123,40 +125,42 @@ const DomainLabel = ({ customDomain, polling }) => {
123125
const DomainGuidelines = ({ customDomain }) => {
124126
const { domain, verification } = customDomain || {}
125127

126-
const dnsRecord = (host, value) => (
127-
<div className='d-flex align-items-center gap-2'>
128-
<span className={`${styles.record}`}>
129-
<small className='fw-bold text-muted d-flex align-items-center gap-1 position-relative'>
130-
host
131-
<CopyButton
132-
value={host}
133-
append={
134-
<ClipboardLine
135-
className={`${styles.clipboard}`}
136-
style={{ width: '1rem', height: '1rem' }}
137-
/>
138-
}
139-
/>
140-
</small>
141-
<pre>{host}</pre>
142-
</span>
143-
<span className={`${styles.record}`}>
144-
<small className='fw-bold text-muted d-flex align-items-center gap-1 position-relative'>
145-
value
146-
<CopyButton
147-
value={value}
148-
append={
149-
<ClipboardLine
150-
className={`${styles.clipboard}`}
151-
style={{ width: '1rem', height: '1rem' }}
152-
/>
153-
}
154-
/>
155-
</small>
156-
<pre>{value}</pre>
157-
</span>
158-
</div>
159-
)
128+
const dnsRecord = ({ host, value }) => {
129+
return (
130+
<div className='d-flex align-items-center gap-2'>
131+
<span className={`${styles.record}`}>
132+
<small className='fw-bold text-muted d-flex align-items-center gap-1 position-relative'>
133+
host
134+
<CopyButton
135+
value={host}
136+
append={
137+
<ClipboardLine
138+
className={`${styles.clipboard}`}
139+
style={{ width: '1rem', height: '1rem' }}
140+
/>
141+
}
142+
/>
143+
</small>
144+
<pre>{host}</pre>
145+
</span>
146+
<span className={`${styles.record}`}>
147+
<small className='fw-bold text-muted d-flex align-items-center gap-1 position-relative'>
148+
value
149+
<CopyButton
150+
value={value}
151+
append={
152+
<ClipboardLine
153+
className={`${styles.clipboard}`}
154+
style={{ width: '1rem', height: '1rem' }}
155+
/>
156+
}
157+
/>
158+
</small>
159+
<pre>{value}</pre>
160+
</span>
161+
</div>
162+
)
163+
}
160164

161165
return (
162166
<div className='d-flex'>
@@ -165,18 +169,18 @@ const DomainGuidelines = ({ customDomain }) => {
165169
<h5>Step 1: Verify your domain</h5>
166170
<p>Add the following DNS records to verify ownership of your domain:</p>
167171
<h6>CNAME</h6>
168-
{dnsRecord(domain || 'www', verification?.dns?.cname)}
172+
{dnsRecord({ host: domain || 'www', value: verification?.dns?.cname })}
169173
<hr />
170174
<h6>TXT</h6>
171-
{dnsRecord(`_snverify.${domain}`, verification?.dns?.txt)}
175+
{dnsRecord({ host: `_snverify.${domain}`, value: verification?.dns?.txt })}
172176
</div>
173177
)}
174178
{verification?.ssl?.state === 'PENDING' && (
175179
<div className=''>
176180
<h5>Step 2: Prepare your domain for SSL</h5>
177181
<p>We issued an SSL certificate for your domain. To validate it, add the following CNAME record:</p>
178182
<h6>CNAME</h6>
179-
{dnsRecord(verification?.ssl?.cname || 'waiting for SSL certificate', verification?.ssl?.value || 'waiting for SSL certificate')}
183+
{dnsRecord({ host: verification?.ssl?.cname || 'waiting for SSL certificate', value: verification?.ssl?.value || 'waiting for SSL certificate' })}
180184
</div>
181185
)}
182186
</div>
@@ -220,7 +224,7 @@ export default function CustomDomainForm ({ sub }) {
220224
toaster.success('domain removed successfully')
221225
}
222226
} catch (error) {
223-
toaster.danger('failed to update domain', { error })
227+
toaster.danger(error.message)
224228
}
225229
}
226230

@@ -234,6 +238,7 @@ export default function CustomDomainForm ({ sub }) {
234238
>
235239
<div className='d-flex align-items-center gap-2'>
236240
<Input
241+
groupClassName='w-100'
237242
label={<DomainLabel customDomain={data?.customDomain} polling={polling} />}
238243
name='domain'
239244
placeholder='www.example.com'

0 commit comments

Comments
 (0)