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

Update fork UX to make it more similar to the project creation #1252

Merged
merged 11 commits into from
Feb 25, 2021

Conversation

lorenzo-cavazzi
Copy link
Member

I have reused quite a few components from "new project".
I needed to create:

  • A mapper component to map the redux content (we can remove it later and use the useSelector hook)
  • A container component containing the hooks and the fork function. Even if fork could be part of the state component, we don't really need to store much in the redux store. Including it in the container component makes the whole logic easier to understand.

I moved the redirect logic from the client functions to the react components and added notifications.

We can improve the error handling if necessary -- most of the errors are now prevented by the realtime validation, so I wouldn't focus much on that unless we notice specific errors happening frequently.

/deploy
fix #1118

* use the same rules to get the slug and validate the title.
* remove local redux store.

fix #1118
@lorenzo-cavazzi lorenzo-cavazzi added this to the sprint-2021-02-19 milestone Feb 22, 2021
@lorenzo-cavazzi lorenzo-cavazzi requested a review from a team as a code owner February 22, 2021 15:07
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 22, 2021 15:08 Inactive
@RenkuBot
Copy link
Contributor

You can access the deployment of this PR at https://renku-ci-ui-1252.dev.renku.ch

@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 22, 2021 16:22 Inactive
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 22, 2021 17:23 Inactive
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 22, 2021 18:05 Inactive
Copy link
Contributor

@ciyer ciyer left a comment

Choose a reason for hiding this comment

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

Overall works well, and code looks good. I have one issue that needs to be fixed -- the fork button doesn't work on the first invocation after a page load. The other points I raised are all optional, I would say.

client/src/project/new/ProjectNew.container.js Outdated Show resolved Hide resolved
const { btnClass, btnContent, error, fork, forkError, forkedTitle, forking } = props;

const [modalOpen, setModalOpen] = useState(false);
const toggle = () => setModalOpen(!modalOpen);
Copy link
Contributor

Choose a reason for hiding this comment

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

There seems to be a problem here. The first time I click the fork button after a page load, it flashes open, then closes. Subsequent clicks work, but the first one does not.

This does not happen in develop mode as often, but happens reliably in the production build. This may have something to do with the problems with tests as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point and it may very well be the cause of the failing tests.
After some experiments, it looks like the mapStateToProps is re-triggered when we get responses from APIs with irrelevant content for the fork.
The cause is in the mapping function in one of the ancestor components, mapping the local project redux store to the global project view. This means we can't really find an elegant solution until the Project redux store is united with the global one.

A workaround could be storing the modal state in the mapper component ForkProjectMapper, but I fear we may need to store all the relevant data in the redux store to prevent losing the state.

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed offline, the problem can't be solved in a very elegant way.
I've tried to move the main Modal component to the Project.present page to avoid flashing content. This is still not bulletproof (an unrelated project API may still return data when the modal is open and cause a re-draw), but it seems to work well in most cases.

I added a loader while we fetch the necessary data for the validation to prevent circumventing them (it's not to difficult when clicking fast and having a lot of projects).

Screenshot_20210224_190404

//client.runPipeline(forked.project.id);

// automatically redirect only when the user hasn't changed location
if (mounted && history.location.pathname === startingLocation)
Copy link
Contributor

Choose a reason for hiding this comment

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

This works nicely!

I found a minor issue with the UX here which is that if I close the popup, but stay on the same project page, then I still get redirected. I sort of expected the notification only if I was still looking at the pop-up, but I think the current behavior is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree the expected behavior is the one you described.
The notifications work with the route location, but we can easily check if the modal is still open and force showing the notification whenever that is not the case.

@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 24, 2021 10:46 Inactive
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 24, 2021 12:10 Inactive
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 24, 2021 14:41 Inactive
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 24, 2021 15:43 Inactive
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 24, 2021 18:04 Inactive
@lorenzo-cavazzi
Copy link
Member Author

All the points should be fixed, even if moving the Modal to an ancestor component is not a very elegant solution. This makes the Fork components harder to re-use. Adapting them to non-modals is fairly easy if we will ever need to do that.

@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 25, 2021 07:42 Inactive
ciyer
ciyer previously approved these changes Feb 25, 2021
Copy link
Contributor

@ciyer ciyer left a comment

Choose a reason for hiding this comment

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

Changes look good; and everything works very well now! 🎉

@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1252 February 25, 2021 10:38 Inactive
@lorenzo-cavazzi
Copy link
Member Author

The acceptance tests passed in 5cadb46 . I reverted the change before merging the PR

@lorenzo-cavazzi lorenzo-cavazzi merged commit 84aa787 into master Feb 25, 2021
@lorenzo-cavazzi lorenzo-cavazzi deleted the 1118-fork branch February 25, 2021 13:52
@RenkuBot
Copy link
Contributor

Tearing down the temporary RenkuLab deplyoment for this PR.

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.

Adapt the fork UI/UX to be similar to new project creation
3 participants