generated from Kentico/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(repository) * feat(docs): client module development instructions
- Loading branch information
Showing
40 changed files
with
2,096 additions
and
2,085 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
194 changes: 97 additions & 97 deletions
194
src/Kentico.Xperience.Lucene.Admin/Components/LuceneIndexConfigurationComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,97 @@ | ||
using CMS.DataEngine; | ||
|
||
using Kentico.Xperience.Admin.Base; | ||
using Kentico.Xperience.Admin.Base.FormAnnotations; | ||
using Kentico.Xperience.Admin.Base.Forms; | ||
using Kentico.Xperience.Lucene.Admin; | ||
using Kentico.Xperience.Lucene.Core.Indexing; | ||
|
||
[assembly: RegisterFormComponent( | ||
identifier: LuceneIndexConfigurationComponent.IDENTIFIER, | ||
componentType: typeof(LuceneIndexConfigurationComponent), | ||
name: "Lucene Search Index Configuration")] | ||
|
||
namespace Kentico.Xperience.Lucene.Admin; | ||
|
||
#pragma warning disable S2094 // intentionally empty class | ||
public class LuceneIndexConfigurationComponentProperties : FormComponentProperties | ||
{ | ||
} | ||
#pragma warning restore | ||
|
||
public class LuceneIndexConfigurationComponentClientProperties : FormComponentClientProperties<IEnumerable<LuceneIndexIncludedPath>> | ||
{ | ||
public IEnumerable<LuceneIndexContentType>? PossibleContentTypeItems { get; set; } | ||
} | ||
|
||
public sealed class LuceneIndexConfigurationComponentAttribute : FormComponentAttribute | ||
{ | ||
} | ||
|
||
[ComponentAttribute(typeof(LuceneIndexConfigurationComponentAttribute))] | ||
public class LuceneIndexConfigurationComponent : FormComponent<LuceneIndexConfigurationComponentProperties, LuceneIndexConfigurationComponentClientProperties, IEnumerable<LuceneIndexIncludedPath>> | ||
{ | ||
public const string IDENTIFIER = "kentico.xperience-integrations-lucene-admin.lucene-index-configuration"; | ||
|
||
internal List<LuceneIndexIncludedPath>? Value { get; set; } | ||
|
||
public override string ClientComponentName => "@kentico/xperience-integrations-lucene-admin/LuceneIndexConfiguration"; | ||
|
||
public override IEnumerable<LuceneIndexIncludedPath> GetValue() => Value ?? []; | ||
public override void SetValue(IEnumerable<LuceneIndexIncludedPath> value) => Value = value.ToList(); | ||
|
||
[FormComponentCommand] | ||
public Task<ICommandResponse<RowActionResult>> DeletePath(string path) | ||
{ | ||
var toRemove = Value?.Find(x => Equals(x.AliasPath == path, StringComparison.OrdinalIgnoreCase)); | ||
if (toRemove != null) | ||
{ | ||
Value?.Remove(toRemove); | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
|
||
[FormComponentCommand] | ||
public Task<ICommandResponse<RowActionResult>> SavePath(LuceneIndexIncludedPath path) | ||
{ | ||
var value = Value?.SingleOrDefault(x => Equals(x.AliasPath == path.AliasPath, StringComparison.OrdinalIgnoreCase)); | ||
|
||
if (value is not null) | ||
{ | ||
Value?.Remove(value); | ||
} | ||
|
||
Value?.Add(path); | ||
|
||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
|
||
[FormComponentCommand] | ||
public Task<ICommandResponse<RowActionResult>> AddPath(string path) | ||
{ | ||
if (Value?.Exists(x => x.AliasPath == path) ?? false) | ||
{ | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
else | ||
{ | ||
Value?.Add(new LuceneIndexIncludedPath(path)); | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
} | ||
|
||
protected override async Task ConfigureClientProperties(LuceneIndexConfigurationComponentClientProperties properties) | ||
{ | ||
var allWebsiteContentTypes = DataClassInfoProvider.ProviderObject | ||
.Get() | ||
.WhereEquals(nameof(DataClassInfo.ClassContentTypeType), "Website") | ||
.GetEnumerableTypedResult() | ||
.Select(x => new LuceneIndexContentType(x.ClassName, x.ClassDisplayName, 0)); | ||
|
||
properties.Value = Value ?? []; | ||
properties.PossibleContentTypeItems = allWebsiteContentTypes.ToList(); | ||
|
||
await base.ConfigureClientProperties(properties); | ||
} | ||
} | ||
using CMS.DataEngine; | ||
|
||
using Kentico.Xperience.Admin.Base; | ||
using Kentico.Xperience.Admin.Base.FormAnnotations; | ||
using Kentico.Xperience.Admin.Base.Forms; | ||
using Kentico.Xperience.Lucene.Admin; | ||
using Kentico.Xperience.Lucene.Core.Indexing; | ||
|
||
[assembly: RegisterFormComponent( | ||
identifier: LuceneIndexConfigurationComponent.IDENTIFIER, | ||
componentType: typeof(LuceneIndexConfigurationComponent), | ||
name: "Lucene Search Index Configuration")] | ||
|
||
namespace Kentico.Xperience.Lucene.Admin; | ||
|
||
#pragma warning disable S2094 // intentionally empty class | ||
public class LuceneIndexConfigurationComponentProperties : FormComponentProperties | ||
{ | ||
} | ||
#pragma warning restore | ||
|
||
public class LuceneIndexConfigurationComponentClientProperties : FormComponentClientProperties<IEnumerable<LuceneIndexIncludedPath>> | ||
{ | ||
public IEnumerable<LuceneIndexContentType>? PossibleContentTypeItems { get; set; } | ||
} | ||
|
||
public sealed class LuceneIndexConfigurationComponentAttribute : FormComponentAttribute | ||
{ | ||
} | ||
|
||
[ComponentAttribute(typeof(LuceneIndexConfigurationComponentAttribute))] | ||
public class LuceneIndexConfigurationComponent : FormComponent<LuceneIndexConfigurationComponentProperties, LuceneIndexConfigurationComponentClientProperties, IEnumerable<LuceneIndexIncludedPath>> | ||
{ | ||
public const string IDENTIFIER = "kentico.xperience-integrations-lucene-admin.lucene-index-configuration"; | ||
|
||
internal List<LuceneIndexIncludedPath>? Value { get; set; } | ||
|
||
public override string ClientComponentName => "@kentico/xperience-integrations-lucene-admin/LuceneIndexConfiguration"; | ||
|
||
public override IEnumerable<LuceneIndexIncludedPath> GetValue() => Value ?? []; | ||
public override void SetValue(IEnumerable<LuceneIndexIncludedPath> value) => Value = value.ToList(); | ||
|
||
[FormComponentCommand] | ||
public Task<ICommandResponse<RowActionResult>> DeletePath(string path) | ||
{ | ||
var toRemove = Value?.Find(x => Equals(x.AliasPath == path, StringComparison.OrdinalIgnoreCase)); | ||
if (toRemove != null) | ||
{ | ||
Value?.Remove(toRemove); | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
|
||
[FormComponentCommand] | ||
public Task<ICommandResponse<RowActionResult>> SavePath(LuceneIndexIncludedPath path) | ||
{ | ||
var value = Value?.SingleOrDefault(x => Equals(x.AliasPath == path.AliasPath, StringComparison.OrdinalIgnoreCase)); | ||
|
||
if (value is not null) | ||
{ | ||
Value?.Remove(value); | ||
} | ||
|
||
Value?.Add(path); | ||
|
||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
|
||
[FormComponentCommand] | ||
public Task<ICommandResponse<RowActionResult>> AddPath(string path) | ||
{ | ||
if (Value?.Exists(x => x.AliasPath == path) ?? false) | ||
{ | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
else | ||
{ | ||
Value?.Add(new LuceneIndexIncludedPath(path)); | ||
return Task.FromResult(ResponseFrom(new RowActionResult(false))); | ||
} | ||
} | ||
|
||
protected override async Task ConfigureClientProperties(LuceneIndexConfigurationComponentClientProperties properties) | ||
{ | ||
var allWebsiteContentTypes = DataClassInfoProvider.ProviderObject | ||
.Get() | ||
.WhereEquals(nameof(DataClassInfo.ClassContentTypeType), "Website") | ||
.GetEnumerableTypedResult() | ||
.Select(x => new LuceneIndexContentType(x.ClassName, x.ClassDisplayName, 0)); | ||
|
||
properties.Value = Value ?? []; | ||
properties.PossibleContentTypeItems = allWebsiteContentTypes.ToList(); | ||
|
||
await base.ConfigureClientProperties(properties); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
using CMS; | ||
using CMS.Base; | ||
using CMS.Core; | ||
|
||
using Kentico.Xperience.Admin.Base; | ||
using Kentico.Xperience.Lucene.Admin; | ||
using Kentico.Xperience.Lucene.Core; | ||
using Kentico.Xperience.Lucene.Core.Scaling; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
[assembly: RegisterModule(typeof(LuceneAdminModule))] | ||
|
||
namespace Kentico.Xperience.Lucene.Admin; | ||
|
||
/// <summary> | ||
/// Manages administration features and integration. | ||
/// </summary> | ||
internal class LuceneAdminModule : AdminModule | ||
{ | ||
private LuceneModuleInstaller installer = null!; | ||
private IWebFarmService webFarmService = null!; | ||
public LuceneAdminModule() : base(nameof(LuceneAdminModule)) { } | ||
|
||
protected override void OnInit(ModuleInitParameters parameters) | ||
{ | ||
base.OnInit(parameters); | ||
|
||
RegisterClientModule("kentico", "xperience-integrations-lucene-admin"); | ||
|
||
var services = parameters.Services; | ||
|
||
installer = services.GetRequiredService<LuceneModuleInstaller>(); | ||
webFarmService = services.GetRequiredService<IWebFarmService>(); | ||
|
||
ApplicationEvents.Initialized.Execute += InitializeModule; | ||
ApplicationEvents.Initialized.Execute += RegisterLuceneWebFarmTasks; | ||
} | ||
|
||
private void InitializeModule(object? sender, EventArgs e) => | ||
installer.Install(); | ||
|
||
private void RegisterLuceneWebFarmTasks(object? sender, EventArgs e) | ||
{ | ||
webFarmService.RegisterTask<IndexLogWebPageItemWebFarmTask>(); | ||
webFarmService.RegisterTask<IndexLogReusableItemWebFarmTask>(); | ||
webFarmService.RegisterTask<RebuildWebFarmTask>(); | ||
} | ||
} | ||
using CMS; | ||
using CMS.Base; | ||
using CMS.Core; | ||
|
||
using Kentico.Xperience.Admin.Base; | ||
using Kentico.Xperience.Lucene.Admin; | ||
using Kentico.Xperience.Lucene.Core; | ||
using Kentico.Xperience.Lucene.Core.Scaling; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
[assembly: RegisterModule(typeof(LuceneAdminModule))] | ||
|
||
namespace Kentico.Xperience.Lucene.Admin; | ||
|
||
/// <summary> | ||
/// Manages administration features and integration. | ||
/// </summary> | ||
internal class LuceneAdminModule : AdminModule | ||
{ | ||
private LuceneModuleInstaller installer = null!; | ||
private IWebFarmService webFarmService = null!; | ||
public LuceneAdminModule() : base(nameof(LuceneAdminModule)) { } | ||
|
||
protected override void OnInit(ModuleInitParameters parameters) | ||
{ | ||
base.OnInit(parameters); | ||
|
||
RegisterClientModule("kentico", "xperience-integrations-lucene-admin"); | ||
|
||
var services = parameters.Services; | ||
|
||
installer = services.GetRequiredService<LuceneModuleInstaller>(); | ||
webFarmService = services.GetRequiredService<IWebFarmService>(); | ||
|
||
ApplicationEvents.Initialized.Execute += InitializeModule; | ||
ApplicationEvents.Initialized.Execute += RegisterLuceneWebFarmTasks; | ||
} | ||
|
||
private void InitializeModule(object? sender, EventArgs e) => | ||
installer.Install(); | ||
|
||
private void RegisterLuceneWebFarmTasks(object? sender, EventArgs e) | ||
{ | ||
webFarmService.RegisterTask<IndexLogWebPageItemWebFarmTask>(); | ||
webFarmService.RegisterTask<IndexLogReusableItemWebFarmTask>(); | ||
webFarmService.RegisterTask<RebuildWebFarmTask>(); | ||
} | ||
} |
12 changes: 6 additions & 6 deletions
12
src/Kentico.Xperience.Lucene.Admin/LuceneIndexPermissions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace Kentico.Xperience.Lucene.Admin; | ||
|
||
internal static class LuceneIndexPermissions | ||
{ | ||
public const string REBUILD = "Rebuild"; | ||
} | ||
namespace Kentico.Xperience.Lucene.Admin; | ||
|
||
internal static class LuceneIndexPermissions | ||
{ | ||
public const string REBUILD = "Rebuild"; | ||
} |
28 changes: 14 additions & 14 deletions
28
src/Kentico.Xperience.Lucene.Admin/Providers/AnalyzerOptionsProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
using Kentico.Xperience.Admin.Base.FormAnnotations; | ||
using Kentico.Xperience.Lucene.Core.Indexing; | ||
|
||
namespace Kentico.Xperience.Lucene.Admin.Providers; | ||
|
||
internal class AnalyzerOptionsProvider : IDropDownOptionsProvider | ||
{ | ||
public Task<IEnumerable<DropDownOptionItem>> GetOptionItems() => | ||
Task.FromResult(AnalyzerStorage.Analyzers.Keys.Select(x => new DropDownOptionItem() | ||
{ | ||
Value = x, | ||
Text = x | ||
})); | ||
} | ||
using Kentico.Xperience.Admin.Base.FormAnnotations; | ||
using Kentico.Xperience.Lucene.Core.Indexing; | ||
|
||
namespace Kentico.Xperience.Lucene.Admin.Providers; | ||
|
||
internal class AnalyzerOptionsProvider : IDropDownOptionsProvider | ||
{ | ||
public Task<IEnumerable<DropDownOptionItem>> GetOptionItems() => | ||
Task.FromResult(AnalyzerStorage.Analyzers.Keys.Select(x => new DropDownOptionItem() | ||
{ | ||
Value = x, | ||
Text = x | ||
})); | ||
} |
Oops, something went wrong.