Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Ensure a firewall can only reference a RuleSet once ([#13169](https://github.com/linode/manager/pull/13169))
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const props: FirewallRuleDrawerProps = {
category: 'inbound',
isOpen: true,
mode: 'create',
inboundAndOutboundRules: [],
handleOpenPrefixListDrawer: mockHandleOpenPrefixListDrawer,
onClose: mockOnClose,
onSubmit: mockOnSubmit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const FirewallRuleDrawer = React.memo(
isOpen,
mode,
onClose,
inboundAndOutboundRules,
ruleToModifyOrView,
} = props;

Expand Down Expand Up @@ -303,6 +304,7 @@ export const FirewallRuleDrawer = React.memo(
'ruleset'
);
}}
inboundAndOutboundRules={inboundAndOutboundRules}
ruleErrors={ruleToModifyOrView?.errors}
{...formikProps}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface FirewallRuleDrawerProps {
plRuleRef: PrefixListRuleReference,
contextType: PrefixListDrawerContext['type']
) => void;
inboundAndOutboundRules: FirewallRuleType[];
isOpen: boolean;
mode: FirewallRuleDrawerMode;
onClose: () => void;
Expand Down Expand Up @@ -67,5 +68,6 @@ export interface FirewallRuleSetFormProps
prefixListLabel: string,
plRuleRef: PrefixListRuleReference
) => void;
inboundAndOutboundRules: FirewallRuleType[];
ruleErrors?: FirewallRuleError[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ export const FirewallRuleSetForm = React.memo(
(props: FirewallRuleSetFormProps) => {
const {
category,
closeDrawer,
errors,
handleOpenPrefixListDrawer,
handleSubmit,
inboundAndOutboundRules,
setFieldTouched,
setFieldValue,
touched,
closeDrawer,
values,
} = props;

Expand All @@ -59,7 +60,13 @@ export const FirewallRuleSetForm = React.memo(
() =>
ruleSets
// TODO: Firewall RuleSets: Remove this client-side filter once the API supports filtering by the 'type' field
.filter((ruleSet) => ruleSet.type === category) // Display only rule sets applicable to the given category
.filter(
(ruleSet) =>
ruleSet.type === category &&
!inboundAndOutboundRules.some(
(rule) => rule.ruleset === ruleSet.id
)
) // Display only rule sets applicable to the given category and filter out rule sets already referenced by the FW
.map((ruleSet) => ({
label: ruleSet.label,
value: ruleSet.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ export const FirewallRulesLanding = React.memo((props: Props) => {
modeViewedFrom: ruleDrawer.mode,
});
}}
inboundAndOutboundRules={[
...(rules.inbound ?? []),
...(rules.outbound ?? []),
]}
isOpen={
location.pathname.endsWith('add/inbound') ||
location.pathname.endsWith('add/outbound') ||
Expand Down