-
Notifications
You must be signed in to change notification settings - Fork 51
fix(PM-3270): removing reviewer when new review config is added or review type is updated #1715
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
Open
hentrymartin
wants to merge
3
commits into
develop
Choose a base branch
from
pm-3270
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,9 +152,9 @@ class ChallengeReviewerField extends Component { | |
| this.loadWorkflows() | ||
| } | ||
|
|
||
| updateAssignedMembers (challengeResources, challenge) { | ||
| updateAssignedMembers (challengeResources, challenge, prevChallenge = null) { | ||
| const reviewersWithPhaseName = challenge.reviewers.map(item => { | ||
| const phase = challenge.phases && challenge.phases.find(p => p.phaseId === item.phaseId) | ||
| const phase = challenge.phases && challenge.phases.find(p => (p.id === item.phaseId) || (p.phaseId === item.phaseId)) | ||
| return { | ||
| ...item, | ||
| name: phase && phase.name | ||
|
|
@@ -171,21 +171,77 @@ class ChallengeReviewerField extends Component { | |
|
|
||
| const assignedMembers = {} | ||
|
|
||
| const unchangedReviewers = new Set() | ||
| if (prevChallenge && prevChallenge.reviewers) { | ||
| const prevReviewers = prevChallenge.reviewers || [] | ||
| challenge.reviewers.forEach((reviewer, index) => { | ||
| const prevReviewer = prevReviewers[index] | ||
|
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. [ |
||
| if (prevReviewer && | ||
| prevReviewer.phaseId === reviewer.phaseId && | ||
| (reviewer.isMemberReview !== false) && | ||
| (prevReviewer.isMemberReview !== false)) { | ||
| unchangedReviewers.add(index) | ||
| if (this.state.assignedMembers[index]) { | ||
| assignedMembers[index] = [...this.state.assignedMembers[index]] | ||
| } | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| challengeResources.forEach((resource) => { | ||
| const indices = reviewerIndex[ResourceToPhaseNameMap[resource.roleName]] || [] | ||
| const phaseName = ResourceToPhaseNameMap[resource.roleName] | ||
| if (!phaseName) return | ||
|
|
||
| const indices = reviewerIndex[phaseName] || [] | ||
|
|
||
| // Distribute resources across all reviewers with the same phase name | ||
| indices.forEach((index) => { | ||
| if (!assignedMembers[index]) { | ||
| assignedMembers[index] = [] | ||
| const reviewer = challenge.reviewers[index] | ||
| if (!reviewer || (reviewer.isMemberReview === false)) return | ||
|
|
||
| if (unchangedReviewers.has(index)) { | ||
| const existing = assignedMembers[index] || [] | ||
| const alreadyAssigned = existing.some(m => | ||
| m && (m.userId === resource.memberId || m.handle === resource.memberHandle) | ||
| ) | ||
| if (!alreadyAssigned) { | ||
| if (!assignedMembers[index]) { | ||
| assignedMembers[index] = [] | ||
| } | ||
| assignedMembers[index].push({ | ||
| handle: resource.memberHandle, | ||
| userId: resource.memberId | ||
| }) | ||
| } | ||
| } else { | ||
| if (!assignedMembers[index]) { | ||
| assignedMembers[index] = [] | ||
| } | ||
| const existing = assignedMembers[index] | ||
| const alreadyAssigned = existing.some(m => | ||
| m && (m.userId === resource.memberId || m.handle === resource.memberHandle) | ||
| ) | ||
| if (!alreadyAssigned) { | ||
| assignedMembers[index].push({ | ||
| handle: resource.memberHandle, | ||
| userId: resource.memberId | ||
| }) | ||
| } | ||
| } | ||
| assignedMembers[index].push({ | ||
| handle: resource.memberHandle, | ||
| userId: resource.memberId | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| // Clean up assignments for reviewers that no longer exist or are no longer member reviewers | ||
| Object.keys(assignedMembers).forEach(indexStr => { | ||
| const index = parseInt(indexStr, 10) | ||
| const reviewer = challenge.reviewers[index] | ||
| if (index >= challenge.reviewers.length || | ||
| !reviewer || | ||
| (reviewer.isMemberReview === false)) { | ||
| delete assignedMembers[index] | ||
| } | ||
| }) | ||
|
|
||
| if (!isEqual(this.state.assignedMembers, assignedMembers)) { | ||
| this.setState({ | ||
| assignedMembers | ||
|
|
@@ -222,7 +278,7 @@ class ChallengeReviewerField extends Component { | |
| })() | ||
|
|
||
| if (challenge && this.doUpdateAssignedMembers && reviewersChanged) { | ||
| this.updateAssignedMembers(challengeResources, challenge) | ||
| this.updateAssignedMembers(challengeResources, challenge, prevChallenge) | ||
| } | ||
|
|
||
| if (challenge && prevChallenge && | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[💡
maintainability]The condition
(p.id === item.phaseId) || (p.phaseId === item.phaseId)might be redundant ifp.idandp.phaseIdare always the same. Ensure that both properties are necessary and distinct. If not, consider simplifying the condition.