|
| 1 | +import type { TemplateResult } from 'lit'; |
1 | 2 | import { css, html, LitElement, nothing } from 'lit'; |
2 | 3 | import { customElement, property, query } from 'lit/decorators.js'; |
3 | 4 | import { Commands } from '../../../../../constants.commands'; |
@@ -89,6 +90,9 @@ export class GlFeatureGatePlusState extends LitElement { |
89 | 90 | @property({ attribute: false, type: Number }) |
90 | 91 | state?: SubscriptionState; |
91 | 92 |
|
| 93 | + @property({ type: String }) |
| 94 | + webroot?: string; |
| 95 | + |
92 | 96 | protected override firstUpdated() { |
93 | 97 | if (this.appearance === 'alert') { |
94 | 98 | queueMicrotask(() => this.button.focus()); |
@@ -137,21 +141,7 @@ export class GlFeatureGatePlusState extends LitElement { |
137 | 141 | proPreviewLengthInDays - consumedDaysCount > 0 |
138 | 142 | ) { |
139 | 143 | 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)} |
155 | 145 | `; |
156 | 146 | } |
157 | 147 |
|
@@ -223,6 +213,80 @@ export class GlFeatureGatePlusState extends LitElement { |
223 | 213 | private renderPromo(promo: Promo | undefined) { |
224 | 214 | return html`<gl-promo .promo=${promo}></gl-promo>`; |
225 | 215 | } |
| 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 | + } |
226 | 290 | } |
227 | 291 |
|
228 | 292 | function generateCommandLink(command: Commands, source: Source | undefined) { |
|
0 commit comments