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

[App Search] Results follow-up #96709

Merged
merged 6 commits into from
Apr 12, 2021
Merged

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Apr 9, 2021

Summary

I missed the boat for pushing up changes to #96184, so here's a follow up PR with some clean up items.

  • CSS cleanup: c4627d5
  • ResultActions refactor + DRYing out link behavior: f8cf5dd
    • Create new separate ResultActions component
    • Pass actions array through to header and have header in charge of conditional visibility / FlexItem wrapper (this matches the other header items)
    • shouldLinkToDetailPage: instead of generating custom JSX, just have it be a standard action and append it to the actions array
    • ResultHeaderItem - switch to EuiLinkTo, no need for extra wrapper
    • ResultHeader - DRY out unnecessary extra path generation - instead pass down a conditional documentLink instead of a bool

QA

  • Tested documents view in a source engine + click behavior
  • Tested documents view in a meta engine + click behavior
  • Tested Relevance Tuning results in a source & meta engine
  • Tested Curations results in a source & meta engine
  • Tested with a screen reader (IMO, the new action behavior of the link/eye button is better now)

Checklist

- Create new separate ResultActions component
- Pass actions array through to header and have haeder in charge of conditional visibility / FlexItem wrapper (this matches the other header items)
- shouldLinkToDetailPage: instead of generating custom JSX, just have it be a standard action and append it to the actions array

Link behavior:
- ResultHeaderItem - switch to EuiLinkTo, no need for extra wrapper
- ResultHeader - DRY out unnecessary extra path generation - instead pass down a conditional documentLink instead of a bool
@cee-chen cee-chen added release_note:skip Skip the PR/issue when compiling release notes v7.13.0 auto-backport Deprecated - use backport:version if exact versions are needed labels Apr 9, 2021
@cee-chen cee-chen requested review from daveyholler, JasonStoltz and a team April 9, 2021 18:27
Comment on lines -101 to -112
expect(buttons).toHaveLength(2);

expect(buttons.first().prop('iconType')).toEqual('eyeClosed');
expect(buttons.first().prop('color')).toEqual('danger');
buttons.first().simulate('click');
expect(actions[0].onClick).toHaveBeenCalled();

expect(buttons.last().prop('iconType')).toEqual('starFilled');
// Note that no iconColor was passed so it was defaulted to primary
expect(buttons.last().prop('color')).toEqual('primary');
buttons.last().simulate('click');
expect(actions[1].onClick).toHaveBeenCalled();
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of this got moved to the new result_actions.test.tsx

shouldLinkToDetailPage={shouldLinkToDetailPage}
actions={<ResultActions />}
documentLink={documentLink}
actions={actions}
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 could have left this as actions={<ResultActions actions={actions} />} but moving <ResultActions> to ResultHeader made it easier to unit test without diving, and the conditional logic pattern there matched the rest of the conditional header items.

Comment on lines +34 to +41
<header className="appSearchResultHeader">
<EuiFlexGroup
alignItems="center"
gutterSize="s"
justifyContent="spaceBetween"
responsive={false}
wrap
>
Copy link
Member Author

@cee-chen cee-chen Apr 9, 2021

Choose a reason for hiding this comment

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

Responsive enhancements:

Before:

After:

Wrapping also generally just responds better on result cards that aren't on a smaller screen but are in a smaller column (e.g. Relevance Tuning).


export const ResultActions: React.FC<Props> = ({ actions }) => {
return (
<EuiFlexGroup gutterSize="s" responsive={false}>
Copy link
Member Author

Choose a reason for hiding this comment

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

responsive={false} was added here. See above before/after screenshot

@JasonStoltz
Copy link
Member

@elasticmachine merge upstream

Copy link
Contributor

@daveyholler daveyholler left a comment

Choose a reason for hiding this comment

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

Visually, LGTM. (Sorry for getting merge-happy on the other PR 😝)

@cee-chen
Copy link
Member Author

Haha all good, no worries! Totally on me for not leaving a comment / skiving off that day 😆

actions: ResultAction[];
}

export const ResultActions: React.FC<Props> = ({ actions }) => {
Copy link
Member

@JasonStoltz JasonStoltz Apr 12, 2021

Choose a reason for hiding this comment

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

Good call on moving this out to its own component, this simplifies things greatly.

Copy link
Member

@JasonStoltz JasonStoltz left a comment

Choose a reason for hiding this comment

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

LGTM, I recommend making that change to unshift though!

@JasonStoltz
Copy link
Member

Great work on this BTW, thank you for taking the time to improve this.

@cee-chen cee-chen enabled auto-merge (squash) April 12, 2021 16:55
@cee-chen
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 1323 1324 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 2.0MB 1.9MB -4.4KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@cee-chen cee-chen merged commit 171f398 into elastic:master Apr 12, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 12, 2021
* CSS cleanup

* Refactor ResultActions component + DRY out link behavior

- Create new separate ResultActions component
- Pass actions array through to header and have haeder in charge of conditional visibility / FlexItem wrapper (this matches the other header items)
- shouldLinkToDetailPage: instead of generating custom JSX, just have it be a standard action and append it to the actions array

Link behavior:
- ResultHeaderItem - switch to EuiLinkTo, no need for extra wrapper
- ResultHeader - DRY out unnecessary extra path generation - instead pass down a conditional documentLink instead of a bool

* PR feedback: Fix test name

* PR feedback: unshift

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

@cee-chen cee-chen deleted the results-cleanup branch April 12, 2021 19:17
kibanamachine added a commit that referenced this pull request Apr 12, 2021
* CSS cleanup

* Refactor ResultActions component + DRY out link behavior

- Create new separate ResultActions component
- Pass actions array through to header and have haeder in charge of conditional visibility / FlexItem wrapper (this matches the other header items)
- shouldLinkToDetailPage: instead of generating custom JSX, just have it be a standard action and append it to the actions array

Link behavior:
- ResultHeaderItem - switch to EuiLinkTo, no need for extra wrapper
- ResultHeader - DRY out unnecessary extra path generation - instead pass down a conditional documentLink instead of a bool

* PR feedback: Fix test name

* PR feedback: unshift

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants