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

[MDS] Update Data source selector behavior for defaultOption #6372

Merged
merged 15 commits into from
Apr 10, 2024

Conversation

huyaboo
Copy link
Member

@huyaboo huyaboo commented Apr 8, 2024

Description

Previously, DataSourceSelector did not respect the Placeholder text. This PR will modify the behavior of defaultOption to be more consistent

TODO:

Issues Resolved

Partially addresses #6274

Screenshot

Testing the changes

The following are the test scenarios:

  • if defaultOption = undefined;:

    • Show defaultDataSource:
    • image
    • Show Local Cluster if hideLocalCluster is disabled and defaultDataSource is filtered out:
    • image
    • Show first datasource in list if Local Cluster is hidden and defaultDataSource is filtered out:
    • image
    • Show toast when nothing is left:
    • image
  • if defaultOption = []:

    • Show placeholder text:
    • image
  • if defaultOption = [{id}]:

    • If id = undefined throw toast:
    • image
    • If id = Source B and Source B is not filtered out, show selected option:
    • image
    • If id = Source B and Source B is filtered out, show toast:
    • image
    • If id = invalid-id, show toast:
    • image

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

BionIT and others added 4 commits April 5, 2024 22:19
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
@huyaboo huyaboo changed the title Data source selector [MDS] Update Data source selector behavior for defaultOption Apr 8, 2024
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
i18n.translate('dataSource.fetchDataSourceError', {
defaultMessage: 'Data source with id is not available',
})
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also use the callback function to tell plugins team that Invalid state?

Copy link
Member Author

Choose a reason for hiding this comment

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

So this function, regardless of valid/invalid id, will set the new state and call the callback function. If the id is valid, we change the selectedOption to be whatever was set in props and call the callback function with this. IF the id is invalid, we change the selectedOption to be [] and return the callback function with []. The only thing that changes is whether to add a toast message.

Copy link
Collaborator

Choose a reason for hiding this comment

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

GOt it.

});
this.props.onSelectedDataSource(selectedOption);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if plugins team pass in local cluster?

Copy link
Member Author

Choose a reason for hiding this comment

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

Local Cluster should already be in the dataSources because we check if the hideLocalCluster is disabled and add the local cluster before calling this method. In this case, the id = '' and because Local Cluster is in the list of datasources, dataSources.find((ds) => ds.id === id) should return the Local Cluster

Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sense!

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Copy link

codecov bot commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 32.63%. Comparing base (85df662) to head (6d7a49a).
Report is 3 commits behind head on main.

❗ Current head 6d7a49a differs from pull request most recent head 456209a. Consider uploading reports for the commit 456209a to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #6372       +/-   ##
===========================================
- Coverage   55.58%   32.63%   -22.96%     
===========================================
  Files        1199     2249     +1050     
  Lines       24259    45490    +21231     
  Branches     4087     7127     +3040     
===========================================
+ Hits        13485    14844     +1359     
- Misses      10133    29951    +19818     
- Partials      641      695       +54     
Flag Coverage Δ
Linux_1 32.63% <ø> (?)
Windows_2 ?

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhyuanqi
Copy link
Collaborator

zhyuanqi commented Apr 9, 2024

Hi Huy. Could you check the code cov. It shows failed on my side

BionIT
BionIT previously approved these changes Apr 10, 2024
if (!dataSource) {
this.props.notifications.addWarning(
i18n.translate('dataSource.fetchDataSourceError', {
defaultMessage: 'Data source with id is not available',
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably should start extracting the error handling messages out so that we can keep the message consistent across all data source component

zhongnansu
zhongnansu previously approved these changes Apr 10, 2024
Copy link
Member

@zhongnansu zhongnansu left a comment

Choose a reason for hiding this comment

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

lgtm, can you resolve the conflict of changelog.md

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
@huyaboo huyaboo dismissed stale reviews from zhongnansu and BionIT via 456209a April 10, 2024 04:56
@zhongnansu zhongnansu merged commit 8151ef5 into opensearch-project:main Apr 10, 2024
75 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 10, 2024
* Refactor selector component changes

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor selector

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add unit tests for selector component

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Set initial state as [] to prevent page breaking

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Remove change

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add changelog

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Update snapshots

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Update snapshots and fix tests

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Fix merge conflict

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

---------

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Co-authored-by: Lu Yu <nluyu@amazon.com>
(cherry picked from commit 8151ef5)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
@seraphjiang
Copy link
Member

Thanks @huyaboo @zhyuanqi @BionIT @zhongnansu to keep enhance the experience for MDS

zhongnansu pushed a commit that referenced this pull request Apr 10, 2024
…6391)

* Refactor selector component changes

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Refactor selector

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add unit tests for selector component

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Set initial state as [] to prevent page breaking

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Remove change

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Add changelog

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Update snapshots

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Update snapshots and fix tests

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

* Fix merge conflict

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>

---------

Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Co-authored-by: Lu Yu <nluyu@amazon.com>
(cherry picked from commit 8151ef5)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@huyaboo huyaboo deleted the data-source-selector branch April 18, 2024 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants