Skip to content

Commit

Permalink
fix(network) allow disabling of dhcp in ipv4/ipv6 network configurati…
Browse files Browse the repository at this point in the history
…on i.e. on bridge networks. Avoid crash reported in #814

Signed-off-by: David Edler <david.edler@canonical.com>
  • Loading branch information
edlerd committed Jul 12, 2024
1 parent 0fc2601 commit 01eaf3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/pages/networks/forms/NetworkFormIpv4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ const NetworkFormIpv4: FC<Props> = ({ formik }) => {
: []),

...(formik.values.networkType !== "ovn" &&
formik.values.networkType !== "physical" &&
hasDhcp
formik.values.networkType !== "physical"
? [
getConfigurationRow({
formik,
name: "ipv4_dhcp_expiry",
label: "IPv4 DHCP expiry",
defaultValue: "",
disabled: !hasDhcp,
disabledReason: "IPv4 DHCP is disabled",
children: <Input type="text" />,
}),

Expand All @@ -45,6 +46,8 @@ const NetworkFormIpv4: FC<Props> = ({ formik }) => {
name: "ipv4_dhcp_ranges",
label: "IPv4 DHCP ranges",
defaultValue: "",
disabled: !hasDhcp,
disabledReason: "IPv4 DHCP is disabled",
children: <Textarea />,
}),
]
Expand Down
11 changes: 8 additions & 3 deletions src/pages/networks/forms/NetworkFormIpv6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
]
: []),

...(hasDhcp &&
formik.values.networkType !== "ovn" &&
...(formik.values.networkType !== "ovn" &&
formik.values.networkType !== "physical"
? [
getConfigurationRow({
formik,
name: "ipv6_dhcp_expiry",
label: "IPv6 DHCP expiry",
defaultValue: "",
disabled: !hasDhcp,
disabledReason: "IPv6 DHCP is disabled",
children: <Input type="text" />,
}),

Expand All @@ -45,18 +46,22 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
name: "ipv6_dhcp_ranges",
label: "IPv6 DHCP ranges",
defaultValue: "",
disabled: !hasDhcp,
disabledReason: "IPv6 DHCP is disabled",
children: <Textarea />,
}),
]
: []),

...(hasDhcp && formik.values.networkType !== "physical"
...(formik.values.networkType !== "physical"
? [
getConfigurationRow({
formik,
name: "ipv6_dhcp_stateful",
label: "IPv6 DHCP stateful",
defaultValue: "",
disabled: !hasDhcp,
disabledReason: "IPv6 DHCP is disabled",
children: <Select options={optionTrueFalse} />,
}),
]
Expand Down

0 comments on commit 01eaf3f

Please sign in to comment.