Skip to content

Commit

Permalink
ensure all web summaries and email summaries have correct domain cont…
Browse files Browse the repository at this point in the history
…ext (#4546)
  • Loading branch information
lcampbell2 authored May 25, 2023
1 parent f3c38e7 commit 85860c5
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions frontend/src/summaries/Doughnut.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const Doughnut = ({
height,
width,
title,
id,
valueAccessor = (d) => d,
innerRadius = Math.ceil(width / 2.8),
outerRadius = Math.ceil(width / 2.2),
Expand All @@ -28,7 +29,7 @@ export const Doughnut = ({
})
const { i18n } = useLingui()

const domainContext = title.includes('DMARC') ? (
const domainContext = ['email', 'spf', 'dkim'].includes(id) ? (
<Trans>Internet-facing</Trans>
) : (
<Trans>Web-hosting</Trans>
Expand All @@ -42,9 +43,7 @@ export const Doughnut = ({
y={15}
textAnchor="middle"
dominantBaseline="central"
fontSize={
i18n.locale === 'en' ? `${width / 256}rem` : `${width / 300}rem`
}
fontSize={i18n.locale === 'en' ? `${width / 256}rem` : `${width / 300}rem`}
transform={`translate(${width / 2}, ${height / 2})`}
>
<Trans>Domains</Trans>
Expand All @@ -54,9 +53,7 @@ export const Doughnut = ({
y={i18n.locale === 'en' ? 20 : 30}
textAnchor="middle"
dominantBaseline="central"
fontSize={
i18n.locale === 'en' ? `${width / 256}rem` : `${width / 300}rem`
}
fontSize={i18n.locale === 'en' ? `${width / 256}rem` : `${width / 300}rem`}
transform={`translate(${width / 2}, ${height / 2})`}
>
{domainContext}
Expand All @@ -67,9 +64,7 @@ export const Doughnut = ({
y={40}
textAnchor="middle"
dominantBaseline="central"
fontSize={
i18n.locale === 'en' ? `${width / 256}rem` : `${width / 512}rem`
}
fontSize={i18n.locale === 'en' ? `${width / 256}rem` : `${width / 512}rem`}
transform={`translate(${width / 2}, ${height / 2})`}
>
<Trans>Domains</Trans>
Expand Down Expand Up @@ -116,11 +111,7 @@ export const Doughnut = ({
<div {...rest}>
<Box my="4">{chartContent}</Box>
{arcs.map(({ title, count, percentage }, index) => {
if (
(percentage % 1 === 0.5 &&
['Compliant', 'Implemented'].includes(title)) ||
percentage % 1 > 0.5
) {
if ((percentage % 1 === 0.5 && ['Compliant', 'Implemented'].includes(title)) || percentage % 1 > 0.5) {
percentage = Math.ceil(percentage)
} else {
percentage = Math.floor(percentage)
Expand All @@ -136,20 +127,9 @@ export const Doughnut = ({
py={arcs.length > 2 ? '2' : '5'}
overflow="hidden"
>
<svg
height={30}
width={30}
style={{ display: 'inline', marginRight: '1em' }}
aria-hidden="true"
>
<svg height={30} width={30} style={{ display: 'inline', marginRight: '1em' }} aria-hidden="true">
<g>
<rect
stroke="#fff"
strokeWidth="2"
width="30"
height="30"
fill={data[index].color}
/>
<rect stroke="#fff" strokeWidth="2" width="30" height="30" fill={data[index].color} />
</g>
</svg>
<p
Expand Down

0 comments on commit 85860c5

Please sign in to comment.