Skip to content

Commit 51305e5

Browse files
committed
#35694 Licensing and UX changes
1 parent d4f9e06 commit 51305e5

35 files changed

+277
-142
lines changed

Metalama.Backstage.Commands/BackstageCommandFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public static void ConfigureCommandApp(
4242
.WithData( options )
4343
.WithDescription( "Starts the trial period." );
4444

45-
license.AddCommand<RegisterFreeCommand>( "free" )
45+
license.AddCommand<RegisterCommunityCommand>( "community" )
4646
.WithData( options )
47-
.WithDescription( "Switches to Metalama Free." );
47+
.WithDescription( "Switches to Metalama Community." );
4848

4949
configureBranch?.Invoke( "license", license );
5050
} );

Metalama.Backstage.Commands/Licensing/RegisterFreeCommand.cs renamed to Metalama.Backstage.Commands/Licensing/RegisterCommunityCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
namespace Metalama.Backstage.Commands.Licensing;
77

8-
internal class RegisterFreeCommand : BaseCommand<BaseCommandSettings>
8+
internal class RegisterCommunityCommand : BaseCommand<BaseCommandSettings>
99
{
1010
protected override void Execute( ExtendedCommandContext context, BaseCommandSettings settings )
1111
{
1212
var service = context.ServiceProvider.GetRequiredBackstageService<ILicenseRegistrationService>();
1313

14-
if ( !service.TryRegisterFreeEdition( out var errorMessage ) )
14+
if ( !service.TryRegisterCommunityEdition( out var errorMessage ) )
1515
{
1616
throw new CommandException( errorMessage );
1717
}
1818

19-
context.Console.WriteSuccess( "You are now using Metalama Free." );
19+
context.Console.WriteSuccess( "You are now using Metalama Community." );
2020
}
2121
}

Metalama.Backstage.Desktop.Windows/ViewModel/ViewModelBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static bool TryGetNotificationViewModel(
2424
settings.Kind,
2525
"Activate Metalama",
2626
"""
27-
Choose between Metalama Free,
28-
a 45-day trial of Metalama Ultimate, or register a license key.
27+
Choose between Metalama Core,
28+
Metalama Community, or register a license key.
2929
""",
3030
new CommandActionViewModel( "Activate", activationArguments.Setup ) );
3131

Metalama.Backstage.Worker/Pages/ChooseLicenseKind.cshtml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,30 @@
1414
<input type="hidden" id="action" name="action" value=""/>
1515

1616
<div class="arrow-buttons">
17-
<div onclick="submitForm('StartFree')">
18-
<h4>Use Metalama [Free]</h4>
17+
<div onclick="submitForm('UseCore')">
18+
<h4>Stay with Metalama Core</h4>
1919
<p>
20-
Discover the essentials with Metalama [Free] — your gateway to cleaner code.
20+
Metalama Core is free for everyone, but you won't be able to use the advanced features included in the Visual Studio extension.
2121
Ideal for an initial foray, with an easy upgrade path when you're ready for more.
2222
</p>
2323
</div>
2424

25+
<div onclick="submitForm('UseCommunity')">
26+
<h4>Use Metalama Community</h4>
27+
<p>
28+
Get a free license key for the Metalama Visual Studio extension.
29+
Available for non-commercial use, individuals and small bussinesses.
30+
</p>
31+
</div>
32+
2533
@if (LicenseRegistrationService.CanRegisterTrialEdition)
2634
{
2735
<div onclick="submitForm('StartTrial')">
28-
<h4>Start a 45-day Trial of Metalama [Ultimate]</h4>
29-
<p>Discover the full capabilities of Metalama Ultimate.</p>
36+
<h4>Start a 45-day Trial of Metalama Enterprise</h4>
37+
<p>Discover the full capabilities of Metalama Enterprise.</p>
3038
<p>
3139
For teams with extended procurement processes, request a
32-
<a href="@Model.WebLinks.GetTeamTeamTrial" target="_blank" onclick="event.stopPropagation()">60-day renewable team evaluation key</a>
40+
<a href="@Model.WebLinks.GetTeamTeamTrial" target="_blank" onclick="event.stopPropagation()">60-day renewable team evaluation key</a>
3341
(available for teams of 5 or more developers).
3442
</p>
3543
</div>

Metalama.Backstage.Worker/Pages/ChooseLicenseKind.cshtml.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ public IActionResult OnPost( string action )
2222
{
2323
switch ( action )
2424
{
25-
case "StartFree":
26-
GlobalState.LicenseKind = LicenseKind.Free;
25+
case "UseCore":
26+
GlobalState.LicenseKind = LicenseKind.Core;
2727

28-
return this.Redirect( "/Consents" );
28+
return this.Redirect( "/DoneCore" );
29+
30+
case "UseCommunity":
31+
GlobalState.LicenseKind = LicenseKind.Community;
32+
33+
return this.Redirect( "/Community" );
2934

3035
case "StartTrial":
3136
GlobalState.LicenseKind = LicenseKind.Trial;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@page
2+
@model CommunityModel
3+
4+
<form method="post">
5+
<div class="radio">
6+
<div class="label">
7+
<label>
8+
<input type="radio" asp-for="UseKind" value="@CommunityUseKind.Individual">
9+
I am an individual developer.
10+
</label>
11+
</div>
12+
</div>
13+
14+
<div class="radio">
15+
<div class="label">
16+
<label>
17+
<input type="radio" asp-for="UseKind" value="@CommunityUseKind.SmallBusiness">
18+
I am going to use Metalama in a small business (less than 1 million USD in annual revenue) with up to 4 other developers.
19+
</label>
20+
</div>
21+
</div>
22+
23+
<div class="radio">
24+
<div class="label">
25+
<label>
26+
<input type="radio" asp-for="UseKind" value="@CommunityUseKind.NonCommercial">
27+
I am going to use Metalama for non-commercial purposes: open source, learning, academic research, educational or demos.
28+
</label>
29+
</div>
30+
</div>
31+
32+
<div class="radio">
33+
<div class="label">
34+
<label>
35+
<input type="radio" asp-for="UseKind" value="@CommunityUseKind.Other">
36+
None of the above.
37+
</label>
38+
</div>
39+
</div>
40+
41+
<div class="continue-button">
42+
<button type="submit">Continue</button>
43+
</div>
44+
45+
</form>
46+
47+
48+
@foreach (var error in Model.ErrorMessages)
49+
{
50+
<div class="text-danger">
51+
@error
52+
</div>
53+
}
54+
55+
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.AspNetCore.Mvc.RazorPages;
5+
using System.Collections.Generic;
6+
7+
namespace Metalama.Backstage.Pages;
8+
9+
#pragma warning disable SA1649
10+
11+
public class CommunityModel : PageModel
12+
{
13+
[BindProperty]
14+
public CommunityUseKind? UseKind { get; set; }
15+
16+
public List<string> ErrorMessages { get; } = [];
17+
18+
public IActionResult OnPost()
19+
{
20+
if ( this.UseKind == null )
21+
{
22+
this.ErrorMessages.Add( "Please select one of the options above." );
23+
24+
return this.Page();
25+
}
26+
27+
if ( this.UseKind == CommunityUseKind.Other )
28+
{
29+
this.ErrorMessages.Add( "We're sorry, but the Metalama Community license is only available for non-commercial use, individuals or small bussinesses. " );
30+
31+
return this.Page();
32+
}
33+
34+
return this.Redirect( "/Consents" );
35+
}
36+
}
37+
38+
public enum CommunityUseKind
39+
{
40+
NonCommercial,
41+
Individual,
42+
SmallBusiness,
43+
Other
44+
}

Metalama.Backstage.Worker/Pages/Consents.cshtml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page
2+
@using Metalama.Backstage.Pages.Shared
23
@using Metalama.Backstage.UserInterface
34
@model ConsentsPageModel
45
@inject WebLinks WebLinks;
@@ -21,7 +22,7 @@
2122
$('#AcceptAll').change(function() {
2223
// Check or uncheck all other checkboxes based on 'Accept All' state
2324
var isChecked = $(this).is(':checked');
24-
$('input[type="checkbox"]').not(this).prop('checked', isChecked);
25+
$('input[type="checkbox"]:enabled').not(this).prop('checked', isChecked);
2526
});
2627
2728
@@ -32,33 +33,44 @@
3233
<form method="post">
3334
@if (Model.IsDeviceOnline)
3435
{
35-
<input id="recaptchaResponse" type="hidden" asp-for="RecaptchaResponse "/>
36+
<input id="recaptchaResponse" type="hidden" asp-for="RecaptchaResponse"/>
3637

3738
<div class="checkbox">
38-
<input id="subscribeToNewsletterCheckbox" type="checkbox" asp-for="SubscribeToNewsletter ">
39+
<input id="subscribeToNewsletterCheckbox" type="checkbox" asp-for="SubscribeToNewsletter">
3940
<div class="label">
4041
<p>
41-
<label asp-for="SubscribeToNewsletter ">Subscribe to the Metalama newsletter and the welcome e-mail course.</label>
42+
<label asp-for="SubscribeToNewsletter">Subscribe to the Metalama newsletter and the welcome e-mail course.</label>
4243
<small>You can unsubscribe or change your preferences at any time.</small>
4344
</p>
4445
<p>
45-
<label asp-for="EmailAddress ">Email:</label> <input type="text" asp-for="EmailAddress ">
46+
<label asp-for="EmailAddress">Email:</label> <input type="text" asp-for="EmailAddress">
4647
</p>
4748

4849
</div>
4950
</div>
5051
}
5152
<div class="checkbox">
52-
<input type="checkbox" asp-for="EnableTelemetry ">
53+
@{
54+
var mandatoryTelemetry = GlobalState.LicenseKind == LicenseKind.Community;
55+
}
56+
57+
<input type="checkbox" asp-for="EnableTelemetry" checked="@mandatoryTelemetry" disabled="@mandatoryTelemetry">
5358
<div class="label">
54-
<label asp-for="EnableTelemetry ">Help improve Metalama by sending <a href="@WebLinks.PrivacyPolicy" target="_blank">anonymous usage and performance statistics</a>.</label>
59+
<label asp-for="EnableTelemetry">
60+
Help improve Metalama by sending <a href="@WebLinks.PrivacyPolicy" target="_blank">anonymous usage and performance statistics</a>.
61+
62+
@if (mandatoryTelemetry)
63+
{
64+
<small>Telemetry is mandatory for Metalama Community users.</small>
65+
}
66+
</label>
5567
</div>
5668
</div>
5769

5870
<div class="checkbox">
59-
<input type="checkbox" asp-for="AcceptLicense ">
71+
<input type="checkbox" asp-for="AcceptLicense">
6072
<div class="label">
61-
<label asp-for="AcceptLicense ">
73+
<label asp-for="AcceptLicense">
6274
I accept the terms of the <a href="@WebLinks.LicenseAgreement" target="_blank">License Agreement</a> and the <a href="@WebLinks.PrivacyPolicy" target="_blank">Privacy Policy</a>. I understand
6375
that the software is subject to License Audit and I consent with the collection of usage data.
6476
</label>

Metalama.Backstage.Worker/Pages/Consents.cshtml.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,12 @@ await httpClient.GetStringAsync(
163163
// Register the license.
164164
switch ( GlobalState.LicenseKind )
165165
{
166-
case LicenseKind.Trial:
166+
case LicenseKind.Core:
167+
return this.Redirect( "/DoneCore" );
168+
169+
case LicenseKind.Community:
167170
{
168-
if ( !this._licenseRegistrationService.TryRegisterTrialEdition( out var errorMessage ) )
171+
if ( !this._licenseRegistrationService.TryRegisterCommunityEdition( out var errorMessage ) )
169172
{
170173
this.ErrorMessages.Add( errorMessage );
171174

@@ -175,9 +178,9 @@ await httpClient.GetStringAsync(
175178
break;
176179
}
177180

178-
case LicenseKind.Free:
181+
case LicenseKind.Trial:
179182
{
180-
if ( !this._licenseRegistrationService.TryRegisterFreeEdition( out var errorMessage ) )
183+
if ( !this._licenseRegistrationService.TryRegisterTrialEdition( out var errorMessage ) )
181184
{
182185
this.ErrorMessages.Add( errorMessage );
183186

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@page
22
@model DonePageModel
33

4-
@* This content is only shown when offline. See the OnGet method. *@
4+
@* This content is shown when offline, or when the online welcome page has already been shown. See the OnGet method. *@
55

66
<p class="text-center">Thank you for activating Metalama.</p>
77
<p class="text-center">You can now close this window.</p>

0 commit comments

Comments
 (0)