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

Storage add-ons v2: Expose the extended storage add-ons behind the feature flag. #97794

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"titan/iframe-control-panel": false,
"two-factor/enhanced-security": true,
"upgrades/redirect-payments": true,
"upgrades/storage-add-on-v2": true,
"upgrades/upcoming-renewals-notices": true,
"upgrades/wpcom-monthly-plans": true,
"untangling/hosting-menu": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import config from '@automattic/calypso-config';
import {
PRODUCT_WPCOM_CUSTOM_DESIGN,
PRODUCT_WPCOM_UNLIMITED_THEMES,
Expand All @@ -7,6 +8,11 @@ import {
} from '@automattic/calypso-products';
import i18n from 'i18n-calypso';
import {
ADD_ON_350GB_STORAGE,
ADD_ON_300GB_STORAGE,
ADD_ON_250GB_STORAGE,
ADD_ON_200GB_STORAGE,
ADD_ON_150GB_STORAGE,
ADD_ON_100GB_STORAGE,
ADD_ON_50GB_STORAGE,
ADD_ON_CUSTOM_DESIGN,
Expand All @@ -18,7 +24,7 @@ import unlimitedThemesIcon from './icons/unlimited-themes';
import type { AddOnMeta } from './types';

export const getAddOnsList = (): AddOnMeta[] => {
return [
const defaultAddOns: AddOnMeta[] = [
{
addOnSlug: ADD_ON_UNLIMITED_THEMES,
productSlug: PRODUCT_WPCOM_UNLIMITED_THEMES,
Expand Down Expand Up @@ -55,4 +61,52 @@ export const getAddOnsList = (): AddOnMeta[] => {
),
},
];

if ( config.isEnabled( 'upgrades/storage-add-on-v2' ) ) {
return [
...defaultAddOns,
{
addOnSlug: ADD_ON_150GB_STORAGE,
productSlug: PRODUCT_1GB_SPACE,
featureSlugs: null,
icon: spaceUpgradeIcon,
quantity: 150,
name: i18n.translate( '150 GB Storage' ),
},
{
addOnSlug: ADD_ON_200GB_STORAGE,
productSlug: PRODUCT_1GB_SPACE,
featureSlugs: null,
icon: spaceUpgradeIcon,
quantity: 200,
name: i18n.translate( '200 GB Storage' ),
},
{
addOnSlug: ADD_ON_250GB_STORAGE,
productSlug: PRODUCT_1GB_SPACE,
featureSlugs: null,
icon: spaceUpgradeIcon,
quantity: 250,
name: i18n.translate( '250 GB Storage' ),
},
{
addOnSlug: ADD_ON_300GB_STORAGE,
productSlug: PRODUCT_1GB_SPACE,
featureSlugs: null,
icon: spaceUpgradeIcon,
quantity: 300,
name: i18n.translate( '300 GB Storage' ),
},
{
addOnSlug: ADD_ON_350GB_STORAGE,
productSlug: PRODUCT_1GB_SPACE,
featureSlugs: null,
icon: spaceUpgradeIcon,
quantity: 350,
name: i18n.translate( '350 GB Storage' ),
},
];
}

return defaultAddOns;
};
22 changes: 20 additions & 2 deletions packages/data-stores/src/add-ons/constants.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
export const STORAGE_LIMIT = 203;
export const STORAGE_LIMIT = 403;

export const ADD_ON_JETPACK_AI_MONTHLY = 'jetpack_ai_monthly-add-on';
export const ADD_ON_UNLIMITED_THEMES = 'unlimited_themes-add-on';
export const ADD_ON_CUSTOM_DESIGN = 'custom_design-add-on';
export const ADD_ON_50GB_STORAGE = '50gb-storage-add-on';
export const ADD_ON_100GB_STORAGE = '100gb-storage-add-on';
export const ADD_ON_150GB_STORAGE = '150gb-storage-add-on';
export const ADD_ON_200GB_STORAGE = '200gb-storage-add-on';
export const ADD_ON_250GB_STORAGE = '250gb-storage-add-on';
export const ADD_ON_300GB_STORAGE = '300gb-storage-add-on';
export const ADD_ON_350GB_STORAGE = '350gb-storage-add-on';

export const ADD_ONS = < const >[
ADD_ON_JETPACK_AI_MONTHLY,
ADD_ON_UNLIMITED_THEMES,
ADD_ON_CUSTOM_DESIGN,
ADD_ON_50GB_STORAGE,
ADD_ON_100GB_STORAGE,
ADD_ON_150GB_STORAGE,
ADD_ON_200GB_STORAGE,
ADD_ON_250GB_STORAGE,
ADD_ON_300GB_STORAGE,
ADD_ON_350GB_STORAGE,
];

export const STORAGE_ADD_ONS = < const >[ ADD_ON_50GB_STORAGE, ADD_ON_100GB_STORAGE ];
export const STORAGE_ADD_ONS = < const >[
ADD_ON_50GB_STORAGE,
ADD_ON_100GB_STORAGE,
ADD_ON_150GB_STORAGE,
ADD_ON_200GB_STORAGE,
ADD_ON_250GB_STORAGE,
ADD_ON_300GB_STORAGE,
ADD_ON_350GB_STORAGE,
];
2 changes: 1 addition & 1 deletion packages/data-stores/src/add-ons/hooks/use-add-ons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo } from '@wordpress/element';
import { useTranslate } from 'i18n-calypso';
import * as ProductsList from '../../products-list';
import * as Site from '../../site';
import { getAddOnsList } from '../addons-list';
import { getAddOnsList } from '../add-ons-list';
import useAddOnCheckoutLink from './use-add-on-checkout-link';
import { createAddOnPriceKey, useAddOnPrices } from './use-add-on-prices';
import type { AddOnMeta } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ interface Props {
export function isStorageQuantityAvailable( quantity: number, storage: SiteMediaStorage ): boolean {
const existingAddOnStorage = storage.maxStorageBytesFromAddOns / Math.pow( 1024, 3 );
const currentMaxStorage = storage.maxStorageBytes / Math.pow( 1024, 3 );
const availableStorageUpgrade = STORAGE_LIMIT - currentMaxStorage;
const isWithinStorageLimit = STORAGE_LIMIT >= currentMaxStorage - existingAddOnStorage + quantity;

return existingAddOnStorage < quantity && quantity <= availableStorageUpgrade;
return existingAddOnStorage < quantity && isWithinStorageLimit;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ const getIntegerVolume = (
* TODO: the default 50GB should be coming from plan context, not hardcoded here
*/
return 150;
case AddOns.ADD_ON_150GB_STORAGE:
return 200;
case AddOns.ADD_ON_200GB_STORAGE:
return 250;
case AddOns.ADD_ON_250GB_STORAGE:
return 300;
case AddOns.ADD_ON_300GB_STORAGE:
return 350;
case AddOns.ADD_ON_350GB_STORAGE:
return 400;
default:
return 0;
}
Expand Down
Loading