-
Notifications
You must be signed in to change notification settings - Fork 6
use review period permissions in UI #2444
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
Changes from all commits
a8cd70e
6f7e6fa
85f127c
a6d69ea
8bec441
0550945
d68e1cc
e8128d8
3f74be0
a13315e
c671c77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| import PropTypes from 'prop-types'; | ||
| import queryString from 'query-string'; | ||
| import React, { | ||
| useEffect, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alphabetized imported items.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My OCD thanks you for this! |
||
| useContext, | ||
| useCallback, | ||
| useContext, | ||
| useEffect, | ||
| useRef, | ||
| useState, | ||
| useRef | ||
| } from 'react'; | ||
| import { useLocation, useHistory } from 'react-router-dom'; | ||
|
|
||
|
|
@@ -65,6 +65,9 @@ import { | |
| selectCurrentMembers, | ||
| selectCurrentUser, | ||
| selectCurrentUserSubordinates, | ||
| selectHasDeleteReviewPeriodPermission, | ||
| selectHasLaunchReviewPeriodPermission, | ||
| selectHasUpdateReviewPeriodPermission, | ||
| selectIsAdmin, | ||
| selectReviewPeriod, | ||
| selectSupervisors, | ||
|
|
@@ -127,6 +130,7 @@ const TeamReviews = ({ onBack, periodId }) => { | |
|
|
||
| const [approvalMode, setApprovalMode] = useState(false); | ||
| const [assignments, setAssignments] = useState([]); | ||
| const [canUpdate, setCanUpdate] = useState(false); | ||
| const [confirmApproveAllOpen, setConfirmApproveAllOpen] = useState(false); | ||
| const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false); | ||
| const [confirmationText, setConfirmationText] = useState(''); | ||
|
|
@@ -174,6 +178,7 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| isManager && period.reviewStatus === ReviewStatus.AWAITING_APPROVAL | ||
| ); | ||
| } | ||
| setCanUpdate(selectHasUpdateReviewPeriodPermission(state)); | ||
| }, [state]); | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -735,7 +740,7 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| key={reviewer.id} | ||
| label={reviewer.name} | ||
| variant="outlined" | ||
| onDelete={() => deleteReviewer(member, reviewer)} | ||
| onDelete={canUpdate ? () => deleteReviewer(member, reviewer) : null} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lots of UI elements are not either removed or disabled based on the values of |
||
| style={{ | ||
| backgroundColor: reviewer.approved | ||
| ? 'var(--checkins-palette-action-green)' | ||
|
|
@@ -753,7 +758,8 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| case ReviewStatus.PLANNING: | ||
| return <Button onClick={requestApproval}>Request Approval</Button>; | ||
| case ReviewStatus.AWAITING_APPROVAL: | ||
| return <Button onClick={requestApproval}>Launch Review</Button>; | ||
| return selectHasLaunchReviewPeriodPermission(state) ? | ||
| <Button onClick={requestApproval}>Launch Review</Button> : null; | ||
| default: | ||
| return null; | ||
| } | ||
|
|
@@ -843,37 +849,43 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| <Typography variant="h4">{period?.name ?? ''} Team Reviews</Typography> | ||
| {period && isAdmin && ( | ||
| <div> | ||
| <Tooltip | ||
| title={ | ||
| period.reviewStatus === ReviewStatus.OPEN | ||
| ? 'Archive' | ||
| : 'Unarchive' | ||
| } | ||
| > | ||
| <IconButton | ||
| onClick={toggleReviewPeriod} | ||
| aria-label={ | ||
| {canUpdate && ( | ||
| <Tooltip | ||
| title={ | ||
| period.reviewStatus === ReviewStatus.OPEN | ||
| ? 'Archive' | ||
| : 'Unarchive' | ||
| } | ||
| > | ||
| {period.reviewStatus === ReviewStatus.OPEN ? ( | ||
| <Archive /> | ||
| ) : ( | ||
| <Unarchive /> | ||
| )} | ||
| </IconButton> | ||
| </Tooltip> | ||
| <Tooltip title="Delete"> | ||
| <IconButton | ||
| onClick={confirmDelete} | ||
| edge="end" | ||
| aria-label="Delete" | ||
| > | ||
| <Delete /> | ||
| </IconButton> | ||
| </Tooltip> | ||
| <IconButton | ||
| onClick={toggleReviewPeriod} | ||
| aria-label={ | ||
| period.reviewStatus === ReviewStatus.OPEN | ||
| ? 'Archive' | ||
| : 'Unarchive' | ||
| } | ||
| > | ||
| {period.reviewStatus === ReviewStatus.OPEN ? ( | ||
| <Archive /> | ||
| ) : ( | ||
| <Unarchive /> | ||
| )} | ||
| </IconButton> | ||
| </Tooltip> | ||
| )} | ||
|
|
||
| {selectHasDeleteReviewPeriodPermission(state) && ( | ||
| <Tooltip title="Delete"> | ||
| <IconButton | ||
| onClick={confirmDelete} | ||
| edge="end" | ||
| aria-label="Delete" | ||
| > | ||
| <Delete /> | ||
| </IconButton> | ||
| </Tooltip> | ||
| )} | ||
|
|
||
| {approvalMode && ( | ||
| <FormControlLabel | ||
| control={ | ||
|
|
@@ -896,20 +908,20 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| date={period.launchDate} | ||
| setDate={val => handleLaunchDateChange(val, period)} | ||
| label="Launch Date" | ||
| disabled={!isAdmin} | ||
| disabled={!canUpdate} | ||
| open={period?.reviewStatus === ReviewStatus?.PLANNING} | ||
| /> | ||
| <DatePickerField | ||
| date={period.selfReviewCloseDate} | ||
| setDate={val => handleSelfReviewDateChange(val, period)} | ||
| label="Self-Review Date" | ||
| disabled={!isAdmin} | ||
| disabled={!canUpdate} | ||
| /> | ||
| <DatePickerField | ||
| date={period.closeDate} | ||
| setDate={val => handleCloseDateChange(val, period)} | ||
| label="Close Date" | ||
| disabled={!isAdmin} | ||
| disabled={!canUpdate} | ||
| /> | ||
| </div> | ||
| {approvalButton()} | ||
|
|
@@ -938,22 +950,25 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| ) | ||
| }} | ||
| /> | ||
| <div> | ||
| <Button onClick={() => setConfirmApproveAllOpen(true)}> | ||
| Approve All | ||
| </Button> | ||
| <Button onClick={unapproveAll}>Unapprove All</Button> | ||
| </div> | ||
| {canUpdate && ( | ||
| <div> | ||
| <Button onClick={() => setConfirmApproveAllOpen(true)}> | ||
| Approve All | ||
| </Button> | ||
| <Button onClick={unapproveAll}>Unapprove All</Button> | ||
| </div> | ||
| )} | ||
| </div> | ||
| )} | ||
|
|
||
| {/* TODO: Only render this if the user has a specific permission. */} | ||
| <MemberSelector | ||
| className="team-skill-member-selector" | ||
| exportable | ||
| onChange={updateTeamMembers} | ||
| selected={teamMembers} | ||
| /> | ||
| {canUpdate && ( | ||
| <MemberSelector | ||
| className="team-skill-member-selector" | ||
| exportable | ||
| onChange={updateTeamMembers} | ||
| selected={teamMembers} | ||
| /> | ||
| )} | ||
|
|
||
| <List dense role="list"> | ||
| {visibleTeamMembers().map(member => ( | ||
|
|
@@ -970,13 +985,17 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| <div className="chip-row"> | ||
| <Typography>Reviewers:</Typography> | ||
| {renderReviewers(member)} | ||
| <IconButton | ||
| aria-label="Edit Reviewers" | ||
| onClick={() => editReviewers(member)} | ||
| > | ||
| <AddCircle /> | ||
| </IconButton> | ||
| {approvalMode && ( | ||
|
|
||
| {canUpdate && ( | ||
| <IconButton | ||
| aria-label="Edit Reviewers" | ||
| onClick={() => editReviewers(member)} | ||
| > | ||
| <AddCircle /> | ||
| </IconButton> | ||
| )} | ||
|
|
||
| {canUpdate && approvalMode && ( | ||
| <Button onClick={() => toggleApproval(member)}> | ||
| {isMemberApproved(member) ? 'Unapprove' : 'Approve'} | ||
| </Button> | ||
|
|
@@ -1020,9 +1039,7 @@ const TeamReviews = ({ onBack, periodId }) => { | |
| </DialogContent> | ||
| <DialogActions> | ||
| <Button onClick={handleConfirmDeleteClose}>No</Button> | ||
| <Button onClick={deleteReviewPeriod} autoFocus> | ||
| Yes | ||
| </Button> | ||
| <Button onClick={deleteReviewPeriod} autoFocus>Yes</Button> | ||
| </DialogActions> | ||
| </Dialog> | ||
| <Dialog | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was renamed to
selectHasViewPulseReportPermissionfor consistency with other permissions.