Skip to content
This repository has been archived by the owner on Jun 14, 2019. It is now read-only.

Fixes an issue when deleting an integration from it's detail page #424

Merged
merged 2 commits into from
Jun 10, 2019

Conversation

elvisisking
Copy link
Contributor

@riccardo-forina
Copy link
Collaborator

What if I delete the integration from the dashboard? Will it go to the integrations list?

@elvisisking
Copy link
Contributor Author

It does now go to the list page @riccardo-forina:( I need to fix that.

@riccardo-forina
Copy link
Collaborator

I dunno it’s not that big of a deal I think. @dongniwang what do you think? Is it a problem if users are redirected to the integrations list page after deleting an integration, regardless of where they were? Eg. deleting from the dashboard will take you to the integrations list page.

@riccardo-forina
Copy link
Collaborator

PR Storybook available here

@gashcrumb
Copy link
Collaborator

gashcrumb commented Jun 5, 2019

I think the redirect should only occur if you're on the detail page. It'd definitely be weird to delete an integration on the dashboard there and then wind up on the integration list page.

And also the angular app only redirected if you were on the detail page, so there's that 😃

@dongniwang
Copy link
Contributor

dongniwang commented Jun 5, 2019

Yeah, I think it makes sense to delete and return to the integration list when you're on the details page.

But if delete happens from the dashboard, I would expect to see a confirmation dialog then a toast notification saying that the delete was successful.

We (meaning UX) should be better in documenting these interactions. Thanks for fixing the behavior! And I think it's not a big deal that it takes users back to the list page for now.

@elvisisking
Copy link
Contributor Author

@riccardo-forina @gashcrumb wdyt of this code that conditionally redirects to the integrations list page only when on the integration details page:

if (history.location.pathname.endsWith("details")) {
  history.push(resolvers.list());
}

And might there be a better way to do this?

@riccardo-forina
Copy link
Collaborator

Yeah, please no :D

What about adding a postDeleteHref: H.LocationDescriptionObject property to the WithIntegrationActions component, and let the consumers of that component specify the right URL to use for the redirect?

@elvisisking
Copy link
Contributor Author

Yeah that is much nicer @riccardo-forina . Will do.

@riccardo-forina
Copy link
Collaborator

PR Storybook available here

@elvisisking
Copy link
Contributor Author

While things are working as expected when an integration is deleted (redirect to list when on details page, otherwise stay on same page), I'm getting the following error in the console when the delete action from the kebab menu on the integration DetailsPage and MetricsPage is used:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
    in Fetch (created by Context.Consumer)
    in SyndesisFetch (created by WithChangeListener)
    in WithChangeListener (created by Context.Consumer)
    in Fetch (created by Context.Consumer)
    in SyndesisFetch (created by WithIntegration)
    in WithIntegration (created by WithMonitoredIntegration)
    in WithMonitoredIntegration (at DetailsPage.tsx:46)
    in Route (created by WithRouteData)
    in WithRouteData (at DetailsPage.tsx:44)
    in Translation (at DetailsPage.tsx:40)
    in DetailsPage (created by Context.Consumer)

It seems like the code in ChangeListener.componentWillUnmount() should not let this happen but not sure. I've tried a few things in the details page to fix this but seems like this could be a bigger issue especially when deleting objects from detail pages.

@gashcrumb
Copy link
Collaborator

gashcrumb commented Jun 7, 2019 via email

@riccardo-forina
Copy link
Collaborator

Ooooh it was the Fetch raising the warning, you didn’t t mention that! That’s the fetch promise that will still trigger even if the Fetch component has been unmounted. The problem is that no browser implements abortable fetches, so there is no way to work around this without replacing the browser’s own fetch with some polyfilled version that’s abortable, like whatwg-fetch (which is basically an xhr request wrapped in a fetch compatible interface). Or drop it in favor of something like axios.

Anyway, this isn’t something urgent, the warning is safe to ignore in this case (but should be ultimately addressed)

@riccardo-forina
Copy link
Collaborator

PR Storybook available here

- see issue syndesisio/syndesis#5578
- added WithRouter to WithIntegrationActions
- after a successful delete, the integrations list page is displayed
…st page from the details page.

- create optional postDeleteHref property of WithIntegrationActions that will do a redirect if set
@riccardo-forina
Copy link
Collaborator

PR Storybook available here

@paoloantinori
Copy link
Contributor

@riccardo-forina with your last comment, are you saying that we can merge this?

@pure-bot
Copy link
Contributor

pure-bot bot commented Jun 10, 2019

Pull request approved by @riccardo-forina - applying approved label

@pure-bot pure-bot bot added the approved label Jun 10, 2019
@pure-bot pure-bot bot merged commit 4353b27 into syndesisio:master Jun 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants