import { Construction, Eye, FlaskConical, Pencil } from 'lucide-react'; import { useEffect, useState } from 'react'; import { ActionFunctionArgs, LoaderFunctionArgs, useFetcher, useLoaderData, useRevalidator, } from 'react-router'; import Button from '~/components/Button'; import Code from '~/components/Code'; import Link from '~/components/Link'; import Notice from '~/components/Notice'; import Tabs from '~/components/Tabs'; import type { LoadContext } from '~/server'; import toast from '~/utils/toast'; import { aclAction } from './acl-action'; import { aclLoader } from './acl-loader'; import { Differ, Editor } from './components/cm.client'; export async function loader(request: LoaderFunctionArgs) { return aclLoader(request); } export async function action(request: ActionFunctionArgs) { return aclAction(request); } export default function Page() { // Access is a write check here, we already check read in aclLoader const { access, writable, policy } = useLoaderData(); const [codePolicy, setCodePolicy] = useState(policy); const fetcher = useFetcher(); const { revalidate } = useRevalidator(); const disabled = !access || !writable; // Disable if no permission or not writable useEffect(() => { // Update the codePolicy when the loader data changes if (policy !== codePolicy) { setCodePolicy(policy); } }, [policy]); useEffect(() => { if (!fetcher.data) { // No data yet, return return; } if (fetcher.data.success === true) { toast('Updated policy'); revalidate(); } }, [fetcher.data]); return (
{!access ? ( You do not have the necessary permissions to edit the Access Control List policy. Please contact your administrator to request access or to make changes to the ACL policy. ) : !writable ? ( The ACL policy mode is most likely set to file in your Headscale configuration. This means that the ACL file cannot be edited through the web interface. In order to resolve this, you'll need to set acl.mode to database in your Headscale configuration. ) : undefined}

Access Control List (ACL)

The ACL file is used to define the access control rules for your network. You can find more information about the ACL file in the{' '} Tailscale ACL guide {' '} and the{' '} Headscale docs .

{fetcher.data?.error !== undefined ? ( {fetcher.data.error.split(':').slice(1).join(': ') ?? 'An unknown error occurred while trying to update the ACL policy.'} ) : undefined} Edit file
} > Preview changes } > Preview rules } >

Previewing rules is not available yet. This feature is still in development and is pretty complicated to implement. Hopefully I will be able to get to it soon.

); }