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

[MD]Add default icon in multi-selectable picker #6357

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

zhyuanqi
Copy link
Collaborator

@zhyuanqi zhyuanqi commented Apr 5, 2024

Description

Add default icon in multi-selectable picker and fix a bug in when datasource length is 0, localcluster would not be added.

Screenshot

Screen.Recording.2024-04-05.at.2.55.15.PM.mov

Testing the changes

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

@zhyuanqi zhyuanqi changed the title Add default icon in multi-selectable picker and fix a bug Add default icon in multi-selectable picker Apr 5, 2024
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 67.52%. Comparing base (85df662) to head (c92dc71).

❗ Current head c92dc71 differs from pull request most recent head da6b83e. Consider uploading reports for the commit da6b83e to get more accurate results

Files Patch % Lines
..._multi_selectable/data_source_multi_selectable.tsx 84.61% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #6357       +/-   ##
===========================================
+ Coverage   55.58%   67.52%   +11.93%     
===========================================
  Files        1199     3378     +2179     
  Lines       24259    65885    +41626     
  Branches     4087    10661     +6574     
===========================================
+ Hits        13485    44487    +31002     
- Misses      10133    18808     +8675     
- Partials      641     2590     +1949     
Flag Coverage Δ
Linux_1 32.63% <ø> (?)
Linux_2 55.62% <ø> (?)
Linux_3 44.90% <85.71%> (?)
Linux_4 34.99% <0.00%> (?)
Windows_1 32.65% <ø> (?)
Windows_2 55.58% <ø> (ø)
Windows_3 44.91% <85.71%> (?)
Windows_4 34.99% <0.00%> (?)

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.

@@ -148,7 +153,14 @@ export const DataSourceFilterGroup: React.FC<DataSourceFilterGroupProps> = ({
showIcons={true}
style={itemStyle}
>
{item.label}
<EuiFlexGroup alignItems="center">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like the default icon can be extracted into its own module since it will be shared among multiple components

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

would do

});

this.props.onSelectedDataSources(selectedOptions.filter((option) => option.checked === 'on'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like we can just send back selectedOptions since selectedOptions always have checked field being set to on

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will make the change

@zhyuanqi zhyuanqi force-pushed the readonly branch 2 times, most recently from 643e663 to 5924364 Compare April 8, 2024 23:53
defaultDataSource: string | null;
}

export const ShowDataSourceOption: React.FC<ShowDataSourceOptionProps> = ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we simply name it DataSourceOption and then DataSourceOptionProps

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi We have a type called DataSourceOption already. Let me rename it to DataSourceOptionItem as it shows each item

visible: true,
})
);
try {
Copy link
Member

Choose a reason for hiding this comment

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

why change from .catch() to try {} catch(){}, I didn't see the code logic differer from before

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Zhongnan this is the original code(https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data_source_management/public/components/data_source_multi_selectable/data_source_multi_selectable.tsx#L46). It puts all the logic under if (fetchedDataSources?.length) { I want to refactor the code, so i use the try{} catch {}
Now it is

try {
    const fetchedDataSources = await getDataSourcesWithFields....
   if (fetchedDataSources?.length) {
     ...
  }
   if (!this.props.hideLocalCluster) {
   ....
  }

}.catch() {
}

Copy link
Member

Choose a reason for hiding this comment

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

@zhyuanqi got you. this is fixing the bug that local host not able to render due to datasource.length = 0. Thanks!

zhongnansu
zhongnansu previously approved these changes Apr 9, 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

@zhongnansu zhongnansu changed the title Add default icon in multi-selectable picker [MD]Add default icon in multi-selectable picker Apr 9, 2024
@zhongnansu zhongnansu added backport 2.x multiple datasource multiple datasource project labels Apr 9, 2024
BionIT
BionIT previously approved these changes Apr 9, 2024
@BionIT
Copy link
Collaborator

BionIT commented Apr 9, 2024

@zhyuanqi zhyuanqi dismissed stale reviews from BionIT and zhongnansu via 95268bf April 9, 2024 18:13
@zhyuanqi zhyuanqi force-pushed the readonly branch 2 times, most recently from 95268bf to d2b8457 Compare April 9, 2024 18:14
@zhongnansu zhongnansu merged commit 87deeda into opensearch-project:main Apr 9, 2024
66 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 9, 2024
Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>
(cherry picked from commit 87deeda)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
@BionIT BionIT added the v2.14.0 label Apr 11, 2024
zhongnansu pushed a commit that referenced this pull request Apr 11, 2024
Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>
(cherry picked from commit 87deeda)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
zhongnansu pushed a commit that referenced this pull request Apr 11, 2024
Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>
(cherry picked from commit 87deeda)
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>
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.

3 participants