-
Notifications
You must be signed in to change notification settings - Fork 380
feat: [M3-9984] Add support for entities to have multiple firewalls on CM #12241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
5e75978
4a4548a
d7b5c7d
d57753a
25b24b0
9f49e9b
0408ccc
75b97bf
72d718b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
Support for Linodes and NodeBalancers to have multiple firewalls ([#12241](https://github.com/linode/manager/pull/12241)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import { Link } from 'src/components/Link'; | |
import { FirewallSelect } from 'src/features/Firewalls/components/FirewallSelect'; | ||
import { formattedTypes } from 'src/features/Firewalls/FirewallDetail/Devices/constants'; | ||
|
||
import type { FirewallDeviceEntityType } from '@linode/api-v4'; | ||
import type { Firewall, FirewallDeviceEntityType } from '@linode/api-v4'; | ||
|
||
interface Values { | ||
firewallId: number; | ||
|
@@ -22,13 +22,18 @@ const schema = object({ | |
}); | ||
|
||
interface Props { | ||
attachedFirewalls: Firewall[]; | ||
entityId: number; | ||
entityType: FirewallDeviceEntityType; | ||
onCancel: () => void; | ||
} | ||
|
||
export const AddFirewallForm = (props: Props) => { | ||
const { entityId, entityType, onCancel } = props; | ||
const { attachedFirewalls, entityId, entityType, onCancel } = props; | ||
const hasEnabledFirewall = attachedFirewalls?.some( | ||
(firewall) => firewall.status === 'enabled' | ||
); | ||
|
||
const { enqueueSnackbar } = useSnackbar(); | ||
|
||
const entityLabel = formattedTypes[entityType] ?? entityType; | ||
|
@@ -51,6 +56,13 @@ export const AddFirewallForm = (props: Props) => { | |
} | ||
}; | ||
|
||
const optionsFilter = (firewall: Firewall) => { | ||
return ( | ||
!(hasEnabledFirewall && firewall.status === 'enabled') && | ||
!attachedFirewalls?.some((fw) => fw.id === firewall.id) | ||
); | ||
}; | ||
Comment on lines
+59
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot assign a firewall to our entity if
rather than filtering out, should I just let the API return an error if the user can't assign the firewall? (I think I prefer filtering out ineligible firewalls though) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like API errors personally because they help the user understand why something isn't allowed, but UX tends to like not letting users run into them If we hide some options, maybe we should add some copy or helper text or tooltip or noOptionsMessage to help inform them about the "1 active firewall" limitation We can let UX decide, but my vote will always be let the user see the API error π There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can I assign multiple firewalls to a linode/nodebalancer if the "Add Firewall" option only allows assigning one firewall at a time, and only when no firewall is currently assigned? Am I missing something? This is what I'm seeing (same in the case of nodebalancer): Screen.Recording.2025-05-21.at.4.11.28.PM.mov |
||
|
||
return ( | ||
<form onSubmit={form.handleSubmit(onSubmit)}> | ||
<Stack spacing={2}> | ||
|
@@ -66,6 +78,7 @@ export const AddFirewallForm = (props: Props) => { | |
errorText={fieldState.error?.message} | ||
label="Firewall" | ||
onChange={(e, value) => field.onChange(value?.id)} | ||
optionsFilter={optionsFilter} | ||
placeholder="Select a Firewall" | ||
textFieldProps={{ | ||
inputRef: field.ref, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure if it matters, but
??
might be better here