feat(admin): streamline group management
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { AdminModalForm } from "./admin-modal-form";
|
||||
|
||||
export function GroupPolicyControl({
|
||||
action,
|
||||
enabled,
|
||||
groupId,
|
||||
groupName,
|
||||
memberCount,
|
||||
policy,
|
||||
returnLocation,
|
||||
}: {
|
||||
action: (formData: FormData) => Promise<void>;
|
||||
enabled: boolean;
|
||||
groupId: string;
|
||||
groupName: string;
|
||||
memberCount: number;
|
||||
policy: string;
|
||||
returnLocation: "list" | "detail";
|
||||
}) {
|
||||
const nextState = enabled ? "deny" : "allow";
|
||||
return (
|
||||
<AdminModalForm
|
||||
action={action}
|
||||
description={`${nextState === "allow" ? "Allow" : "Deny"} ${policy.toLowerCase()} for ${memberCount} effective ${memberCount === 1 ? "member" : "members"} of ${groupName}.`}
|
||||
submitLabel={`${nextState === "allow" ? "Allow" : "Deny"} access`}
|
||||
title={`${nextState === "allow" ? "Allow" : "Deny"} ${policy}?`}
|
||||
triggerClassName={`min-w-24 border px-3 py-2 font-mono text-[9px] font-bold uppercase tracking-wider ${enabled ? "border-signal bg-signal text-ink" : "border-accent bg-transparent text-accent"}`}
|
||||
triggerLabel={enabled ? "Allowed" : "Denied"}
|
||||
triggerPressed={enabled}
|
||||
>
|
||||
<input name="groupId" type="hidden" value={groupId} />
|
||||
<input name="enabled" type="hidden" value={enabled ? "no" : "yes"} />
|
||||
<input name="returnLocation" type="hidden" value={returnLocation} />
|
||||
</AdminModalForm>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user