From 944afe60eda35ce03ba366842f395cf044e78331 Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Mon, 29 Aug 2022 19:19:23 -0400 Subject: [PATCH] Updates subscription banner content on the graph --- src/webviews/apps/plus/graph/GraphWrapper.tsx | 49 +++++++++++++++++---------- src/webviews/apps/plus/graph/graph.scss | 4 +++ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index 771a281..1e412d6 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -18,7 +18,7 @@ import type { State, } from '../../../../plus/webviews/graph/protocol'; import type { Subscription } from '../../../../subscription'; -import { getTimeRemaining, SubscriptionState } from '../../../../subscription'; +import { getSubscriptionTimeRemaining, SubscriptionState } from '../../../../subscription'; import { pluralize } from '../../../../system/string'; export interface GraphWrapperProps extends State { @@ -240,6 +240,22 @@ export function GraphWrapper({ onDismissBanner?.('trial'); }; + const renderTrialDays = () => { + if ( + !subscriptionSnapshot || + ![SubscriptionState.FreeInPreview, SubscriptionState.FreePlusInTrial].includes(subscriptionSnapshot.state) + ) { + return; + } + + const days = getSubscriptionTimeRemaining(subscriptionSnapshot, 'days') ?? 0; + return ( + + GitLens+ Trial ({days < 1 ? '< 1 day' : pluralize('day', days)} left) + + ); + }; + const renderAlertContent = () => { if (subscriptionSnapshot == null || !isPrivateRepo) return; @@ -248,11 +264,8 @@ export function GraphWrapper({ let content; let actions; let days = 0; - if ( - [SubscriptionState.FreeInPreview, SubscriptionState.FreePlusInTrial].includes(subscriptionSnapshot.state) && - subscriptionSnapshot.previewTrial != null - ) { - days = getTimeRemaining(subscriptionSnapshot.previewTrial.expiresOn, 'days') ?? 0; + if ([SubscriptionState.FreeInPreview, SubscriptionState.FreePlusInTrial].includes(subscriptionSnapshot.state)) { + days = getSubscriptionTimeRemaining(subscriptionSnapshot, 'days') ?? 0; } switch (subscriptionSnapshot.state) { @@ -271,8 +284,8 @@ export function GraphWrapper({ GitLens+ trial - . Once your trial ends, you'll need a paid plan to continue to use the Commit Graph on this - and other private repos. + . Once your trial ends, you'll need a paid plan to continue to use GitLens+ features, + including the Commit Graph, on this and other private repos.

); @@ -283,18 +296,16 @@ export function GraphWrapper({ content = ( <>

Extend Your GitLens+ Trial

-

Sign in to extend your free trial by an additional 7-days.

+

+ Your free trial has ended, please sign in to extend your trial of GitLens+ features on + private repos by an additional 7-days. +

); actions = ( - <> - - Extend Trial - {' '} - - View Plans - - + + Extend Trial + ); break; case SubscriptionState.FreePlusTrialExpired: @@ -304,7 +315,8 @@ export function GraphWrapper({ <>

GitLens+ Trial Expired

- Upgrade your account to use the Commit Graph and other GitLens+ features on private repos. + Your free trial has ended, please upgrade your account to continue to use GitLens+ features, + including the Commit Graph, on this and other private repos.

); @@ -488,6 +500,7 @@ export function GraphWrapper({ )}
+ {renderTrialDays()} Preview