Skip to content

Commit ce7f7cf

Browse files
committed
Merge branch 'develop' into cf-jan-2021
# Conflicts: # src/components/ChallengeEditor/index.js # src/containers/ChallengeEditor/index.js
2 parents ca73946 + 39671b8 commit ce7f7cf

File tree

12 files changed

+20
-190
lines changed

12 files changed

+20
-190
lines changed

src/actions/challenges.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
fetchGroupDetail,
1717
updateChallenge,
1818
patchChallenge,
19-
deleteChallenge as deleteChallengeAPI,
2019
createChallenge as createChallengeAPI,
2120
createResource as createResourceAPI,
2221
deleteResource as deleteResourceAPI
@@ -40,9 +39,6 @@ import {
4039
CREATE_CHALLENGE_PENDING,
4140
CREATE_CHALLENGE_SUCCESS,
4241
CREATE_CHALLENGE_FAILURE,
43-
DELETE_CHALLENGE_PENDING,
44-
DELETE_CHALLENGE_SUCCESS,
45-
DELETE_CHALLENGE_FAILURE,
4642
LOAD_CHALLENGE_RESOURCES
4743
} from '../config/constants'
4844
import { loadProject } from './projects'
@@ -280,26 +276,6 @@ export function partiallyUpdateChallengeDetails (challengeId, partialChallengeDe
280276
}
281277
}
282278

283-
export function deleteChallenge (challengeId) {
284-
return async (dispatch) => {
285-
dispatch({
286-
type: DELETE_CHALLENGE_PENDING
287-
})
288-
289-
return deleteChallengeAPI(challengeId).then((challenge) => {
290-
return dispatch({
291-
type: DELETE_CHALLENGE_SUCCESS,
292-
challengeDetails: challenge
293-
})
294-
}).catch((error) => {
295-
dispatch({
296-
type: DELETE_CHALLENGE_FAILURE
297-
})
298-
throw error
299-
})
300-
}
301-
}
302-
303279
export function loadTimelineTemplates () {
304280
return async (dispatch) => {
305281
const timelineTemplates = await fetchTimelineTemplates()

src/components/ChallengeEditor/ChallengeEditor.module.scss

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
.actionButtons {
242242
position: absolute;
243243
top: 30px;
244-
a,button {
244+
a {
245245
height: 40px;
246246
}
247247
}
@@ -251,13 +251,7 @@
251251
}
252252

253253
.actionButtonsRight {
254-
display: flex;
255-
align-items: center;
256254
right: 20px;
257-
258-
button {
259-
margin-right: 20px;
260-
}
261255
}
262256

263257
.buttonContainer {

src/components/ChallengeEditor/index.js

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class ChallengeEditor extends Component {
6868
super(props)
6969
this.state = {
7070
isLaunch: false,
71-
isDeleteLaunch: false,
7271
isConfirm: false,
7372
isClose: false,
7473
isOpenAdvanceSettings: false,
@@ -123,8 +122,6 @@ class ChallengeEditor extends Component {
123122
this.getAvailableTimelineTemplates = this.getAvailableTimelineTemplates.bind(this)
124123
this.autoUpdateChallengeThrottled = _.throttle(this.validateAndAutoUpdateChallenge.bind(this), 3000) // 3s
125124
this.updateResource = this.updateResource.bind(this)
126-
this.onDeleteChallenge = this.onDeleteChallenge.bind(this)
127-
this.deleteModalLaunch = this.deleteModalLaunch.bind(this)
128125
}
129126

130127
componentDidMount () {
@@ -135,27 +132,6 @@ class ChallengeEditor extends Component {
135132
this.resetChallengeData(this.setState.bind(this))
136133
}
137134

138-
deleteModalLaunch () {
139-
if (!this.state.isDeleteLaunch) {
140-
this.setState({ isDeleteLaunch: true })
141-
}
142-
}
143-
144-
async onDeleteChallenge () {
145-
const { deleteChallenge, challengeDetails, history } = this.props
146-
try {
147-
this.setState({ isSaving: true })
148-
// Call action to delete the challenge
149-
await deleteChallenge(challengeDetails.id)
150-
this.setState({ isSaving: false })
151-
this.resetModal()
152-
history.push(`/projects/${challengeDetails.projectId}/challenges`)
153-
} catch (e) {
154-
const error = _.get(e, 'response.data.message', 'Unable to Delete the challenge')
155-
this.setState({ isSaving: false, error })
156-
}
157-
}
158-
159135
/**
160136
* Validates challenge and if its valid calling an autosave method
161137
*
@@ -233,7 +209,7 @@ class ChallengeEditor extends Component {
233209
}
234210

235211
resetModal () {
236-
this.setState({ isLoading: false, isConfirm: false, isLaunch: false, error: null, isCloseTask: false, isDeleteLaunch: false })
212+
this.setState({ isLoading: false, isConfirm: false, isLaunch: false, error: null, isCloseTask: false })
237213
}
238214

239215
/**
@@ -1500,7 +1476,6 @@ class ChallengeEditor extends Component {
15001476
</div>
15011477
<div className={styles.title}>{getTitle(isNew)}</div>
15021478
<div className={cn(styles.actionButtons, styles.actionButtonsRight)}>
1503-
{this.props.challengeDetails.status === 'New' && <PrimaryButton text={'Delete'} type={'danger'} onClick={this.deleteModalLaunch} />}
15041479
<PrimaryButton text={'Back'} type={'info'} submit link={`/projects/${projectDetail.id}/challenges`} />
15051480
</div>
15061481
<div className={styles.textRequired}>* Required</div>

src/components/ChallengesComponent/ChallengeCard/ChallengeCard.module.scss

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -257,31 +257,6 @@
257257
}
258258
}
259259

260-
.deleteButton {
261-
height: 22px;
262-
width: 86px;
263-
border-radius: 11.5px;
264-
display: flex;
265-
justify-content: center;
266-
align-items: center;
267-
background-color: $tc-red;
268-
border-color: $tc-red;
269-
cursor: pointer;
270-
271-
span {
272-
@include roboto;
273-
274-
font-size: 14px;
275-
font-weight: 400;
276-
line-height: 17px;
277-
color: $white;
278-
text-transform: capitalize;
279-
display: flex;
280-
justify-content: center;
281-
align-items: center;
282-
}
283-
}
284-
285260
.icon {
286261
vertical-align: bottom;
287262
}

src/components/ChallengesComponent/ChallengeCard/index.js

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,14 @@ const getPhaseInfo = (c) => {
9696
* @param onUpdateLaunch
9797
* @returns {*}
9898
*/
99-
const hoverComponents = (challenge, onUpdateLaunch, deleteModalLaunch) => {
99+
const hoverComponents = (challenge, onUpdateLaunch) => {
100100
const communityAppUrl = `${COMMUNITY_APP_URL}/challenges/${challenge.id}`
101101
const directUrl = `${DIRECT_PROJECT_URL}/contest/detail?projectId=${challenge.legacyId}`
102102
const orUrl = `${ONLINE_REVIEW_URL}/review/actions/ViewProjectDetails?pid=${challenge.legacyId}`
103103

104104
// NEW projects never have Legacy challenge created, so don't show links and "Activate" button for them at all
105105
if (challenge.status.toUpperCase() === CHALLENGE_STATUS.NEW) {
106-
if (challenge.status.toUpperCase() === CHALLENGE_STATUS.NEW) {
107-
return (
108-
<button className={styles.deleteButton} onClick={deleteModalLaunch}>
109-
<span>Delete</span>
110-
</button>
111-
)
112-
}
106+
return null
113107
}
114108

115109
return challenge.legacyId ? (
@@ -183,13 +177,10 @@ class ChallengeCard extends React.Component {
183177
this.state = {
184178
isConfirm: false,
185179
isLaunch: false,
186-
isDeleteLaunch: false,
187180
isSaving: false
188181
}
189182
this.onUpdateConfirm = this.onUpdateConfirm.bind(this)
190183
this.onUpdateLaunch = this.onUpdateLaunch.bind(this)
191-
this.onDeleteChallenge = this.onDeleteChallenge.bind(this)
192-
this.deleteModalLaunch = this.deleteModalLaunch.bind(this)
193184
this.resetModal = this.resetModal.bind(this)
194185
this.onLaunchChallenge = this.onLaunchChallenge.bind(this)
195186
}
@@ -204,14 +195,8 @@ class ChallengeCard extends React.Component {
204195
}
205196
}
206197

207-
deleteModalLaunch () {
208-
if (!this.state.isDeleteLaunch) {
209-
this.setState({ isDeleteLaunch: true })
210-
}
211-
}
212-
213198
resetModal () {
214-
this.setState({ isConfirm: false, isLaunch: false, isDeleteLaunch: false })
199+
this.setState({ isConfirm: false, isLaunch: false })
215200
}
216201

217202
async onLaunchChallenge () {
@@ -236,39 +221,12 @@ class ChallengeCard extends React.Component {
236221
}
237222
}
238223

239-
async onDeleteChallenge () {
240-
const { deleteChallenge, challenge } = this.props
241-
try {
242-
this.setState({ isSaving: true })
243-
// Call action to delete the challenge
244-
await deleteChallenge(challenge.id)
245-
this.setState({ isSaving: false })
246-
this.resetModal()
247-
} catch (e) {
248-
const error = _.get(e, 'response.data.message', 'Unable to Delete the challenge')
249-
this.setState({ isSaving: false, error })
250-
}
251-
}
252-
253224
render () {
254-
const { isLaunch, isConfirm, isSaving, isDeleteLaunch } = this.state
225+
const { isLaunch, isConfirm, isSaving } = this.state
255226
const { challenge, shouldShowCurrentPhase, reloadChallengeList } = this.props
256227
const { phaseMessage, endTime } = getPhaseInfo(challenge)
257228
return (
258229
<div className={styles.item}>
259-
{
260-
isDeleteLaunch && !isConfirm && (
261-
<ConfirmationModal
262-
title='Confirm Delete'
263-
message={`Do you want to delete "${challenge.name}"?`}
264-
theme={theme}
265-
isProcessing={isSaving}
266-
errorMessage={this.state.error}
267-
onCancel={this.resetModal}
268-
onConfirm={this.onDeleteChallenge}
269-
/>
270-
)
271-
}
272230
{ isLaunch && !isConfirm && (
273231
<ConfirmationModal
274232
title='Confirm Launch'
@@ -310,7 +268,7 @@ class ChallengeCard extends React.Component {
310268
<span className='block light-text'>{endTime}</span>
311269
</Link>)}
312270
<div className={cn(styles.col4, styles.editingContainer)}>
313-
{hoverComponents(challenge, this.onUpdateLaunch, this.deleteModalLaunch)}
271+
{hoverComponents(challenge, this.onUpdateLaunch, this.props.showError)}
314272
</div>
315273
<div className={cn(styles.col4, styles.iconsContainer)}>
316274
<div className={styles.faIconContainer}>
@@ -329,15 +287,16 @@ class ChallengeCard extends React.Component {
329287

330288
ChallengeCard.defaultPrps = {
331289
shouldShowCurrentPhase: true,
290+
showError: () => {},
332291
reloadChallengeList: () => {}
333292
}
334293

335294
ChallengeCard.propTypes = {
336295
challenge: PropTypes.object,
337296
shouldShowCurrentPhase: PropTypes.bool,
297+
showError: PropTypes.func,
338298
reloadChallengeList: PropTypes.func,
339-
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
340-
deleteChallenge: PropTypes.func.isRequired
299+
partiallyUpdateChallengeDetails: PropTypes.func.isRequired
341300
}
342301

343302
export default withRouter(ChallengeCard)

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ class ChallengeList extends Component {
102102
page,
103103
perPage,
104104
totalChallenges,
105-
partiallyUpdateChallengeDetails,
106-
deleteChallenge
105+
partiallyUpdateChallengeDetails
107106
} = this.props
108107
if (warnMessage) {
109108
return <Message warnMessage={warnMessage} />
@@ -212,9 +211,9 @@ class ChallengeList extends Component {
212211
<ChallengeCard
213212
shouldShowCurrentPhase={selectedTab === 0}
214213
challenge={c}
214+
showError={this.showError}
215215
reloadChallengeList={this.reloadChallengeList}
216216
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
217-
deleteChallenge={deleteChallenge}
218217
/>
219218
</li>
220219
)
@@ -257,8 +256,7 @@ ChallengeList.propTypes = {
257256
page: PropTypes.number.isRequired,
258257
perPage: PropTypes.number.isRequired,
259258
totalChallenges: PropTypes.number.isRequired,
260-
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
261-
deleteChallenge: PropTypes.func.isRequired
259+
partiallyUpdateChallengeDetails: PropTypes.func.isRequired
262260
}
263261

264262
export default ChallengeList

src/components/ChallengesComponent/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ const ChallengesComponent = ({
2626
page,
2727
perPage,
2828
totalChallenges,
29-
partiallyUpdateChallengeDetails,
30-
deleteChallenge
29+
partiallyUpdateChallengeDetails
3130
}) => {
3231
return (
3332
<Sticky top={10}>
@@ -87,7 +86,6 @@ const ChallengesComponent = ({
8786
perPage={perPage}
8887
totalChallenges={totalChallenges}
8988
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
90-
deleteChallenge={deleteChallenge}
9189
/>
9290
)}
9391
</div>
@@ -111,8 +109,7 @@ ChallengesComponent.propTypes = {
111109
page: PropTypes.number.isRequired,
112110
perPage: PropTypes.number.isRequired,
113111
totalChallenges: PropTypes.number.isRequired,
114-
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
115-
deleteChallenge: PropTypes.func.isRequired
112+
partiallyUpdateChallengeDetails: PropTypes.func.isRequired
116113
}
117114

118115
ChallengesComponent.defaultProps = {

src/config/constants.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ export const CREATE_CHALLENGE_SUCCESS = 'CREATE_CHALLENGE_SUCCESS'
4848
export const CREATE_CHALLENGE_PENDING = 'CREATE_CHALLENGE_PENDING'
4949
export const CREATE_CHALLENGE_FAILURE = 'CREATE_CHALLENGE_FAILURE'
5050

51-
export const DELETE_CHALLENGE_SUCCESS = 'DELETE_CHALLENGE_SUCCESS'
52-
export const DELETE_CHALLENGE_PENDING = 'DELETE_CHALLENGE_PENDING'
53-
export const DELETE_CHALLENGE_FAILURE = 'DELETE_CHALLENGE_FAILURE'
54-
5551
export const LOAD_PROJECT_DETAILS = 'LOAD_PROJECT_DETAILS'
5652
export const LOAD_PROJECT_DETAILS_SUCCESS = 'LOAD_PROJECT_DETAILS_SUCCESS'
5753
export const LOAD_PROJECT_DETAILS_PENDING = 'LOAD_PROJECT_DETAILS_PENDING'

src/containers/ChallengeEditor/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
loadResourceRoles,
2626
updateChallengeDetails,
2727
partiallyUpdateChallengeDetails,
28-
deleteChallenge,
2928
createChallenge,
3029
replaceResourceInRole
3130
} from '../../actions/challenges'
@@ -411,7 +410,6 @@ ChallengeEditor.propTypes = {
411410
updateChallengeDetails: PropTypes.func.isRequired,
412411
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
413412
createChallenge: PropTypes.func.isRequired,
414-
deleteChallenge: PropTypes.func.isRequired,
415413
replaceResourceInRole: PropTypes.func
416414
// members: PropTypes.arrayOf(PropTypes.shape())
417415
}
@@ -447,7 +445,6 @@ const mapDispatchToProps = {
447445
loadResourceRoles,
448446
updateChallengeDetails,
449447
partiallyUpdateChallengeDetails,
450-
deleteChallenge,
451448
createChallenge,
452449
replaceResourceInRole
453450
}

0 commit comments

Comments
 (0)