Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
bkapustik committed May 27, 2024
2 parents 6c5bc02 + 12d631f commit f6aef09
Show file tree
Hide file tree
Showing 75 changed files with 4,903 additions and 4,858 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@ on:
- "**/Client/**/*.json"

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

steps:
- uses: actions/checkout@v4

- name: Run dotnet format
run: dotnet format --exclude ./examples/** --verify-no-changes

build:
name: build
runs-on: ubuntu-latest
needs: dotnet-format
defaults:
run:
shell: pwsh
Expand All @@ -40,15 +51,15 @@ jobs:
PROJECT_NAME: Kentico.Xperience.AzureSearch

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: "Install Node.js from package.json version"
uses: actions/setup-node@v4
with:
node-version-file: ./src/${{ env.PROJECT_NAME }}/Admin/Client/package.json

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

Expand Down
24 changes: 22 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,28 @@
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/examples/DancingGoat/bin/Debug/net6.0/DancingGoat.dll",
"preLaunchTask": ".NET: build (Solution)",
"program": "${workspaceFolder}/examples/DancingGoat/bin/Debug/net8.0/DancingGoat.dll",
"args": [],
"cwd": "${workspaceFolder}/examples/DancingGoat",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Launch (DancingGoat) - LOCAL_NUGET",
"type": "coreclr",
"request": "launch",
"preLaunchTask": ".NET: build (Solution) - LOCAL_NUGET",
"program": "${workspaceFolder}/examples/DancingGoat/bin/Debug/net8.0/DancingGoat.dll",
"args": [],
"cwd": "${workspaceFolder}/examples/DancingGoat",
"stopAtEntry": false,
Expand Down
26 changes: 20 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
],
"problemMatcher": "$msCompile"
},
{
"label": ".NET: build (Solution) - LOCAL_NUGET",
"command": "dotnet",
"type": "process",
"args": [
"build",
"-p:LOCAL_NUGET=true",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": ".NET: rebuild (Solution)",
"command": "dotnet",
Expand Down Expand Up @@ -47,14 +59,16 @@
"problemMatcher": "$msCompile"
},
{
"label": ".NET: format (Azure)",
"label": ".NET: format (AzureSearch)",
"command": "dotnet",
"type": "process",
"args": ["format", "Kentico.Xperience.AzureSearch.csproj"],
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/src/Kentico.Xperience.AzureSearch"
}
"args": [
"format",
"Kentico.Xperience.AzureSearch.sln",
"--exclude",
"./examples/**"
],
"problemMatcher": "$msCompile"
},
{
"label": ".NET: watch (DancingGoat)",
Expand Down
4 changes: 2 additions & 2 deletions docs/Contributing-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ Then start Webpack dev server by running the scripts found in `~/src/Kentico.Xpe
- `refactor/` - for restructuring of existing features
- `fix/` - for bugfixes

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

> use `dotnet: format` VS Code task.
> use `.NET: format (AzureSearch)` 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
110 changes: 55 additions & 55 deletions src/Kentico.Xperience.AzureSearch/Admin/AzureSearchAdminModule.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
using CMS;
using CMS.Base;
using CMS.Core;

using Kentico.Xperience.Admin.Base;
using Kentico.Xperience.AzureSearch.Admin;
using Kentico.Xperience.AzureSearch.Aliasing;
using Kentico.Xperience.AzureSearch.Indexing;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

[assembly: RegisterModule(typeof(AzureSearchAdminModule))]

namespace Kentico.Xperience.AzureSearch.Admin;

/// <summary>
/// Manages administration features and integration.
/// </summary>
internal class AzureSearchAdminModule : AdminModule
{
private IAzureSearchConfigurationStorageService storageService = null!;
private AzureSearchModuleInstaller installer = null!;

public AzureSearchAdminModule() : base(nameof(AzureSearchAdminModule)) { }

protected override void OnInit(ModuleInitParameters parameters)
{
base.OnInit(parameters);

var options = Service.Resolve<IOptions<AzureSearchOptions>>();

if (!options.Value?.SearchServiceEnabled ?? false)
{
return;
}

RegisterClientModule("kentico", "xperience-integrations-azuresearch");

var services = parameters.Services;

installer = services.GetRequiredService<AzureSearchModuleInstaller>();
storageService = services.GetRequiredService<IAzureSearchConfigurationStorageService>();

ApplicationEvents.Initialized.Execute += InitializeModule;
}

private void InitializeModule(object? sender, EventArgs e)
{
installer.Install();

AzureSearchIndexStore.SetIndicies(storageService);
AzureSearchIndexAliasStore.SetAliases(storageService);
}
}
using CMS;
using CMS.Base;
using CMS.Core;

using Kentico.Xperience.Admin.Base;
using Kentico.Xperience.AzureSearch.Admin;
using Kentico.Xperience.AzureSearch.Aliasing;
using Kentico.Xperience.AzureSearch.Indexing;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

[assembly: RegisterModule(typeof(AzureSearchAdminModule))]

namespace Kentico.Xperience.AzureSearch.Admin;

/// <summary>
/// Manages administration features and integration.
/// </summary>
internal class AzureSearchAdminModule : AdminModule
{
private IAzureSearchConfigurationStorageService storageService = null!;
private AzureSearchModuleInstaller installer = null!;

public AzureSearchAdminModule() : base(nameof(AzureSearchAdminModule)) { }

protected override void OnInit(ModuleInitParameters parameters)
{
base.OnInit(parameters);

var options = Service.Resolve<IOptions<AzureSearchOptions>>();

if (!options.Value?.SearchServiceEnabled ?? false)
{
return;
}

RegisterClientModule("kentico", "xperience-integrations-azuresearch");

var services = parameters.Services;

installer = services.GetRequiredService<AzureSearchModuleInstaller>();
storageService = services.GetRequiredService<IAzureSearchConfigurationStorageService>();

ApplicationEvents.Initialized.Execute += InitializeModule;
}

private void InitializeModule(object? sender, EventArgs e)
{
installer.Install();

AzureSearchIndexStore.SetIndicies(storageService);
AzureSearchIndexAliasStore.SetAliases(storageService);
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
using System.ComponentModel.DataAnnotations;

using Kentico.Xperience.Admin.Base.FormAnnotations;

namespace Kentico.Xperience.AzureSearch.Admin;

public class AzureSearchAliasConfigurationModel
{
public int Id { get; set; }

[TextInputComponent(
Label = "Alias Name",
Order = 1)]
[Required]
[MinLength(1)]
[MaxLength(128)]
[RegularExpression("^(?!-)[a-z0-9-]+(?<!-)$", ErrorMessage = "Alias name must only contain lowercase letters, digits or dashes, cannot start or end with dashes and is limited to 128 characters.")]
public string AliasName { get; set; } = "";

[GeneralSelectorComponent(dataProviderType: typeof(ExistingIndexOptionsProvider), Label = "Index Names", Order = 2)]
[MinLength(1, ErrorMessage = "You must select at least one index name")]
public IEnumerable<string> IndexNames { get; set; } = Enumerable.Empty<string>();

public AzureSearchAliasConfigurationModel()
{ }

public AzureSearchAliasConfigurationModel(
AzureSearchIndexAliasItemInfo alias,
IEnumerable<string> aliasIndexes)
{
Id = alias.AzureSearchIndexAliasItemId;
AliasName = alias.AzureSearchIndexAliasItemIndexAliasName;
IndexNames = aliasIndexes;
}
}
using System.ComponentModel.DataAnnotations;

using Kentico.Xperience.Admin.Base.FormAnnotations;

namespace Kentico.Xperience.AzureSearch.Admin;

public class AzureSearchAliasConfigurationModel
{
public int Id { get; set; }

[TextInputComponent(
Label = "Alias Name",
Order = 1)]
[Required]
[MinLength(1)]
[MaxLength(128)]
[RegularExpression("^(?!-)[a-z0-9-]+(?<!-)$", ErrorMessage = "Alias name must only contain lowercase letters, digits or dashes, cannot start or end with dashes and is limited to 128 characters.")]
public string AliasName { get; set; } = "";

[GeneralSelectorComponent(dataProviderType: typeof(ExistingIndexOptionsProvider), Label = "Index Names", Order = 2)]
[MinLength(1, ErrorMessage = "You must select at least one index name")]
public IEnumerable<string> IndexNames { get; set; } = Enumerable.Empty<string>();

public AzureSearchAliasConfigurationModel()
{ }

public AzureSearchAliasConfigurationModel(
AzureSearchIndexAliasItemInfo alias,
IEnumerable<string> aliasIndexes)
{
Id = alias.AzureSearchIndexAliasItemId;
AliasName = alias.AzureSearchIndexAliasItemIndexAliasName;
IndexNames = aliasIndexes;
}
}
Loading

0 comments on commit f6aef09

Please sign in to comment.