Skip to content

Commit df175d7

Browse files
authored
Maintainance: fix the condition to show banner (#6221)
1 parent c9a88d3 commit df175d7

7 files changed

Lines changed: 47 additions & 6 deletions

File tree

Source/Blazorise/Base/BaseComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected override async Task OnAfterRenderAsync( bool firstRender )
141141
{
142142
if ( LicenseChecker.ShouldPrint() )
143143
{
144-
await JSUtilitiesModule.Log( $"%c{LicenseChecker.GetPrintMessage()}", "color: #3B82F6; padding: 0;" );
144+
await JSUtilitiesModule.Log( LicenseChecker.ShowBanner(), $"%c{LicenseChecker.GetPrintMessage()}", "color: #3B82F6; padding: 0;" );
145145
}
146146
}
147147

Source/Blazorise/Interfaces/Modules/IJSUtilitiesModule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ public interface IJSUtilitiesModule : IBaseJSModule
169169
/// <summary>
170170
/// Writes a log message to the browser console.
171171
/// </summary>
172+
/// <param name="showBanner">If true, shows the Blazorise banner.</param>
172173
/// <param name="message">Message to write.</param>
173174
/// <param name="args">Optional parameters.</param>
174175
/// <returns>A task that represents the asynchronous operation.</returns>
175-
ValueTask Log( string message, params string[] args );
176+
ValueTask Log( bool showBanner, string message, params string[] args );
176177

177178
/// <summary>
178179
/// Checks if the current system theme is in dark mode.

Source/Blazorise/Licensing/BlazoriseLicenseChecker.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ internal bool ShouldPrint()
4747
return false;
4848
}
4949

50+
internal bool ShowBanner()
51+
{
52+
return !( BlazoriseLicenseProvider.PrintResult == BlazoriseLicensePrintResult.Licensed
53+
|| BlazoriseLicenseProvider.PrintResult == BlazoriseLicensePrintResult.Community
54+
|| BlazoriseLicenseProvider.PrintResult == BlazoriseLicensePrintResult.Trial );
55+
}
56+
5057
internal string GetPrintMessage()
5158
{
5259
if ( BlazoriseLicenseProvider.PrintResult == BlazoriseLicensePrintResult.Community )
@@ -59,6 +66,11 @@ internal string GetPrintMessage()
5966
return "Your Community License for the Blazorise component library has expired. To continue using our library and receive updates, please renew your license at https://blazorise.com/acount. Thank you for your continued interest in Blazorise!";
6067
}
6168

69+
if ( BlazoriseLicenseProvider.PrintResult == BlazoriseLicensePrintResult.TrialExpired )
70+
{
71+
return "Your trial period for the Blazorise component library has expired. To continue using our library and access premium features, please consider purchasing a commercial license at https://blazorise.com/commercial. We appreciate your interest in Blazorise and look forward to serving you!";
72+
}
73+
6274
if ( BlazoriseLicenseProvider.PrintResult == BlazoriseLicensePrintResult.LicensedExpired )
6375
{
6476
return "Your Commercial License for the Blazorise component library has expired. Please renew your license at https://blazorise.com/account to maintain access to premium features and support. We appreciate your business and look forward to continuing our partnership!";

Source/Blazorise/Licensing/BlazoriseLicensePrintResult.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public enum BlazoriseLicensePrintResult
3535
/// </summary>
3636
Trial,
3737

38+
/// <summary>
39+
/// Indicates whether the trial period for the application has expired.
40+
/// </summary>
41+
TrialExpired,
42+
3843
/// <summary>
3944
/// License was unable to be validated.
4045
/// </summary>

Source/Blazorise/Licensing/BlazoriseLicenseProvider.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,29 @@ public sealed class BlazoriseLicenseProvider
1515
{
1616
#region Members
1717

18+
/// <summary>
19+
/// The default maximum number of rows allowed in a data grid for unlicensed users.
20+
/// </summary>
1821
public const int DEFAULT_UNLICENSED_LIMIT_DATAGRID_MAX_ROWS = 1000;
22+
23+
/// <summary>
24+
/// The default maximum number of rows returned by the autocomplete feature for unlicensed users.
25+
/// </summary>
1926
public const int DEFAULT_UNLICENSED_LIMIT_AUTOCOMPLETE_MAX_ROWS = 1000;
27+
28+
/// <summary>
29+
/// The default maximum number of rows allowed in charts for unlicensed users.
30+
/// </summary>
2031
public const int DEFAULT_UNLICENSED_LIMIT_CHARTS_MAX_ROWS = 10;
32+
33+
/// <summary>
34+
/// The default maximum number of rows that can be displayed in a list view for unlicensed users.
35+
/// </summary>
2136
public const int DEFAULT_UNLICENSED_LIMIT_LISTVIEW_MAX_ROWS = 1000;
37+
38+
/// <summary>
39+
/// The default maximum number of rows displayed in a tree view for unlicensed users.
40+
/// </summary>
2241
public const int DEFAULT_UNLICENSED_LIMIT_TREEVIEW_MAX_ROWS = 100;
2342

2443
private static readonly Assembly CurrentAssembly = typeof( BlazoriseLicenseProvider ).Assembly;
@@ -161,7 +180,7 @@ private static BlazoriseLicensePrintResult ResolveBlazoriseLicensePrintResult( L
161180
}
162181

163182
if ( licenseResult == BlazoriseLicenseResult.Trial )
164-
return BlazoriseLicensePrintResult.Trial;
183+
return Result == BlazoriseLicenseResult.Trial ? BlazoriseLicensePrintResult.Trial : BlazoriseLicensePrintResult.TrialExpired;
165184

166185
return BlazoriseLicensePrintResult.None;
167186
}

Source/Blazorise/Modules/JSUtilitiesModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public ValueTask CopyToClipboard( ElementReference elementRef, string elementId
109109
=> InvokeSafeVoidAsync( "copyToClipboard", elementRef, elementId );
110110

111111
/// <inheritdoc/>
112-
public ValueTask Log( string message, params string[] args )
113-
=> InvokeSafeVoidAsync( "log", message, args );
112+
public ValueTask Log( bool showBanner, string message, params string[] args )
113+
=> InvokeSafeVoidAsync( "log", showBanner, message, args );
114114

115115
private ElementReference? ResolveElementReference( ElementReference elementReference )
116116
=> elementReference.Context is null ? null : elementReference;

Source/Blazorise/wwwroot/utilities.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,13 @@ export function verifyRsa(publicKey, content, signature) {
331331
return false;
332332
}
333333

334-
export function log(message, args) {
334+
export function log(showBanner, message, args) {
335335
console.log(message, args);
336336

337+
if (!showBanner) {
338+
return;
339+
}
340+
337341
const HOST_ID = "blazorise-license-banner-host";
338342
const GLOBAL = "__blazoriseBannerState__";
339343

0 commit comments

Comments
 (0)