-
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 field class refactor #73180
Index pattern field class refactor #73180
Conversation
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.
There seems to be a functional test failing related to this change. Other than that LGTM, checked on Mac/Ubuntu Chrome, all seems to be working.
this.groups.get(field.type)!.set(field.name, field); | ||
}; | ||
private removeByGroup = (field: IFieldType) => this.groups.get(field.type)!.delete(field.name); | ||
export class FieldList extends Array<IndexPatternField> implements IIndexPatternFieldList { |
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'm a bit concerned about extending the native Array
here. Array
has many public methods, are we sure we want to expose all of those as part of FieldList
. If users use those, they can basically mutate the FieldList
while by-passing the business logic of FieldList
.
Maybe we could use composition instead?
class FieldList {
private data: Array<IndexPatternField> = [];
}
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.
++
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.
100% agree, but I'm avoiding changing the class interfaces in this PR. Will address in a follow up - #68020
|
||
specs.map((field) => this.add(field)); | ||
} | ||
getByName = (name: IndexPatternField['name']) => this.byName.get(name); |
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.
All these could have readonly
modifier.
getByName = (name: IndexPatternField['name']) => this.byName.get(name); | |
readonly getByName = (name: IndexPatternField['name']) => this.byName.get(name); |
or
getByName = (name: IndexPatternField['name']) => this.byName.get(name); | |
public readonly getByName = (name: IndexPatternField['name']) => this.byName.get(name); |
displayName: string, | ||
onNotification: OnNotification | ||
) { | ||
this.indexPattern = indexPattern; |
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 don't like the fact that we need to pass indexPattern in just to be able to get to formatter, could we:
- remove format function and have consumers always use
indexPattern.getFormatterForField(field)
? - or actually push that to the service, so we would do something like
indexPatterns.getFormatter(indexPattern, field)
and both IndexPattern and IndexPatternField get rid of that dependency (and can be static)
i am fine with doing this later, i am just wondering how reasonable you think that 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.
100% This PR keeps the class interfaces largely the same. My next PR will address this -#71909
I investigated the failing functional test in the transform plugin. We use the Kibana index pattern field information to determine whether that field is suitable to be used for a preview visualization. Among other things we check against the On
When running this PR, we get:
Since in our code we do a strict equal check ( The code causing this can be found here: https://github.com/elastic/kibana/blob/master/x-pack/plugins/ml/public/application/components/data_grid/common.ts#L157 Hope this helps, let me know if I can help out with more investigations. |
Thanks! Extremely helpful! |
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
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
@elasticmachine merge upstream |
- Better distinction and relationship between IndexPatternField and its spec - IndexPatternField class is no longer defined via object mutation - Reduction of dependencies - UI code moved into Index Pattern class (will be removed in next ticket) - IndexPattern field list was previously composed of IndexPatternFields or specs, now only IndexPatternFields - IndexPattern field list was previously redefined when loading fields, now only its contents are replaced. # Conflicts: # docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md # src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts # src/plugins/data/public/index.ts
- Better distinction and relationship between IndexPatternField and its spec - IndexPatternField class is no longer defined via object mutation - Reduction of dependencies - UI code moved into Index Pattern class (will be removed in next ticket) - IndexPattern field list was previously composed of IndexPatternFields or specs, now only IndexPatternFields - IndexPattern field list was previously redefined when loading fields, now only its contents are replaced.
…-task * master: (42 commits) Allow any hostname for chromium proxy bypass (elastic#74693) [ML] ML on Kibana Management: Add ability to pass a group ID filter to job management page (elastic#74533) [Metrics UI] Fix No Data preview pluralization (elastic#74399) [Bug][Security_Solution][Telemetry] Capitalize S in macOS (elastic#74688) Remove karma tests from legacy maps (elastic#74668) [Ingest Manager] stop creating events-* index pattern and placeholder index (elastic#74683) [Enterprise Search] Update the browser/document title on plugin navigation (elastic#74392) [visualizations] Add i18n translation for 'No results found' (elastic#74619) [maps] convert vector style properties to TS (elastic#74553) bump geckodriver binary to 0.27 (elastic#74638) fix: update apm agents to catch abort requests (elastic#74658) [Security Solution] Resolver children pagination (elastic#74603) add memoryStatus to df analytics page and analytics table in management (elastic#74570) [Ingest Manager] Allow prerelease in package version (elastic#74452) [App Arch]: remove legacy karma tests (elastic#74599) [i18n] revert reverted changes (elastic#74633) [Lens] Clear out all attribute properties before updating (elastic#74483) [Uptime] Fix full reloads while navigating to alert/ml (elastic#73796) Index pattern field class refactor (elastic#73180) [ML] Functional tests - stabilize DFA job type check (elastic#74631) ...
Summary
Checklist
For maintainers