Skip to content

Commit

Permalink
Enable the role basics update and role permissions update for sub org…
Browse files Browse the repository at this point in the history
…anization roles
  • Loading branch information
ShanChathusanda93 committed Jan 26, 2025
1 parent 0f974ff commit 4038dce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-mice-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.roles.v2": patch
---

enable role basic update and role permission update in sub org roles
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { useAPIResources } from "@wso2is/admin.api-resources.v2/api";
import { useGetAuthorizedAPIList } from "@wso2is/admin.api-resources.v2/api/useGetAuthorizedAPIList";
import { APIResourceCategories, APIResourcesConstants } from "@wso2is/admin.api-resources.v2/constants";
import { APIResourceUtils } from "@wso2is/admin.api-resources.v2/utils/api-resource-utils";
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";
import {
AlertInterface,
AlertLevels,
Expand Down Expand Up @@ -95,7 +94,6 @@ export const UpdatedRolePermissionDetails: FunctionComponent<RolePermissionDetai

const { t } = useTranslation();
const dispatch: Dispatch = useDispatch();
const { isSubOrganization } = useGetCurrentOrganizationType();

const [ isSubmitting, setIsSubmitting ] = useState<boolean>(false);
const [ selectedAPIResourceId, setSelectedAPIResourceId ] = useState<string>(undefined);
Expand All @@ -109,7 +107,7 @@ export const UpdatedRolePermissionDetails: FunctionComponent<RolePermissionDetai
const [ apiCallNextAfterValue, setAPICallNextAfterValue ] = useState<string>(null);

const shouldFetchAPIResources: boolean = role?.audience?.type?.
toUpperCase() === RoleAudienceTypes.ORGANIZATION && !isSubOrganization();
toUpperCase() === RoleAudienceTypes.ORGANIZATION;

const {
data: currentAPIResourcesListData,
Expand Down
9 changes: 3 additions & 6 deletions features/admin.roles.v2/components/edit-role/edit-role.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

import { AppState, FeatureConfigInterface, OrganizationType } from "@wso2is/admin.core.v1";
import { AppState, FeatureConfigInterface } from "@wso2is/admin.core.v1";
import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type";

Check warning on line 20 in features/admin.roles.v2/components/edit-role/edit-role.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

'useGetCurrentOrganizationType' is defined but never used. Allowed unused vars must match /^_/u
import { UserManagementConstants } from "@wso2is/admin.users.v1/constants";
import { RoleConstants } from "@wso2is/core/constants";
Expand Down Expand Up @@ -69,7 +69,6 @@ export const EditRole: FunctionComponent<EditRoleProps> = (props: EditRoleProps)
} = props;

const { t } = useTranslation();
const { organizationType } = useGetCurrentOrganizationType();

const featureConfig: FeatureAccessConfigInterface = useSelector(
(state: AppState) => state?.config?.ui?.features?.userRoles);
Expand Down Expand Up @@ -100,8 +99,6 @@ export const EditRole: FunctionComponent<EditRoleProps> = (props: EditRoleProps)
const [ isAdminRole, setIsAdminRole ] = useState<boolean>(false);
const [ isEveryoneRole, setIsEveryoneRole ] = useState<boolean>(false);

const isSubOrg: boolean = organizationType === OrganizationType.SUBORGANIZATION;

/**
* Set the if the role is `Internal/admin`.
*/
Expand All @@ -122,7 +119,7 @@ export const EditRole: FunctionComponent<EditRoleProps> = (props: EditRoleProps)
render: () => (
<ResourceTab.Pane controlledSegmentation attached={ false }>
<BasicRoleDetails
isReadOnly={ isSubOrg || isAdminRole || isEveryoneRole || isReadOnly }
isReadOnly={ isAdminRole || isEveryoneRole || isReadOnly }
role={ roleObject }
onRoleUpdate={ onRoleUpdate }
tabIndex={ 0 }
Expand All @@ -135,7 +132,7 @@ export const EditRole: FunctionComponent<EditRoleProps> = (props: EditRoleProps)
render: () => (
<ResourceTab.Pane controlledSegmentation attached={ false }>
<UpdatedRolePermissionDetails
isReadOnly={ isSubOrg || isAdminRole || isReadOnly }
isReadOnly={ isAdminRole || isReadOnly }
role={ roleObject }
onRoleUpdate={ onRoleUpdate }
tabIndex={ 1 }
Expand Down

0 comments on commit 4038dce

Please sign in to comment.