Skip to content

Commit 21ad073

Browse files
committed
add tips for graph for each trial day
1 parent d537ac5 commit 21ad073

File tree

8 files changed

+101
-23
lines changed

8 files changed

+101
-23
lines changed

src/constants.storage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ export type GlobalStorage = {
7777
'launchpadView:groups:expanded': StoredLaunchpadGroup[];
7878
'graph:searchMode': StoredGraphSearchMode;
7979
'views:scm:grouped:welcome:dismissed': boolean;
80-
} & { [key in `confirm:ai:tos:${AIProviders}`]: boolean }
81-
} & { [key in `plus:featurePreviewTrial:${Sources}:consumedDays`]: { startedOn: string; expiresOn: string }[] } & {
80+
} & { [key in `confirm:ai:tos:${AIProviders}`]: boolean } & {
81+
[key in `plus:featurePreviewTrial:${Sources}:consumedDays`]: { startedOn: string; expiresOn: string }[];
82+
} & {
8283
[key in `confirm:ai:tos:${AIProviders}`]: boolean;
8384
} & {
8485
[key in `provider:authentication:skip:${string}`]: boolean;

src/plus/webviews/graph/graphWebview.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
import { GlyphChars } from '../../../constants';
2121
import { Commands } from '../../../constants.commands';
2222
import type { StoredGraphFilters, StoredGraphRefType } from '../../../constants.storage';
23-
import { proPreviewLengthInDays, proTrialLengthInDays } from '../../../constants.subscription';
23+
import { proPreviewLengthInDays } from '../../../constants.subscription';
2424
import type { GraphShownTelemetryContext, GraphTelemetryContext, TelemetryEvents } from '../../../constants.telemetry';
2525
import type { Container } from '../../../container';
2626
import { CancellationError } from '../../../errors';
@@ -2574,6 +2574,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
25742574

25752575
return {
25762576
...this.host.baseWebviewState,
2577+
webroot: this.host.getWebRoot(),
25772578
windowFocused: this.isWindowFocused,
25782579
repositories: await formatRepositories(this.container.git.openRepositories),
25792580
selectedRepository: this.repository.path,

src/plus/webviews/graph/protocol.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type {
2525
import type { Config, DateStyle, GraphBranchesVisibility } from '../../../config';
2626
import type { SupportedCloudIntegrationIds } from '../../../constants.integrations';
2727
import type { SearchQuery } from '../../../constants.search';
28-
import type { Source, Sources } from '../../../constants.telemetry';
28+
import type { Sources } from '../../../constants.telemetry';
2929
import type { RepositoryVisibility } from '../../../git/gitProvider';
3030
import type { GitTrackingState } from '../../../git/models/branch';
3131
import type { GitGraphRowType } from '../../../git/models/graph';
@@ -93,6 +93,7 @@ export const supportedRefMetadataTypes: GraphRefMetadataType[] = ['upstream', 'p
9393

9494
export interface State extends WebviewState {
9595
windowFocused?: boolean;
96+
webroot?: string;
9697
repositories?: GraphRepository[];
9798
selectedRepository?: string;
9899
selectedRepositoryVisibility?: RepositoryVisibility;
90.1 KB
Loading
95.9 KB
Loading

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,7 @@ export function GraphWrapper({
15471547
featureWithArticleIfNeeded="the Commit Graph"
15481548
source={{ source: 'graph', detail: 'gate' }}
15491549
state={subscription?.state}
1550+
webroot={state.webroot}
15501551
visible={!allowed}
15511552
>
15521553
<p slot="feature">

src/webviews/apps/plus/shared/components/feature-gate-plus-state.ts

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TemplateResult } from 'lit';
12
import { css, html, LitElement, nothing } from 'lit';
23
import { customElement, property, query } from 'lit/decorators.js';
34
import { urls } from '../../../../../constants';
@@ -90,6 +91,9 @@ export class GlFeatureGatePlusState extends LitElement {
9091
@property({ attribute: false, type: Number })
9192
state?: SubscriptionState;
9293

94+
@property({ type: String })
95+
webroot?: string;
96+
9397
protected override firstUpdated() {
9498
if (this.appearance === 'alert') {
9599
queueMicrotask(() => this.button.focus());
@@ -111,8 +115,6 @@ export class GlFeatureGatePlusState extends LitElement {
111115
consumedDaysCount = this.featureInPreviewTrial?.[feature]?.consumedDays?.length ?? 0;
112116
}
113117

114-
const feature = this.source?.source || '';
115-
116118
switch (this.state) {
117119
case SubscriptionState.VerificationRequired:
118120
return html`
@@ -142,21 +144,7 @@ export class GlFeatureGatePlusState extends LitElement {
142144
proPreviewLengthInDays - consumedDaysCount > 0
143145
) {
144146
return html`
145-
<gl-button appearance="${appearance}" href="${this.featurePreviewTrialCommandLink}"
146-
>Continue</gl-button
147-
>
148-
<p>
149-
Continuing gives you ${pluralize('day', proPreviewLengthInDays - consumedDaysCount)} to
150-
preview ${this.featureWithArticleIfNeeded ? `${this.featureWithArticleIfNeeded} on` : ''}
151-
privately-hosted repositories.<br />
152-
${appearance !== 'alert' ? html`<br />` : ''} For full access to all GitLens Pro features,
153-
<a href="${generateCommandLink(Commands.PlusSignUp, this.source)}"
154-
>start your free ${proTrialLengthInDays}-day Pro trial</a
155-
>
156-
- no credit card required. Or
157-
<a href="${generateCommandLink(Commands.PlusLogin, this.source)}" title="Sign In">sign in</a
158-
>.
159-
</p>
147+
${this.getFeaturePreviewModalFor(feature, proPreviewLengthInDays - consumedDaysCount)}
160148
`;
161149
}
162150

@@ -206,6 +194,80 @@ export class GlFeatureGatePlusState extends LitElement {
206194
private renderPromo(promo: Promo | undefined) {
207195
return html`<gl-promo .promo=${promo}></gl-promo>`;
208196
}
197+
198+
private getFeaturePreviewModalFor(feature: Sources, daysLeft: number) {
199+
const appearance = (this.appearance ?? 'alert') === 'alert' ? 'alert' : nothing;
200+
let partial: TemplateResult<1> | undefined;
201+
switch (feature) {
202+
case 'graph':
203+
switch (daysLeft) {
204+
case 2:
205+
partial = html`<p>Try Commit Search</p>
206+
<p>
207+
Search for commits in your repo by author, commit message, SHA, file, change, or type.
208+
Turn on the commit filter to show only commits that match your query.
209+
</p>
210+
<p>
211+
<img
212+
src="${this.webroot ?? ''}/media/graph-commit-search.webp"
213+
style="width:100%"
214+
alt="Graph Commit Search"
215+
/>
216+
</p> `;
217+
break;
218+
case 1:
219+
partial = html`
220+
<p>Try the Graph Minimap</p>
221+
<p>
222+
Visualize the amount of changes to a repository over time, and inspect specific points
223+
in the history to locate branches, stashes, tags and pull requests.
224+
</p>
225+
<p>
226+
<img
227+
src="${this.webroot ?? ''}/media/graph-minimap.webp"
228+
style="width:100%"
229+
alt="Graph Minimap"
230+
/>
231+
</p>
232+
`;
233+
break;
234+
}
235+
return html`
236+
${partial}
237+
<gl-button appearance="${appearance}" href="${this.featurePreviewTrialCommandLink}"
238+
>Continue</gl-button
239+
>
240+
<p>
241+
Continuing gives you ${pluralize('day', daysLeft)} to preview
242+
${this.featureWithArticleIfNeeded ? `${this.featureWithArticleIfNeeded} on` : ''}
243+
privately-hosted repositories.<br />
244+
${appearance !== 'alert' ? html`<br />` : ''} For full access to all GitLens Pro features,
245+
<a href="${generateCommandLink(Commands.PlusSignUp, this.source)}"
246+
>start your free ${proTrialLengthInDays}-day Pro trial</a
247+
>
248+
- no credit card required. Or
249+
<a href="${generateCommandLink(Commands.PlusLogin, this.source)}" title="Sign In">sign in</a>.
250+
</p>
251+
`;
252+
default:
253+
return html`
254+
<gl-button appearance="${appearance}" href="${this.featurePreviewTrialCommandLink}"
255+
>Continue</gl-button
256+
>
257+
<p>
258+
Continuing gives you ${pluralize('day', daysLeft)} to preview
259+
${this.featureWithArticleIfNeeded ? `${this.featureWithArticleIfNeeded} on` : ''}
260+
privately-hosted repositories.<br />
261+
${appearance !== 'alert' ? html`<br />` : ''} For full access to all GitLens Pro features,
262+
<a href="${generateCommandLink(Commands.PlusSignUp, this.source)}"
263+
>start your free ${proTrialLengthInDays}-day Pro trial</a
264+
>
265+
- no credit card required. Or
266+
<a href="${generateCommandLink(Commands.PlusLogin, this.source)}" title="Sign In">sign in</a>.
267+
</p>
268+
`;
269+
}
270+
}
209271
}
210272

211273
function generateCommandLink(command: Commands, source: Source | undefined) {

src/webviews/apps/shared/components/feature-gate.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ export class GlFeatureGate extends LitElement {
113113
@property({ type: Boolean })
114114
visible?: boolean;
115115

116+
@property({ type: String })
117+
webroot?: string;
118+
116119
override render() {
117120
if (!this.visible || (this.state != null && isSubscriptionStatePaidOrTrial(this.state))) {
118121
this.hidden = true;
@@ -125,17 +128,26 @@ export class GlFeatureGate extends LitElement {
125128
: 'welcome';
126129

127130
this.hidden = false;
131+
132+
const featureInTrial = this.source?.source;
133+
const featureInTrialInfo = featureInTrial ? this.featureInPreviewTrial?.[featureInTrial] : undefined;
134+
const shouldHideFeature =
135+
featureInTrial === 'graph' &&
136+
featureInTrialInfo &&
137+
featureInTrialInfo.consumedDays.length > 0 &&
138+
featureInTrialInfo.consumedDays.length < 3;
128139
return html`
129140
<section>
130141
<slot></slot>
131-
<slot name="feature"></slot>
142+
<slot name="feature" ?hidden=${shouldHideFeature}></slot>
132143
<gl-feature-gate-plus-state
133144
appearance=${appearance}
134145
.featureWithArticleIfNeeded=${this.featureWithArticleIfNeeded}
135146
.source=${this.source}
136147
.state=${this.state}
137148
.featureInPreviewTrial=${this.featureInPreviewTrial}
138-
featurePreviewTrialCommandLink=${this.featurePreviewTrialCommandLink}
149+
.featurePreviewTrialCommandLink=${this.featurePreviewTrialCommandLink}
150+
.webroot=${this.webroot}
139151
></gl-feature-gate-plus-state>
140152
</section>
141153
`;

0 commit comments

Comments
 (0)