Skip to content

Commit 79b3d96

Browse files
d13eamodio
authored andcommitted
Adds cyber week banner to welcome
1 parent 8595c9a commit 79b3d96

File tree

7 files changed

+65
-2
lines changed

7 files changed

+65
-2
lines changed
32.8 KB
Loading
34.6 KB
Loading

src/webviews/apps/welcome/welcome.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ <h1 class="welcome__brand"><gitlens-logo></gitlens-logo> <small>Git Supercharged
5555
<strong>understand</strong>, <strong>write</strong>, and <strong>review</strong> code. Focus,
5656
collaborate, accelerate.
5757
</p>
58+
<div class="promo-banner" id="promo" hidden>
59+
<a
60+
href="https://www.gitkraken.com/cw23?utm_source=cyber_week&utm_medium=gitlens_banner&utm_campaign=cyber_week_2023"
61+
aria-label="Cyber Week Sale: 50% off first seat of Pro — only $4/month! Includes entire GitKraken suite of dev tools."
62+
>
63+
<img
64+
class="promo-banner__media is-dark"
65+
src="#{webroot}/media/cyberweek-2023-wide-dark.webp"
66+
alt=""
67+
/>
68+
<img
69+
class="promo-banner__media is-light"
70+
src="#{webroot}/media/cyberweek-2023-wide-light.webp"
71+
alt=""
72+
/>
73+
</a>
74+
</div>
5875
</section>
5976
<section class="welcome__section">
6077
<h2>Powerful Features</h2>

src/webviews/apps/welcome/welcome.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
@use '../shared/styles/normalize';
44
@use '../shared/styles/theme';
55

6+
.vscode-high-contrast,
7+
.vscode-dark {
8+
--promo-banner-dark-display: inline-block;
9+
}
10+
11+
.vscode-high-contrast-light,
12+
.vscode-light {
13+
--promo-banner-light-display: inline-block;
14+
}
15+
616
// normalize type
717
body {
818
line-height: 1.4;
@@ -183,6 +193,24 @@ gk-card p {
183193
margin: 0;
184194
}
185195

196+
.promo-banner {
197+
text-align: center;
198+
199+
&__media {
200+
width: 100%;
201+
max-width: 100%;
202+
height: auto;
203+
204+
&.is-light {
205+
display: var(--promo-banner-light-display, none);
206+
}
207+
208+
&.is-dark {
209+
display: var(--promo-banner-dark-display, none);
210+
}
211+
}
212+
}
213+
186214
.welcome {
187215
padding: var(--gitlens-gutter-width);
188216

src/webviews/apps/welcome/welcome.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ export class WelcomeApp extends App<State> {
9393
this.updateFeatures();
9494
this.updateRepoState();
9595
this.updateAccountState();
96+
this.updatePromo();
97+
}
98+
99+
private updatePromo() {
100+
const { canShowPromo } = this.state;
101+
document.getElementById('promo')!.hidden = !(canShowPromo ?? false);
96102
}
97103

98104
private updateVersion() {

src/webviews/welcome/protocol.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export interface State extends WebviewState {
99
currentLine: Config['currentLine']['enabled'];
1010
};
1111
repoFeaturesBlocked?: boolean;
12-
isTrialOrPaid?: boolean;
12+
isTrialOrPaid: boolean;
13+
canShowPromo: boolean;
1314
}
1415

1516
export interface UpdateConfigurationParams {

src/webviews/welcome/welcomeWebview.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ConfigurationChangeEvent } from 'vscode';
22
import { Disposable, workspace } from 'vscode';
33
import type { Container } from '../../container';
44
import type { Subscription } from '../../plus/gk/account/subscription';
5-
import { SubscriptionState } from '../../plus/gk/account/subscription';
5+
import { isSubscriptionPaid, SubscriptionState } from '../../plus/gk/account/subscription';
66
import type { SubscriptionChangeEvent } from '../../plus/gk/account/subscriptionService';
77
import { configuration } from '../../system/configuration';
88
import type { IpcMessage } from '../protocol';
@@ -77,6 +77,7 @@ export class WelcomeWebviewProvider implements WebviewProvider<State> {
7777
this.container.git.openRepositoryCount === 0 ||
7878
this.container.git.hasUnsafeRepositories(),
7979
isTrialOrPaid: await this.getTrialOrPaidState(subscription),
80+
canShowPromo: await this.getCanShowPromo(subscription),
8081
};
8182
}
8283

@@ -90,6 +91,16 @@ export class WelcomeWebviewProvider implements WebviewProvider<State> {
9091
return false;
9192
}
9293

94+
private async getCanShowPromo(subscription?: Subscription): Promise<boolean> {
95+
const expiresTime = new Date('2023-12-06T07:59:00.000Z').getTime(); // 2023-12-05 23:59:00 PST-0800
96+
if (Date.now() > expiresTime) {
97+
return false;
98+
}
99+
100+
const sub = subscription ?? (await this.container.subscription.getSubscription(true));
101+
return !isSubscriptionPaid(sub);
102+
}
103+
93104
private updateConfiguration(params: UpdateConfigurationParams) {
94105
void configuration.updateEffective(`${params.type}.enabled`, params.value);
95106
}

0 commit comments

Comments
 (0)