-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Runtime fields] Editor phase 1 #81472
Conversation
@elasticmachine merge upstream |
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@elasticmachine merge upstream |
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
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.
Happy with the proposed changes! Great work @sebelga . It would be good to see a real-world use of this component so that we can really put the API to the test, but AFAICT everything looks in order 🍻
Thanks for the review @jloleysens ! Yes, once integrated we will have a better sense if something is missing in the API or could be improved. I do expect it to evolve as requirements come in so we should not worry too much about it at this stage. |
export interface RuntimeField { | ||
name: string; | ||
type: RuntimeType; | ||
script: 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.
Using this now as a type for what the editor returns, means we've decided against a higher level "intention" abstraction, that we would e.g. save later on "the user wanted to extract the weekday" instead of the full script? Could you please elaborate a bit on why we made the decicions to always store a script?
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.
At this stage, we haven't decided against anything yet 😊 What we do know for sure is that we will need to be able to return the raw script whenever the user wants to go that way and he will bypass any UI we create to help him build the script. And this is the first iteration of the editor, it only allows to write a script.
When we will improve on the UX to create the script we can decide how best to store the user intention 👍
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.
@timroes @sebelga Maybe we can split the difference. We want something that will be forward compatible but we don't necessarily want to fully define it or block progress on this pr.
I'll toss out an idea - what if a future version of RuntimeField
had an editor
attribute as so -
export interface RuntimeFieldEditor {
id: string; // or something more specific
params: { [key: string]: any; }
}
lack of an editor param would indicate the generic editor we're currently working on.
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 could work, but I was more seeing something like a "script definition" object. If present, then the script is generated.
interface RuntimeField {
name: string;
type: string;
script: string;
scriptDefinition?: {
// To be defined! :)
dateParse: {
target: '_doc',
field: 'eventDate',
...
},
stringConcat: {
...
},
__meta__: {
version: 1, // anything needed to easily upgrade between versions
}
}
}
But it's a bit early to define the interface IMO.
The way the API currently looks in the description means that every consumer needs to take care about saving those fields. What is our plan to make the integration better into the apps, so not everyone needs to put those fields into the index pattern? Will the index pattern service get a method to invoke this editor with some callbacks once it's saved? |
I agree with @timroes, it seems to me the editor should integrate with IndexPattern:
is there a usecase for having a RuntimeField outside of IndexPattern ? |
It can be defined on a field mapping. |
@timroes @ppisljar Thanks for the feedback. What you are suggesting is what I originally had in mind. If you search for "ExampleIntegration" in my draft Google doc, in my proposal you can see that the consuming app only provides an index pattern id (it could also be the object) and all the responsibility of fetching/updating the index pattern occurred inside the runtime field editor. As @mattkime says, there is a use case where the user adds a runtime field to the index mappings. @stacey-gammon told me that the responsibility of the runtime field editor ends by providing the runtime field to the consumer. We will then add a layer in between the I don't have the exact API for that layer but it will be something like (correct me if I'm wrong Stacey) const editField = (field) => {
actionsService.getTriggerActions('EDIT_FIELD')[0].execute({ field, indexPatternObject }, callback);
}; What happens when executing the action is probably what you refer to encapsulating all the logic to update the index pattern object, right? |
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.
New bundle limit LGTM
} | ||
|
||
// 3. Load the editor and open it anywhere in your app | ||
const MyComponent = () => { |
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.
Did you think about adding an example plugin so the example code would be tested and guaranteed to always be up to date? It's so tough to remember to keep code snippets like this up to date with API changed.
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.
Thanks for reminding me of this. Yes I will create an example plugin 👍
Recently we had a discussion of how the runtime fields editor might exist inside the index pattern field editor, along side the field format editor. @sebelga mentioned that it wouldn't work with the api presented here and he's correct. At very least there's a mismatch. The runtime field editor currently takes an I'm trying to think of how this might change its return value. Perhaps at some point it might return whether the runtime field value is valid but I don't think we have that functionality at this point. |
@mattkime There are multiple ways to integrate the editor. Either calling a handler (in this case the consumer does not worry about EuiFlyout or anything) or through one of the exposed static React components. One of them is the component you mention, which corresponds to the body of the Flyout. From what we discussed, I think the runtime field editor should be enhanced to support everything that is editable from inside index pattern management. So all-consuming app benefit from it. So on your side when clicking "edit" on a field you do a simple check: Is it a runtime field ? yes --> open runtimeFieldEditor(field), no --> open fieldEditor(field) The "field editor" should have a similar interface as the runtime field editor ( |
@sebelga Thanks and apologies, I did overlook the standalone component. We're in agreement. |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Distributable file count
Page load bundle
History
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
Thanks for the review @ppisljar ! I will merge this PR now. To reiterate on what we discussed offline, there will be a layer between what is exposed in this PR and the consuming OSS apps. This layer, as you suggest, will allow the following flow:
|
…o-node-details * 'master' of github.com:elastic/kibana: (65 commits) update chromedriver dependency to 87 (elastic#83624) [TSVB] use new Search API for rollup search (elastic#83275) [TSVB] Y-axis has number formatting not considering all series formatters in the group (elastic#83438) [Logs UI] Update <LogStream /> internal state when its props change (elastic#83302) Add tag bulk action context menu (elastic#82816) [code coverage] adding plugin to flush coverage data (elastic#83447) [UsageCollection] Expose `KibanaRequest` to explicitly opted-in collectors (elastic#83413) Added eventBus to trigger and listen plotHandler event (elastic#83435) [Runtime fields] Editor phase 1 (elastic#81472) [Maps] Fix threshold alert issue resolving nested fields (elastic#83577) chore(NA): remove usage of unverified es snapshots (elastic#83589) [DOCS] Adds Elastic Contributor Program link (elastic#83561) Upgrade EUI to v30.2.0 (elastic#82730) Don't show loading screen during auto-reload (elastic#83376) Functional tests - fix esArchive mappings with runtime fields (elastic#83530) [deb/rpm] Create keystore after installation (elastic#76465) [rpm] Create default environment file at "/etc/sysconfig/kibana" (elastic#82144) [docker] removes workaround for missing crypto-policies-scripts subpackage (elastic#83455) [ML] Persisted URL state for the Data frame analytics jobs and models pages (elastic#83439) adds xpack.security.authc.selector.enabled setting (elastic#83551) ...
This PR adds the "runtimeFields" x-pack plugin which exposes the runtime field editor. The editor will be consumed initially by OSS apps (Index pattern management, Discover, Lens...).
[EDIT] As mentioned in the comment below, the editor won't be consumed directly by OSS apps. There will be an index_pattern_management_enhanced x-pack plugin that will register an action to edit a field. This action will be responsible of opening the runtime field editor. And it is this action that the OSS consuming apps will execute when editing or creating a runtime field.
The code in this PR has already been reviewed in several other PRs (#81766, #82116, #82464). So let's use this PR to discuss any concerns regarding the API proposed to integrate the editor in other Kibana apps.
The README.md contains detailed information on how the editor is exposed with the initial IN/OUT interfaces for consumers.
Snippet