From 2dc55918c7d3e7f3126d5891267d901c46238eb4 Mon Sep 17 00:00:00 2001 From: Allan Guwatudde Date: Mon, 24 Apr 2023 16:37:22 +0300 Subject: [PATCH] [MM-52287] - Cloud Free should not show the ability to start a trial (#23073) * [MM-52287] - Cloud Free should not show the ability to start a trial * fix logic --- .../admin_console/billing/billing_summary/index.tsx | 12 ++++++++---- .../src/selectors/entities/preferences.ts | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/webapp/channels/src/components/admin_console/billing/billing_summary/index.tsx b/webapp/channels/src/components/admin_console/billing/billing_summary/index.tsx index e53bd72570..8f0d5c5c56 100644 --- a/webapp/channels/src/components/admin_console/billing/billing_summary/index.tsx +++ b/webapp/channels/src/components/admin_console/billing/billing_summary/index.tsx @@ -5,6 +5,7 @@ import React from 'react'; import {useSelector} from 'react-redux'; import {getSubscriptionProduct, checkHadPriorTrial, getCloudSubscription} from 'mattermost-redux/selectors/entities/cloud'; +import {cloudReverseTrial} from 'mattermost-redux/selectors/entities/preferences'; import {CloudProducts} from 'utils/constants'; @@ -27,17 +28,20 @@ type BillingSummaryProps = { const BillingSummary = ({isFreeTrial, daysLeftOnTrial, onUpgradeMattermostCloud}: BillingSummaryProps) => { const subscription = useSelector(getCloudSubscription); const product = useSelector(getSubscriptionProduct); + const reverseTrial = useSelector(cloudReverseTrial); let body = noBillingHistory; const isPreTrial = subscription?.is_free_trial === 'false' && subscription?.trial_end_at === 0; const hasPriorTrial = useSelector(checkHadPriorTrial); - const showTryEnterprise = product?.sku === CloudProducts.STARTER && isPreTrial; - const showUpgradeProfessional = product?.sku === CloudProducts.STARTER && hasPriorTrial; + const isStarterPreTrial = product?.sku === CloudProducts.STARTER && isPreTrial; + const isStarterPostTrial = product?.sku === CloudProducts.STARTER && hasPriorTrial; - if (showTryEnterprise) { + if (isStarterPreTrial && reverseTrial) { + body = ; + } else if (isStarterPreTrial) { body = tryEnterpriseCard; - } else if (showUpgradeProfessional) { + } else if (isStarterPostTrial) { body = ; } else if (isFreeTrial) { body = freeTrial(onUpgradeMattermostCloud, daysLeftOnTrial); diff --git a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/preferences.ts b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/preferences.ts index b2d3c1a672..b3f5d1f843 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/preferences.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/preferences.ts @@ -300,6 +300,10 @@ export function deprecateCloudFree(state: GlobalState): boolean { return getFeatureFlagValue(state, 'DeprecateCloudFree') === 'true'; } +export function cloudReverseTrial(state: GlobalState): boolean { + return getFeatureFlagValue(state, 'CloudReverseTrial') === 'true'; +} + export function appsSidebarCategoryEnabled(state: GlobalState): boolean { return getFeatureFlagValue(state, 'AppsSidebarCategory') === 'true'; }