Skip to content
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

fix(containers/DeleteRessource): fix behaviour when refreshing browser #1053

Merged
merged 18 commits into from
Feb 14, 2018

Conversation

romainseb
Copy link
Contributor

@romainseb romainseb commented Feb 8, 2018

What is the problem this PR is trying to solve?
When we refresh the browser, the desired collection to populate the modal is not always there.
Also, when we refresh the browser, some event needed on saga start are not dispatched
What is the chosen solution to this problem?
change function done in render to mapStateToProps to watch the redux change state & re-evaluate the searched resource
remove the needed event to start the saga. We got the id & the url to redirect with this action catched, so one part is declared in the saga declaration on the sagaRouter, the other part ( id ) is get on routerParams

Please check if the PR fulfills these requirements

  • The PR commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Related design / discussions / pages (not in jira), if any, are all linked or available in the PR

[x] This PR introduces a breaking change

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

> eslint --config ../../.eslintrc src

The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead.

/home/travis/build/Talend/ui/packages/containers/src/ActionSplitDropdown/ActionSplitDropdown.test.js
4:10 error 'ActionSplitDropdown' is defined but never used no-unused-vars

/home/travis/build/Talend/ui/packages/containers/src/DeleteResource/DeleteResource.test.js
4:15 error 'List' is defined but never used no-unused-vars
Copy link
Contributor

Choose a reason for hiding this comment

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

OMG !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops

return {};
}

export default cmfConnect({ componentId: 'DeleteResource', mapStateToProps })(Container);
Copy link
Contributor

Choose a reason for hiding this comment

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

componentId: 'DeleteResource' => componentId: ownProps => ownProps.id || ownProps.componentId
Right now the componentId is hardcoded.

getLabel() {
return this.props.resource
? { label: this.props.resource.get('label'), found: true }
: { label: '', found: false };
}
Copy link
Contributor

Choose a reason for hiding this comment

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

return {
label: this.props.resource.get('label', '')
found: !!resource
}
what do u think ?

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

try {
yield race({
deleteConfirmationValidate: call(
deleteResourceValidate,
uri,
resourceType,
id,
routerParams.id,
Copy link
Contributor

Choose a reason for hiding this comment

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

problem i see here is how to handle routes where the the resource indentifier is not strictly called id, how to deal with nested routes if we force all resources identifier to be called id

example connection/:id/dataset/:id with a delete at the end ?

@acateland
Copy link
Contributor

couldn't on reload check the existence of the collection inside the sagas ? maybe wait or maybe immediatly redirect ? from the saga

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

resourceType,
resourcePath,
redirectUrl,
routerParamsAttribute,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing in docblock
missing on doc, maybe we should handle a default value ?
or runtime check the parameters ?

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@romainseb romainseb merged commit 39fa09b into master Feb 14, 2018
@romainseb romainseb deleted the sromain/fix-delete-ressource-refresh branch February 14, 2018 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants