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

[KED-2996] Feature/toggle bookmark behavior #689

Merged
merged 25 commits into from
Jan 18, 2022

Conversation

tynandebold
Copy link
Member

@tynandebold tynandebold commented Jan 10, 2022

Description

Resolves KED-2996.

Development notes

This PR enables all the bookmark functionality. There are three places where you can bookmark a run from:

  • The runs list card
  • The pipeline toolbar (when not in comparison view)
  • From the kebab menu (when in comparison view)

Each area is wired up to now be able to toggle bookmarks.

I also wired up the close icon next to the kebab menu. That was a quick win and easy to do.

QA notes

I chose not to include the bookmark help text on hover in the runs list. Here's a design screenshot:

image

I did this for two reasons:

  • By default, the help text gets cut off and can't extend outside of the sidebar. There's a lot of overhead here that would have made this seemingly simple change time consuming and, in my opinion, not worthwhile for our MVP approach.
  • When I did have it there, though not working perfectly, it felt very intrusive with the tooltip coming up over and over and over again.

Separately, I also ordered the icons like this:

image

And not like this:

image

Isn't the close icon always on an end? I didn't feel right when it was in the middle.

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

Copy link
Contributor

@rashidakanchwala rashidakanchwala left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks Tynan!!!

Comment on lines 103 to 114
// Remove for now.
// it('enables the pin button when show changes is enabled ', () => {
// const wrapper = mount(
// <RunMetadata
// enableShowChanges={true}
// isSingleRun={false}
// runs={twoRuns}
// />
// );

// expect(wrapper.find('.pipeline-menu-button__pin').length).toEqual(4);
// });
Copy link
Contributor

Choose a reason for hiding this comment

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

This test can be put back in once the useMutation hook is moved up to the wrapper level.

On another note, please add relevant tests to cover the introduction of the new kebab menu and the bookmark icon.

Copy link
Member Author

@tynandebold tynandebold Jan 12, 2022

Choose a reason for hiding this comment

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

I wish this was true. The test still fails even if the mutation hook is moved. The hook itself still fires in this file, so it doesn't make a difference.

I won't be able to write any tests either. As soon as the details-metadata__buttons markup becomes available with two runs in comparison view, we get that Apollo client error I wrote about in the PR description.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this problem with useMutation would be something we need to resolve within this PR as this seems to restrict our ability to write tests, which I highly doubt it would be designed this way given how many users there are within the react community.

Throwing a thought here - looking at the error it looks like the test was not able to locate the client, which you might need to wrap the wrapper with an ApolloProvider in the test?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, it also does seem weird that this problem surfaces in this PR and not in the previous one when we introduced the mutation hook for the first time - I wonder what is the reason behind that?

it might either suggest that there might be a different setup, or perhaps there wasn't the right tests set up to properly test that 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

Haha, agreed! I'm looking into this now: https://www.apollographql.com/docs/react/development-testing/testing/

Will report back.

const humanReadableTime = toHumanReadableTime(timestamp);

const onClick = (id) => {
const onClick = (id, e) => {
Copy link
Contributor

@studioswong studioswong Jan 12, 2022

Choose a reason for hiding this comment

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

please rename this to something more description such as onToggleBookmarkButton, etc.

Please also add a test to cover the dead zone scenerio too - it can be just set up to test that updateRunDetailsfunction gets called

Copy link
Member Author

@tynandebold tynandebold Jan 12, 2022

Choose a reason for hiding this comment

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

This function can either toggle the bookmark or fire the onRunSelection function, so it isn't strictly about the bookmark.

I can change it to onRunsListCardClick. Is that ok?

I added a test but it also fails because of the Apollo bug. Uncomment the code and then try it here:

npm run test src/components/experiment-tracking/runs-list-card/runs-list-card.test.js

Copy link
Contributor

@studioswong studioswong left a comment

Choose a reason for hiding this comment

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

Thanks for setting this up, the bookmark journey works well in general.

One thing I noticed. - on toggling 'show changes' off the entire burger menu, including the toggle bookmark buttons, etc, also gets toggled off, while instead they should still exist and only the 'pin run' button should be toggled off.

I'll continue to go through some of the code and leave further single comments if I see anything.

@tynandebold
Copy link
Member Author

Thanks for setting this up, the bookmark journey works well in general.

One thing I noticed. - on toggling 'show changes' off the entire burger menu, including the toggle bookmark buttons, etc, also gets toggled off, while instead they should still exist and only the 'pin run' button should be toggled off.

I'll continue to go through some of the code and leave further single comments if I see anything.

Updated everything you asked for. Lmk if there's anything else :)

@tynandebold tynandebold requested a review from yetudada as a code owner January 18, 2022 13:51
@@ -22,10 +21,8 @@ export const UPDATE_RUN_DETAILS = gql`
`;

export const useUpdateRunDetails = () => {
const [_updateRunDetails, { error, loading, reset }] = useMutation(
UPDATE_RUN_DETAILS,
{ client }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the object the one that was causing the problems for the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

No it wasn't that. It's just we were't actually mocking the useUpdateRunDetails mutation.

Copy link
Contributor

Choose a reason for hiding this comment

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

indeed. I've always wondered why we need to pass in the client here as it's passed on from the ApolloProvider anyways, good to delete this here.

Copy link
Collaborator

@limdauto limdauto left a comment

Choose a reason for hiding this comment

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

I haven't tested the functionality but the code LGTM!

src/apollo/queries.js Show resolved Hide resolved
RELEASE.md Outdated Show resolved Hide resolved
Copy link
Contributor

@studioswong studioswong left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for getting through with the fix to the tests!

I've left a few comments which I'll let you fix them before merging it in. For the tests for run-details-modal, I'll let you decide on whether to tackle it in this PR or as a separate PR.

@tynandebold tynandebold merged commit 2c19edc into main Jan 18, 2022
@tynandebold tynandebold deleted the feature/toggle-bookmark-behavior#ked-2996 branch January 18, 2022 17:06
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.

4 participants