Skip to content

Commit bb85954

Browse files
committed
Additional fix for PROD-4330
1 parent d860cc2 commit bb85954

File tree

1 file changed

+14
-5
lines changed
  • src/components/ChallengeEditor/Resources

1 file changed

+14
-5
lines changed

src/components/ChallengeEditor/Resources/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ export default class Resources extends React.Component {
161161
const currentPhase = getCurrentPhase(challenge).toLowerCase()
162162
const isCurrentPhasesNotSubmissionOrRegistration = _.every(['submission', 'registration'], (phase) => currentPhase.indexOf(phase) < 0)
163163
const exceptionHandlesDeleteList = {}
164-
// The creator of the challenge can't be deleted
165-
exceptionHandlesDeleteList[challenge.createdBy] = true
166164
_.forEach(submissions, (s) => {
167165
// do not allow to delete submitters who submitted
168166
exceptionHandlesDeleteList[s.createdBy] = true
@@ -182,15 +180,26 @@ export default class Resources extends React.Component {
182180
], (status) => challenge.status.toUpperCase() === status)
183181
) {
184182
if (
185-
// Copilots can't delete themselves from the challenge
183+
// The creator of the challenge can't be deleted
184+
resourceItem.memberHandle === challenge.createdBy
185+
) {
186186
// where the copilot has multiple roles, we should allow the additional roles to be deleted, but not the copilot role
187+
if (`${resourceItem.role}`.toLowerCase().indexOf('copilot') >= 0) {
188+
exceptionResourceIdDeleteList[resourceItem.id] = true
189+
}
190+
} else if (
191+
// Copilots can't delete themselves from the challenge
187192
loggedInUserResource &&
188193
_.some(loggedInUserResource.roles, (role) => `${role}`.toLowerCase().indexOf('copilot') >= 0) &&
189-
loggedInUserResource.memberHandle === resourceItem.memberHandle &&
190-
`${resourceItem.role}`.toLowerCase().indexOf('copilot') >= 0
194+
loggedInUserResource.memberHandle === resourceItem.memberHandle
191195
) {
192196
exceptionResourceIdDeleteList[resourceItem.id] = true
193197
}
198+
} else if (
199+
// The creator of the challenge can't be deleted
200+
resourceItem.memberHandle === challenge.createdBy
201+
) {
202+
exceptionResourceIdDeleteList[resourceItem.id] = true
194203
} else if (
195204
// If the current phase is not submission or registration
196205
// then we will disable removing reviewers and copilots.

0 commit comments

Comments
 (0)