Skip to content

Commit

Permalink
Enable role creation and deletion capability in sub organization level
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanChathusanda93 committed Jan 2, 2025
1 parent 2236b69 commit d0ea674
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
10 changes: 7 additions & 3 deletions features/admin.roles.v2/components/role-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
IdentifiableComponentInterface,
LoadableComponentInterface,
RoleListInterface,
RolePropertyInterface,
RolesInterface
} from "@wso2is/core/models";
import {
Expand Down Expand Up @@ -296,8 +297,10 @@ export const RoleList: React.FunctionComponent<RoleListProps> = (props: RoleList
},
{
hidden: (role: RolesInterface) => {
return isSubOrg
|| role?.meta?.systemRole
const isSharedRole: boolean = role?.properties?.some((property: RolePropertyInterface) =>
property?.name === "isSharedRole" && property?.value === "true");

return role?.meta?.systemRole
|| (
role?.displayName === CommonRoleConstants.ADMIN_ROLE ||
role?.displayName === CommonRoleConstants.ADMIN_GROUP ||
Expand All @@ -306,7 +309,8 @@ export const RoleList: React.FunctionComponent<RoleListProps> = (props: RoleList
|| !isFeatureEnabled(userRolesFeatureConfig,
RoleConstants.FEATURE_DICTIONARY.get("ROLE_DELETE"))
|| !hasRequiredScopes(userRolesFeatureConfig,
userRolesFeatureConfig?.scopes?.delete, allowedScopes);
userRolesFeatureConfig?.scopes?.delete, allowedScopes)
|| isSharedRole;
},
icon: (): SemanticICONS => "trash alternate",
onClick: (e: SyntheticEvent, role: RolesInterface): void => {
Expand Down
34 changes: 16 additions & 18 deletions features/admin.roles.v2/pages/role.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,25 @@ const RolesPage: FunctionComponent<RolesPagePropsInterface> = (
return (
<PageLayout
action={
!isSubOrg && !isRolesListLoading && (rolesList?.totalResults > 0)
? (
<Show when={ featureConfig?.userRoles?.scopes?.create }>
<PrimaryButton
data-componentid={ `${componentId}-add-button` }
onClick={ () => handleCreateRole() }
>
<Icon
data-componentid={ `${componentId}-add-button-icon` }
name="add"
/>
{ t("roles:list.buttons.addButton", { type: "Role" }) }
</PrimaryButton>
</Show>
) : null
(
<Show when={ featureConfig?.userRoles?.scopes?.create }>
<PrimaryButton
data-componentid={ `${componentId}-add-button` }
onClick={ () => handleCreateRole() }
>
<Icon
data-componentid={ `${componentId}-add-button-icon` }
name="add"
/>
{ t("roles:list.buttons.addButton", { type: "Role" }) }
</PrimaryButton>
</Show>
)
}
title={ t("pages:roles.title") }
pageTitle={ t("pages:roles.title") }
description={ isSubOrg
? t("pages:roles.alternateSubTitle")
: (
description={
(
<>
{ t("pages:roles.subTitle") }
<DocumentationLink
Expand Down
6 changes: 6 additions & 0 deletions modules/core/src/models/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface RolesInterface {
permissions?: string[] | RolePermissionInterface[];
audience?: RoleAudiencesInterface;
associatedApplications?: RoleConnectedApplicationInterface[];
properties?: RolePropertyInterface[];
}

/**
Expand Down Expand Up @@ -101,3 +102,8 @@ export interface RoleConnectedApplicationInterface {
value?: string;
$ref?: string;
}

export interface RolePropertyInterface {
name: string;
value: string;
}

0 comments on commit d0ea674

Please sign in to comment.