Skip to content

Commit

Permalink
Fix administrators not being able to edit and delete B2B organizations
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan committed Sep 30, 2024
1 parent e642fe6 commit 83281b7
Showing 1 changed file with 8 additions and 33 deletions.
41 changes: 8 additions & 33 deletions features/admin.organizations.v1/components/organization-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export const OrganizationList: FunctionComponent<OrganizationListPropsInterface>
const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features);

const hasOrganizationUpdatePermissions: boolean = useRequiredScopes(featureConfig?.organizations?.scopes?.update);
const hasOrganizationDeletePermissions: boolean = useRequiredScopes(featureConfig?.organizations?.scopes?.delete);

const [ showDeleteConfirmationModal, setShowDeleteConfirmationModal ] = useState<boolean>(false);
const [ deletingOrganization, setDeletingOrganization ] = useState<OrganizationInterface>(undefined);

Expand Down Expand Up @@ -426,51 +428,24 @@ export const OrganizationList: FunctionComponent<OrganizationListPropsInterface>
featureConfig?.organizations,
OrganizationManagementConstants.FEATURE_DICTIONARY.get("ORGANIZATION_UPDATE")
),
icon: (organization: OrganizationInterface): SemanticICONS => {

let isAuthorized: boolean = false;

authorizedList?.organizations?.map((org: OrganizationInterface) => {
if (org.id === organization.id) {
isAuthorized = true;
}
});

return !hasOrganizationUpdatePermissions || !isAuthorized
icon: (_organization: OrganizationInterface): SemanticICONS => {
return !hasOrganizationUpdatePermissions
? "eye"
: "pencil alternate";
},
onClick: (e: SyntheticEvent, organization: OrganizationInterface): void =>
handleOrganizationEdit(organization.id),
popupText: (organization: OrganizationInterface ): string => {

let isAuthorized: boolean = false;

authorizedList?.organizations?.map((org: OrganizationInterface) => {
if (org.id === organization.id) {
isAuthorized = true;
}
});

return !hasOrganizationUpdatePermissions || !isAuthorized
popupText: (_organization: OrganizationInterface ): string => {
return !hasOrganizationUpdatePermissions
? t("common:view")
: t("common:edit");
},
renderer: "semantic-icon"
},
{
"data-componentid": `${ componentId }-item-delete-button`,
hidden: (organization: OrganizationInterface): boolean => {

let isAuthorized: boolean = false;

authorizedList?.organizations?.map((org: OrganizationInterface) => {
if (org.id === organization.id) {
isAuthorized = true;
}
});

return !hasOrganizationUpdatePermissions || !isAuthorized;
hidden: (_organization: OrganizationInterface): boolean => {
return !hasOrganizationDeletePermissions;
},
icon: (): SemanticICONS => "trash alternate",
onClick: (e: SyntheticEvent, organization: OrganizationInterface): void => {
Expand Down

0 comments on commit 83281b7

Please sign in to comment.