Updated TLS components, to refresh when new data comes in

This commit is contained in:
Alicia Sykes 2023-09-09 20:30:09 +01:00
parent 5297b2ffe7
commit d8bb822a4e
3 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import { useState } from 'react'; import { useState, useEffect } from 'react';
import { Card } from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Button from 'components/Form/Button'; import Button from 'components/Form/Button';
import { ExpandableRow } from 'components/Form/Row'; import { ExpandableRow } from 'components/Form/Row';
@ -29,6 +29,10 @@ const TlsCard = (props: {data: any, title: string, actionButtons: any }): JSX.El
const [cipherSuites, setCipherSuites] = useState(makeCipherSuites(props.data)); const [cipherSuites, setCipherSuites] = useState(makeCipherSuites(props.data));
const [loadState, setLoadState] = useState<undefined | 'loading' | 'success' | 'error'>(undefined); const [loadState, setLoadState] = useState<undefined | 'loading' | 'success' | 'error'>(undefined);
useEffect(() => { // Update cipher suites when data changes
setCipherSuites(makeCipherSuites(props.data));
}, [props.data]);
const updateData = (id: number) => { const updateData = (id: number) => {
setCipherSuites([]); setCipherSuites([]);
setLoadState('loading'); setLoadState('loading');

View File

@ -1,5 +1,5 @@
import { useState } from 'react'; import { useState, useEffect } from 'react';
import { Card } from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Button from 'components/Form/Button'; import Button from 'components/Form/Button';
import { ExpandableRow } from 'components/Form/Row'; import { ExpandableRow } from 'components/Form/Row';
@ -38,6 +38,10 @@ const TlsCard = (props: {data: any, title: string, actionButtons: any }): JSX.El
const [clientSupport, setClientSupport] = useState(makeClientSupport(props.data)); const [clientSupport, setClientSupport] = useState(makeClientSupport(props.data));
const [loadState, setLoadState] = useState<undefined | 'loading' | 'success' | 'error'>(undefined); const [loadState, setLoadState] = useState<undefined | 'loading' | 'success' | 'error'>(undefined);
useEffect(() => {
setClientSupport(makeClientSupport(props.data));
}, [props.data]);
const updateData = (id: number) => { const updateData = (id: number) => {
setClientSupport([]); setClientSupport([]);
setLoadState('loading'); setLoadState('loading');

View File

@ -1,5 +1,5 @@
import { useState } from 'react'; import { useState, useEffect } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import colors from 'styles/colors'; import colors from 'styles/colors';
import { Card } from 'components/Form/Card'; import { Card } from 'components/Form/Card';
@ -74,6 +74,11 @@ const TlsCard = (props: {data: any, title: string, actionButtons: any }): JSX.El
const [tlsResults, setTlsResults] = useState(makeResults(props.data)); const [tlsResults, setTlsResults] = useState(makeResults(props.data));
const [loadState, setLoadState] = useState<undefined | 'loading' | 'success' | 'error'>(undefined); const [loadState, setLoadState] = useState<undefined | 'loading' | 'success' | 'error'>(undefined);
useEffect(() => {
setTlsRowWata(makeExpandableData(props.data));
setTlsResults(makeResults(props.data));
}, [props.data]);
const updateData = (id: number) => { const updateData = (id: number) => {
setTlsRowWata([]); setTlsRowWata([]);
setLoadState('loading'); setLoadState('loading');