Skip to content

Commit

Permalink
fix(forms) Simplify formik prop propagation
Browse files Browse the repository at this point in the history
Update src/pages/settings/Settings.tsx

Co-authored-by: Michele Lo Russo <michele.lorusso@canonical.com>

Signed-off-by: David Edler <david.edler@canonical.com>
  • Loading branch information
edlerd committed Dec 1, 2023
1 parent 330c22e commit 42c65c3
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 90 deletions.
6 changes: 3 additions & 3 deletions src/components/forms/CloudInitForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const CloudInitForm: FC<Props> = ({ formik }) => {
}
rows={[
getInstanceConfigurationRow({
formik: formik,
formik,
label: "Network config",
name: "cloud_init_network_config",
defaultValue: "\n\n",
Expand All @@ -62,7 +62,7 @@ const CloudInitForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "User data",
name: "cloud_init_user_data",
defaultValue: "\n\n",
Expand All @@ -78,7 +78,7 @@ const CloudInitForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Vendor data",
name: "cloud_init_vendor_data",
defaultValue: "\n\n",
Expand Down
10 changes: 5 additions & 5 deletions src/components/forms/ResourceLimitsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ResourceLimitsForm: FC<Props> = ({ formik }) => {
<InstanceConfigurationTable
rows={[
getInstanceConfigurationRow({
formik: formik,
formik,
name: "limits_cpu",
label: "Exposed CPU limit",
defaultValue: DEFAULT_CPU_LIMIT,
Expand All @@ -65,7 +65,7 @@ const ResourceLimitsForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
name: "limits_memory",
label: "Memory limit",
defaultValue: DEFAULT_MEM_LIMIT,
Expand All @@ -82,7 +82,7 @@ const ResourceLimitsForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
name: "limits_memory_swap",
label: "Memory swap (Containers only)",
defaultValue: "",
Expand All @@ -97,15 +97,15 @@ const ResourceLimitsForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
name: "limits_disk_priority",
label: "Disk priority",
defaultValue: "",
children: <Select options={diskPriorities} />,
}),

getInstanceConfigurationRow({
formik: formik,
formik,
name: "limits_processes",
label: "Max number of processes (Containers only)",
defaultValue: "",
Expand Down
18 changes: 9 additions & 9 deletions src/components/forms/SecurityPoliciesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
<InstanceConfigurationTable
rows={[
getInstanceConfigurationRow({
formik: formik,
formik,
label: "Protect deletion",
name: "security_protection_delete",
defaultValue: "",
Expand All @@ -69,7 +69,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Privileged (Containers only)",
name: "security_privileged",
defaultValue: "",
Expand All @@ -84,7 +84,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Protect UID/GID shift (Containers only)",
name: "security_protection_shift",
defaultValue: "",
Expand All @@ -96,7 +96,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Base host id (Containers only)",
name: "security_idmap_base",
defaultValue: "",
Expand All @@ -114,7 +114,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Idmap size (Containers only)",
name: "security_idmap_size",
defaultValue: "",
Expand All @@ -133,7 +133,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Unique idmap (Containers only)",
name: "security_idmap_isolated",
defaultValue: "",
Expand All @@ -145,7 +145,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Allow /dev/lxd in the instance (Containers only)",
name: "security_devlxd",
defaultValue: "",
Expand All @@ -157,7 +157,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label:
"Make /1.0/images API available over /dev/lxd (Containers only)",
name: "security_devlxd_images",
Expand All @@ -170,7 +170,7 @@ const SecurityPoliciesForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Enable secureboot (VMs only)",
name: "security_secureboot",
defaultValue: "",
Expand Down
8 changes: 4 additions & 4 deletions src/components/forms/SnapshotsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ const SnapshotsForm: FC<Props> = ({ formik }) => {
<InstanceConfigurationTable
rows={[
getInstanceConfigurationRow({
formik: formik,
formik,
label: "Snapshot name pattern",
name: "snapshots_pattern",
defaultValue: "",
children: <Input placeholder="Enter name pattern" type="text" />,
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Expire after",
name: "snapshots_expiry",
defaultValue: "",
children: <Input placeholder="Enter expiry expression" type="text" />,
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Snapshot stopped instances",
name: "snapshots_schedule_stopped",
defaultValue: "",
Expand All @@ -60,7 +60,7 @@ const SnapshotsForm: FC<Props> = ({ formik }) => {
}),

getInstanceConfigurationRow({
formik: formik,
formik,
label: "Schedule",
name: "snapshots_schedule",
defaultValue: "",
Expand Down
6 changes: 3 additions & 3 deletions src/pages/networks/forms/NetworkFormBridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const NetworkFormBridge: FC<Props> = ({ formik }) => {
<ConfigurationTable
rows={[
getNetworkConfigurationRow({
formik: formik,
formik,
name: "bridge_mtu",
label: "MTU",
help: "Bridge MTU (default varies if tunnel or fan setup)",
Expand All @@ -23,7 +23,7 @@ const NetworkFormBridge: FC<Props> = ({ formik }) => {
}),

getNetworkConfigurationRow({
formik: formik,
formik,
name: "bridge_hwaddr",
label: "Hardware address",
help: "MAC address for the bridge",
Expand All @@ -34,7 +34,7 @@ const NetworkFormBridge: FC<Props> = ({ formik }) => {
...(formik.values.type === "bridge"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "bridge_driver",
label: "Bridge driver",
help: "Native or openvswitch",
Expand Down
6 changes: 3 additions & 3 deletions src/pages/networks/forms/NetworkFormDns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const NetworkFormDns: FC<Props> = ({ formik }) => {
<ConfigurationTable
rows={[
getNetworkConfigurationRow({
formik: formik,
formik,
name: "dns_domain",
label: "DNS domain",
help: "Domain to advertise to DHCP clients and use for DNS resolution",
Expand All @@ -25,7 +25,7 @@ const NetworkFormDns: FC<Props> = ({ formik }) => {
...(formik.values.type === "bridge"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "dns_mode",
label: "DNS mode",
defaultValue: "",
Expand Down Expand Up @@ -57,7 +57,7 @@ const NetworkFormDns: FC<Props> = ({ formik }) => {
: []),

getNetworkConfigurationRow({
formik: formik,
formik,
name: "dns_search",
label: "DNS search",
help: "Full comma-separated domain search list, defaulting to DNS domain value",
Expand Down
10 changes: 5 additions & 5 deletions src/pages/networks/forms/NetworkFormIpv4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const NetworkFormIpv4: FC<Props> = ({ formik }) => {
<ConfigurationTable
rows={[
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv4_dhcp",
label: "IPv4 DHCP",
defaultValue: "",
Expand All @@ -27,7 +27,7 @@ const NetworkFormIpv4: FC<Props> = ({ formik }) => {
...(formik.values.type !== "ovn" && hasDhcp
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv4_dhcp_expiry",
label: "IPv4 DHCP expiry",
help: "When to expire DHCP leases",
Expand All @@ -36,7 +36,7 @@ const NetworkFormIpv4: FC<Props> = ({ formik }) => {
}),

getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv4_dhcp_ranges",
label: "IPv4 DHCP ranges",
help: "Comma-separated list of IP ranges to use for DHCP (FIRST-LAST format)",
Expand All @@ -49,7 +49,7 @@ const NetworkFormIpv4: FC<Props> = ({ formik }) => {
...(formik.values.type === "ovn"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv4_l3only",
label: "IPv4 L3 only",
defaultValue: "",
Expand All @@ -61,7 +61,7 @@ const NetworkFormIpv4: FC<Props> = ({ formik }) => {
...(formik.values.type !== "ovn"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv4_ovn_ranges",
label: "IPv4 OVN ranges",
help: "Comma-separated list of IPv4 ranges to use for child OVN network routers (FIRST-LAST format)",
Expand Down
12 changes: 6 additions & 6 deletions src/pages/networks/forms/NetworkFormIpv6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
<ConfigurationTable
rows={[
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_dhcp",
label: "IPv6 DHCP",
defaultValue: "",
Expand All @@ -27,7 +27,7 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
...(hasDhcp && formik.values.type !== "ovn"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_dhcp_expiry",
label: "IPv6 DHCP expiry",
help: "When to expire DHCP leases",
Expand All @@ -36,7 +36,7 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
}),

getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_dhcp_ranges",
label: "IPv6 DHCP ranges",
help: "Comma-separated list of IPv6 ranges to use for DHCP (FIRST-LAST format)",
Expand All @@ -49,7 +49,7 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
...(hasDhcp
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_dhcp_stateful",
label: "IPv6 DHCP stateful",
defaultValue: "",
Expand All @@ -61,7 +61,7 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
...(formik.values.type === "ovn"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_l3only",
label: "IPv6 L3 only",
defaultValue: "",
Expand All @@ -73,7 +73,7 @@ const NetworkFormIpv6: FC<Props> = ({ formik }) => {
...(formik.values.type !== "ovn"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_ovn_ranges",
label: "IPv6 OVN ranges",
help: "Comma-separated list of IPv6 ranges to use for child OVN network routers (FIRST-LAST format)",
Expand Down
8 changes: 4 additions & 4 deletions src/pages/networks/forms/NetworkFormMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const NetworkFormMain: FC<Props> = ({ formik, project }) => {
<ConfigurationTable
rows={[
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv4_address",
label: "IPv4 address",
defaultValue: "auto",
Expand Down Expand Up @@ -93,7 +93,7 @@ const NetworkFormMain: FC<Props> = ({ formik, project }) => {
...(formik.values.ipv4_address !== "none"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv4_nat",
label: "IPv4 NAT",
defaultValue: "",
Expand All @@ -103,7 +103,7 @@ const NetworkFormMain: FC<Props> = ({ formik, project }) => {
: []),

getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_address",
label: "IPv6 address",
defaultValue: "auto",
Expand Down Expand Up @@ -135,7 +135,7 @@ const NetworkFormMain: FC<Props> = ({ formik, project }) => {
...(formik.values.ipv6_address !== "none"
? [
getNetworkConfigurationRow({
formik: formik,
formik,
name: "ipv6_nat",
label: "IPv6 NAT",
defaultValue: "",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/projects/forms/ClusterRestrictionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ const ClusterRestrictionForm: FC<Props> = ({ formik }) => {
<InstanceConfigurationTable
rows={[
getInstanceConfigurationRow({
formik: formik,
formik,
name: "restricted_cluster_groups",
label: "Cluster groups targeting",
defaultValue: "",
children: <Input placeholder="Enter value" type="text" />,
}),

getInstanceConfigurationRow({
formik: formik,
formik,
name: "restricted_cluster_target",
label: "Direct cluster targeting",
defaultValue: "",
Expand Down
Loading

0 comments on commit 42c65c3

Please sign in to comment.