Skip to content

Add an option to select a timeline template #1072

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

Merged
merged 10 commits into from
Mar 11, 2021

Conversation

ThomasKranitsas
Copy link
Contributor

No description provided.

Copy link
Contributor

@maxceem maxceem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. At the moment only default timeline templates are loaded as per Default Timeline Templates #881. As a result inside timeline selects we can see only one default option and cannot change the timeline template.

  2. If I change the URL for loading timeline templates https://github.com/topcoder-platform/work-manager/blob/feature/timeline-template/src/services/challenges.js#L94 (remove isDefault=true). Then selects would show more timelines to select. This would reveal some issue:

    • choose "Design" and "Challenge" - see the correct templates for Design
    • change track to "Data Science" - see correct templates for DS
    • change track again to "Design" - templates are still showing for DS, not for Design

    See demo video https://monosnap.com/file/4DqtnNo7PUKk5lxweMbzfregakW8z

Comment on lines 25 to 32
shouldComponentUpdate (nextProps) {
const { onUpdateSelect, challengeTimelines, timelineTemplates, challenge } = nextProps
const hasSelectedTypeAndTrack = !_.isEmpty(challenge.typeId) && !_.isEmpty(challenge.trackId)
if ((hasSelectedTypeAndTrack && this.state.validOptions.length === 0) || this.state.matchString !== `${challenge.typeId}-${challenge.trackId}-${this.state.selectedOption.value}`) {
this.checkData(onUpdateSelect, challengeTimelines, timelineTemplates, challenge)
}
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that shouldComponentUpdate is used as a replacement for unsafecomponentWillUpdate and it triggers this.setState and external callback onUpdateSelect inside. As per my understanding such approach is not recommended and in particular it could lead to a circular re-reredering.

Here is some guide on which approaches are recommended as a replacement for unsafe methods https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html.
It includes examples for updating state based on props and invoking external callbacks.

@vikasrohit
Copy link

Merging to push the changes to prod as separate release now.

@vikasrohit vikasrohit merged commit 942f682 into develop Mar 11, 2021
@vikasrohit vikasrohit linked an issue Mar 11, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timeline Template Selection
3 participants