fix: resolve CI lint errors in CopyVlanModal
- Replace ternary-as-statement with if/else (no-unused-expressions) - Escape apostrophe in JSX string (react/no-unescaped-entities) - Wrap targetPorts in useMemo to stabilise useMemo deps - Remove unused setPortDirect helper
This commit is contained in:
@@ -192,7 +192,10 @@ export default function CopyVlanModal({
|
|||||||
queryKey: ['ports', deviceId],
|
queryKey: ['ports', deviceId],
|
||||||
queryFn: () => devicesApi.getPorts(deviceId).then((r) => r.data),
|
queryFn: () => devicesApi.getPorts(deviceId).then((r) => r.data),
|
||||||
});
|
});
|
||||||
const targetPorts: SwitchPort[] = targetPortsData?.ports ?? [];
|
const targetPorts = useMemo<SwitchPort[]>(
|
||||||
|
() => targetPortsData?.ports ?? [],
|
||||||
|
[targetPortsData]
|
||||||
|
);
|
||||||
|
|
||||||
const targetBridgeNames = useMemo(
|
const targetBridgeNames = useMemo(
|
||||||
() => targetPorts.filter((p) => p.type === 'bridge').map((p) => p.name).sort(naturalSort),
|
() => targetPorts.filter((p) => p.type === 'bridge').map((p) => p.name).sort(naturalSort),
|
||||||
@@ -238,13 +241,6 @@ export default function CopyVlanModal({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const setPortDirect = (vlanId: number, portName: string, value: PortAssignment) => {
|
|
||||||
setPortAssignments((prev) => ({
|
|
||||||
...prev,
|
|
||||||
[vlanId]: { ...(prev[vlanId] ?? {}), [portName]: value },
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
const getAssignment = (vlanId: number, portName: string): PortAssignment =>
|
const getAssignment = (vlanId: number, portName: string): PortAssignment =>
|
||||||
portAssignments[vlanId]?.[portName] ?? 'none';
|
portAssignments[vlanId]?.[portName] ?? 'none';
|
||||||
|
|
||||||
@@ -329,7 +325,7 @@ export default function CopyVlanModal({
|
|||||||
const toggleVlan = (vlanId: number) =>
|
const toggleVlan = (vlanId: number) =>
|
||||||
setSelectedVlanIds((prev) => {
|
setSelectedVlanIds((prev) => {
|
||||||
const next = new Set(prev);
|
const next = new Set(prev);
|
||||||
next.has(vlanId) ? next.delete(vlanId) : next.add(vlanId);
|
if (next.has(vlanId)) { next.delete(vlanId); } else { next.add(vlanId); }
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -514,7 +510,7 @@ export default function CopyVlanModal({
|
|||||||
|
|
||||||
{op.status === 'identical' && (
|
{op.status === 'identical' && (
|
||||||
<p className="text-xs text-gray-400 dark:text-slate-500">
|
<p className="text-xs text-gray-400 dark:text-slate-500">
|
||||||
Your port assignment matches what's already on this device — nothing to change.
|
Your port assignment matches what's already on this device — nothing to change.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user