-
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
[Curation] Add Result Manually flyout/search #94887
Conversation
- not really sure which API endpoint to use, hedging my bets
- fairly simple, mostly concerned with flyout behavior & search query - could likely be reused (or replaced with??) query tester logic in the future
- with custom isPromoted / isHidden logic & actions
|
||
router.get( | ||
{ | ||
path: '/api/app_search/engines/{engineName}/curation_search', |
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 have no idea if this is a good API route name, sorry y'all 😬 Def feel free to give suggestions, I was worried curations/search
made it seem like you're searching for curations rather than searching for documents 😕
onSearch({ results }: { results: Result[] }): { results: Result[] }; | ||
} | ||
|
||
export const AddResultLogic = kea<MakeLogicType<AddResultValues, AddResultActions>>({ |
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 new logic file is pretty simple - I'm thinking we could reuse it for the query tester flyout which is super similar, or potentially just straight up convert the AddResultFlyout into the QueryTesterFlyout (just passing custom actions)
|
||
expect(http.get).toHaveBeenCalledWith( | ||
'/api/app_search/engines/some-engine/curation_search', | ||
{ query: { query: 'hello world' } } |
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 made me double take initially but it's legit lol. The first query
is the payload format our server wants, and the 2nd query
is param key we use for searching
it('sets searchResults & dataLoading to false', () => { | ||
mount({ searchResults: [], dataLoading: true }); | ||
|
||
AddResultLogic.actions.onSearch(MOCK_SEARCH_RESPONSE); | ||
|
||
expect(AddResultLogic.values).toEqual({ | ||
...DEFAULT_VALUES, | ||
searchResults: MOCK_SEARCH_RESPONSE.results, | ||
dataLoading: 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.
Curse you @JasonStoltz, I really want the helper you described in #94769 (comment) now 😆
searchQuery: [ | ||
'', | ||
{ | ||
search: (_, { query }) => query, |
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.
Oh yeah, one more question for y'all!! I was wondering about this when I was recording the screen capture for the PR, but should I be resetting the search query back to ''
whenever the flyout opens/closes? 🤔 Was it weird that the search input persisted...? Or was it cool?... maaybe??...
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 think as a user I typically expect state to reset whenever I close a modal, fwiw.
You know, as I started thinking about this, I saw the following and had a thought...
{isFlyoutOpen && <AddResultFlyout />}
I'm used to modals having their state reset automatically whenever they're closed because they are unmounted whenever isFlyoutOpen
is false.
That's because the modal state is usually local to the modal component. I guess because the AddResultLogic
state is higher in the component tree than AddResultFlyout
, it never unmounts.
I don't have an opinion about whether or not this would be better or worse, but you could lift the isFlyoutOpen
state up a level and push the logic down to be contained in AddResultFlyout
.
That's just an open ended thought to consider.
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.
👍 to clearing state on modal open/close!
I guess because the AddResultLogic state is higher in the component tree than AddResultFlyout, it never unmounts
FWIW even if we removed {isFlyoutOpen && <AddResultFlyout />}
from Curation.tsx, state would still be preserved on close. This is because we're calling const { flyoutOpen } = useActions(AddResultLogic)
in PromotedDocuments & HiddenDocuments, and AddResultLogic
being present in those views preserves the logic file and keeps it from unmounting. 🤷
EDIT: I think I misread your comment about changing where isFlyoutOpen
is located, sorry 🤔 Not totally sure if that change is better or worse either personally. I think I like it where it is for unit testing - just IMO, it's slightly nicer to check conditionally for the presence of AddResultFlyout
rather than checking for an empty render. And it prevents an extra level of indenting/nesting in AddResultFlyout
, which is kinda nicer too. Not a big deal either way though like you said
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.
Commit that resets the search query: 6c559ac
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.
Great work, as always
|
||
import { AddResultLogic } from './'; | ||
|
||
describe('AddResultLogic', () => { |
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 putting this in it's own logic
searchQuery: [ | ||
'', | ||
{ | ||
search: (_, { query }) => query, |
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 think as a user I typically expect state to reset whenever I close a modal, fwiw.
You know, as I started thinking about this, I saw the following and had a thought...
{isFlyoutOpen && <AddResultFlyout />}
I'm used to modals having their state reset automatically whenever they're closed because they are unmounted whenever isFlyoutOpen
is false.
That's because the modal state is usually local to the modal component. I guess because the AddResultLogic
state is higher in the component tree than AddResultFlyout
, it never unmounts.
I don't have an opinion about whether or not this would be better or worse, but you could lift the isFlyoutOpen
state up a level and push the logic down to be contained in AddResultFlyout
.
That's just an open ended thought to consider.
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / general / Firefox XPack UI Functional Tests.x-pack/test/functional/apps/grok_debugger/grok_debugger·js.logstash grok debugger app "before all" hook in "grok debugger app"Standard Out
Stack Trace
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: cc @JasonStoltz |
* Set up curation search server route - not really sure which API endpoint to use, hedging my bets * Set up AddResultLogic - fairly simple, mostly concerned with flyout behavior & search query - could likely be reused (or replaced with??) query tester logic in the future * Add main AddResultFlyout component - with custom isPromoted / isHidden logic & actions * Update AddResultButton to open flyout * Update Curation page to render the flyout * PR feedback: reset search query on flyout re-open
* Set up curation search server route - not really sure which API endpoint to use, hedging my bets * Set up AddResultLogic - fairly simple, mostly concerned with flyout behavior & search query - could likely be reused (or replaced with??) query tester logic in the future * Add main AddResultFlyout component - with custom isPromoted / isHidden logic & actions * Update AddResultButton to open flyout * Update Curation page to render the flyout * PR feedback: reset search query on flyout re-open Co-authored-by: Constance <[email protected]>
Summary
The final Curation feature PR! 🎉 This adds in the 'Add result manually' functionality. This was previously a separate page in the standalone UI and is moving to a flyout for improved UX.
Screencaps
QA
Checklist