Let create/edit client role w/ fine-grained auth. (#32249)
Fixes #31537 Signed-off-by: Stan Silvert <ssilvert@redhat.com>
This commit is contained in:
parent
eeae50fb43
commit
85a0fa389c
3 changed files with 13 additions and 1 deletions
|
@ -12,7 +12,7 @@ export const NewRoleRoute: AppRouteObject = {
|
||||||
element: <CreateClientRole />,
|
element: <CreateClientRole />,
|
||||||
breadcrumb: (t) => t("createRole"),
|
breadcrumb: (t) => t("createRole"),
|
||||||
handle: {
|
handle: {
|
||||||
access: "manage-clients",
|
access: "query-clients",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ export const RoleForm = ({
|
||||||
onSubmit={handleSubmit(onSubmit)}
|
onSubmit={handleSubmit(onSubmit)}
|
||||||
role={role}
|
role={role}
|
||||||
className="pf-v5-u-mt-lg"
|
className="pf-v5-u-mt-lg"
|
||||||
|
fineGrainedAccess={true} // We would never want to show this form in read-only mode
|
||||||
>
|
>
|
||||||
<TextControl
|
<TextControl
|
||||||
name="name"
|
name="name"
|
||||||
|
|
|
@ -80,6 +80,8 @@ export default function RealmRoleTabs() {
|
||||||
"manage-authorization",
|
"manage-authorization",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [canManageClientRole, setCanManageClientRole] = useState(false);
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const convert = (role: RoleRepresentation) => {
|
const convert = (role: RoleRepresentation) => {
|
||||||
const { attributes, ...rest } = role;
|
const { attributes, ...rest } = role;
|
||||||
|
@ -116,6 +118,14 @@ export default function RealmRoleTabs() {
|
||||||
[key],
|
[key],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useFetch(
|
||||||
|
async () => adminClient.clients.findOne({ id: clientId }),
|
||||||
|
(client) => {
|
||||||
|
if (clientId) setCanManageClientRole(client?.access?.manage as boolean);
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
const onSubmit: SubmitHandler<AttributeForm> = async (formValues) => {
|
const onSubmit: SubmitHandler<AttributeForm> = async (formValues) => {
|
||||||
try {
|
try {
|
||||||
const { attributes, ...rest } = formValues;
|
const { attributes, ...rest } = formValues;
|
||||||
|
@ -312,6 +322,7 @@ export default function RealmRoleTabs() {
|
||||||
<AttributesForm
|
<AttributesForm
|
||||||
form={form}
|
form={form}
|
||||||
save={onSubmit}
|
save={onSubmit}
|
||||||
|
fineGrainedAccess={canManageClientRole}
|
||||||
reset={() =>
|
reset={() =>
|
||||||
setValue("attributes", attributes, { shouldDirty: false })
|
setValue("attributes", attributes, { shouldDirty: false })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue