@@ -161,8 +161,6 @@ export default class Resources extends React.Component {
161
161
const currentPhase = getCurrentPhase ( challenge ) . toLowerCase ( )
162
162
const isCurrentPhasesNotSubmissionOrRegistration = _ . every ( [ 'submission' , 'registration' ] , ( phase ) => currentPhase . indexOf ( phase ) < 0 )
163
163
const exceptionHandlesDeleteList = { }
164
- // The creator of the challenge can't be deleted
165
- exceptionHandlesDeleteList [ challenge . createdBy ] = true
166
164
_ . forEach ( submissions , ( s ) => {
167
165
// do not allow to delete submitters who submitted
168
166
exceptionHandlesDeleteList [ s . createdBy ] = true
@@ -182,15 +180,26 @@ export default class Resources extends React.Component {
182
180
] , ( status ) => challenge . status . toUpperCase ( ) === status )
183
181
) {
184
182
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
+ ) {
186
186
// 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
187
192
loggedInUserResource &&
188
193
_ . 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
191
195
) {
192
196
exceptionResourceIdDeleteList [ resourceItem . id ] = true
193
197
}
198
+ } else if (
199
+ // The creator of the challenge can't be deleted
200
+ resourceItem . memberHandle === challenge . createdBy
201
+ ) {
202
+ exceptionResourceIdDeleteList [ resourceItem . id ] = true
194
203
} else if (
195
204
// If the current phase is not submission or registration
196
205
// then we will disable removing reviewers and copilots.
0 commit comments