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] Added all Document related routes and logic #83324

Merged
merged 10 commits into from
Nov 17, 2020

Conversation

JasonStoltz
Copy link
Member

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

@JasonStoltz JasonStoltz added release_note:skip Skip the PR/issue when compiling release notes v7.11.0 labels Nov 12, 2020
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);
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 used to use a server generated message, but that is not i18n compliant so I moved the message inline here.

Copy link
Contributor

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
Copy link
Member Author

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.

Copy link
Contributor

@cee-chen cee-chen Nov 12, 2020

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

Copy link
Member Author

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}`
Copy link
Member Author

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.

@JasonStoltz JasonStoltz marked this pull request as ready for review November 12, 2020 18:51
@JasonStoltz JasonStoltz requested a review from a team November 12, 2020 18:51
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.

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


export interface FieldDetails {
name: string;
value: string | string[];
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member Author

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.

a40fcb9

Copy link
Contributor

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

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);
Copy link
Contributor

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

@apmmachine
Copy link
Contributor

apmmachine commented Nov 16, 2020

💚 Build Succeeded

@JasonStoltz
Copy link
Member Author

@constancecchen I made some changes, take a look!

@JasonStoltz JasonStoltz requested a review from cee-chen November 16, 2020 16:14
@cee-chen
Copy link
Contributor

cee-chen commented Nov 16, 2020

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 as SomeLogicValues as a way to override incorrectly typed values in source code. Kea should be able to handle correctly type checking all values from us going forward, including in tests, so I'm confused why we need to re-define our mock values there.

@JasonStoltz
Copy link
Member Author

Good points. Updated.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Distributable file count

id before after diff
default 42835 42836 +1

History

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

JasonStoltz added a commit to JasonStoltz/kibana that referenced this pull request Nov 17, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 17, 2020
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants