Skip to content

Commit b8e2b92

Browse files
committed
add tips for graph for each trial day
1 parent e6bce18 commit b8e2b92

File tree

7 files changed

+98
-19
lines changed

7 files changed

+98
-19
lines changed

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 & 15 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 { Commands } from '../../../../../constants.commands';
@@ -89,6 +90,9 @@ export class GlFeatureGatePlusState extends LitElement {
8990
@property({ attribute: false, type: Number })
9091
state?: SubscriptionState;
9192

93+
@property({ type: String })
94+
webroot?: string;
95+
9296
protected override firstUpdated() {
9397
if (this.appearance === 'alert') {
9498
queueMicrotask(() => this.button.focus());
@@ -137,21 +141,7 @@ export class GlFeatureGatePlusState extends LitElement {
137141
proPreviewLengthInDays - consumedDaysCount > 0
138142
) {
139143
return html`
140-
<gl-button appearance="${appearance}" href="${this.featurePreviewTrialCommandLink}"
141-
>Continue</gl-button
142-
>
143-
<p>
144-
Continuing gives you ${pluralize('day', proPreviewLengthInDays - consumedDaysCount)} to
145-
preview ${this.featureWithArticleIfNeeded ? `${this.featureWithArticleIfNeeded} on` : ''}
146-
privately-hosted repositories.<br />
147-
${appearance !== 'alert' ? html`<br />` : ''} For full access to all GitLens Pro features,
148-
<a href="${generateCommandLink(Commands.PlusSignUp, this.source)}"
149-
>start your free ${proTrialLengthInDays}-day Pro trial</a
150-
>
151-
- no credit card required. Or
152-
<a href="${generateCommandLink(Commands.PlusLogin, this.source)}" title="Sign In">sign in</a
153-
>.
154-
</p>
144+
${this.getFeaturePreviewModalFor(feature, proPreviewLengthInDays - consumedDaysCount)}
155145
`;
156146
}
157147

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

228292
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)