Adds unique keys to itteratbles, remove react warn

This commit is contained in:
Alicia Sykes 2024-03-20 21:20:41 +00:00
parent d43a05a0ed
commit 2304aaf17c
8 changed files with 27 additions and 11 deletions

View File

@ -159,7 +159,7 @@ export const ExpandableRow = (props: RowProps) => {
{ rowList?.map((row: RowProps, index: number) => { { rowList?.map((row: RowProps, index: number) => {
return ( return (
<SubRow key={`${row.lbl}-${index}`}> <SubRow key={`${row.lbl}-${index}`}>
<span className="lbl" title={row.title}>{row.lbl}</span> <span className="lbl" title={row.title?.toString()}>{row.lbl}</span>
<span className="val" title={row.val} onClick={() => copyToClipboard(row.val)}> <span className="val" title={row.val} onClick={() => copyToClipboard(row.val)}>
{formatValue(row.val)} {formatValue(row.val)}
</span> </span>
@ -199,7 +199,7 @@ const Row = (props: RowProps) => {
if (children) return <StyledRow key={`${lbl}-${val}`}>{children}</StyledRow>; if (children) return <StyledRow key={`${lbl}-${val}`}>{children}</StyledRow>;
return ( return (
<StyledRow key={`${lbl}-${val}`}> <StyledRow key={`${lbl}-${val}`}>
{ lbl && <span className="lbl" title={title}>{lbl}</span> } { lbl && <span className="lbl" title={title?.toString()}>{lbl}</span> }
<span className="val" title={val} onClick={() => copyToClipboard(val)}> <span className="val" title={val} onClick={() => copyToClipboard(val)}>
{formatValue(val)} {formatValue(val)}
</span> </span>

View File

@ -6,11 +6,13 @@ const BlockListsCard = (props: {data: any, title: string, actionButtons: any }):
const blockLists = props.data.blocklists; const blockLists = props.data.blocklists;
return ( return (
<Card heading={props.title} actionButtons={props.actionButtons}> <Card heading={props.title} actionButtons={props.actionButtons}>
{ blockLists.map((blocklist: any) => ( { blockLists.map((blocklist: any, blockIndex: number) => (
<Row <Row
title={blocklist.serverIp} title={blocklist.serverIp}
lbl={blocklist.server} lbl={blocklist.server}
val={blocklist.isBlocked ? '❌ Blocked' : '✅ Not Blocked'} /> val={blocklist.isBlocked ? '❌ Blocked' : '✅ Not Blocked'}
key={`blocklist-${blockIndex}-${blocklist.serverIp}`}
/>
))} ))}
</Card> </Card>
); );

View File

@ -18,12 +18,12 @@ const DnsServerCard = (props: {data: any, title: string, actionButtons: any }):
return ( return (
<Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
{dnsSecurity.dns.map((dns: any, index: number) => { {dnsSecurity.dns.map((dns: any, index: number) => {
return (<> return (<div key={`dns-${index}`}>
{ dnsSecurity.dns.length > 1 && <Heading as="h4" size="small" color={colors.primary}>DNS Server #{index+1}</Heading> } { dnsSecurity.dns.length > 1 && <Heading as="h4" size="small" color={colors.primary}>DNS Server #{index+1}</Heading> }
<Row lbl="IP Address" val={dns.address} key={`ip-${index}`} /> <Row lbl="IP Address" val={dns.address} key={`ip-${index}`} />
{ dns.hostname && <Row lbl="Hostname" val={dns.hostname} key={`host-${index}`} /> } { dns.hostname && <Row lbl="Hostname" val={dns.hostname} key={`host-${index}`} /> }
<Row lbl="DoH Support" val={dns.dohDirectSupports ? '✅ Yes*' : '❌ No*'} key={`doh-${index}`} /> <Row lbl="DoH Support" val={dns.dohDirectSupports ? '✅ Yes*' : '❌ No*'} key={`doh-${index}`} />
</>); </div>);
})} })}
{dnsSecurity.dns.length > 0 && (<small> {dnsSecurity.dns.length > 0 && (<small>
* DoH Support is determined by the DNS server's response to a DoH query. * DoH Support is determined by the DNS server's response to a DoH query.

View File

@ -13,7 +13,7 @@ span.val {
const ServerStatusCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => { const ServerStatusCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const serverStatus = props.data; const serverStatus = props.data;
return ( return (
<Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}> <Card heading={props.title.toString()} actionButtons={props.actionButtons} styles={cardStyles}>
<Row lbl="" val=""> <Row lbl="" val="">
<span className="lbl">Is Up?</span> <span className="lbl">Is Up?</span>
{ serverStatus.isUp ? <span className="val up"> Online</span> : <span className="val down"> Offline</span>} { serverStatus.isUp ? <span className="val up"> Online</span> : <span className="val down"> Offline</span>}

View File

@ -52,7 +52,7 @@ const TlsCard = (props: {data: any, title: string, actionButtons: any }): JSX.El
<Card heading={props.title} actionButtons={props.actionButtons}> <Card heading={props.title} actionButtons={props.actionButtons}>
{ cipherSuites.length && cipherSuites.map((cipherSuite: any, index: number) => { { cipherSuites.length && cipherSuites.map((cipherSuite: any, index: number) => {
return ( return (
<ExpandableRow lbl={cipherSuite.title} val="" rowList={cipherSuite.fields} /> <ExpandableRow key={`tls-${index}`} lbl={cipherSuite.title} val="" rowList={cipherSuite.fields} />
); );
})} })}
{ !cipherSuites.length && ( { !cipherSuites.length && (

View File

@ -59,8 +59,15 @@ const TlsCard = (props: {data: any, title: string, actionButtons: any }): JSX.El
const scanId = props.data?.id; const scanId = props.data?.id;
return ( return (
<Card heading={props.title} actionButtons={props.actionButtons}> <Card heading={props.title} actionButtons={props.actionButtons}>
{clientSupport.map((support: any) => { {clientSupport.map((support: any, index: number) => {
return (<ExpandableRow lbl={support.title} val={support.value || '?'} rowList={support.fields} />) return (
<ExpandableRow
key={`tls-client-${index}`}
lbl={support.title}
val={support.value || '?'}
rowList={support.fields}
/>
)
})} })}
{ !clientSupport.length && ( { !clientSupport.length && (
<div> <div>

View File

@ -99,7 +99,13 @@ const TlsCard = (props: {data: any, title: string, actionButtons: any }): JSX.El
<Card heading={props.title} actionButtons={props.actionButtons}> <Card heading={props.title} actionButtons={props.actionButtons}>
{ tlsResults.length > 0 && tlsResults.map((row: any, index: number) => { { tlsResults.length > 0 && tlsResults.map((row: any, index: number) => {
return ( return (
<Row lbl={row.lbl} val={row.val} plaintext={row.plaintext} listResults={row.list} /> <Row
lbl={row.lbl}
val={row.val}
plaintext={row.plaintext}
listResults={row.list}
key={`tls-issues-${index}`}
/>
); );
})} })}
<Expandable> <Expandable>

View File

@ -7,6 +7,7 @@ import colors from 'styles/colors';
interface Props { interface Props {
children: ReactNode; children: ReactNode;
title?: string; title?: string;
key?: string;
} }
interface State { interface State {