Skip to content

Commit

Permalink
Merge pull request #581 from johnduprey/react-dev
Browse files Browse the repository at this point in the history
Individual Domain
  • Loading branch information
KelvinTegelaar authored Jan 13, 2022
2 parents cb06484 + ce2275a commit 795d6ef
Showing 1 changed file with 20 additions and 102 deletions.
122 changes: 20 additions & 102 deletions src/views/tenant/standards/IndividualDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Form, Field } from 'react-final-form'
import { useSearchParams } from 'react-router-dom'
import { useLazyListDomainTestsQuery, useListDomainTestsQuery } from '../../../store/api/domains'
import StatusIcon from 'src/components/cipp/StatusIcon'
import CippCodeBlock from 'src/components/cipp/CippCodeBlock'
import CippOffcanvas from 'src/components/cipp/CippOffcanvas'
import {
CAlert,
CButton,
CCallout,
CCard,
Expand All @@ -17,7 +17,6 @@ import {
CForm,
CFormLabel,
CFormInput,
CFormTextarea,
CRow,
CCardTitle,
CListGroup,
Expand All @@ -41,7 +40,6 @@ import {
faExclamationTriangle,
faExpandAlt,
faTimesCircle,
faCopy,
faExternalLinkAlt,
} from '@fortawesome/free-solid-svg-icons'

Expand All @@ -53,7 +51,6 @@ const IconWarning = () => (
<FontAwesomeIcon icon={faExclamationTriangle} className="text-warning mx-2" />
)
const IconExternalLink = () => <FontAwesomeIcon icon={faExternalLinkAlt} className="me-2" />
const IconCopy = () => <FontAwesomeIcon icon={faCopy} />

const domainCheckProps = {
readOnly: PropTypes.bool,
Expand Down Expand Up @@ -233,25 +230,6 @@ const SPFResultsCard = ({ domain }) => {
const textareaRef = useRef(null)
let record = data?.SPFResults?.Record

function copyToClipboard(e) {
textareaRef.current.select()
document.execCommand('copy')
//e.target.focus()
window.getSelection().removeAllRanges()
setCopyAlertVisible()
window.setTimeout(() => {
setCopyAlertVisible(false)
}, 2000)
}

const textareaStyle = {
overflow: 'hidden',
resize: 'none',
paddingRight: '40px',
}

const [copyAlertVisible, setCopyAlertVisible] = useState(false)

useEffect(() => {
if (textareaRef && textareaRef.current) {
textareaRef.current.style.height = '0px'
Expand All @@ -262,26 +240,7 @@ const SPFResultsCard = ({ domain }) => {
return (
<ResultsCard data={data} type="SPF">
{record && (
<div style={{ position: 'relative' }}>
<CButton
onClick={copyToClipboard}
style={{ position: 'absolute', top: '4px', right: '4px' }}
size="sm"
color="light"
>
<IconCopy />
</CButton>
<CFormTextarea
style={textareaStyle}
ref={textareaRef}
className="bg-secondary text-white mb-2"
value={record}
readOnly
/>
<CAlert visible={copyAlertVisible} color="info">
Copied!
</CAlert>
</div>
<CippCodeBlock language="text" code={record} showLineNumbers={false} wrapLongLines={true} />
)}
</ResultsCard>
)
Expand Down Expand Up @@ -324,7 +283,7 @@ const MXResultsCard = ({ domain }) => {
title="Mail Provider Info"
>
{records.length > 0 && (
<div>
<>
<COffcanvasTitle>MX Records</COffcanvasTitle>
<CTable striped small>
<CTableHead>
Expand All @@ -342,7 +301,7 @@ const MXResultsCard = ({ domain }) => {
))}
</CTableBody>
</CTable>
</div>
</>
)}
<COffcanvasTitle>Documentation</COffcanvasTitle>
<CListGroup>
Expand Down Expand Up @@ -384,57 +343,11 @@ MXResultsCard.propTypes = sharedProps
const DMARCResultsCard = ({ domain }) => {
const { data } = useListDomainTestsQuery({ domain })
let record = data?.DMARCResults?.Record
const textareaRef = useRef(null)

function copyToClipboard(e) {
textareaRef.current.select()
document.execCommand('copy')
//e.target.focus()
window.getSelection().removeAllRanges()
setCopyAlertVisible()
window.setTimeout(() => {
setCopyAlertVisible(false)
}, 2000)
}
const [copyAlertVisible, setCopyAlertVisible] = useState(false)

const textareaStyle = {
overflow: 'hidden',
resize: 'none',
paddingRight: '40px',
}

useEffect(() => {
if (textareaRef && textareaRef.current) {
textareaRef.current.style.height = '0px'
const scrollHeight = textareaRef.current.scrollHeight
textareaRef.current.style.height = scrollHeight + 'px'
}
}, [record])

return (
<ResultsCard data={data} type="DMARC">
{record && (
<div style={{ position: 'relative' }}>
<CButton
onClick={copyToClipboard}
style={{ position: 'absolute', top: '4px', right: '4px' }}
size="sm"
color="light"
>
<IconCopy />
</CButton>
<CFormTextarea
style={textareaStyle}
ref={textareaRef}
className="bg-secondary text-white mb-2"
value={record}
readOnly
/>
<CAlert visible={copyAlertVisible} color="info">
Copied!
</CAlert>
</div>
<CippCodeBlock language="text" code={record} showLineNumbers={false} wrapLongLines={true} />
)}
</ResultsCard>
)
Expand Down Expand Up @@ -469,12 +382,13 @@ const DNSSECResultsCard = ({ domain }) => {
)}
<CCollapse visible={visible} className="mb-2">
{keys.map((key, idx) => (
<CFormTextarea
className="bg-secondary text-white mb-2"
<CippCodeBlock
language="text"
key={`${idx}-dnssec-key`}
value={key}
readOnly
></CFormTextarea>
code={key}
showLineNumbers={false}
wrapLongLines={true}
/>
))}
</CCollapse>
</ResultsCard>
Expand Down Expand Up @@ -512,11 +426,15 @@ const DKIMResultsCard = ({ domain }) => {
{records.map((record, idx) => (
<div key={`${idx}-dkim-record`}>
<CFormLabel>{record?.Selector}._domainkey</CFormLabel>
<CFormTextarea
className="bg-secondary text-white mb-2"
value={record?.Record}
readOnly
></CFormTextarea>
{record && (
<CippCodeBlock
language="text"
key={`${idx}-dnssec-key`}
code={record?.Record}
showLineNumbers={false}
wrapLongLines={true}
/>
)}
</div>
))}
</CCollapse>
Expand Down

0 comments on commit 795d6ef

Please sign in to comment.