Show the Authentik users table as the Users and groups tab opens
The list is the point of that tab, so it is read on open rather than behind a Show users button, for an Authentik that has the management token. If the read fails the button stays, as Try again. Groups are still read on request. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
655b1443ec
commit
43d9ece8bc
2 files changed
+10
-4
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useState, type FormEvent } from "react";
|
||||
import { useEffect, useState, type FormEvent } from "react";
|
||||
import { api, type AuthentikGroup, type AuthentikInfo, type AuthentikPerson } from "../api/client";
|
||||
import AuthentikEditUser, { type AuthentikChange } from "./AuthentikEditUser";
|
||||
import TimeAgo from "./TimeAgo";
|
||||
@@ -7,7 +7,7 @@ import { confirmDialog, promptDialog } from "../utils/dialogs";
|
||||
import { readableError } from "../utils/errors";
|
||||
|
||||
/**
|
||||
* The people in an Authentik, for an administrator to edit, switch off, switch on again or delete. Switching off is the way that can be undone; deleting asks for the user name to be typed.
|
||||
* The people in an Authentik, read when the tab opens, for an administrator to edit, switch off, switch on again or delete. Switching off is the way that can be undone; deleting asks for the user name to be typed.
|
||||
* The account the token belongs to has no buttons, and neither does the last active administrator: the server refuses them too, and says why.
|
||||
*/
|
||||
export default function AuthentikUserList({ a }: { a: AuthentikInfo }) {
|
||||
@@ -21,6 +21,12 @@ export default function AuthentikUserList({ a }: { a: AuthentikInfo }) {
|
||||
const [groups, setGroups] = useState<AuthentikGroup[] | null>(null);
|
||||
const [groupsError, setGroupsError] = useState<string | null>(null);
|
||||
|
||||
// The list is the point of the tab, so it is read as the tab opens. If that fails, the button below tries again.
|
||||
useEffect(() => {
|
||||
if (a.canCreateUsers) void load("");
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [a.id, a.canCreateUsers]);
|
||||
|
||||
if (!a.canCreateUsers) return null;
|
||||
|
||||
async function startEdit(p: AuthentikPerson) {
|
||||
@@ -120,7 +126,7 @@ export default function AuthentikUserList({ a }: { a: AuthentikInfo }) {
|
||||
<ErrorNotice error={error} />
|
||||
{people === null ? (
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => void load()} disabled={busy !== null}>
|
||||
{busy === "list" ? "Reading…" : "Show users"}
|
||||
{busy === "list" ? "Reading…" : error ? "Try again" : "Show users"}
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user