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

feat: autoSelectDefault and showUsageStatus props of StorageSelector #2180

Merged
merged 19 commits into from
Feb 8, 2024

Conversation

ironAiken2
Copy link
Contributor

@ironAiken2 ironAiken2 commented Jan 26, 2024

image

This PR resolves #2151

feature:

  • autoSelectDefault
    : set default selected host, "default" | "usage" or no use.
  • showUsageSelect
    : "true" for showing usage in each host, "false" for disabling the feature.
  • useControllableValue
    : StorageSelect component can be controllable or not. If the parent passes state, it uses it; otherwise, it uses its own state.

Checklist: (if applicable)

  • Mention to the original issue
  • Documentation
  • Minium required manager version
  • Specific setting for review (eg., KB link, endpoint or how to setup)
  • Minimum requirements to check during review
  • Test case(s) to demonstrate the difference of before/after

…sageStatus

cases:
1. all props are "false" or only showUsageStatus is "false
: no auto selected value

2. only autoSelectDefault is "true"
: use query response's default field

3. autoSelectDefault and showUsageStatus are both "true"
: set default value that have minimum usage
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2180.d3g9cs6u59b8lw.amplifyapp.com

@ironAiken2

This comment was marked as resolved.

react/src/components/StorageSelect.tsx Outdated Show resolved Hide resolved
react/src/components/StorageSelect.tsx Outdated Show resolved Hide resolved
react/src/components/StorageSelect.tsx Show resolved Hide resolved
react/src/components/StorageSelect.tsx Outdated Show resolved Hide resolved
@github-actions github-actions bot added size:L 100~500 LoC and removed size:XL 500~ LoC labels Jan 29, 2024
Copy link
Contributor

@lizable lizable left a comment

Choose a reason for hiding this comment

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

Works okay, but there are a few touchups needed. Please refer to the comments above.

<Flex justify="between" align="center">
<Badge
// @ts-ignore
status={status[idx]}

This comment was marked as resolved.

}, [vhostInfo]);

const optionRender = useMemo(() => {
const status = ['success', 'warning', 'error'];

This comment was marked as resolved.

Copy link
Contributor

@lizable lizable left a comment

Choose a reason for hiding this comment

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

I just found some minor test failures in github action, originated from dependency array in hooks(useEffect and useMemo). You could either follow the guidance from github action or just input (// eslint-disable-next-line react-hooks/exhaustive-deps) right above the line if there has certain reason (facebook/create-react-app#6880 (comment)).

@lizable lizable self-requested a review February 1, 2024 09:07
Copy link
Contributor

@lizable lizable left a comment

Choose a reason for hiding this comment

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

Please resolve test failure on github action following the comments above.

Copy link

github-actions bot commented Feb 1, 2024

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements
3.14% (+0.01% 🔼)
101/3214
🔴 Branches
3.32% (+0.01% 🔼)
67/2016
🔴 Functions
1.56% (+0.01% 🔼)
17/1093
🔴 Lines
3.2% (+0.01% 🔼)
101/3154
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / StorageSelect.tsx
0% 0% 0% 0%

Test suite run success

20 tests passing in 4 suites.

Report generated by 🧪jest coverage report action from 876731c

@ironAiken2
Copy link
Contributor Author

I thought the "vhostInfo" data is used directly within the useEffect, and changes in it have a significant impact on determining the selectd host. So I added vhostInfo to the dependencies array.

However, the other items are only configurable in code, so I removed them from the Dependencies array because I thought they were less likely to be changed because the user can't change their settings.

Copy link
Contributor

@lizable lizable left a comment

Choose a reason for hiding this comment

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

LGTM.

const [state, setState] = useControllableValue({ value, onChange });

useEffect(() => {
console.log('!');
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this line.

Comment on lines 97 to 98
minWidth: 165,
direction: 'ltr',
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason to set the direction here?

Comment on lines 92 to 97
{/* TODO: add tooltip for '여유/주의/부족' */}
{vhostInfo?.volume_info[host]?.usage && (
<Tooltip
title="여유 or 주의 or 부족"
// @ts-ignore
getPopupContainer={() => shadowRoot}
Copy link
Member

Choose a reason for hiding this comment

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

I push a commit to add a tooltip with getPopupContainer. Please add a proper text for each case. @ironAiken2

Copy link
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

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

LGTM!

@yomybaby
Copy link
Member

yomybaby commented Feb 8, 2024

I pushed commits to display search highlights and update type definition. @ironAiken2 , Please check.
I merged this PR. Thank you!

@yomybaby yomybaby merged commit 1df0f7d into main Feb 8, 2024
6 of 7 checks passed
@yomybaby yomybaby deleted the feat/storage-selector branch February 8, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L 100~500 LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: autoSelectDefault and showUsageStatus props of StorageSelector
3 participants