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: [M3-9065] - Build new Quotas Controls #11647

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

abailly-akamai
Copy link
Contributor

@abailly-akamai abailly-akamai commented Feb 11, 2025

Description 📝

This PR implements the controls for managing quotas in Cloud Manager, with a focus on filtering and displaying quota information based on service type and region/endpoint selection.

Changes

  • New Quotas Component Structure

    • Moved from single file to organized structure under features/Account/Quotas/
    • Added new components, utilities, and tests
  • Enhanced Region Selection

    • Added support for 'global' region option
    • Added special handling for Object Storage endpoints
    • Updated RegionSelect component to show a globe icon for global regions
  • Types and Constants

    • Added quotaTypes constant mapping
    • Updated QuotaUsage type to support null values
    • Added new constants for global quota handling
  • UI Components

    • New service selection dropdown
    • Dynamic region/endpoint selection based on service type
    • Loading states and error handling

Implementation Details

  • API Integration

    • Enhanced mock handlers for quotas
    • Added support for filtering by region and S3 endpoints
    • Updated pagination response handling
  • Testing

    • Added comprehensive tests for the Quotas component
    • Added tests for utility functions
    • Mock setup for API responses
  • Type Safety

    • Improved TypeScript definitions
    • Added proper type guards
    • Enhanced error handling with proper types

Note

The JSON data rendering in the page under the controls was made for development & review to verify data until the Quotas table is built - It'll be obviously removed

Preview 📷

Screenshot 2025-02-13 at 11 44 57

How to test 🧪

Prerequisites

  • Ensure the limits evolution feature flag is turned on
    Screenshot 2025-02-13 at 11 49 08
  • ⚠️ Turn on MSW, crud mode ( important!)

Verification steps

  • Navigate to /accounts > "Quotas" Tab
  • Confirm behavior of controls
    • "Linodes" and "Kubernetes" should enable a region select, with a global option
    • "Object Storage" should enable an "S3 endpoint" select, with a global option
      • Note the style and icons differ (aka are missing) in this select which is intentional
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

@abailly-akamai abailly-akamai marked this pull request as ready for review February 13, 2025 16:57
@abailly-akamai abailly-akamai requested a review from a team as a code owner February 13, 2025 16:57
@abailly-akamai abailly-akamai requested review from cpathipa and hkhalil-akamai and removed request for a team February 13, 2025 16:57
@abailly-akamai abailly-akamai changed the title upcoming: [M3-9065] - Build new Quotas Filters upcoming: [M3-9065] - Build new Quotas Controls Feb 13, 2025
Copy link

Coverage Report:
Base Coverage: 80.13%
Current Coverage: 80.15%

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 508 passing tests on test run #8 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing508 Passing2 Skipped106m 36s

Comment on lines +68 to +72
const { getByText } = renderWithTheme(
<QueryClientProvider client={queryClient}>
<Quotas />
</QueryClientProvider>
);
Copy link
Member

Choose a reason for hiding this comment

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

Our renderWithTheme function allows you to pass a custom queryClient in the options if needed. We may want to do that here

Suggested change
const { getByText } = renderWithTheme(
<QueryClientProvider client={queryClient}>
<Quotas />
</QueryClientProvider>
);
const { getByText } = renderWithTheme(<Quotas />, { queryClient });

Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Nice to see this shaping up. Just left a few comments and questions

setSelectedLocation(null);
};

return (
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to break up this markup as it grows, similar to Linode create

Comment on lines +39 to +43
const globalOption = regionFactory.build({
capabilities: [],
id: GLOBAL_QUOTA_VALUE,
label: GLOBAL_QUOTA_LABEL,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe factories are not kosher for use in non-test related code.

It also doesn't make sense to have fields like country, status, etc for the global option. Perhaps we could design a new interface for the global option (that RegionSelect would accept)? Alternatively, we could add a boolean prop to RegionSelect like includeGlobalOption?: boolean.

Copy link
Contributor Author

@abailly-akamai abailly-akamai Feb 13, 2025

Choose a reason for hiding this comment

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

I believe factories are not kosher for use in non-test related code

I remember condemning this for another PR (it happens in a couple other places) but not really having a compelling argument that we should never either. Just satisfying types but it's not clean.

What you suggest is exactly what I was trying to avoid but I understand the concern - the global props is very specific to this feature, does not really belong as a prop for an edge case, and I wanted to avoid bloating the component further. That being said I can go that route if things are not clear enough

Copy link
Contributor

Choose a reason for hiding this comment

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

the global props is very specific to this feature

Yes but we already are making lots of changes to RegionSelect in order to get this to work

Copy link
Contributor

Choose a reason for hiding this comment

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

That being said I am not immovable on this issue, I'm fine with going this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a fair comment. And DX documentation supersedes a hidden feature at a cost of an isolated case prop. I'll update accordingly 👍

@@ -22,6 +22,12 @@ export const getRegionCountryGroup = (region: Region | undefined) => {
return 'Other';
}

// The global option should not be grouped
// An empty string here makes sense to avoid bigger refactors to an already complicated Component
if (region.id === 'global') {
Copy link
Contributor

@hkhalil-akamai hkhalil-akamai Feb 13, 2025

Choose a reason for hiding this comment

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

'global' is now a magic string that isn't documented in any interface. See my comment above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants