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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10724-fixed-1722289139869.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Sources not displaying correctly in Firewall Rule drawer ([#10724](https://github.com/linode/manager/pull/10724))
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { parseCIDR, parse as parseIP } from 'ipaddr.js';
import { uniq } from 'ramda';

import {
FirewallOptionItem,
allIPs,
allIPv4,
allIPv6,
allowAllIPv4,
allowAllIPv6,
allowNoneIPv4,
allowNoneIPv6,
allowsAllIPs,
predefinedFirewallFromRule,
} from 'src/features/Firewalls/shared';
Expand All @@ -25,6 +26,7 @@ import type {
FirewallRuleProtocol,
FirewallRuleType,
} from '@linode/api-v4/lib/firewalls';
import type { FirewallOptionItem } from 'src/features/Firewalls/shared';
import type { ExtendedIP } from 'src/utilities/ipUtils';

export const IP_ERROR_MESSAGE = 'Must be a valid IPv4 or IPv6 range.';
Expand Down Expand Up @@ -172,11 +174,11 @@ export const getInitialAddressFormValue = (
return 'all';
}

if (allowAllIPv4(addresses)) {
if (allowAllIPv4(addresses) && allowNoneIPv6(addresses)) {
return 'allIPv4';
}

if (allowAllIPv6(addresses)) {
if (allowAllIPv6(addresses) && allowNoneIPv4(addresses)) {
return 'allIPv6';
}

Expand Down
14 changes: 10 additions & 4 deletions packages/manager/src/features/Firewalls/shared.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Grants, Profile } from '@linode/api-v4';
import {
import { truncateAndJoinList } from 'src/utilities/stringUtils';

import type { Grants, Profile } from '@linode/api-v4';
import type {
FirewallRuleProtocol,
FirewallRuleType,
} from '@linode/api-v4/lib/firewalls/types';

import { truncateAndJoinList } from 'src/utilities/stringUtils';

export type FirewallPreset = 'dns' | 'http' | 'https' | 'mysql' | 'ssh';

export interface FirewallOptionItem<T = number | string, L = string> {
Expand Down Expand Up @@ -198,6 +198,12 @@ export const allowAllIPv4 = (addresses: FirewallRuleType['addresses']) =>
export const allowAllIPv6 = (addresses: FirewallRuleType['addresses']) =>
addresses?.ipv6?.includes(allIPv6);

export const allowNoneIPv4 = (addresses: FirewallRuleType['addresses']) =>
!addresses?.ipv4?.length;

export const allowNoneIPv6 = (addresses: FirewallRuleType['addresses']) =>
!addresses?.ipv6?.length;

export const generateRuleLabel = (ruleType?: FirewallPreset) =>
ruleType ? predefinedFirewalls[ruleType].label : 'Custom';

Expand Down