Browse Source

Adds auto-start of preview trial on Graph

main
Eric Amodio 2 years ago
parent
commit
ae5983b117
2 changed files with 23 additions and 17 deletions
  1. +15
    -12
      src/plus/subscription/subscriptionService.ts
  2. +8
    -5
      src/plus/webviews/graph/graphWebview.ts

+ 15
- 12
src/plus/subscription/subscriptionService.ts View File

@ -394,14 +394,14 @@ export class SubscriptionService implements Disposable {
@gate()
@log()
async startPreviewTrial(): Promise<void> {
async startPreviewTrial(silent?: boolean): Promise<void> {
if (!(await ensurePlusFeaturesEnabled())) return;
let { plan, previewTrial } = this._subscription;
if (previewTrial != null || plan.effective.id !== SubscriptionPlanId.Free) {
void this.showHomeView();
if (plan.effective.id === SubscriptionPlanId.Free) {
if (!silent && plan.effective.id === SubscriptionPlanId.Free) {
const confirm: MessageItem = { title: 'Sign in to GitLens+', isCloseAffordance: true };
const cancel: MessageItem = { title: 'Cancel' };
const result = await window.showInformationMessage(
@ -415,6 +415,7 @@ export class SubscriptionService implements Disposable {
void this.loginOrSignUp();
}
}
return;
}
@ -446,17 +447,19 @@ export class SubscriptionService implements Disposable {
previewTrial: previewTrial,
});
const confirm: MessageItem = { title: 'OK', isCloseAffordance: true };
const learn: MessageItem = { title: 'Learn More' };
const result = await window.showInformationMessage(
`You have started a ${days} day trial of GitLens+ features for both public and private repos.`,
{ modal: true },
confirm,
learn,
);
if (!silent) {
const confirm: MessageItem = { title: 'OK', isCloseAffordance: true };
const learn: MessageItem = { title: 'Learn More' };
const result = await window.showInformationMessage(
`You have started a ${days} day trial of GitLens+ features for both public and private repos.`,
{ modal: true },
confirm,
learn,
);
if (result === learn) {
this.learn();
if (result === learn) {
this.learn();
}
}
}

+ 8
- 5
src/plus/webviews/graph/graphWebview.ts View File

@ -450,11 +450,14 @@ export class GraphWebview extends WebviewBase {
// If we have a set of data refresh to the same set
const limit = this._graph?.paging?.limit ?? config.defaultItemLimit;
// only check on private
const access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
// TODO: probably not the right place to set this
if (this._etagSubscription == null) {
this._etagSubscription = this.container.subscription.etag;
// Check for GitLens+ access
let access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
this._etagSubscription = this.container.subscription.etag;
// If we don't have access to GitLens+, but the preview trial hasn't been started, auto-start it
if (!access.allowed && access.subscription.current.previewTrial == null) {
await this.container.subscription.startPreviewTrial(true);
access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
}
const data = await this.container.git.getCommitsForGraph(

Loading…
Cancel
Save