-
Notifications
You must be signed in to change notification settings - Fork 370
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
upcoming: [DI-20935] - Support for tags filter in CloudPulse #11457
upcoming: [DI-20935] - Support for tags filter in CloudPulse #11457
Conversation
- Added tag filter selection component - Made tag filter as an optional dependency - Passed tag as an x-filter to filter resources - Included exhaustive unit test cases - Updated mocks for handling tags
… from other filters
Coverage Report: ❌ |
label: string; | ||
optional?: boolean; | ||
placeholder?: string; | ||
resourceType: string | undefined; |
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.
Note: For resourceType
I would love to type this a little better even if for now we only support linode, volumes, dbaas
but that's a separate effort.
return Array.from( | ||
new Set(linodes.flatMap((linode: Linode) => linode.tags)) | ||
) |
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: A little cleaner
return Array.from( | |
new Set(linodes.flatMap((linode: Linode) => linode.tags)) | |
) | |
return [...new Set(linodes.flatMap((linode: Linode) => linode.tags))] |
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.
fyi, this throws error Type 'Set<string>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
if (tags && savePreferences) { | ||
const defaultTags = | ||
defaultValue && Array.isArray(defaultValue) | ||
? defaultValue.map((tag) => String(tag)) | ||
: []; | ||
const tag = tags.filter((tag) => | ||
defaultTags.includes(String(tag.label)) | ||
); | ||
handleTagsChange(tag); | ||
setSelectedTags(tag); | ||
} else { | ||
setSelectedTags([]); | ||
handleTagsChange([]); | ||
} |
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 it's always best to define the base case first like:
if (!tags || !savePreferences) {
setSelectedTags([]);
handleTagsChange([]);
return;
}
Then everything else doesn't need to be wrapped in any if/else block
defaultValue && Array.isArray(defaultValue) | ||
? defaultValue.map((tag) => String(tag)) | ||
: []; | ||
const tag = tags.filter((tag) => |
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.
Should we renamed tag
to filteredTags
?
Cloud Manager UI test results🔺 1 failing test on test run #3 ↗︎
Details
TroubleshootingUse this command to re-run the failing tests: yarn cy:run -s "cypress/e2e/core/linodes/clone-linode.spec.ts" |
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.
✅ confirmed tags select + filtering of the mock data when selecting tags
thank you! Have a few optional comments below
const filteredById = orFilters.some( | ||
let filteredLinodes = linodes; // Default to the original linodes in case no filters are applied | ||
|
||
// filter the linodes based on id or region |
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.
@@ -0,0 +1,120 @@ | |||
import { Autocomplete } from '@linode/ui'; |
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.
should this file be renamed to match the CloudPulseTagsSelect
component name?
}); | ||
|
||
if (tagProps === undefined) { | ||
expect(true).toEqual(false); // fail test |
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.
do we need this line / do we want this test to ever fail? (I also wasn't able to get this test to fail unless I purposely set tagProps to undefined)
note - the way our github checks are currently set up, if a unit test fails, that would prevent us from merging a PR, so I'm hesitant about having this 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.
@coliu-akamai , previously we were checking for undefined like below
expect(tagProps).toBeUndefined();
if we do that proceed to validation below it will introduce a non null assertion, so we have validated explicitly and proceeded with early return and failure
const { getByPlaceholderText } = renderWithTheme(
<Grid item sx={{ marginLeft: 2 }} xs>
{RenderComponent({
componentKey: 'tags',
componentProps: {
...getTagsProperties(
{
config: tagProps!, // we need to introduce a non null assertion here, so we are
dashboard: mockDashboard,
isServiceAnalyticsIntegration: false,
},
vi.fn()
),
},
key: 'tags',
})}
</Grid>
);
Also we need to fail here because we need tagFilter for linode case
Cloud Manager E2E
|
Project |
Cloud Manager E2E
|
Branch Review |
develop
|
Run status |
|
Run duration | 29m 01s |
Commit |
|
Committer | Ankita |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
1
|
|
2
|
|
2
|
|
0
|
|
470
|
View all changes introduced in this branch ↗︎ |
Tests for review
cypress/e2e/core/linodes/linode-config.spec.ts • 1 failed test
Test | Artifacts | |
---|---|---|
Linode Config management > End-to-End > Clones a config |
Screenshots
Video
|
linodes/resize-linode.spec.ts • 1 flaky test
Test | Artifacts | |
---|---|---|
resize linode > resizes a linode by decreasing size |
Screenshots
Video
|
parentChild/account-switching.spec.ts • 1 flaky test
Test | Artifacts | |
---|---|---|
Parent/Child account switching > From Parent to Child > can switch from Parent account user to Proxy account user from Billing page |
Screenshots
Video
|
…11457) * upcoming: [DI-20935] - Add support for tags filter - Added tag filter selection component - Made tag filter as an optional dependency - Passed tag as an x-filter to filter resources - Included exhaustive unit test cases - Updated mocks for handling tags * upcoming: [DI-20935] - updated mocks * upcoming: [DI-20935] - updated UTs * upcoming: [DI-20935] - small fix * upcoming: [DI-20935] - small fix * upcoming: [DI-20935] - add required field for custom select, update UT * upcoming: [DI-20935] - PR comments * upcoming: [DI-20935] - PR comments * upcoming: [DI-20935] - small fix * upcoming: [DI-20935] - test case fix * upcoming: [DI-20935] - Add optional subtitle on tags, remove required from other filters * upcoming: [DI-20935] - PR comments * upcoming: [DI-20935] - small fix * upcoming: [DI-20935] - small fix * upcoming: [DI-20935] - small fix * upcoming: [DI-20935] - PR Comments * upcoming: [DI-20935] - prop drill optional * upcoming: [DI-20935] - linting fix * upcoming: [DI-20935] - mock enhancement * upcoming: [DI-20935] - small preferences fix * upcoming: [DI-20935] - Add changeset * upcoming: [DI-20935] - resolve pr comments
Description 📝
Added tags as an optional filter under service type - linode.
Changes 🔄
List any change(s) relevant to the reviewer.
Target release date 🗓️
14-Jan-2025
Preview 📷
Screen.Recording.2024-12-23.at.7.08.29.PM.mov
How to test 🧪
Verification steps
Author Checklists
As an Author, to speed up the review process, I considered 🤔
👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support
As an Author, before moving this PR from Draft to Open, I confirmed ✅