Skip to content

Commit

Permalink
Add new Paid Expired state to detect when a license has expired
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiolms committed Sep 6, 2024
1 parent d640245 commit beda0e0
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 0 deletions.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17880,6 +17880,15 @@
},
"when": "gitlens:plus:state == 6"
},
{
"id": "pro-expired-reactivate",
"title": "Reactivate Pro Power-up",
"description": "Reactivate your Pro account and experience all the new [Pro features](https://gitkraken.com/gitlens/pro-features?utm_source=gitlens-extension&utm_medium=in-app-links) and the full [GitKraken DevEx platform](https://gitkraken.com/devex?utm_source=gitlens-extension&utm_medium=in-app-links).\n\n[Reactivate Pro](command:gitlens.plus.upgrade?%7B%22source%22%3A%22walkthrough%22%7D)\n\n**Pro Features**\n$(gitlens-graph)  [Commit Graph](command:gitlens.openWalkthrough?%7B%22step%22%3A%22visualize%22,%22source%22%3A%22walkthrough%22%7D) — visualize your repository and keep track of all work in progress\n$(rocket)  [Launchpad](command:gitlens.openWalkthrough?%7B%22step%22%3A%22launchpad%22,%22source%22%3A%22walkthrough%22%7D) — stay focused and keep your team unblocked\n$(gitlens-code-suggestion)  [Code Suggest](command:gitlens.openWalkthrough?%7B%22step%22%3A%22code-collab%22,%22source%22%3A%22walkthrough%22%7D) — free your code reviews from unnecessary restrictions\n$(gitlens-cloud-patch)  [Cloud Patches](command:gitlens.openWalkthrough?%7B%22step%22%3A%22code-collab%22,%22source%22%3A%22walkthrough%22%7D) — easily and securely share code with your teammates\n$(gitlens-worktrees-view)  **Worktrees** — work on multiple branches simultaneously\n$(gitlens-workspaces-view)  **Workspaces** — group and manage multiple repositories together\n$(graph-scatter)  [Visual File History](command:gitlens.openWalkthrough?%7B%22step%22%3A%22visualize%22,%22source%22%3A%22walkthrough%22%7D) — visualize the evolution of a file and quickly identify when the most impactful changes were made and by whom",
"media": {
"markdown": "walkthroughs/welcome/pro-reactivate.md"
},
"when": "gitlens:plus:state == 6"
},
{
"id": "visualize",
"title": "Visualize with Commit Graph & Visual File History",
Expand Down
1 change: 1 addition & 0 deletions src/constants.telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export type TelemetryEvents = {
| 'pro-trial'
| 'pro-upgrade'
| 'pro-reactivate'
| 'pro-expired-reactivate'
| 'pro-paid'
| 'visualize'
| 'launchpad'
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export type WalkthroughSteps =
| 'pro-trial'
| 'pro-upgrade'
| 'pro-reactivate'
| 'pro-expired-reactivate'
| 'pro-paid'
| 'visualize'
| 'launchpad'
Expand Down
1 change: 1 addition & 0 deletions src/plus/gk/account/promos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const promos: Promo[] = [
SubscriptionState.FreePlusInTrial,
SubscriptionState.FreePlusTrialExpired,
SubscriptionState.FreePlusTrialReactivationEligible,
SubscriptionState.PaidExpired,
],
expiresOn: new Date('2024-09-10T06:59:00.000Z').getTime(),
commandTooltip: 'Sale: Save up to 80% on GitLens Pro - lowest price of the year!',
Expand Down
12 changes: 12 additions & 0 deletions src/plus/gk/account/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export const enum SubscriptionState {
FreePlusTrialReactivationEligible = 5,
/** Indicates a Paid user */
Paid = 6,
/** Indicates a Paid user whose subscription has expired */
PaidExpired = 7,
}

export function getSubscriptionStateString(state: SubscriptionState | undefined): string {
Expand All @@ -95,6 +97,8 @@ export function getSubscriptionStateString(state: SubscriptionState | undefined)
return 'trial-reactivation-eligible';
case SubscriptionState.Paid:
return 'paid';
case SubscriptionState.PaidExpired:
return 'paid-expired';
default:
return 'unknown';
}
Expand Down Expand Up @@ -125,6 +129,10 @@ export function computeSubscriptionState(subscription: Optional<Subscription, 's
case SubscriptionPlanId.Pro:
case SubscriptionPlanId.Teams:
case SubscriptionPlanId.Enterprise:
if (effective.expiresOn != null && new Date(effective.expiresOn) < new Date()) {
return SubscriptionState.PaidExpired;
}

return SubscriptionState.Paid;
}
}
Expand All @@ -148,6 +156,10 @@ export function computeSubscriptionState(subscription: Optional<Subscription, 's

case SubscriptionPlanId.Teams:
case SubscriptionPlanId.Enterprise:
if (effective.expiresOn != null && new Date(effective.expiresOn) < new Date()) {
return SubscriptionState.PaidExpired;
}

return SubscriptionState.Paid;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/plus/gk/account/subscriptionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ export class SubscriptionService implements Disposable {
step: 'pro-paid',
});
break;
case SubscriptionState.PaidExpired:
void executeCommand<OpenWalkthroughCommandArgs>(Commands.OpenWalkthrough, {
...source,
step: 'pro-expired-reactivate',
});
break;
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/webviews/apps/plus/account/components/account-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ export class AccountContent extends LitElement {
</p>
`;

case SubscriptionState.PaidExpired:
return html`
<p>
Your ${getSubscriptionPlanName(this.planId)} plan has ended. Reactivate your
${getSubscriptionPlanName(this.planId)} account and experience all the new
<a href="${urls.proFeatures}">Pro features</a> and the full
<a href="${urls.platform}">GitKraken DevEx platform</a>
</p>
<button-container>
<gl-button full href="command:gitlens.plus.upgrade">Upgrade to Pro</gl-button>
</button-container>
${this.renderPromo(promo)} ${this.renderIncludesDevEx()}
`;

case SubscriptionState.VerificationRequired:
return html`
<p>You must verify your email before you can access Pro features.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ export class GlFeatureGatePlusState extends LitElement {
features.
</p>`;

case SubscriptionState.PaidExpired:
return html` <gl-button
appearance="${appearance}"
href="${generateCommandLink(Commands.PlusUpgrade, this.source)}"
>Upgrade to Pro</gl-button
>
${this.renderPromo(promo)}
<p>
Your Pro license has ended. Please upgrade for full access to
${this.featureWithArticleIfNeeded ? `${this.featureWithArticleIfNeeded} and other ` : ''}Pro
features.
</p>`;

case SubscriptionState.FreePlusTrialReactivationEligible:
return html`
<gl-button
Expand Down
7 changes: 7 additions & 0 deletions src/webviews/apps/shared/components/feature-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ export class GlFeatureBadge extends LitElement {
${this.renderUpgradeActions(html`<p>Please upgrade for full access to Pro features:</p>`)}`;
break;

case SubscriptionState.PaidExpired:
content = html`<p>
Your Pro license as ended. You can now only use Pro features on publicly-hosted repos.
</p>
${this.renderUpgradeActions(html`<p>Please upgrade for full access to Pro features:</p>`)}`;
break;

case SubscriptionState.FreePlusTrialReactivationEligible:
content = html`<p>
Reactivate your Pro trial and experience all the new Pro features — free for another 7 days!
Expand Down

0 comments on commit beda0e0

Please sign in to comment.