Skip to content

Commit

Permalink
Allow community admins to view manage access tab (#11871)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHuf authored Oct 31, 2024
1 parent 72e5d9f commit 57a27fd
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions apps/web/src/pages/Communities/CommunityLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useQuery } from "urql";
import { ThrowNotFound, Pending } from "@gc-digital-talent/ui";
import { getLocalizedName } from "@gc-digital-talent/i18n";
import { FragmentType, getFragment, graphql } from "@gc-digital-talent/graphql";
import { ROLE_NAME, useAuthorization } from "@gc-digital-talent/auth";
import { unpackMaybes } from "@gc-digital-talent/helpers";
import { ROLE_NAME } from "@gc-digital-talent/auth";
import { notEmpty } from "@gc-digital-talent/helpers";

import SEO from "~/components/SEO/SEO";
import AdminHero from "~/components/HeroDeprecated/AdminHero";
Expand Down Expand Up @@ -108,6 +108,23 @@ const CommunityLayoutCommunityName_Query = graphql(/* GraphQL */ `
...CommunityLayout_Community
teamIdForRoleAssignment
}
myAuth {
roleAssignments {
id
role {
id
name
isTeamBased
}
team {
id
name
}
teamable {
id
}
}
}
}
`);

Expand All @@ -124,11 +141,11 @@ const CommunityLayout = () => {
},
});

const { userAuthInfo } = useAuthorization();
const roleAssignments = unpackMaybes(userAuthInfo?.roleAssignments);
const roleAssignmentsFiltered =
data?.myAuth?.roleAssignments?.filter(notEmpty) ?? [];
const canAdmin = checkRole(
[ROLE_NAME.PlatformAdmin, ROLE_NAME.CommunityAdmin],
roleAssignments,
roleAssignmentsFiltered,
communityId,
);

Expand Down

0 comments on commit 57a27fd

Please sign in to comment.