fix: clicking a machine name in users page redirects

This commit is contained in:
Aarnav Tale 2024-11-04 14:59:13 -05:00
parent 331a9c8dcf
commit d5ee8ae0f3
No known key found for this signature in database
2 changed files with 11 additions and 5 deletions

View File

@ -6,14 +6,19 @@ interface Props {
name: string
value: string
isCopyable?: boolean
link?: string
}
export default function Attribute({ name, value, isCopyable }: Props) {
export default function Attribute({ name, value, link, isCopyable }: Props) {
const canCopy = isCopyable ?? false
return (
<dl className="flex gap-1 text-sm w-full">
<dt className="w-1/2 shrink-0 min-w-0 truncate text-gray-700 dark:text-gray-300 py-1">
{name}
{link ? (
<a className="hover:underline" href={link}>
{name}
</a>
) : name}
</dt>
{canCopy

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { type DataRef, DndContext, useDraggable, useDroppable } from '@dnd-kit/core'
import { DataRef, DndContext, useDraggable, useDroppable } from '@dnd-kit/core'
import { PersonIcon } from '@primer/octicons-react'
import { type ActionFunctionArgs, json, type LoaderFunctionArgs } from '@remix-run/node'
import { ActionFunctionArgs, json, LoaderFunctionArgs } from '@remix-run/node'
import { useActionData, useLoaderData, useSubmit } from '@remix-run/react'
import { useEffect, useState } from 'react'
import { ClientOnly } from 'remix-utils/client-only'
@ -10,7 +10,7 @@ import Attribute from '~/components/Attribute'
import Card from '~/components/Card'
import StatusCircle from '~/components/StatusCircle'
import { toast } from '~/components/Toaster'
import { type Machine, type User } from '~/types'
import { Machine, User } from '~/types'
import { cn } from '~/utils/cn'
import { loadContext } from '~/utils/config/headplane'
import { loadConfig } from '~/utils/config/headscale'
@ -299,6 +299,7 @@ function MachineChip({ machine }: { readonly machine: Machine }) {
<StatusCircle isOnline={machine.online} className="w-4 h-4 px-1 w-fit" />
<Attribute
name={machine.givenName}
link={`machines/${machine.id}`}
value={machine.ipAddresses[0]}
/>
</div>