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: 4 additions & 1 deletion web/messages/en/modal.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,8 @@
"modal_assign_user_device_ip_card_title": "{deviceName} IP settings",
"modal_assign_user_device_ip_assignment_description": "You can change the IP address for this device separately in each location/network one-by-one.",
"modal_assign_user_device_ip_success": "{deviceName}'s IP addresses were successfully updated.",
"modal_assign_user_device_ip_error": "Failed to update IP addresses"
"modal_assign_user_device_ip_error": "Failed to update IP addresses",
"modal_no_available_locations_title": "Cannot add network device",
"modal_no_available_locations_body": "Network devices can only be added to locations that have MFA disabled. You don't have any locations that meet this requirement. You can create a new location in the Locations section.",
"modal_no_available_locations_go_to_locations": "Go to locations"
}
12 changes: 11 additions & 1 deletion web/src/pages/NetworkDevicesPage/NetworkDevicesTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMutation } from '@tanstack/react-query';
import { useNavigate } from '@tanstack/react-router';
import {
createColumnHelper,
getCoreRowModel,
Expand Down Expand Up @@ -45,6 +46,7 @@ type RowData = NetworkDevice;
const columnHelper = createColumnHelper<RowData>();

export const NetworkDevicesTable = ({ networkDevices }: Props) => {
const navigate = useNavigate();
const reservedNames = useMemo(
() => networkDevices.map((n) => n.name),
[networkDevices],
Expand All @@ -60,7 +62,15 @@ export const NetworkDevicesTable = ({ networkDevices }: Props) => {
['name'],
['asc'],
);
if (!availableLocations.length) return;
if (!availableLocations.length) {
openModal(ModalName.ConfirmAction, {
title: m.modal_no_available_locations_title(),
contentMd: m.modal_no_available_locations_body(),
actionPromise: async () => navigate({ to: '/locations' }),
submitProps: { text: m.modal_no_available_locations_go_to_locations() },
});
return;
}
const { data: availableIps } = await api.network_device.getAvailableIp(
availableLocations[0].id,
);
Expand Down
Loading