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

Extract componenterrors from client #15445

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

adrinr
Copy link
Collaborator

@adrinr adrinr commented Jan 27, 2025

Description

In order to add some new validation for settings, we added a new system for handling component errors from the builder, in the design section: #15414
We want to aggregate these errors on a view, but given that the previous error checks (required settings and required ancestors) lived within the client itself, we could not show these in the aggregation.
This PR moves this logic out of the client, passing the full responsibility to the builder. Doing so, we will be able to display these errors as it pleases us.

No changes in logic or functionality should apply, as it should behave exactly as it is currently does.

Copy link

linear bot commented Jan 27, 2025

@adrinr adrinr changed the title Budi 9016/extract componenterrors from client Extract componenterrors from client Jan 27, 2025
Copy link

qa-wolf bot commented Jan 27, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@adrinr adrinr marked this pull request as ready for review January 28, 2025 10:48
@adrinr adrinr added the do not merge PR is not ready to be merged - generally the PR description should say why label Jan 31, 2025
@adrinr
Copy link
Collaborator Author

adrinr commented Jan 31, 2025

This cannot be merged until the CHECK_COMPONENT_SETTINGS_ERRORS flag is on. Otherwise, the existing error checks will be lost

Copy link
Member

@aptkingston aptkingston left a comment

Choose a reason for hiding this comment

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

Nice work @adrinr! Much better to have this all controlled by the builder instead.

I was having a play with it locally to check everything, and it looks like there are some differences with required settings for certain components - particularly the chart block. The chart block definition is huge and has many sections which are conditional, but currently it will correctly flag data source as a required setting, then flag label column and data columns as required too, one after each other as you fill them in.

On this branch, once you pick a datasource it does not correctly flag the other settings as missing required settings - it tries to render the chart and the error you get (Add some rows to your datasource to start using your component) is rendered by the chart itself.

On master

First error:
image
Second error:
image
Third error:
image

This branch

First error (correct):
image
Second error (incorrect, as this is rendering the real component now. The blue border means it's no longer in an "error" state):
image

I presume this is just something to do with the complicated definition of the chart block, and maybe the component errors are not properly being re-evaluated whenever one error is fixed.

Apart from this, it all looks good!

@github-actions github-actions bot added size/l and removed size/m labels Jan 31, 2025
@adrinr
Copy link
Collaborator Author

adrinr commented Jan 31, 2025

Nice work @adrinr! Much better to have this all controlled by the builder instead.

I was having a play with it locally to check everything, and it looks like there are some differences with required settings for certain components - particularly the chart block. The chart block definition is huge and has many sections which are conditional, but currently it will correctly flag data source as a required setting, then flag label column and data columns as required too, one after each other as you fill them in.

On this branch, once you pick a datasource it does not correctly flag the other settings as missing required settings - it tries to render the chart and the error you get (Add some rows to your datasource to start using your component) is rendered by the chart itself.

On master

First error: image Second error: image Third error: image

This branch

First error (correct): image Second error (incorrect, as this is rendering the real component now. The blue border means it's no longer in an "error" state): image

I presume this is just something to do with the complicated definition of the chart block, and maybe the component errors are not properly being re-evaluated whenever one error is fixed.

Apart from this, it all looks good!

Good catch! This should be fixed with the recent changes. I missed the "sections" in the manifests, so I now reused the current logic for it

@adrinr adrinr requested a review from aptkingston January 31, 2025 19:47
@adrinr adrinr removed the do not merge PR is not ready to be merged - generally the PR description should say why label Feb 3, 2025
}
})
return settings
}
Copy link
Member

Choose a reason for hiding this comment

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

We have componentStore.getComponentSettings already - does this basically just do the same thing? That function gets all settings for a certain component type and flattens them into a single array, accounting for sections.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This does not work, as it flattens the list completely. We have some settings, such as Date column that depends on a higher level dependsOn. So we need to iterate trough them instead to be able to see if it's actually required.
To be clear, this code from here is the same that was being used within the client, I just extracted it

@adrinr adrinr requested a review from aptkingston February 3, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants