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

[Fix] VisType switching persistence and selectively show warning #3715

Merged
merged 8 commits into from
Mar 31, 2023

Conversation

ashwin-pc
Copy link
Member

@ashwin-pc ashwin-pc commented Mar 28, 2023

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

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md // Skipping changelog since this is a fix within the same release
  • Commits are signed per the DCO using --signoff

ashwin-pc and others added 3 commits March 24, 2023 11:42
@ashwin-pc ashwin-pc requested a review from a team as a code owner March 28, 2023 02:06
@ashwin-pc ashwin-pc added Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry backport 2.x v2.7.0 labels Mar 28, 2023
@ashwin-pc ashwin-pc self-assigned this Mar 28, 2023
@ashwin-pc ashwin-pc linked an issue Mar 28, 2023 that may be closed by this pull request
Signed-off-by: Ashwin P Chandran <[email protected]>
Comment on lines -45 to -58

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');
});
Copy link
Member Author

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

@ashwin-pc
Copy link
Member Author

ashwin-pc commented Mar 28, 2023

The cypress test failures are expected since the vis type picker no longer has a popup which is expected. PR to fix the tests here: opensearch-project/opensearch-dashboards-functional-test#600

Update: PR merged, tests should not fail

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2023

Codecov Report

Merging #3715 (6c7997e) into main (fd61f7a) will decrease coverage by 0.02%.
The diff coverage is 59.57%.

📣 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     
Flag Coverage Δ
Linux 66.38% <59.57%> (-0.02%) ⬇️
Windows 66.38% <59.57%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...uilder/public/application/components/right_nav.tsx 8.69% <0.00%> (-2.42%) ⬇️
...plication/utils/state_management/shared_actions.ts 100.00% <ø> (ø)
...blic/application/utils/get_persisted_agg_params.ts 84.84% <84.84%> (ø)

... 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.

Copy link
Member

@joshuarrrr joshuarrrr left a 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?

joshuarrrr
joshuarrrr previously approved these changes Mar 30, 2023
Signed-off-by: Ashwin P Chandran <[email protected]>
joshuarrrr
joshuarrrr previously approved these changes Mar 31, 2023
@joshuarrrr
Copy link
Member

@ashwin-pc The visbuilder cypress tests still seem to be failing. Shouldn't they pass on this PR?

@abbyhu2000
Copy link
Member

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

Copy link
Member

@abbyhu2000 abbyhu2000 left a 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;
Copy link
Member

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

Copy link
Member Author

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) {
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, make sense

@ashwin-pc
Copy link
Member Author

ashwin-pc commented Mar 31, 2023

@ashwin-pc The visbuilder cypress tests still seem to be failing. Shouldn't they pass on this PR?

yeah made a blooper in my revision, fixed now :)

@ashwin-pc
Copy link
Member Author

ashwin-pc commented Mar 31, 2023

It seems like the persistence rule is changed. Should we document this new persisting rule somewhere? Maybe in the code? @ashwin-pc

The only thing thats changed is that we also filter for agg filters now. Did we document the original persistence logic in code somewhere?

@abbyhu2000
Copy link
Member

It seems like the persistence rule is changed. Should we document this new persisting rule somewhere? Maybe in the code? @ashwin-pc

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.

Copy link
Member

@abbyhu2000 abbyhu2000 left a 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

@ashwin-pc ashwin-pc merged commit 2db2c43 into opensearch-project:main Mar 31, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 31, 2023
* 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>
vagimeli pushed a commit to vagimeli/OpenSearch-Dashboards that referenced this pull request Apr 4, 2023
…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]>
ashwin-pc pushed a commit that referenced this pull request Apr 4, 2023
…) (#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>
sikhote pushed a commit to sikhote/OpenSearch-Dashboards that referenced this pull request Apr 24, 2023
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry v2.7.0 vis builder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VisBuilder] Remove warning popup for vis type change
6 participants