-
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
[NP] Remove IndexedArray usage in Schemas #61410
[NP] Remove IndexedArray usage in Schemas #61410
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
merge conflict between base and head |
…xed-array # Conflicts: # src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts
@elasticmachine merge upstream |
@@ -70,7 +70,7 @@ function DefaultEditorAggGroup({ | |||
}: DefaultEditorAggGroupProps) { | |||
const groupNameLabel = (search.aggs.aggGroupNamesMap() as any)[groupName]; | |||
// e.g. buckets can have no aggs | |||
const schemaNames = getSchemasByGroup(schemas, groupName).map(s => s.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.
Here schemas
has already contained schemas by group from groupName
. So we don't need to get them again.
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.
Tested locally in Chrome, works as expected! 👍
I would only adjust some types as recommended below 👇
@@ -46,8 +45,7 @@ export interface Schema { | |||
} | |||
|
|||
export class Schemas { | |||
// @ts-ignore | |||
all: IndexedArray<Schema>; | |||
all: Schema[] = []; |
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 would specify metrics
& buckets
here also.
Basically, this class should implements the ISchemas
interface.
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.
👍 Done.
Since now Schemas
has the same properties as ISchemas
has, I got rid of ISchemas
.
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.
hmm, AFAIK ISchemas
was intentionally created to use an interface instead of class instance (there were a lot of places with such an approach, so all of interfaces starts with I
).
@flash1293 am I 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.
@stacey-gammon When I remember correctly you started to remove the types separate to actual class implementations in some places, right? Do you know what the current best practices around this are?
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.
For awhile we (app arch) were moving toward an I
prefix convention in these scenarios, but have since stopped doing this in favor of waiting for type-only imports which are available in TS 3.8. I believe this is the approach the platform team is taking too.
In the meantime, for the cases where we need a separate type in the interim, we have been inconsistent, using I*
in some places but not in others.
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.
In that case I like the current solution, once TS 3.8 is merged, we can do a bulk change of the remaining places.
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.
For those who want to follow along, here's the PR which is working toward upgrading TS in Kibana: #57774
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.
Discussion here if you are interested on the I-prefix: #51674
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.
Tested with various aggregation configurations (adding/removing) - everything seems to be there and working as intended - LGTM. Left some small nits about types in addition to Daniils remarks
src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/vis_default_editor/public/components/agg_group.test.tsx
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Remove IndexedArray usage from schemas.ts * Update unit tests * Revert default value * Update sidebar.tsx * Updated TS * Fix code review comments * Remove ISchemas * Revert ISchemas Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* master: Switch to embeddable factory interface with optional override (elastic#61165) fix text error in diagrams (elastic#62101) [Index management] Prepare support Index template V2 format (elastic#61588) Updates dashboard images (elastic#62011) [Maps] remove MapBounds type (elastic#62332) [Uptime] Convert anomaly Jobs name to lowercase to comply with… (elastic#62293) Make d3 place nicely with object values (elastic#62004) EMT-287: update schema with elastic agent id (elastic#62252) [Maps] fix replaceLayerList to handle case where map is not intialized (elastic#62202) Remove support for deprecated xpack.telemetry configurations (elastic#51142) [Uptime] Remove static constant for index name completely (elastic#62256) [APM] E2E: install dependencies for vanilla workspaces (elastic#62178) [backport] Bump to 5.1.3 (elastic#62286) Show server name in Remote Cluster detail panel (elastic#62250) Rename some alert types (elastic#61693) changing duration type to ms, s, m (elastic#62265) [ML] Clear Kibana index pattern cache on creation or form reset. (elastic#62184) Move `src/legacy/server/index_patterns` to data plugin (server) (Remove step) (elastic#61618) [NP] Remove IndexedArray usage in Schemas (elastic#61410)
Part of #60098.
Remove IndexedArray usage in Schemas