Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/docs #76

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/Contributing-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ To run the example project Admin customization in development mode, add the foll
}
```

The Xperience web application requests client modules from a webpack dev server that runs parallel to the Xperience application.

Changes to client code are immediately integrated and don’t require a restart or rebuild of the web application.

Before you start developing, the webpack server needs to be manually started by running

```bash
npm run start
```
from the root of the module folder, in our case in the `/src/Kentico.Xperience.Lucene.Admin/Client` folder.

## Development Workflow

### Prepare your Git branch and commits
Expand Down
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);
}
}
98 changes: 49 additions & 49 deletions src/Kentico.Xperience.Lucene.Admin/LuceneAdminModule.cs
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 src/Kentico.Xperience.Lucene.Admin/LuceneIndexPermissions.cs
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";
}
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
}));
}
Loading
Loading