mirror of
https://github.com/tale/headplane.git
synced 2026-08-26 04:16:49 +00:00
fix: use new headscale user api routes
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
import Code from '~/components/Code';
|
||||
import Dialog from '~/components/Dialog';
|
||||
import Input from '~/components/Input';
|
||||
|
||||
export default function Add() {
|
||||
return (
|
||||
<Dialog>
|
||||
<Dialog.Button>Add a new user</Dialog.Button>
|
||||
<Dialog.Panel>
|
||||
<Dialog.Title>Add a new user</Dialog.Title>
|
||||
<Dialog.Text className="mb-8">
|
||||
Enter a username to create a new user. Usernames can be addressed when
|
||||
managing ACL policies.
|
||||
</Dialog.Text>
|
||||
<input type="hidden" name="_method" value="create" />
|
||||
<Input
|
||||
isRequired
|
||||
name="username"
|
||||
label="Username"
|
||||
placeholder="my-new-user"
|
||||
/>
|
||||
</Dialog.Panel>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import Dialog from '~/components/Dialog';
|
||||
import Input from '~/components/Input';
|
||||
|
||||
// TODO: Support image upload for user avatars
|
||||
export default function CreateUser() {
|
||||
return (
|
||||
<Dialog>
|
||||
<Dialog.Button>Add a new user</Dialog.Button>
|
||||
<Dialog.Panel>
|
||||
<Dialog.Title>Add a new user</Dialog.Title>
|
||||
<Dialog.Text className="mb-6">
|
||||
Enter a username to create a new user. Usernames can be addressed when
|
||||
managing ACL policies.
|
||||
</Dialog.Text>
|
||||
<input type="hidden" name="action_id" value="create_user" />
|
||||
<div className="flex flex-col gap-4">
|
||||
<Input
|
||||
isRequired
|
||||
name="username"
|
||||
label="Username"
|
||||
placeholder="my-new-user"
|
||||
/>
|
||||
<Input
|
||||
name="display_name"
|
||||
label="Display Name"
|
||||
placeholder="John Doe"
|
||||
/>
|
||||
<Input name="email" label="Email" placeholder="name@example.com" />
|
||||
</div>
|
||||
</Dialog.Panel>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { X } from 'lucide-react';
|
||||
import Dialog from '~/components/Dialog';
|
||||
import { User } from '~/types';
|
||||
|
||||
interface Props {
|
||||
user: User;
|
||||
}
|
||||
|
||||
// TODO: Warn that OIDC users will be recreated on next login
|
||||
export default function DeleteUser({ user }: Props) {
|
||||
const name =
|
||||
(user.displayName?.length ?? 0) > 0 ? user.displayName : user.name;
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<Dialog.IconButton label={`Delete ${name}`}>
|
||||
<X className="p-0.5" />
|
||||
</Dialog.IconButton>
|
||||
<Dialog.Panel>
|
||||
<Dialog.Title>Delete {name}?</Dialog.Title>
|
||||
<Dialog.Text className="mb-6">
|
||||
Are you sure you want to delete {name}? A deleted user cannot be
|
||||
recovered.
|
||||
</Dialog.Text>
|
||||
<input type="hidden" name="action_id" value="delete_user" />
|
||||
<input type="hidden" name="user_id" value={user.id} />
|
||||
</Dialog.Panel>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { X } from 'lucide-react';
|
||||
import Code from '~/components/Code';
|
||||
import Dialog from '~/components/Dialog';
|
||||
|
||||
interface Props {
|
||||
username: string;
|
||||
}
|
||||
|
||||
export default function Remove({ username }: Props) {
|
||||
return (
|
||||
<Dialog>
|
||||
<Dialog.IconButton label={`Delete ${username}`}>
|
||||
<X className="p-0.5" />
|
||||
</Dialog.IconButton>
|
||||
<Dialog.Panel>
|
||||
<Dialog.Title>Delete {username}?</Dialog.Title>
|
||||
<Dialog.Text className="mb-8">
|
||||
Are you sure you want to delete {username}? A deleted user cannot be
|
||||
recovered.
|
||||
</Dialog.Text>
|
||||
<input type="hidden" name="_method" value="delete" />
|
||||
<input type="hidden" name="username" value={username} />
|
||||
</Dialog.Panel>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,35 +1,34 @@
|
||||
import { Pencil } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import Dialog from '~/components/Dialog';
|
||||
import Input from '~/components/Input';
|
||||
import { User } from '~/types';
|
||||
|
||||
interface Props {
|
||||
username: string;
|
||||
user: User;
|
||||
}
|
||||
|
||||
// TODO: Server side validation before submitting
|
||||
export default function Rename({ username }: Props) {
|
||||
const [newName, setNewName] = useState(username);
|
||||
|
||||
export default function RenameUser({ user }: Props) {
|
||||
return (
|
||||
<Dialog>
|
||||
<Dialog.IconButton label={`Rename ${username}`}>
|
||||
<Dialog.IconButton label={`Rename ${user.name}`}>
|
||||
<Pencil className="p-1" />
|
||||
</Dialog.IconButton>
|
||||
<Dialog.Panel>
|
||||
<Dialog.Title>Rename {username}?</Dialog.Title>
|
||||
<Dialog.Text className="mb-8">
|
||||
Enter a new username for {username}. Changing a username will not
|
||||
<Dialog.Title>Rename {user.name}?</Dialog.Title>
|
||||
<Dialog.Text className="mb-6">
|
||||
Enter a new username for {user.name}. Changing a username will not
|
||||
update any ACL policies that may refer to this user by their old
|
||||
username.
|
||||
</Dialog.Text>
|
||||
<input type="hidden" name="_method" value="rename" />
|
||||
<input type="hidden" name="old" value={username} />
|
||||
<input type="hidden" name="action_id" value="rename_user" />
|
||||
<input type="hidden" name="user_id" value={user.id} />
|
||||
<Input
|
||||
isRequired
|
||||
name="new"
|
||||
name="new_name"
|
||||
label="Username"
|
||||
placeholder="my-new-name"
|
||||
defaultValue={user.name}
|
||||
/>
|
||||
</Dialog.Panel>
|
||||
</Dialog>
|
||||
Reference in New Issue
Block a user