-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
- 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
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(); |
There was a problem hiding this comment.
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
x-pack/plugins/enterprise_search/public/applications/app_search/components/result/result.tsx
Outdated
Show resolved
Hide resolved
shouldLinkToDetailPage={shouldLinkToDetailPage} | ||
actions={<ResultActions />} | ||
documentLink={documentLink} | ||
actions={actions} |
There was a problem hiding this comment.
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.
<header className="appSearchResultHeader"> | ||
<EuiFlexGroup | ||
alignItems="center" | ||
gutterSize="s" | ||
justifyContent="spaceBetween" | ||
responsive={false} | ||
wrap | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
export const ResultActions: React.FC<Props> = ({ actions }) => { | ||
return ( | ||
<EuiFlexGroup gutterSize="s" responsive={false}> |
There was a problem hiding this comment.
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
@elasticmachine merge upstream |
There was a problem hiding this 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 😝)
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 }) => { |
There was a problem hiding this comment.
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.
...ns/enterprise_search/public/applications/app_search/components/result/result_header.test.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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!
Great work on this BTW, thank you for taking the time to improve this. |
x-pack/plugins/enterprise_search/public/applications/app_search/components/result/result.tsx
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
* 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 <[email protected]>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
* 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 <[email protected]> Co-authored-by: Constance <[email protected]>
Summary
I missed the boat for pushing up changes to #96184, so here's a follow up PR with some clean up items.
QA
Checklist