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

refactor: [M3-8101] - Use network-transfer/prices endpoint for transfer overage pricing #10566

Merged

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Jun 11, 2024

Description 📝

This PR is a follow up to #10468 and uses the newly added network-transfer/prices endpoint to fetch network transfer overage pricing from the API, finishing off the transition for OBJ to dynamic pricing data.

Loading and error states are addressed, especially in the OMC Create Bucket drawer, which I missed in the first PR - see Reproduction steps in the Testing section.

Changes 🔄

  • Created the necessary api-v4 endpoint, query, and interface to use the network-transfer/prices endpoint.
  • Created the necessary factories and endpoint in the MSW to support a mocked response to the API endpoint.
  • Added UX for error handling in the unlikely event that network transfer pricing cannot be calculated: disable primary action button and display tooltip error.
  • Added loading state for network transfer pricing.
  • Updated unit tests.

Target release date 🗓️

6/24

Preview 📷

Before After
Screenshot 2024-06-11 at 9 24 00 AM Screenshot 2024-06-11 at 9 24 11 AM Screenshot 2024-06-11 at 9 24 25 AM Screenshot 2024-06-11 at 9 20 17 AM Screenshot 2024-06-11 at 9 20 27 AM Screenshot 2024-06-11 at 9 20 37 AM
n/a Screenshot 2024-06-11 at 9 21 03 AM
n/a Screenshot 2024-06-11 at 9 22 12 AM

How to test 🧪

Prerequisites

  • For OMC, ensure you have the account capability with the necessary tags on your prod account. We are depending on this and not the LD flag.

Reproduction steps

(How to reproduce the issue, if applicable)

  • To observe that we were missing loading and error state in the OMC Create Bucket drawer, use the React Query dev tools to "Trigger loading" and "Trigger error" states for the [ "network-transfer", "prices"] and ["object-storage", "types"] endpoints. Observe the primary action button does not have loading or error state.

Verification steps

(How to verify changes)

  • Test the following with the OMC feature enabled (tags on account) and disabled (no OMC tags on account):
    • Go to http://localhost:3000/object-storage/buckets/create.
    • Select a regularly priced region (e.g. us-east), Jakarta, and Sao Paulo. For each, confirm that outbound transfer overage pricing (the second price) matches production.
    • Confirm you can still create a bucket.
    • Confirm that loading and error states are present by toggling in RQ dev tools as described above, or block the network requests.

As an Author I have considered 🤔

Check all that apply

  • 👀 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

@mjac0bs mjac0bs self-assigned this Jun 11, 2024
@mjac0bs mjac0bs requested a review from a team as a code owner June 11, 2024 16:29
@mjac0bs mjac0bs requested review from jdamore-linode and hana-akamai and removed request for a team June 11, 2024 16:29
@mjac0bs mjac0bs changed the title refactor: [M3-8101] - Use network-transfer/pricing endpoint for transfer overage pricing refactor: [M3-8101] - Use network-transfer/prices endpoint for transfer overage pricing Jun 11, 2024
@mjac0bs mjac0bs added @linode/api-v4 Changes are made to the @linode/api-v4 package Ready for Review DC-Specific Pricing labels Jun 11, 2024
Comment on lines +81 to +94
data: objTypes,
isError: isErrorObjTypes,
isInitialLoading: isLoadingObjTypes,
} = useObjectStorageTypesQuery(isOpen);

const isInvalidPrice = !types || isErrorTypes;
const {
data: transferTypes,
isError: isErrorTransferTypes,
isInitialLoading: isLoadingTransferTypes,
} = useNetworkTransferPricesQuery(isOpen);

const isErrorTypes = isErrorTransferTypes || isErrorObjTypes;
const isLoadingTypes = isLoadingTransferTypes || isLoadingObjTypes;
const isInvalidPrice =
!objTypes || !transferTypes || isErrorTypes || isErrorTransferTypes;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These additions are made twice (once here, once in the next file) since we currently have two create bucket drawer components.

Comment on lines +198 to +206
(showGDPRCheckbox && !hasSignedAgreement) ||
isErrorTypes,
label: 'Create Bucket',
loading: isLoading,
loading:
isLoading || Boolean(formik.values.region && isLoadingTypes),
tooltipText:
!isLoadingTypes && isInvalidPrice
? PRICES_RELOAD_ERROR_NOTICE_TEXT
: '',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't add the loading and error state for the Create button in the initial PR for the first type of overage pricing in the OMC drawer - I forgot we had two drawers - so it has been added here now.

(OveragePricing is shared between the original and OMC drawer, so we were fine there.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now being returned from API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now being returned from API.

Copy link

github-actions bot commented Jun 11, 2024

Coverage Report:
Base Coverage: 82.76%
Current Coverage: 82.75%

@mjac0bs mjac0bs requested a review from cpathipa June 11, 2024 17:09
Copy link
Contributor

@cpathipa cpathipa left a comment

Choose a reason for hiding this comment

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

LGTM!

@mjac0bs mjac0bs added Add'tl Approval Needed Waiting on another approval! and removed Ready for Review labels Jun 13, 2024
@hana-akamai hana-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Jun 13, 2024
@mjac0bs mjac0bs merged commit ee2707c into linode:develop Jun 13, 2024
18 checks passed
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! DC-Specific Pricing @linode/api-v4 Changes are made to the @linode/api-v4 package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants