Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit f18605e

Browse files
committed
feat: candidate accept/reject permissions
ref issue #100
1 parent 074e0fb commit f18605e

File tree

8 files changed

+42
-23
lines changed

8 files changed

+42
-23
lines changed

src/constants/permissions.js

+24-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* Examples of CORRECT permission naming and meaning:
1111
* - `VIEW_PROJECT`
12-
* - `EDIT_MILESTONE`
12+
* - `UPDATE_MILESTONE`
1313
* - `DELETE_WORK`
1414
*
1515
* Examples of INCORRECT permissions naming and meaning:
@@ -78,31 +78,43 @@ export const PROJECT_ROLE = {
7878

7979
export const PERMISSIONS = {
8080
/**
81-
* Resource Booking
81+
* Job
8282
*/
83-
EDIT_RESOURCE_BOOKING: {
83+
UPDATE_JOB_STATUS: {
8484
meta: {
85-
group: "Resource Booking",
86-
title: "Edit Resource Booking",
85+
group: "Job",
86+
title: 'Edit Job "status"',
8787
},
8888
topcoderRoles: [TOPCODER_ROLE.BOOKING_MANAGER, TOPCODER_ROLE.ADMINISTRATOR],
8989
},
9090

91-
ACCESS_RESOURCE_BOOKING_MEMBER_RATE: {
91+
/**
92+
* Job Candidate
93+
*/
94+
UPDATE_JOB_CANDIDATE: {
9295
meta: {
93-
group: "Resource Booking",
94-
title: "Access Member Rate (view and edit)",
96+
group: "Job Candidate",
97+
title: 'Update Job Candidate',
9598
},
99+
projectRoles: true,
96100
topcoderRoles: [TOPCODER_ROLE.BOOKING_MANAGER, TOPCODER_ROLE.ADMINISTRATOR],
97101
},
98102

99103
/**
100-
* Job
104+
* Resource Booking
101105
*/
102-
EDIT_JOB_STATUS: {
106+
UPDATE_RESOURCE_BOOKING: {
103107
meta: {
104-
group: "Job",
105-
title: 'Edit Job "status"',
108+
group: "Resource Booking",
109+
title: "Edit Resource Booking",
110+
},
111+
topcoderRoles: [TOPCODER_ROLE.BOOKING_MANAGER, TOPCODER_ROLE.ADMINISTRATOR],
112+
},
113+
114+
ACCESS_RESOURCE_BOOKING_MEMBER_RATE: {
115+
meta: {
116+
group: "Resource Booking",
117+
title: "Access Member Rate (view and edit)",
106118
},
107119
topcoderRoles: [TOPCODER_ROLE.BOOKING_MANAGER, TOPCODER_ROLE.ADMINISTRATOR],
108120
},

src/hoc/withAuthentication/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { useParams } from "@reach/router";
2828
export default function withAuthentication(Component) {
2929
const AuthenticatedComponent = (props) => {
3030
const dispatch = useDispatch();
31-
const { isLoggedIn, authError, teamId } = useSelector(
31+
const { isLoggedIn, authError, teamId, teamMembersLoaded, teamMembersLoadingError } = useSelector(
3232
(state) => state.authUser
3333
);
3434
const params = useParams();
@@ -85,11 +85,12 @@ export default function withAuthentication(Component) {
8585
return (
8686
<>
8787
{/* Show loading indicator until we know if user is logged-in or no.
88+
Also, show loading indicator if we need to know team members but haven't loaded them yet.
8889
In we got error during this process, show error */}
89-
{isLoggedIn === null && <LoadingIndicator error={authError} />}
90+
{isLoggedIn === null || (params.teamId && !teamMembersLoaded) && <LoadingIndicator error={authError || teamMembersLoadingError} />}
9091

91-
{/* Show component only if user is logged-in */}
92-
{isLoggedIn === true ? <Component {...props} /> : null}
92+
{/* Show component only if user is logged-in and if we don't need team members or we already loaded them */}
93+
{isLoggedIn === true && (!params.teamId || teamMembersLoaded) ? <Component {...props} /> : null}
9394
</>
9495
);
9596
};

src/hoc/withAuthentication/reducers/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const initialState = {
1515
teamMembers: undefined,
1616
teamMembersLoading: undefined,
1717
teamMembersLoadingError: undefined,
18+
teamMembersLoaded: false,
1819
};
1920

2021
const authInitialState = _.pick(initialState, [
@@ -56,6 +57,7 @@ const reducer = (state = initialState, action) => {
5657
teamMembers: initialState.teamMembersLoadingError,
5758
teamMembersLoading: true,
5859
teamMembersLoadingError: initialState.teamMembersLoadingError,
60+
teamMembersLoaded: false,
5961
};
6062

6163
case ACTION_TYPE.AUTH_LOAD_TEAM_MEMBERS_SUCCESS: {
@@ -65,6 +67,7 @@ const reducer = (state = initialState, action) => {
6567
...state,
6668
teamMembersLoading: false,
6769
teamMembers: action.payload,
70+
teamMembersLoaded: true,
6871
};
6972
}
7073

@@ -78,6 +81,7 @@ const reducer = (state = initialState, action) => {
7881
...state,
7982
teamMembersLoading: false,
8083
teamMembersLoadingError: action.payload,
84+
teamMembersLoaded: false,
8185
};
8286
}
8387

src/routes/JobForm/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const getEditJobConfig = (skillOptions, onSubmit) => {
103103
validationMessage: "Please, select Status",
104104
name: "status",
105105
selectOptions: STATUS_OPTIONS,
106-
disabled: !hasPermission(PERMISSIONS.EDIT_JOB_STATUS),
106+
disabled: !hasPermission(PERMISSIONS.UPDATE_JOB_STATUS),
107107
},
108108
],
109109
onSubmit: onSubmit,

src/routes/MyTeamsDetails/components/TeamMembers/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ const TeamMembers = ({ team }) => {
158158
`/taas/myteams/${team.id}/rb/${member.id}/edit`
159159
);
160160
},
161-
hidden: !hasPermission(PERMISSIONS.EDIT_RESOURCE_BOOKING),
161+
hidden: !hasPermission(PERMISSIONS.UPDATE_RESOURCE_BOOKING),
162162
},
163163
{
164164
separator: true,
165-
hidden: !hasPermission(PERMISSIONS.EDIT_RESOURCE_BOOKING),
165+
hidden: !hasPermission(PERMISSIONS.UPDATE_RESOURCE_BOOKING),
166166
},
167167
{
168168
label: "Report an Issue",

src/routes/PositionDetails/components/PositionCandidates/index.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import Pagination from "components/Pagination";
2323
import IconResume from "../../../../assets/images/icon-resume.svg";
2424
import { toastr } from "react-redux-toastr";
2525
import { getJobById } from "services/jobs";
26+
import { PERMISSIONS } from "constants/permissions";
27+
import { hasPermission } from "utils/permissions";
2628

2729
/**
2830
* Generates a function to sort candidates
@@ -192,7 +194,7 @@ const PositionCandidates = ({ position, candidateStatus, updateCandidate }) => {
192194
)}
193195
</div>
194196
<div styleName="table-cell cell-action">
195-
{candidateStatus === CANDIDATE_STATUS.OPEN && (
197+
{candidateStatus === CANDIDATE_STATUS.OPEN && hasPermission(PERMISSIONS.UPDATE_JOB_CANDIDATE) && (
196198
<>
197199
Interested in this candidate?
198200
<div styleName="actions">

src/routes/ResourceBookingDetails/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const ResourceBookingDetails = ({ teamId, resourceBookingId }) => {
6363
<div styleName="content-wrapper">
6464
<ResourceSummary member={member} />
6565
<ResourceDetails resource={resource} jobTitle={jobTitle} />
66-
{hasPermission(PERMISSIONS.EDIT_RESOURCE_BOOKING) && (
66+
{hasPermission(PERMISSIONS.UPDATE_RESOURCE_BOOKING) && (
6767
<div styleName="actions">
6868
<Button
6969
size="medium"

src/routes/ResourceBookingForm/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { hasPermission } from "utils/permissions";
1414
import { PERMISSIONS } from "constants/permissions";
1515

16-
const EDIT_RESOURCE_BOOKING_ROWS = [
16+
const UPDATE_RESOURCE_BOOKING_ROWS = [
1717
{ type: FORM_ROW_TYPE.SINGLE, fields: ["handle"] },
1818
{ type: FORM_ROW_TYPE.SINGLE, fields: ["jobTitle"] },
1919
{ type: FORM_ROW_TYPE.GROUP, fields: ["startDate", "endDate"] },
@@ -99,6 +99,6 @@ export const getEditResourceBookingConfig = (onSubmit) => {
9999
},
100100
],
101101
onSubmit: onSubmit,
102-
rows: EDIT_RESOURCE_BOOKING_ROWS,
102+
rows: UPDATE_RESOURCE_BOOKING_ROWS,
103103
};
104104
};

0 commit comments

Comments
 (0)