Skip to content

Commit

Permalink
fix: DHCPTable, TagForm, VLANDetails selectors
Browse files Browse the repository at this point in the history
- In VLANDetails.tsx, update the call to subnetSelectors.getByIds to pass null instead of an empty array when vlan?.subnet_ids is falsy.
- In TagForm.tsx, prevent the events array from being re-created on every render

Signed-off-by: Peter Makowski <me+git@petermakowski.io>
  • Loading branch information
petermakowski committed May 29, 2024
1 parent b8d5a11 commit cb7f12e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/app/base/components/DHCPTable/DHCPTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,11 @@ const DHCPTable = ({
}: Props): JSX.Element | null => {
const [expanded, setExpanded] = useState<DHCPSnippet["id"] | null>(null);
const dhcpsnippetLoading = useSelector(dhcpsnippetSelectors.loading);
const subnetIds = subnets?.map(({ id }) => id) || null;
const dhcpsnippets = useSelector((state: RootState) =>
node
? dhcpsnippetSelectors.getByNode(state, node?.system_id)
: dhcpsnippetSelectors.getBySubnets(
state,
subnets?.map(({ id }) => id)
)
: dhcpsnippetSelectors.getBySubnets(state, subnetIds)
);

useFetchActions([dhcpsnippetActions.fetch]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ const TagForm = ({ systemId }: Props): JSX.Element | null => {
);
const tagsLoading = useSelector(tagSelectors.loading);
const taggingMachines = useSelector(machineSelectors.updatingTags);
const eventActions = [NodeActions.TAG, NodeActions.UNTAG];
const errors = useSelector((state: RootState) =>
machineSelectors.eventErrorsForIds(state, systemId, [
NodeActions.TAG,
NodeActions.UNTAG,
])
machineSelectors.eventErrorsForIds(state, systemId, eventActions)
)[0]?.error;
const canEdit = useCanEdit(machine, true);

Expand Down
2 changes: 1 addition & 1 deletion src/app/subnets/views/VLANDetails/VLANDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const VLANDetails = (): JSX.Element => {
);
const vlansLoading = useSelector(vlanSelectors.loading);
const subnets = useSelector((state: RootState) =>
subnetSelectors.getByIds(state, vlan?.subnet_ids || [])
subnetSelectors.getByIds(state, vlan?.subnet_ids || null)
);
useWindowTitle(`${vlan?.name || "VLAN"} details`);

Expand Down

0 comments on commit cb7f12e

Please sign in to comment.