-
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] Added all Document related routes and logic #83324
Conversation
ecf42b1
to
d91ca4f
Compare
const { http } = HttpLogic.values; | ||
await http.delete(`/api/app_search/engines/${engineName}/documents/${documentId}`); | ||
// Note: This used to use a server generated message, but no i18n so we'll do it here | ||
setQueuedSuccessMessage(DELETE_SUCCESS); |
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 used to use a server generated message, but that is not i18n compliant so I moved the message inline here.
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.
Ooo, great call! I actually have a note buried somewhere in my backlog to figure out what to do with i18n and errors/messages coming in from the server 😬 For easy stuff like this I'm a huge +1 to pulling them out like this. For the more complex wildcard stuff, we'll have to ask the Kibana team for guidance I think
await http.delete(`/api/app_search/engines/${engineName}/documents/${documentId}`); | ||
// Note: This used to use a server generated message, but no i18n so we'll do it here | ||
setQueuedSuccessMessage(DELETE_SUCCESS); | ||
// TODO Handle routing after success |
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.
The old code used a history.push
to navigate back to the document list view after a successful delete.
I wonder if that is the way we should continue doing it or not.
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.
You can use KibanaLogic.values.navigateToUrl()
to replace history.push()
- it works correctly with Kibana's SPA history (doesn't rerender top-level app which resets Kea state) and also automatically prefixes our app route for us.
I'll try to write up a cheat sheet/reference list of conversions like that at some point soon for our migration QOL
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 will re-add this when I have the UI wired up with 404 handling. It will be easier to test.
try { | ||
const { http } = HttpLogic.values; | ||
const response = await http.get( | ||
`/api/app_search/engines/${engineName}/documents/${documentId}` |
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.
Future note to myself. We'll need to handle 404s somehow. It's not handled here.
d91ca4f
to
2100770
Compare
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.
Awesome stuff! Just a bunch of small nits and a quick note about my grand future plans for DocumentLogic and the creation modal (no change requested there, just a heads up).
x-pack/plugins/enterprise_search/server/routes/app_search/documents.test.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/server/routes/app_search/documents.test.ts
Outdated
Show resolved
Hide resolved
|
||
export interface FieldDetails { | ||
name: string; | ||
value: string | string[]; |
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.
[not a change request, just me thinking out loud] Someday in a very distant future it might be nice to clean that up a bit more in a server transform - e.g. by doing isArray(value) ? value : [value]
we know for sure we're always dealing w/ arrays
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.
💯 Yeah that would be ideal
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 made a simple fix for this at the Logic level for now. This could be refactored later, but I think it's worth at least this small amount of effort because it will greatly simplify things downstream in the UI: 772e801
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 awesome, love it! I have a very slight preference to storing / testing normalizeFields
in a utils
file to separate out the array logic from getDocumentDetails
test (in theory a unit test is easier to follow if it handles 1 thing at a time), but it's a very slight preference and I'm fine with merging as-is.
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 reverted it. We actually need to know if it's an array or not on the front-end.
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.
Ahh no worries, I was hoping something like that wouldn't come up, but alas. Some day
...ins/enterprise_search/public/applications/app_search/components/documents/documents_logic.ts
Outdated
Show resolved
Hide resolved
...ins/enterprise_search/public/applications/app_search/components/documents/documents_logic.ts
Outdated
Show resolved
Hide resolved
...terprise_search/public/applications/app_search/components/documents/document_detail_logic.ts
Outdated
Show resolved
Hide resolved
const { http } = HttpLogic.values; | ||
await http.delete(`/api/app_search/engines/${engineName}/documents/${documentId}`); | ||
// Note: This used to use a server generated message, but no i18n so we'll do it here | ||
setQueuedSuccessMessage(DELETE_SUCCESS); |
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.
Ooo, great call! I actually have a note buried somewhere in my backlog to figure out what to do with i18n and errors/messages coming in from the server 😬 For easy stuff like this I'm a huge +1 to pulling them out like this. For the more complex wildcard stuff, we'll have to ask the Kibana team for guidance I think
...se_search/public/applications/app_search/components/documents/documents_detail_logic.test.ts
Outdated
Show resolved
Hide resolved
...se_search/public/applications/app_search/components/documents/documents_detail_logic.test.ts
Outdated
Show resolved
Hide resolved
...se_search/public/applications/app_search/components/documents/documents_detail_logic.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Constance <[email protected]>
@constancecchen I made some changes, take a look! |
I think the only semi-blocking comment that I want to figure out before merging is #83324 (comment) - I'm pushing back against exporting our interfaces because I'm worried it may encourage overriding types / using |
This reverts commit 772e801.
Good points. Updated. |
💚 Build SucceededMetrics [docs]Distributable file count
History
To update your PR or re-run it, just comment with: |
* master: (51 commits) [ML] Persisted URL state for the Data frame analytics jobs and models pages (elastic#83439) adds xpack.security.authc.selector.enabled setting (elastic#83551) skip flaky suite (elastic#77279) [ML] Improve support for script and aggregation fields in anomaly detection jobs (elastic#81923) [Workplace Search] Migrate SourcesLogic from ent-search (elastic#83544) [ML] Add UI test for feature importance features (elastic#82677) [Maps] Improve icons for all layer types (elastic#83503) Replace experimental badge with Beta (elastic#83468) [Fleet][EPM] Unified install and archive (elastic#83384) Move src/legacy/server/keystore to src/cli (elastic#83483) Used SO for saving the API key IDs that should be deleted (elastic#82211) [Uptime] Mock implementation to account for math flakiness test (elastic#83535) [Workplace Search] Enable check for org context based on URL (elastic#83487) [App Search] Added all Document related routes and logic (elastic#83324) [Alerting UI] Fix console error when setting connector params (elastic#83333) [Discover] Allow custom name for fields via index pattern field management (elastic#70039) [Uptime] Fix monitor list down histogram (elastic#83411) remove headers timeout hack, rely on nodejs timeouts (elastic#83419) [ML] Update console autocomplete for ML data frame evaluate API (elastic#83151) [Lens] Color in dimension trigger (elastic#76871) ...
Summary
Adds all logic and routes for Document and Document Detail views
Checklist
Delete any items that are not applicable to this PR.
For maintainers