Skip to content

Commit

Permalink
Merge pull request #54 from Kentico/feat/dotnet-format
Browse files Browse the repository at this point in the history
Add dotnet format check
  • Loading branch information
michalJakubis authored Apr 30, 2024
2 parents be1eb34 + 1d98472 commit 7dbfd09
Show file tree
Hide file tree
Showing 59 changed files with 4,112 additions and 4,103 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
pull_request:
branches: [main]
paths:
- ".github/workflows/ci.yml"
- "**.cs"
- "**.tsx"
- "**.js"
Expand All @@ -25,9 +26,20 @@ on:
- "**/Client/**/*.json"

jobs:
dotnet-format:
name: dotnet-format
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Run dotnet format
run: dotnet format Kentico.Xperience.Lucene.sln --exclude ./examples/** --verify-no-changes

build:
name: build
runs-on: ubuntu-latest
needs: dotnet-format
defaults:
run:
shell: pwsh
Expand Down
12 changes: 7 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@
"label": ".NET: format (Lucene)",
"command": "dotnet",
"type": "process",
"args": ["format", "Kentico.Xperience.Lucene.csproj"],
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/src/Kentico.Xperience.Lucene"
}
"args": [
"format",
"Kentico.Xperience.Lucene.sln",
"--exclude",
"./examples/**"
],
"problemMatcher": "$msCompile"
},
{
"label": ".NET: pack (Lucene)",
Expand Down
4 changes: 2 additions & 2 deletions docs/Contributing-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ To run the example project Admin customization in development mode, add the foll
- `refactor/` - for restructuring of existing features
- `fix/` - for bugfixes

1. Run `dotnet format` against the `src/Kentico.Xperience.Lucene.Admin` project
1. Run `dotnet format` against the `Kentico.Xperience.Lucene` solution

> use `dotnet: format` VS Code task.
> use `.NET: format (Lucene)` VS Code task.
1. Commit changes, with a commit message preferably following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) convention.

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);
}
}
75 changes: 38 additions & 37 deletions src/Kentico.Xperience.Lucene.Admin/LuceneAdminModule.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
using CMS;
using CMS.Base;
using CMS.Core;

using Kentico.Xperience.Admin.Base;
using Kentico.Xperience.Lucene.Admin;
using Kentico.Xperience.Lucene.Core;
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!;
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>();

ApplicationEvents.Initialized.Execute += InitializeModule;
}

private void InitializeModule(object? sender, EventArgs e) =>
installer.Install();
}
using CMS;
using CMS.Base;
using CMS.Core;

using Kentico.Xperience.Admin.Base;
using Kentico.Xperience.Lucene.Admin;
using Kentico.Xperience.Lucene.Core;

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!;
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>();

ApplicationEvents.Initialized.Execute += InitializeModule;
}

private void InitializeModule(object? sender, EventArgs e) =>
installer.Install();
}
Loading

0 comments on commit 7dbfd09

Please sign in to comment.