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: [M3-7035] - Add DC-specific pricing to Linode backups #9588

Merged

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Aug 24, 2023

Description 📝

Pricing for backups is now Region-dependent. This PR uses the mocked API response for the linode/types endpoint to get the correct price for a backup add-on with region_prices data.

Major Changes 🔄

With the dcSpecificPricing feature flag on and MSW on:

  • In the Linode Create flow, adding Backups as an Add-On displays DC-specific backup pricing based on the selected Region in the Add-Ons panel and the checkout summary.
  • On the Linode Details -> Backups tab:
    • The enable backups empty state copy displays DC-specific backup pricing based on the Linode's region.
    • On the Enable Backups confirmation dialog, copy displays correctly calculated DC-specific backup pricing based on the Linode's region.
  • On the Enable All Backups drawer: 
    • Total cost of backups, and each Linode's DC-specific backup price, is displayed and calculated correctly.
    • Minor copy updates (removed "Confirm to add backups to N Linode(s)" and prefixed the total with "Total for N Linodes:")
    • A Region column exists in the table with populated region data for each Linode
    • Modal is widened to fit all four columns (existing + new Regions column)
  • Updated unit tests

Preview 📷

Flow/Component Before After
Linode Create Screenshot 2023-08-28 at 11 46 43 AM Screenshot 2023-08-28 at 9 49 39 AM
Linode Details -> Backups Screenshot 2023-08-28 at 11 45 33 AM Screenshot 2023-08-28 at 9 51 25 AM
Enable Backups Dialog Screenshot 2023-08-28 at 11 45 41 AM Screenshot 2023-08-28 at 9 51 41 AM
Backups Drawer Screenshot 2023-08-28 at 11 44 49 AM Screenshot 2023-08-28 at 11 08 20 AM

How to test 🧪

  1. How to setup test environment?
  • Ensure the dcSpecificPricing feature flag is toggled on.
  • Turn the MSW on.
  1. How to verify changes?
  • Make the changes described below to the mocks.
  • Test that this mocked linode in Jakarta has DC-specific backups pricing (should use mocked region_price) in all the locations mentioned in the table above.
  • Toggle the dcSpecificPricing flag off and confirm the mocked linode in Jakarta does not have any increases in its backup price (should use mocked base price).
  • Remove the region you added earlier from the mocked requestrest.get('*/linode/instances/:id' and confirm that a linode not in Jakarta or Sao Paulo does not have any increases in its backup price (should use mocked base price).
  • Ensure no new regressions in unit and e2e tests.

Update the MSW mocked requestrest.get('*/linode/instances/:id' to include region: 'id-cgk' in the mocked linode created with the factory.

To test Backups Drawer:
Recommend modifying rest.get('*/linode/instances' to use a shorter list of linodes:

      linodeFactory.build({
        backups: { enabled: false },
        label: 'eu-linode',
        region: 'eu-west',
      }),
      linodeFactory.build({
        backups: { enabled: false },
        label: 'DC-Specific Pricing Linode',
        region: 'id-cgk',
      }),
  1. How to run Unit or E2E tests?
yarn test BackupLinodeRow utils AddOnsPanel linodes

@mjac0bs mjac0bs self-assigned this Aug 24, 2023
@mjac0bs mjac0bs force-pushed the M3-7035-add-dc-pricing-to-linode-backups branch from 6737b64 to e3eb1a7 Compare August 28, 2023 14:08
@mjac0bs mjac0bs marked this pull request as ready for review August 28, 2023 19:10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Backups pricing can no longer be calculated at this level because it is DC-dependent.

@@ -82,7 +90,7 @@ export const EnableBackupsDialog = (props: Props) => {
>
<Typography>
Are you sure you want to enable backups on this Linode?{` `}
This will add <Currency quantity={price} />
This will add <Currency quantity={backupsMonthlyPrice ?? 0} />
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 seems somewhat strange that we will display "This will add $0.00 to your account." if there is ever a linode that doesn't have a monthly backup price returned types, but this existing behavior, so I left it because it provides transparency, at least.

@@ -25,6 +25,31 @@ export const getLinodeRegionPrice = (
return type.price;
};

/**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was also added in Alban's PR. Kept consistent function and variable names here.

@@ -85,7 +90,6 @@ import {
import type { Tab } from 'src/components/TabLinkList/TabLinkList';

export interface LinodeCreateProps {
backupsMonthlyPrice?: null | number;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, this is no longer a prop because it is calculated in this component based on region selection.

Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

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

Very nice! Didn't find any issues with the flag on or off!

@bnussman-akamai bnussman-akamai added Add'tl Approval Needed Waiting on another approval! and removed Ready for Review labels Aug 28, 2023
@mjac0bs mjac0bs force-pushed the M3-7035-add-dc-pricing-to-linode-backups branch from bf44f9d to 12a0f11 Compare August 29, 2023 18:53
Comment on lines +97 to +101
return backupsMonthlyPrice && backupsMonthlyPrice > 0 ? (
<Typography variant="body1">
<Currency quantity={backupsMonthlyPrice} /> per month
</Typography>
) : undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the ternary, this will display "0" in the UI.

Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Looks good! happy to move utils around in upcoming work. Good to go 👍

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Aug 29, 2023
@mjac0bs
Copy link
Contributor Author

mjac0bs commented Aug 29, 2023

@abailly-akamai I'll merge now so you can rebase -- thank you for taking care of moving the util!

@mjac0bs mjac0bs merged commit 7ddcf3d into linode:develop Aug 29, 2023
corya-akamai pushed a commit to corya-akamai/manager that referenced this pull request Sep 6, 2023
)

* Add dynamic pricing backups util functions

* Update Enable Backups drawer with dynamic pricing

* Update Backups tab placeholder and confirmation dialog with dynamic pricing

* Update mocks for now

* Revert mock updates after rebase

* Add test for backup price util function

* Add DC-specific pricing to Linode Create flow

* Update cached regions file to include Jakarta and Sao Paulo

* Feature flag changes

* Improve consistency with price variable names

* Update tests

* Renamed util function for consistency with linode#9570

* Added changeset: Add DC-specific pricing to Linode backups

* Update backups drawer total cost util function to use FF

* Address feedback: && over ternary

* Address feedback: util and types

* Missed a spot
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants