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

[Lens] Extend Datasource props validation with VisualizationGroups #82607

Merged

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Nov 4, 2020

Summary

This PR is the second part of #80127, built on top of #81439, so it requires it to be merged before merging this one.

The purpose of this PR is to create a basic infrastructure for future advanced checks on the Dimension Editor in Lens.

dej611 and others added 30 commits October 20, 2020 18:47
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Hey, seems like the getErrorMessages extension is not complete.

getErrorMessages: (state: T) => Array<{ shortMessage: string; longMessage: string }> | undefined;
getErrorMessages: (
state: T,
groups?: VisualizationDimensionGroupConfig[]
Copy link
Contributor

Choose a reason for hiding this comment

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

You added the groups as an optional parameter here, but in the places getErrorMessages is actually called they are not passed in (in workspace and suggestion panel)

@flash1293 flash1293 marked this pull request as ready for review November 6, 2020 13:09
@flash1293 flash1293 requested a review from a team November 6, 2020 13:09
@flash1293 flash1293 added Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0 v8.0.0 labels Nov 6, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@@ -104,8 +104,18 @@ export const validateDatasourceAndVisualization = (
longMessage: string;
}>
| undefined => {
const layersGroups =
currentVisualizationState &&
currentVisualization?.getLayerIds(currentVisualizationState).map((layerId) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This has to be a map (with the keys being the layer id) - otherwise the datasource won't be able to map the right group arrays back to the right internal layer representation.

The type should be

getErrorMessages: (
    state: T,
    layersGroups?: Record<string, VisualizationDimensionGroupConfig[]>
  ) => Array<{ shortMessage: string; longMessage: string }> | undefined;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an array, so always in order, so it shouldn't be a problem: probably the implementation will need to identify layers index anyway internally to output a better contextual message.
I understand it may be also useful to have a lookup by layerId, I'll update.

@dej611 dej611 linked an issue Nov 9, 2020 that may be closed by this pull request
@dej611
Copy link
Contributor Author

dej611 commented Nov 9, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

async chunks size

id before after diff
lens 1.0MB 1.0MB +486.0B

History

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

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

LGTM, code review only

@dej611 dej611 merged commit 97e2dc8 into elastic:master Nov 9, 2020
@dej611 dej611 deleted the feature/lens/datasource-groups-validation branch November 9, 2020 14:22
dej611 added a commit to dej611/kibana that referenced this pull request Nov 9, 2020
…lastic#82607)

* ✨ First pass with visualization validation + error messages

* 🔥 Remove indexpattern error handling for now

* 🏷️ Fix type issues

* ✅ Add getErrorMessage test for data table

* ✅ Add tests for pie and metric error messages

* 🌐 Fix i18n checks issues

* 🐛 Fix last issue

* ✅ Add more tests for the XY visualization validation code

* 👌 Included all feedback from first review

* ✏️ Off by one message

* 🌐 Fix i18n duplicate id

* 🌐 Fix last i18n issue

* 🐛 Fixed a hook reflow issue

* ♻️+✅ Reworked validation flow + tests

* 🏷️ Fix type issue

* 🐛 Improved XY corner cases validation logic

* 🐛 Fix empty datatable scenario

* ✨ + ✅ Improved error messages for invalid datasources + tests

* 🌐 Add missing i18n translation

* 🏷️ Fix type issues

* 🌐 Fix i18n issues

* ✨ Filter out suggestions which fail to build

* 🚚 Migrate datatable validation logic to the building phase, handling it as building state

* 🏷️ Fix type issue

* ✏️ Add comment for future enhancements

* ✏️ Updated comment

* :world_with_meridians: Refactor axis labels

* 🌐 Reworked few validation messages

* 🐛 Fix break down validation + percentage charts

* ✅ Align tests with new validation logic

* ♻️ Fix suggestion panel validation to match main panel

* 🌐 Fix i18n issues

* 🔧 Fix some refs for validation checks in suggestions

* 🐛 Fix missing key prop in multiple errors scenario

* 🐛 Fix swtich issue from XY to partition

* 🌐 Fix i18n messages and aligned tests

* 🐛 Fix suggestions switching bug

* :refactor: Add more validation + refactored validation logic in a single place

* ✏️ Add note about lint hooks disable rule

* 🚨 Fix linting issue

* 🏗️ Add infra API for datasource advanced validation

* ✅ Align tests with new API

* ✅ Fix type issues in tests

* 👌 Early exists added

* ✨ Add layers groups to the API

* ✅ Fix some broken test after the validation change

* 👌 Move to disctionary shape

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dej611 added a commit that referenced this pull request Nov 9, 2020
…ups (#82607) (#82958)

* ✨ First pass with visualization validation + error messages

* 🔥 Remove indexpattern error handling for now

* 🏷️ Fix type issues

* ✅ Add getErrorMessage test for data table

* ✅ Add tests for pie and metric error messages

* 🌐 Fix i18n checks issues

* 🐛 Fix last issue

* ✅ Add more tests for the XY visualization validation code

* 👌 Included all feedback from first review

* ✏️ Off by one message

* 🌐 Fix i18n duplicate id

* 🌐 Fix last i18n issue

* 🐛 Fixed a hook reflow issue

* ♻️+✅ Reworked validation flow + tests

* 🏷️ Fix type issue

* 🐛 Improved XY corner cases validation logic

* 🐛 Fix empty datatable scenario

* ✨ + ✅ Improved error messages for invalid datasources + tests

* 🌐 Add missing i18n translation

* 🏷️ Fix type issues

* 🌐 Fix i18n issues

* ✨ Filter out suggestions which fail to build

* 🚚 Migrate datatable validation logic to the building phase, handling it as building state

* 🏷️ Fix type issue

* ✏️ Add comment for future enhancements

* ✏️ Updated comment

* :world_with_meridians: Refactor axis labels

* 🌐 Reworked few validation messages

* 🐛 Fix break down validation + percentage charts

* ✅ Align tests with new validation logic

* ♻️ Fix suggestion panel validation to match main panel

* 🌐 Fix i18n issues

* 🔧 Fix some refs for validation checks in suggestions

* 🐛 Fix missing key prop in multiple errors scenario

* 🐛 Fix swtich issue from XY to partition

* 🌐 Fix i18n messages and aligned tests

* 🐛 Fix suggestions switching bug

* :refactor: Add more validation + refactored validation logic in a single place

* ✏️ Add note about lint hooks disable rule

* 🚨 Fix linting issue

* 🏗️ Add infra API for datasource advanced validation

* ✅ Align tests with new API

* ✅ Fix type issues in tests

* 👌 Early exists added

* ✨ Add layers groups to the API

* ✅ Fix some broken test after the validation change

* 👌 Move to disctionary shape

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Allow datasource and visualization to display error in workspace
4 participants