11import type { PromoKeys } from '../../../constants.subscription' ;
22import { SubscriptionState } from '../../../constants.subscription' ;
33
4+ export type PromoLocation = 'account' | 'badge' | 'gate' | 'home' ;
5+
46export interface Promo {
57 readonly key : PromoKeys ;
68 readonly code ?: string ;
79 readonly states ?: SubscriptionState [ ] ;
810 readonly expiresOn ?: number ;
911 readonly startsOn ?: number ;
1012
11- readonly command ?: `command:${string } `;
12- readonly commandTooltip ?: string ;
13+ readonly command ?: {
14+ command ?: `command:${string } `;
15+ tooltip : string ;
16+ } ;
17+ readonly locations ?: PromoLocation [ ] ;
18+ readonly quickpick : { detail : string } ;
1319}
1420
1521// Must be ordered by applicable order
@@ -26,7 +32,10 @@ const promos: Promo[] = [
2632 SubscriptionState . ProTrialReactivationEligible ,
2733 ] ,
2834 expiresOn : new Date ( '2024-09-27T06:59:00.000Z' ) . getTime ( ) ,
29- commandTooltip : 'Launchpad Sale: Save 75% or more on GitLens Pro' ,
35+ command : { tooltip : 'Launchpad Sale: Save 75% or more on GitLens Pro' } ,
36+ quickpick : {
37+ detail : '$(rocket) Launchpad Sale: Save 75% or more on GitLens Pro' ,
38+ } ,
3039 } ,
3140 {
3241 key : 'launchpad-extended' ,
@@ -41,7 +50,10 @@ const promos: Promo[] = [
4150 ] ,
4251 startsOn : new Date ( '2024-09-27T06:59:00.000Z' ) . getTime ( ) ,
4352 expiresOn : new Date ( '2024-10-14T06:59:00.000Z' ) . getTime ( ) ,
44- commandTooltip : 'Launchpad Sale: Save 75% or more on GitLens Pro' ,
53+ command : { tooltip : 'Launchpad Sale: Save 75% or more on GitLens Pro' } ,
54+ quickpick : {
55+ detail : '$(rocket) Launchpad Sale: Save 75% or more on GitLens Pro' ,
56+ } ,
4557 } ,
4658 {
4759 key : 'pro50' ,
@@ -53,15 +65,28 @@ const promos: Promo[] = [
5365 SubscriptionState . ProTrialExpired ,
5466 SubscriptionState . ProTrialReactivationEligible ,
5567 ] ,
56- commandTooltip : 'Limited-Time Sale: Save 33% or more on your 1st seat of Pro. See your special price' ,
68+ command : { tooltip : 'Limited-Time Sale: Save 33% or more on your 1st seat of Pro. See your special price' } ,
69+ quickpick : {
70+ detail : '$(star-full) Limited-Time Sale: Save 33% or more on your 1st seat of Pro' ,
71+ } ,
5772 } ,
5873] ;
5974
60- export function getApplicablePromo ( state : number | undefined , key ?: PromoKeys ) : Promo | undefined {
75+ export function getApplicablePromo (
76+ state : number | undefined ,
77+ location ?: PromoLocation ,
78+ key ?: PromoKeys ,
79+ ) : Promo | undefined {
6180 if ( state == null ) return undefined ;
6281
6382 for ( const promo of promos ) {
64- if ( ( key == null || key === promo . key ) && isPromoApplicable ( promo , state ) ) return promo ;
83+ if ( ( key == null || key === promo . key ) && isPromoApplicable ( promo , state ) ) {
84+ if ( location == null || promo . locations == null || promo . locations . includes ( location ) ) {
85+ return promo ;
86+ }
87+
88+ break ;
89+ }
6590 }
6691
6792 return undefined ;
0 commit comments