diff --git a/app/routes/_data.machines._index/action.tsx b/app/routes/_data.machines._index/action.tsx index b15d003..90ba1db 100644 --- a/app/routes/_data.machines._index/action.tsx +++ b/app/routes/_data.machines._index/action.tsx @@ -3,6 +3,7 @@ import { ActionFunctionArgs, json } from '@remix-run/node' import { del, post } from '~/utils/headscale' import { getSession } from '~/utils/sessions' +import log from '~/utils/log' export async function menuAction(request: ActionFunctionArgs['request']) { const session = await getSession(request.headers.get('Cookie')) @@ -82,7 +83,9 @@ export async function menuAction(request: ActionFunctionArgs['request']) { case 'tags': { const tags = data.get('tags')?.toString() - .split(',') ?? [] + .split(',') + .filter((tag) => tag.trim() !== '') + ?? [] try { await post(`v1/node/${id}/tags`, session.get('hsApiKey')!, { @@ -90,7 +93,8 @@ export async function menuAction(request: ActionFunctionArgs['request']) { }) return json({ message: 'Tags updated' }) - } catch { + } catch (error) { + log.debug('APIC', 'Failed to update tags: %s', error) return json({ message: 'Failed to update tags' }, { status: 500, }) diff --git a/app/routes/_data.machines._index/dialogs/tags.tsx b/app/routes/_data.machines._index/dialogs/tags.tsx index 418c845..9adccc6 100644 --- a/app/routes/_data.machines._index/dialogs/tags.tsx +++ b/app/routes/_data.machines._index/dialogs/tags.tsx @@ -1,11 +1,11 @@ import { PlusIcon, XIcon } from '@primer/octicons-react' import { Form, useSubmit } from '@remix-run/react' -import { type Dispatch, type SetStateAction, useState } from 'react' +import { Dispatch, SetStateAction, useState } from 'react' import { Button, Input } from 'react-aria-components' import Dialog from '~/components/Dialog' import Link from '~/components/Link' -import { type Machine } from '~/types' +import { Machine } from '~/types' import { cn } from '~/utils/cn' interface TagsProps {