diff --git a/frontend/src/app/app.tsx b/frontend/src/app/app.tsx index cc30f28..7cc9014 100644 --- a/frontend/src/app/app.tsx +++ b/frontend/src/app/app.tsx @@ -25,7 +25,7 @@ const App: FC = () => {
- + = ({ size="xs" fontFamily="sans-serif" onClick={copyToClipboard} - icon={} + icon={} aria-label="copy" h={4} /> diff --git a/frontend/src/common/form/form.tsx b/frontend/src/common/form/form.tsx index 4442a3a..e9def6a 100644 --- a/frontend/src/common/form/form.tsx +++ b/frontend/src/common/form/form.tsx @@ -13,26 +13,44 @@ const Form: FormComponent = ({ render, ...props }) => { + // handleSubmit is a closure around the form submission function + let handleSubmit: () => void; + const [initialValues, setInitialValues] = useState(initialVals || {}); // Check if the initial values can be added from the URL search params // We only want this to run on mount useEffect(() => { - setInitialValues( - Object.entries(initialValues).reduce((values, [name, val]) => { - const params = new URLSearchParams(window.location.search); + if (window.location.search) { + const params = new URLSearchParams(window.location.search); - let param: string | boolean | null = params.get(name); - if (param === "false") param = false; - if (param === "true") param = true; + setInitialValues( + Object.entries(initialValues).reduce((values, [name, val]) => { + let param: string | boolean | null = params.get(name); + if (param === "false") param = false; + if (param === "true") param = true; - const value = param === null ? val : param; + const value = param === null ? val : param; - return { ...values, [name]: value }; - }, {}) - ); + return { ...values, [name]: value }; + }, {}) + ); + } }, []); // eslint-disable-line + // When the initial values are set check if they are valid + // if they are then submit the form right away. + useEffect(() => { + if (initialValues !== initialVals) { + try { + schema.parse(initialValues); + if (handleSubmit) handleSubmit(); + } catch (err) { + // Do nothing. + } + } + }, [initialValues]); // eslint-disable-line + return ( ( -
- - {form.submitError && ( - - - - There was a problem submitting the form - - {form.submitError} - - - )} + render={(form) => { + handleSubmit = form.handleSubmit; + + return ( + + + {form.submitError && ( + + + + There was a problem submitting the form + + {form.submitError} + + + )} - {render(form)} - - - )} + {render(form)} +
+ + ); + }} /> ); }; diff --git a/frontend/src/common/header/header.tsx b/frontend/src/common/header/header.tsx index 4ac25e7..605de7e 100644 --- a/frontend/src/common/header/header.tsx +++ b/frontend/src/common/header/header.tsx @@ -48,7 +48,7 @@ const Header: FC = () => { > setMenuIsOpen(false)} /> - + diff --git a/frontend/src/pages/bgp-route/bgp-route.view.tsx b/frontend/src/pages/bgp-route/bgp-route.view.tsx index f0a15f7..5247f16 100644 --- a/frontend/src/pages/bgp-route/bgp-route.view.tsx +++ b/frontend/src/pages/bgp-route/bgp-route.view.tsx @@ -47,33 +47,33 @@ const BgpRoute: FC = () => { - - - {!!item.large_community && ( - )} - diff --git a/frontend/src/pages/dns/dns-table.tsx b/frontend/src/pages/dns/dns-table.tsx index 8eb7878..e1f5ecf 100644 --- a/frontend/src/pages/dns/dns-table.tsx +++ b/frontend/src/pages/dns/dns-table.tsx @@ -1,4 +1,4 @@ -import { FC, useMemo } from "react"; +import { FC, Fragment, useMemo } from "react"; import { Button, @@ -147,9 +147,9 @@ const DnsTable: FC = ({ record }) => { {record.map(({ server, records }) => ( - <> + -
Next hop + {item.next_hop}
As path + {item.as_path?.join(", ")}
Community + {item.community?.join(" - ")}
Large community + {item.large_community?.join(" - ")}
Local pref + {item.local_pref}
+ = ({ record }) => { {records.map((row, index) => ( ))} - + ))}