| 1 |
import React from "react"; |
| 2 |
// PatternFly |
| 3 |
import { PageSection, Tabs, Tab, TabTitleText } from "@patternfly/react-core"; |
| 4 |
// Navigation |
| 5 |
import { URL_PREFIX } from "src/navigation/NavRoutes"; |
| 6 |
import { NotFound } from "src/components/errors/PageErrors"; |
| 7 |
// Hooks |
| 8 |
import { useDnsForwardZonesData } from "src/hooks/useDnsForwardZonesData"; |
| 9 |
// Components |
| 10 |
import TitleLayout from "src/components/layouts/TitleLayout"; |
| 11 |
import DataSpinner from "src/components/layouts/DataSpinner"; |
| 12 |
import BreadCrumb, { |
| 13 |
BreadCrumbItem, |
| 14 |
} from "src/components/layouts/BreadCrumb/BreadCrumb"; |
| 15 |
import DnsForwardZonesSettings from "./DnsForwardZonesSettings"; |
| 16 |
// React Router DOM |
| 17 |
import { useSafeParams } from "src/utils/paramsUtils"; |
| 18 |
|
| 19 |
type DnsParams = { |
| 20 |
idnsname: string; |
| 21 |
}; |
| 22 |
|
| 23 |
const DnsForwardZonesTabs = ({ section }: { section: string }) => { |
| 24 |
const { idnsname } = useSafeParams<DnsParams>(["idnsname"]); |
| 25 |
|
| 26 |
// Data loaded from the API |
| 27 |
const { |
| 28 |
isLoading, |
| 29 |
modified, |
| 30 |
metadata, |
| 31 |
resetValues, |
| 32 |
originalDnsForwardZone, |
| 33 |
setDnsForwardZone, |
| 34 |
refetch, |
| 35 |
dnsForwardZone, |
| 36 |
modifiedValues, |
| 37 |
} = useDnsForwardZonesData(idnsname); |
| 38 |
|
| 39 |
const pathname = "dns-forward-zones"; |
| 40 |
const breadcrumbItems: BreadCrumbItem[] = [ |
| 41 |
{ |
| 42 |
name: "DNS forward zones", |
| 43 |
url: URL_PREFIX + "/" + pathname, |
| 44 |
}, |
| 45 |
{ |
| 46 |
name: idnsname, |
| 47 |
url: URL_PREFIX + "/" + pathname + "/" + idnsname, |
| 48 |
isActive: true, |
| 49 |
}, |
| 50 |
]; |
| 51 |
|
| 52 |
// Handling of the API data |
| 53 |
if (isLoading) { |
| 54 |
return <DataSpinner />; |
| 55 |
} |
| 56 |
|
| 57 |
if (!isLoading && dnsForwardZone.idnsname === "") { |
| 58 |
return <NotFound />; |
| 59 |
} |
| 60 |
|
| 61 |
// Return component |
| 62 |
return ( |
| 63 |
<> |
| 64 |
<PageSection hasBodyWrapper={false}> |
| 65 |
<BreadCrumb breadcrumbItems={breadcrumbItems} /> |
| 66 |
<TitleLayout |
| 67 |
id={idnsname} |
| 68 |
preText="DNS forward zone:" |
| 69 |
text={idnsname} |
| 70 |
headingLevel="h1" |
| 71 |
/> |
| 72 |
</PageSection> |
| 73 |
<PageSection hasBodyWrapper={false} type="tabs" isFilled> |
| 74 |
<Tabs |
| 75 |
activeKey={section} |
| 76 |
isBox |
| 77 |
className="pf-v6-u-ml-lg" |
| 78 |
variant="secondary" |
| 79 |
mountOnEnter |
| 80 |
unmountOnExit |
| 81 |
> |
| 82 |
<Tab |
| 83 |
eventKey={"settings"} |
| 84 |
name="settings-details" |
| 85 |
title={<TabTitleText>Settings</TabTitleText>} |
| 86 |
data-cy="dns-zones-tab-settings" |
| 87 |
> |
| 88 |
<DnsForwardZonesSettings |
| 89 |
dnsForwardZone={dnsForwardZone} |
| 90 |
originalDnsForwardZone={originalDnsForwardZone} |
| 91 |
metadata={metadata} |
| 92 |
onDnsForwardZoneChange={setDnsForwardZone} |
| 93 |
onRefresh={refetch} |
| 94 |
isModified={modified} |
| 95 |
isDataLoading={isLoading} |
| 96 |
modifiedValues={modifiedValues} |
| 97 |
onResetValues={resetValues} |
| 98 |
pathname={pathname} |
| 99 |
/> |
| 100 |
</Tab> |
| 101 |
</Tabs> |
| 102 |
</PageSection> |
| 103 |
</> |
| 104 |
); |
| 105 |
}; |
| 106 |
|
| 107 |
export default DnsForwardZonesTabs; |