Skip to content

Commit

Permalink
feat: disable edit IDP group button for restricted permissions
Browse files Browse the repository at this point in the history
Signed-off-by: Mason Hu <[email protected]>
  • Loading branch information
MasWho committed Feb 19, 2025
1 parent e25f30a commit 7dcc0b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/permissions/PermissionIdpGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useSettings } from "context/useSettings";
import { Link } from "react-router-dom";
import { useIdpGroups } from "context/useIdpGroups";
import { useServerEntitlements } from "util/entitlements/server";
import { useIdpGroupEntitlements } from "util/entitlements/idp-groups";

const PermissionIdpGroups: FC = () => {
const notify = useNotify();
Expand All @@ -40,6 +41,7 @@ const PermissionIdpGroups: FC = () => {
const { data: settings } = useSettings();
const hasCustomClaim = settings?.config?.["oidc.groups.claim"];
const { canCreateIdpGroups } = useServerEntitlements();
const { canEditGroup } = useIdpGroupEntitlements();

if (error) {
notify.failure("Loading provider groups failed", error);
Expand Down Expand Up @@ -120,7 +122,12 @@ const PermissionIdpGroups: FC = () => {
onClick={() => panelParams.openEditIdpGroup(idpGroup.name)}
type="button"
aria-label="Edit IDP group details"
title="Edit details"
title={
canEditGroup(idpGroup)
? "Edit details"
: "You do not have permission to edit this IDP group"
}
disabled={!canEditGroup(idpGroup)}
>
<Icon name="edit" />
</Button>,
Expand Down

0 comments on commit 7dcc0b7

Please sign in to comment.