chore: reorganize settings code layout

This commit is contained in:
Aarnav Tale 2025-04-06 13:44:09 -04:00
parent 0e49ccef8e
commit 85a1dfe4be
No known key found for this signature in database
12 changed files with 27 additions and 23 deletions

View File

@ -28,8 +28,8 @@ export default [
...prefix('/settings', [ ...prefix('/settings', [
index('routes/settings/overview.tsx'), index('routes/settings/overview.tsx'),
route('/auth-keys', 'routes/settings/auth-keys.tsx'), route('/auth-keys', 'routes/settings/auth-keys/overview.tsx'),
route('/restrictions', 'routes/settings/pages/restrictions.tsx'), route('/restrictions', 'routes/settings/restrictions/overview.tsx'),
// route('/local-agent', 'routes/settings/local-agent.tsx'), // route('/local-agent', 'routes/settings/local-agent.tsx'),
]), ]),
]), ]),

View File

View File

@ -4,7 +4,7 @@ import Attribute from '~/components/Attribute';
import Button from '~/components/Button'; import Button from '~/components/Button';
import Code from '~/components/Code'; import Code from '~/components/Code';
import toast from '~/utils/toast'; import toast from '~/utils/toast';
import ExpireKey from '../dialogs/expire'; import ExpireAuthKey from './dialogs/expire-auth-key';
interface Props { interface Props {
authKey: PreAuthKey; authKey: PreAuthKey;
@ -37,7 +37,7 @@ export default function AuthKeyRow({ authKey, server }: Props) {
<div suppressHydrationWarning className="flex gap-4 items-center"> <div suppressHydrationWarning className="flex gap-4 items-center">
{(authKey.used && !authKey.reusable) || {(authKey.used && !authKey.reusable) ||
new Date(authKey.expiration) < new Date() ? undefined : ( new Date(authKey.expiration) < new Date() ? undefined : (
<ExpireKey authKey={authKey} /> <ExpireAuthKey authKey={authKey} />
)} )}
<Button <Button
variant="light" variant="light"

View File

@ -7,12 +7,12 @@ import Select from '~/components/Select';
import Switch from '~/components/Switch'; import Switch from '~/components/Switch';
import type { User } from '~/types'; import type { User } from '~/types';
interface Props { interface AddAuthKeyProps {
users: User[]; users: User[];
} }
// TODO: Tags // TODO: Tags
export default function AddPreAuthKey(data: Props) { export default function AddAuthKey(data: AddAuthKeyProps) {
const [reusable, setReusable] = useState(false); const [reusable, setReusable] = useState(false);
const [ephemeral, setEphemeral] = useState(false); const [ephemeral, setEphemeral] = useState(false);

View File

@ -1,11 +1,11 @@
import Dialog from '~/components/Dialog'; import Dialog from '~/components/Dialog';
import type { PreAuthKey } from '~/types'; import type { PreAuthKey } from '~/types';
interface Props { interface ExpireAuthKeyProps {
authKey: PreAuthKey; authKey: PreAuthKey;
} }
export default function ExpireKey({ authKey }: Props) { export default function ExpireAuthKey({ authKey }: ExpireAuthKeyProps) {
return ( return (
<Dialog> <Dialog>
<Dialog.Button>Expire Key</Dialog.Button> <Dialog.Button>Expire Key</Dialog.Button>

View File

@ -8,8 +8,8 @@ import TableList from '~/components/TableList';
import type { LoadContext } from '~/server'; import type { LoadContext } from '~/server';
import type { PreAuthKey, User } from '~/types'; import type { PreAuthKey, User } from '~/types';
import { send } from '~/utils/res'; import { send } from '~/utils/res';
import AuthKeyRow from './components/key'; import AuthKeyRow from './auth-key-row';
import AddPreAuthKey from './dialogs/new'; import AddAuthKey from './dialogs/add-auth-key';
export async function loader({ export async function loader({
request, request,
@ -168,7 +168,7 @@ export default function Page() {
Tailscale documentation Tailscale documentation
</Link> </Link>
</p> </p>
<AddPreAuthKey users={users} /> <AddAuthKey users={users} />
<div className="flex items-center gap-4 mt-4"> <div className="flex items-center gap-4 mt-4">
<Select <Select
label="Filter by User" label="Filter by User"

View File

@ -9,11 +9,11 @@ import Link from '~/components/Link';
import Notice from '~/components/Notice'; import Notice from '~/components/Notice';
import { LoadContext } from '~/server'; import { LoadContext } from '~/server';
import { Capabilities } from '~/server/web/roles'; import { Capabilities } from '~/server/web/roles';
import { restrictionAction } from '../actions/restriction'; import { restrictionAction } from './actions';
import Restriction from '../components/restriction'; import AddDomain from './dialogs/add-domain';
import AddDomain from '../dialogs/add-domain'; import AddGroup from './dialogs/add-group';
import AddGroup from '../dialogs/add-group'; import AddUser from './dialogs/add-user';
import AddUser from '../dialogs/add-user'; import RestrictionTable from './table';
export async function loader({ export async function loader({
request, request,
@ -92,23 +92,27 @@ export default function Page() {
</Link> </Link>
</p> </p>
</div> </div>
<Restriction <RestrictionTable
type="domain" type="domain"
values={settings.domains} values={settings.domains}
isDisabled={isDisabled} isDisabled={isDisabled}
> >
<AddDomain domains={settings.domains} isDisabled={isDisabled} /> <AddDomain domains={settings.domains} isDisabled={isDisabled} />
</Restriction> </RestrictionTable>
<Restriction <RestrictionTable
type="group" type="group"
values={settings.groups} values={settings.groups}
isDisabled={isDisabled} isDisabled={isDisabled}
> >
<AddGroup groups={settings.groups} isDisabled={isDisabled} /> <AddGroup groups={settings.groups} isDisabled={isDisabled} />
</Restriction> </RestrictionTable>
<Restriction type="user" values={settings.users} isDisabled={isDisabled}> <RestrictionTable
type="user"
values={settings.users}
isDisabled={isDisabled}
>
<AddUser users={settings.users} isDisabled={isDisabled} /> <AddUser users={settings.users} isDisabled={isDisabled} />
</Restriction> </RestrictionTable>
</div> </div>
); );
} }

View File

@ -12,7 +12,7 @@ interface RestrictionProps {
isDisabled?: boolean; isDisabled?: boolean;
} }
export default function Restriction({ export default function RestrictionTable({
children, children,
type, type,
values, values,