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] Add header details to the Result Settings page #96623

Merged
merged 10 commits into from
Apr 12, 2021

Conversation

JasonStoltz
Copy link
Member

@JasonStoltz JasonStoltz commented Apr 8, 2021

Summary

This PR adds a header description and actions buttons. It also removes custom modal logic and replaces that with standard window.confirm messages.

These buttons will eventually have additional states, there are certain conditions where they may not appear or be disabled. I will add that in my next PR.

The commits in this PR are atomic, I recommend following along commit by commit.

header

Checklist

Delete any items that are not applicable to this PR.

I assume so since it's just EUI:

For maintainers

@JasonStoltz JasonStoltz 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 8, 2021
@JasonStoltz JasonStoltz requested a review from a team April 8, 2021 17:58
@@ -586,10 +586,9 @@ describe('RelevanceTuningLogic', () => {
confirmSpy.mockImplementation(() => false);

RelevanceTuningLogic.actions.resetSearchSettings();
await nextTick();
Copy link
Member Author

Choose a reason for hiding this comment

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

This was unrelated to the current changes, but I added since I was using this test as a reference.

Without this, it would return a false positive always.

Copy link
Contributor

Choose a reason for hiding this comment

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

++ for the expect cleanup below too!

try {
response = await http.put(url, {
body: JSON.stringify({
result_fields: values.reducedServerResultFields,
Copy link
Member Author

Choose a reason for hiding this comment

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

This previous required reducedServerResultFields to be passed in from the consuming component, which seemed unnecessary, so I changed it to grab the value directly from state.

@@ -32,8 +37,10 @@ describe('RelevanceTuning', () => {
jest.clearAllMocks();
});

const subject = () => shallow(<ResultSettings engineBreadcrumb={['test']} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this! I think I might start stealing this more. But I also like rerender depending on the test/component 🤔 Haha, I'm probably overthinking it

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, OK. I hadn't thought of using rerender for this. This is primarily just to DRY up the code a little bit. The subject pattern is something we use in Rails tests in ent-search.

expect(wrapper.find(ResultSettingsTable).exists()).toBe(false);
expect(wrapper.find(SampleResponse).exists()).toBe(false);
});

it('renders a "save" button that will save the current changes', () => {
const buttons = subject().find(EuiPageHeader).prop('rightSideItems') as React.ReactElement[];
Copy link
Contributor

@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.

[optional] maybe a candidate for another test helper since it's repeated a few times? e.g.

const buttonsSubject = () => subject().find(EuiPageHeader).prop('rightSideItems') as React.ReactElement[];

Copy link
Member Author

Choose a reason for hiding this comment

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

3e51755

I updated tests in Relevance Tuning as well since they were in the same situation.

I took a slightly different approach... I created a selector function (findButtons) which accepts a ShallowWrapper (i.e., subject()) rather than one that calls subject() directly.

It's irrelevant for this instance but as a point of pattern the composability is handy if you have a situation where you need to create the subject differently depending on the test.

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

One super minor change request, this otherwise looks great! Thanks for the super atomic commits & PRs Jason 🙇‍♀️

Comment on lines 33 to 42
const RESTORE_DEFAULTS_BUTTON_LABEL = i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.resultSettings.restoreDefaultsButtonLabel',
{ defaultMessage: 'Restore defaults' }
);

const SAVE_BUTTON_LABEL = i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.resultSettings.saveButtonLabel',
{ defaultMessage: 'Save' }
);

Copy link
Contributor

Choose a reason for hiding this comment

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

[Change request] I DRY'd out these i18n labels a while back - you can delete these and directly import from shared/constants/actions.ts and app_search/constants.ts

import { SAVE_BUTTON_LABEL } from '../../../shared/constants';
import { RESTORE_DEFAULTS_BUTTON_LABEL } from '../../constants';

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, that's so handy, can't believe I forgot about these 🤦 : 9971bfe

@JasonStoltz
Copy link
Member Author

@constancecchen Bonehead move on my part, I realized just now that I didn't create a different message for the "Reset" button 🤦 : 5455a45

@JasonStoltz JasonStoltz requested a review from cee-chen April 12, 2021 15:43
Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Changes LGTM! 👍

@JasonStoltz JasonStoltz enabled auto-merge (squash) April 12, 2021 16:29
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 1323 1322 -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 2.0MB +1.3KB

History

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

@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Apr 12, 2021
@JasonStoltz JasonStoltz deleted the chrome branch April 22, 2021 18:08
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.

3 participants