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

upcoming: [DI-20935] - Support for tags filter in CloudPulse #11457

Merged
merged 22 commits into from
Jan 3, 2025

Conversation

ankita-akamai
Copy link
Contributor

Description 📝

Added tags as an optional filter under service type - linode.

Changes 🔄

List any change(s) relevant to the reviewer.

  • Added tag selection component which is a multi-select.
  • Added subtitle as 'optional' for tags.
  • Made tag filter as an optional dependency for resources.
  • Passed tag as an x-filter to filter resources.
  • Handled preferences.
  • Added unit test cases.
  • Updated mocks for handling tags.

Target release date 🗓️

14-Jan-2025

Preview 📷

Screen.Recording.2024-12-23.at.7.08.29.PM.mov

How to test 🧪

Verification steps

  • Navigate to monitor tab.
  • Select a dashboard under service type - linode.
  • You will be able to see tags filter listed as part of filters.
  • Select any number of tags, select a region, you will see resources filtered out based on both the filters.
  • Now, unselect all tags, choose region and resources, you will still be able to observe metrics as tags is an optional filter.
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


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@ankita-akamai ankita-akamai requested a review from a team as a code owner December 23, 2024 13:56
@ankita-akamai ankita-akamai requested review from carrillo-erik and cpathipa and removed request for a team December 23, 2024 13:56
@ankita-akamai ankita-akamai changed the title upcoming: [DI-20935] - Support for tags filter upcoming: [DI-20935] - Support for tags filter in CloudPulse Dec 23, 2024
@ankita-akamai ankita-akamai self-assigned this Dec 23, 2024
Copy link

github-actions bot commented Dec 23, 2024

Coverage Report:
Base Coverage: 86.96%
Current Coverage: 86.94%

@jaalah-akamai jaalah-akamai self-requested a review December 26, 2024 13:43
label: string;
optional?: boolean;
placeholder?: string;
resourceType: string | undefined;
Copy link
Contributor

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.

Comment on lines +42 to +44
return Array.from(
new Set(linodes.flatMap((linode: Linode) => linode.tags))
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: A little cleaner

Suggested change
return Array.from(
new Set(linodes.flatMap((linode: Linode) => linode.tags))
)
return [...new Set(linodes.flatMap((linode: Linode) => linode.tags))]

Copy link
Contributor Author

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.

Comment on lines 54 to 67
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([]);
}
Copy link
Contributor

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) =>
Copy link
Contributor

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?

@jaalah-akamai jaalah-akamai added Add'tl Approval Needed Waiting on another approval! Cloud Pulse labels Dec 27, 2024
@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🔺 1 failing test on test run #3 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
1 Failing468 Passing2 Skipped108m 7s

Details

Failing Tests
SpecTest
clone-linode.spec.tsclone linode » can clone a Linode from Linode details page

Troubleshooting

Use this command to re-run the failing tests:

yarn cy:run -s "cypress/e2e/core/linodes/clone-linode.spec.ts"

Copy link
Contributor

@coliu-akamai coliu-akamai left a 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
Copy link
Contributor

Choose a reason for hiding this comment

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

note - I see this changing how mock data is handled for placement groups (ex no linodes appearing despite the placement group having 9/10 linodes), but probably not too big an issue / a non issue since it's mock data

image

@@ -0,0 +1,120 @@
import { Autocomplete } from '@linode/ui';
Copy link
Contributor

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

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

Copy link
Contributor

@venkymano-akamai venkymano-akamai Jan 3, 2025

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

@jaalah-akamai jaalah-akamai added Approved Multiple approvals and ready to merge! Question and removed Add'tl Approval Needed Waiting on another approval! labels Jan 3, 2025
@jaalah-akamai jaalah-akamai merged commit 47758c6 into linode:develop Jan 3, 2025
21 of 23 checks passed
Copy link

cypress bot commented Jan 3, 2025

Cloud Manager E2E    Run #7035

Run Properties:  status check failed Failed #7035  •  git commit 47758c6476: upcoming: [DI-20935] - Support for tags filter in CloudPulse (#11457)
Project Cloud Manager E2E
Branch Review develop
Run status status check failed Failed #7035
Run duration 29m 01s
Commit git commit 47758c6476: upcoming: [DI-20935] - Support for tags filter in CloudPulse (#11457)
Committer Ankita
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 470
View all changes introduced in this branch ↗︎

Tests for review

Failed  cypress/e2e/core/linodes/linode-config.spec.ts • 1 failed test

View Output Video

Test Artifacts
Linode Config management > End-to-End > Clones a config Screenshots Video
Flakiness  linodes/resize-linode.spec.ts • 1 flaky test

View Output Video

Test Artifacts
resize linode > resizes a linode by decreasing size Screenshots Video
Flakiness  parentChild/account-switching.spec.ts • 1 flaky test

View Output Video

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

dmcintyr-akamai pushed a commit to dmcintyr-akamai/manager that referenced this pull request Jan 9, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Cloud Pulse Question
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants