-
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
Index pattern public api => common #68289
Index pattern public api => common #68289
Conversation
This reverts commit 5de1b21.
This reverts commit ebc56d8.
Pinging @elastic/kibana-app-arch (Team:AppArch) |
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.
left some initial comments
title, | ||
text, | ||
}); | ||
onNotification({ title, text, color: 'danger', iconType: 'alert' }); |
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.
what if we throw here and let the caller handle the exception. instead of passing onNotification
in they can wrap code in try/cache
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 is good idea but I'd prefer to address it in another ticket as this PR aims to be a minimal set of changes required to provide a common api. I think I'd need to examine all places where index patterns are used to ensure errors are being caught. I've added a ticket to #67920
specs?: FieldSpec[], | ||
shortDotsEnable?: boolean | ||
) => IIndexPatternFieldList; | ||
|
||
export const getIndexPatternFieldListCreator = ({ | ||
fieldFormats, | ||
toastNotifications, | ||
onNotification, |
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.
on this level we can then remove onNotification and leave catching the exception to the caller.
return []; | ||
} | ||
|
||
toasts.addError(err, { | ||
this.onError(err, { |
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.
lets throw here as well and leave it up to the caller to decide what kind of notification they want to show ?
defaultId = patterns[0]; | ||
core.uiSettings.set('defaultIndex', defaultId); | ||
} else { | ||
return onRedirectNoIndexPattern(); |
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.
lets have this method always return and the caller decide what to do (no need to pass in callbacks)
export type EnsureDefaultIndexPattern = () => Promise<unknown> | undefined; | ||
|
||
export const createEnsureDefaultIndexPattern = ( | ||
core: CoreStart, |
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.
lets not pass in whole core but just uiSettingsClient
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.
is there a reason this is wrapped in a function ? why not just export ensureDefaultIndexPattern ?
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 I'd prefer to leave further refactoring of this code to future PRs. I'm drawing a rather arbitrary line since I need to do things backwards - provide the service and then clean up the code.
@elasticmachine merge upstream |
This reverts commit 30bf1e0.
…na into index_pattern_server_api_2
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.
Overall makes sense, my main questions were around keeping some of the old directories in public
which are only re-exporting common
items & could probably be removed.
Also I agree with @ppisljar's idea on getting rid of the callbacks & instead just throwing and relying on the caller to handle things appropriately. But no strong feelings as to whether that's addressed here or as a follow-up.
@@ -17,5 +17,4 @@ | |||
* under the License. | |||
*/ | |||
|
|||
export * from './field_list'; | |||
export * from './field'; | |||
export * from '../../../common/index_patterns/fields'; |
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.
Rather than re-exporting here, should we just remove the public/index_patterns/fields
directory entirely and import items from common/index_patterns/fields
wherever they are needed?
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.
These haven't been removed yet because I ran into errors when I did them all at once. There's an undesirable import somewhere. Just a matter of chasing it down now or later.
export * from './index_patterns'; | ||
export * from './index_patterns_api_client'; | ||
export * from './types'; | ||
export * from '../../../common/index_patterns/index_patterns'; |
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.
Same question, should we re-export from 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.
Addressed other instances but this one is giving me trouble.
No strong opinions here either. Drew the line here because the PR was still relatively easy to understand. Perhaps we should determine where to draw the line by when works starts on the index pattern expression function. I was under the impression that the answer was 'as soon as possible' |
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
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.
code LGTM
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.
Code LGTM -- I'm cool with addressing the items discussed in a followup PR.
Tested Chrome (macOS) and everything seemed to work as expected 👍
I was able to reproduce the "missing indices" error message using the onNotification
callback, though I did not test every notification or error scenario.
Refactor index pattern api so it can be used by public and server services # Conflicts: # src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts # src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts # src/plugins/data/public/index_patterns/index_patterns/index_pattern.tsx
* master: (38 commits) Support migrating from reserved feature privileges (elastic#68504) add `preference` field to SavedObjectsFindOptions (elastic#68620) [ILM] Add "wait for snapshot" policy field to Delete phase (elastic#68505) Cleanup old license overwrites (elastic#68744) Bump TypeScript to v3.9 (elastic#67666) [APM] Service maps - adds new storybook stories to test out various data sets (elastic#68727) Fix vega specification parsing (elastic#67963) docs: add more api information (elastic#68717) [APM] Don't show annotations on charts with no data (elastic#68829) [Metrics UI] Fix Inventory View sorting by handling null values (elastic#67889) skip flaky suite (elastic#68836) [SIEM][Detections Engine] - Fix reference rule url overflow (elastic#68640) Index pattern public api => common (elastic#68289) [APM] Lazy-load alert triggers (elastic#68806) [DOCS] Fix table formatting in ingest manager settings (elastic#68824) [Endpoint] Functional Tests cleanup (elastic#68756) revert previous commit which was unintentional Use Github token instead for project assignments [SIEM][Exceptions] - ExceptionsViewer cleanup (elastic#68739) move @kbn/storybook to devDeps (elastic#68791) ...
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Summary
This pr moves the index pattern api into a common directory and factors out client side code. The next pr will expose index pattern api via server.
Part of moving the index pattern api to a common (client and server) api - #68003
core.notifications.toast
withonNotification
andonError
callback functionsFieldFormatsStart
usage withFieldFormatsStartCommon
kibana_utils/public/{errors, field_mapping}
=>kibana_utils/common/{errors, field_mapping}
common
directory