-
Notifications
You must be signed in to change notification settings - Fork 915
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
[Fix] VisType switching persistence and selectively show warning #3715
Conversation
Signed-off-by: Ashwin Pc <[email protected]>
Signed-off-by: Ashwin Pc <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
|
||
it('should show warning before changing visualization type', async () => { | ||
await PageObjects.visBuilder.selectVisType('metric', false); | ||
const confirmModalExists = await testSubjects.exists('confirmVisChangeModal'); | ||
expect(confirmModalExists).to.be(true); | ||
|
||
await testSubjects.click('confirmModalCancelButton'); | ||
}); | ||
|
||
it('should change visualization type', async () => { | ||
const pickerValue = await PageObjects.visBuilder.selectVisType('metric'); | ||
|
||
expect(pickerValue).to.eql('Metric'); | ||
}); |
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.
Deleted these tests because we now have cypress tests for these. Will remove all the others after 2.7
Update: PR merged, tests should not fail |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #3715 +/- ##
==========================================
- Coverage 66.45% 66.43% -0.02%
==========================================
Files 3210 3210
Lines 61670 61677 +7
Branches 9514 9522 +8
==========================================
- Hits 40981 40978 -3
- Misses 18410 18419 +9
- Partials 2279 2280 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
A couple minor questions/suggestions. Is the updated warning message signed off by UX/product?
src/plugins/vis_builder/public/application/components/right_nav.tsx
Outdated
Show resolved
Hide resolved
src/plugins/vis_builder/public/application/components/right_nav.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Ashwin P Chandran <[email protected]>
@ashwin-pc The visbuilder cypress tests still seem to be failing. Shouldn't they pass on this PR? |
From the PR description, it seems like if no aggregations get dropped, then it should not show the warning sign. I pulled down the branch and tried, it is still showing the warning sign even though in this case no aggregations are dropped. @ashwin-pc Screen.Recording.2023-03-31.at.10.56.17.AM.mov |
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.
It seems like the persistence rule is changed. Should we document this new persisting rule somewhere? Maybe in the code? @ashwin-pc
// Check if schema1 and schema2 exist | ||
if (!schema1 || !schema2) return false; | ||
|
||
if (schema1.name !== schema2.name) return false; |
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.
Is that line needed? Seemed like if schema1 and schema2 already exists, they should already have same schema.name since they are both found by using schema.name === aggConfigParam.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.
Yeah its a little redundant, but are you okay with it going through though? All the tests have passed and making this change would require all the tests to pass again.
return updatedAggConfigParams; | ||
}; | ||
|
||
function isSchemaEqual(schema1?: Schema, schema2?: 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.
nit: I think the naming isSchemaEqual
is a little confusing here since it is also checking if the schemas exist or not.
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.
No this is common. Having an undefined check in the beginning of a function does not change the purpose of the function. The decision to return false instead of throwing an error however is subjective since the main purpose of the function is to check if two schemas are equal. If either or both is undefined, for the purposes of this check, that's correct.
return schema.name === aggConfigParam.schema; | ||
}); | ||
|
||
// see if a matching schma exists in the new visualization type |
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.
nit: typo schma --> schema
// Check if the schema group is the same | ||
if (schema.group !== currentSchema!.group) continue; | ||
|
||
const compatibleSchema = filterByType([aggConfigParam], schema.aggFilter).length !== 0; |
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.
Could you explain more what this line does?
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.
This was the main reason for the change. So each schema today can define a list of agg types it supports. Its not a simple lift and it can sometimes be something like !filter
, In this case we want to make sure that when we select a new schema type to map the agg to, the agg type for the agg config is allowed by the new 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.
Thanks, make sense
yeah made a blooper in my revision, fixed now :) |
The only thing thats changed is that we also filter for agg filters now. Did we document the original persistence logic in code somewhere? |
@ashwin-pc I did not document the rules in the code, i just documented the rules in the proposal issue here: #3482 The reason i said the logics changed is because i see the mapping rule here add logics that will map the identical agg schema first, and then it maps the rest of the aggs to similar schemas. The original mapping rule only does metric to metric, bucket to bucket without mapping the identical schema first. |
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.
LGTM
Just some nits and typos, not a blocker
* Refactor persistnece for simpler logic Signed-off-by: Ashwin Pc <[email protected]> * renamed files Signed-off-by: Ashwin Pc <[email protected]> * only show warning when dropping fields Signed-off-by: Ashwin P Chandran <[email protected]> * delete unnecessary tests Signed-off-by: Ashwin P Chandran <[email protected]> * addresses PR feedback Signed-off-by: Ashwin P Chandran <[email protected]> * Fixes comparison --------- Signed-off-by: Ashwin Pc <[email protected]> Signed-off-by: Ashwin P Chandran <[email protected]> (cherry picked from commit 2db2c43) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…nsearch-project#3715) * Refactor persistnece for simpler logic Signed-off-by: Ashwin Pc <[email protected]> * renamed files Signed-off-by: Ashwin Pc <[email protected]> * only show warning when dropping fields Signed-off-by: Ashwin P Chandran <[email protected]> * delete unnecessary tests Signed-off-by: Ashwin P Chandran <[email protected]> * addresses PR feedback Signed-off-by: Ashwin P Chandran <[email protected]> * Fixes comparison --------- Signed-off-by: Ashwin Pc <[email protected]> Signed-off-by: Ashwin P Chandran <[email protected]> Signed-off-by: vagimeli <[email protected]>
…) (#3760) * Refactor persistnece for simpler logic * renamed files * only show warning when dropping fields * delete unnecessary tests * addresses PR feedback * Fixes comparison --------- (cherry picked from commit 2db2c43) Signed-off-by: Ashwin Pc <[email protected]> Signed-off-by: Ashwin P Chandran <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…nsearch-project#3715) * Refactor persistnece for simpler logic Signed-off-by: Ashwin Pc <[email protected]> * renamed files Signed-off-by: Ashwin Pc <[email protected]> * only show warning when dropping fields Signed-off-by: Ashwin P Chandran <[email protected]> * delete unnecessary tests Signed-off-by: Ashwin P Chandran <[email protected]> * addresses PR feedback Signed-off-by: Ashwin P Chandran <[email protected]> * Fixes comparison --------- Signed-off-by: Ashwin Pc <[email protected]> Signed-off-by: Ashwin P Chandran <[email protected]> Signed-off-by: David Sinclair <[email protected]>
Description
The previous implementation of persistence when switching vis types did not check the schema's agg filter to check if the new agg is compatible with it. This change is based on the previous implementation but simplifies the logic and is a simple function instead of a hook. It also only selectively shows the warning when switching the vis type causes aggregations to be dropped.
Screen.Recording.2023-03-27.at.6.56.39.PM.mov
Issues Resolved
#3647
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr