Skip to content

Commit

Permalink
Merge pull request wso2#6112 from pavinduLakshan/hide_system_apps
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan authored May 2, 2024
2 parents a9a7cc9 + 0656e0a commit 2a9f30f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/shaggy-spoons-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/core": patch
"@wso2is/features": patch
---

Prevent editing, deleting and assigning groups/users to system roles
7 changes: 4 additions & 3 deletions features/admin.roles.v2/components/edit-role/edit-role.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ export const EditRole: FunctionComponent<EditRoleProps> = (props: EditRoleProps)

const isReadOnly: boolean = useMemo(() => {
return !isFeatureEnabled(featureConfig,
LocalRoleConstants.FEATURE_DICTIONARY.get("ROLE_UPDATE")) ||
!hasRequiredScopes(featureConfig,
featureConfig?.scopes?.update, allowedScopes);
LocalRoleConstants.FEATURE_DICTIONARY.get("ROLE_UPDATE"))
|| !hasRequiredScopes(featureConfig,
featureConfig?.scopes?.update, allowedScopes)
|| roleObject?.meta?.systemRole;
}, [ featureConfig, allowedScopes ]);

const isUserReadOnly: boolean = useMemo(() => {
Expand Down
14 changes: 10 additions & 4 deletions features/admin.roles.v2/components/role-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export const RoleList: React.FunctionComponent<RoleListProps> = (props: RoleList
const resolveTableActions = (): TableActionsInterface[] => {
return [
{
hidden: (role: RolesInterface) => role?.meta?.systemRole,
icon: (): SemanticICONS =>
!isReadOnly
? "pencil alternate"
Expand All @@ -292,14 +293,19 @@ export const RoleList: React.FunctionComponent<RoleListProps> = (props: RoleList
renderer: "semantic-icon"
},
{
hidden: (role: RolesInterface) => isSubOrg ||
(role?.displayName === CommonRoleConstants.ADMIN_ROLE ||
hidden: (role: RolesInterface) => {
return isSubOrg
|| role?.meta?.systemRole
|| (
role?.displayName === CommonRoleConstants.ADMIN_ROLE ||
role?.displayName === CommonRoleConstants.ADMIN_GROUP ||
role?.displayName === administratorRoleDisplayName)
role?.displayName === administratorRoleDisplayName
)
|| !isFeatureEnabled(userRolesFeatureConfig,
RoleConstants.FEATURE_DICTIONARY.get("ROLE_DELETE"))
|| !hasRequiredScopes(userRolesFeatureConfig,
userRolesFeatureConfig?.scopes?.delete, allowedScopes),
userRolesFeatureConfig?.scopes?.delete, allowedScopes);
},
icon: (): SemanticICONS => "trash alternate",
onClick: (e: SyntheticEvent, role: RolesInterface): void => {
onRoleDeleteClicked(role);
Expand Down
1 change: 1 addition & 0 deletions modules/core/src/models/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface RolesMetaInterface {
created?: string;
location: string;
lastModified?: string;
systemRole?: boolean;
}

/**
Expand Down

0 comments on commit 2a9f30f

Please sign in to comment.