-
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] Add header details to the Result Settings page #96623
Conversation
Also changed it so that it would read the current settings from state, rather than requiring them to be read and passed back in as it was in ent-search
@@ -586,10 +586,9 @@ describe('RelevanceTuningLogic', () => { | |||
confirmSpy.mockImplementation(() => false); | |||
|
|||
RelevanceTuningLogic.actions.resetSearchSettings(); | |||
await nextTick(); |
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.
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.
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.
++ for the expect cleanup below too!
try { | ||
response = await http.put(url, { | ||
body: JSON.stringify({ | ||
result_fields: values.reducedServerResultFields, |
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.
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']} />); |
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 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
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.
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[]; |
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.
[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[];
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 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.
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.
One super minor change request, this otherwise looks great! Thanks for the super atomic commits & PRs Jason 🙇♀️
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' } | ||
); | ||
|
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.
[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';
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.
Whoops, that's so handy, can't believe I forgot about these 🤦 : 9971bfe
@constancecchen Bonehead move on my part, I realized just now that I didn't create a different message for the "Reset" button 🤦 : 5455a45 |
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.
Changes LGTM! 👍
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…96853) Co-authored-by: Jason Stoltzfus <[email protected]>
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.
Checklist
Delete any items that are not applicable to this PR.
I assume so since it's just EUI:
For maintainers