Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCLOMRS-955 and OCLOMRS-956: Add missing permissions checks for organizations #676

Merged
merged 2 commits into from
Mar 22, 2021

Conversation

suruchee
Copy link
Contributor

Missing Permissions Check for Organization Member Management:OCLOMRS-955 and Missing Permissions Check for "Edit Organization" button:OCLOMRS-956"

…955 and Missing Permissions Check for Edit Organization button:OCLOMRS-956
@coveralls
Copy link

coveralls commented Mar 21, 2021

Coverage Status

Coverage decreased (-0.1%) to 44.784% when pulling 55599f3 on suruchee:OCLOMRS-956 into edea323 on openmrs:master.

Copy link
Collaborator

@hadijahkyampeire hadijahkyampeire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @suruchee , this works well for me. I just have minor suggestions to maintain a good code base, otherwise, I will refer to @ibacher to confirm if this is what is required.

@@ -25,6 +25,7 @@ import {ConfirmationDialog} from "../../../utils";

interface Props {
members?: OrgMember[];
canModifyMembers:boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
canModifyMembers:boolean;
canModifyMembers: boolean;

@@ -59,7 +60,7 @@ const confirmationMsg = () => {
</div>
);
};
const OrganisationMembers: React.FC<Props> = ({ members, orgUrl, addMember, loading, addError, deleteMember ,deleteError}) => {
const OrganisationMembers: React.FC<Props> = ({ canModifyMembers,members, orgUrl, addMember, loading, addError, deleteMember ,deleteError}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const OrganisationMembers: React.FC<Props> = ({ canModifyMembers,members, orgUrl, addMember, loading, addError, deleteMember ,deleteError}) => {
const OrganisationMembers: React.FC<Props> = ({ canModifyMembers, members, orgUrl, addMember, loading, addError, deleteMember ,deleteError}) => {

@@ -109,9 +115,10 @@ const ViewOrganisationPage: React.FC<Props> = ({
retrieveOrgCollections(orgUrl);
retrieveOrgMembers(orgUrl);
}, [orgUrl, retrieveOrg, retrieveOrgCollections, retrieveOrgSources,retrieveOrgMembers]);
const isAnOrgMember = (owner: string, id:string) => Boolean(profile?.username === owner || usersOrgs?.map(org => org.id).includes(id));
const canModify=isAnOrgMember(organisation.created_by, organisation.id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const canModify=isAnOrgMember(organisation.created_by, organisation.id);
const canModify = isAnOrgMember(organisation.created_by, organisation.id);

@@ -1,6 +1,6 @@
import React, {useEffect} from "react";
import {connect} from "react-redux";
import {useLocation} from "react-router-dom";
import {useLocation, useParams} from "react-router-dom";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this import useParams

@@ -29,8 +29,12 @@ import {Grid, makeStyles, createStyles} from "@material-ui/core";
import {EditButton} from "../../containers/components/EditButton";
import {getPrettyError} from "../../../utils";
import { AppState } from "../../../redux";
import {APIOrg, APIProfile, canModifyContainer, profileSelector} from "../../authentication";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this import of canModifyContainer since you are not using it.

@suruchee
Copy link
Contributor Author

Thanks, @hadijahkyampeire for the review, I have updated the PR with improved formatting.

Copy link
Collaborator

@hadijahkyampeire hadijahkyampeire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, well done @suruchee

@ibacher ibacher changed the title Missing Permissions Check for Organization Member Management:OCLOMRS-… OCLOMRS-955 and OCLOMRS-956: Add missing permissions checks for organizations Mar 22, 2021
@ibacher ibacher merged commit 2bc57a5 into openmrs:master Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants