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

[Data View Mgmt] Implement state service #193660

Merged
merged 15 commits into from
Sep 25, 2024

Conversation

mattkime
Copy link
Contributor

@mattkime mattkime commented Sep 22, 2024

Summary

Intermediate step in converting Data View Management to DataViewLazy. Moved useCallback functionality into central service so much of the state functionality is in one place and easier to understand and refactor.

Part of #178926

Broken out from #190292 which tried to do everything in one go and became too messy.

@mattkime mattkime changed the title initial service implementation [Data View Mgmt] Implement state service Sep 23, 2024
@mattkime mattkime self-assigned this Sep 23, 2024
@mattkime mattkime added Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. backport:prev-major Backport to (8.x, 8.17, 8.16) the previous major branch and other branches in development labels Sep 23, 2024
@mattkime mattkime marked this pull request as ready for review September 23, 2024 06:06
@mattkime mattkime requested a review from a team as a code owner September 23, 2024 06:06
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@mattkime mattkime added the release_note:skip Skip the PR/issue when compiling release notes label Sep 23, 2024
@mattkime
Copy link
Contributor Author

/ci

src/plugins/data_views/common/data_views/data_views.ts Outdated Show resolved Hide resolved
dataView,
fields,
indexedFieldTypes,
fieldConflictCount: fields.filter((field) => field.type === 'conflict').length,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can scripted fields cause a conflict?

Suggested change
fieldConflictCount: fields.filter((field) => field.type === 'conflict').length,
fieldConflictCount: dataView.fields.filter((field) => field.type === 'conflict').length,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purposeful as the DataViewLazy field list is a separate object and this code aims to minimize changes from DataView to DataViewLazy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fields excludes scripted fields when defined in setDataView. So my question was whether scripted fields still need to be checked for conflicts.

I tested it and it seems like scripted fields "override" normal fields hence we don't report on type conflicts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, scripted fields override, no conflict possible.

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring! Leaving some questions first.

@mattkime
Copy link
Contributor Author

/ci

@mattkime
Copy link
Contributor Author

/ci

this.updateState({
dataView,
fields,
indexedFieldTypes,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side question: should we run uniq on the resulting indexedFieldTypes or is it fine to have it with duplicates like conflict?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uniq is run in UI code but makes more sense in the service - good call

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@mattkime
Copy link
Contributor Author

/ci

@mattkime mattkime merged commit d772a11 into elastic:main Sep 25, 2024
24 of 26 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 25, 2024
## Summary

Intermediate step in converting Data View Management to DataViewLazy.
Moved `useCallback` functionality into central service so much of the
state functionality is in one place and easier to understand and
refactor.

Part of elastic#178926

Broken out from elastic#190292 which
tried to do everything in one go and became too messy.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Julia Rechkunova <[email protected]>
(cherry picked from commit d772a11)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 25, 2024
## Summary

Intermediate step in converting Data View Management to DataViewLazy.
Moved `useCallback` functionality into central service so much of the
state functionality is in one place and easier to understand and
refactor.

Part of elastic#178926

Broken out from elastic#190292 which
tried to do everything in one go and became too messy.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Julia Rechkunova <[email protected]>
(cherry picked from commit d772a11)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.15
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dataViewManagement 236 239 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dataViewManagement 140.2KB 142.4KB +2.2KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
dataViewManagement 5.0KB 5.2KB +139.0B
dataViews 62.3KB 62.4KB +108.0B
total +247.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
dataViewManagement 3 2 -1

References to deprecated APIs

id before after diff
dataViewManagement 45 35 -10

Total ESLint disabled count

id before after diff
dataViewManagement 3 2 -1

History

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

cc @mattkime

@mattkime mattkime added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) and removed backport:prev-major Backport to (8.x, 8.17, 8.16) the previous major branch and other branches in development labels Sep 25, 2024
@kibanamachine kibanamachine added backport missing Added to PRs automatically when the are determined to be missing a backport. labels Sep 30, 2024
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

kibanamachine added a commit that referenced this pull request Sep 30, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Data View Mgmt] Implement state service
(#193660)](#193660)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Matthew
Kime","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-25T14:37:17Z","message":"[Data
View Mgmt] Implement state service (#193660)\n\n##
Summary\r\n\r\nIntermediate step in converting Data View Management to
DataViewLazy.\r\nMoved `useCallback` functionality into central service
so much of the\r\nstate functionality is in one place and easier to
understand and\r\nrefactor.\r\n\r\nPart of
https://github.com/elastic/kibana/issues/178926\r\n\r\nBroken out from
#190292 which\r\ntried to do
everything in one go and became too
messy.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Julia Rechkunova
<[email protected]>","sha":"d772a11c74af1efd05242516900f06cbeb00dd6f","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data
Views","Feature:Kibana
Management","release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-major"],"title":"[Data
View Mgmt] Implement state
service","number":193660,"url":"https://github.com/elastic/kibana/pull/193660","mergeCommit":{"message":"[Data
View Mgmt] Implement state service (#193660)\n\n##
Summary\r\n\r\nIntermediate step in converting Data View Management to
DataViewLazy.\r\nMoved `useCallback` functionality into central service
so much of the\r\nstate functionality is in one place and easier to
understand and\r\nrefactor.\r\n\r\nPart of
https://github.com/elastic/kibana/issues/178926\r\n\r\nBroken out from
#190292 which\r\ntried to do
everything in one go and became too
messy.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Julia Rechkunova
<[email protected]>","sha":"d772a11c74af1efd05242516900f06cbeb00dd6f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193660","number":193660,"mergeCommit":{"message":"[Data
View Mgmt] Implement state service (#193660)\n\n##
Summary\r\n\r\nIntermediate step in converting Data View Management to
DataViewLazy.\r\nMoved `useCallback` functionality into central service
so much of the\r\nstate functionality is in one place and easier to
understand and\r\nrefactor.\r\n\r\nPart of
https://github.com/elastic/kibana/issues/178926\r\n\r\nBroken out from
#190292 which\r\ntried to do
everything in one go and became too
messy.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Julia Rechkunova
<[email protected]>","sha":"d772a11c74af1efd05242516900f06cbeb00dd6f"}}]}]
BACKPORT-->

Co-authored-by: Matthew Kime <[email protected]>
@kibanamachine kibanamachine added v8.16.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants