diff --git a/Directory.Build.props b/Directory.Build.props
index 16b0953..2e55871 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -5,7 +5,7 @@
$(Company)
Copyright © $(Company) $([System.DateTime]::Now.Year)
$(Company)™
- 3.0.0
+ 3.0.1
MIT
diff --git a/README.md b/README.md
index 146dff1..b570dab 100644
--- a/README.md
+++ b/README.md
@@ -15,9 +15,9 @@ This integration enables you to create [Algolia](https://www.algolia.com/) searc
## Dependencies
-- [ASP.NET Core 6.0](https://dotnet.microsoft.com/en-us/download)
+- [ASP.NET Core 8.0](https://dotnet.microsoft.com/en-us/download)
- [Xperience by Kentico](https://docs.xperience.io/xp/changelog)
-
+- [Algolia](https://www.algolia.com/doc/)
## Package Installation
Add the package to your application using the .NET CLI
diff --git a/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs b/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs
index c2a16d0..ddf2c1e 100644
--- a/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs
+++ b/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs
@@ -5,6 +5,7 @@
using Kentico.Xperience.Algolia.Admin;
using Kentico.Xperience.Algolia.Indexing;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
[assembly: RegisterModule(typeof(AlgoliaAdminModule))]
@@ -23,10 +24,18 @@ public AlgoliaAdminModule() : base(nameof(AlgoliaAdminModule)) { }
protected override void OnInit(ModuleInitParameters parameters)
{
base.OnInit(parameters);
- RegisterClientModule("kentico", "xperience-integrations-algolia");
var services = parameters.Services;
+ var options = services.GetRequiredService>();
+
+ if (!options.Value.IsConfigured)
+ {
+ return;
+ }
+
+ RegisterClientModule("kentico", "xperience-integrations-algolia");
+
installer = services.GetRequiredService();
storageService = services.GetRequiredService();
diff --git a/src/Kentico.Xperience.Algolia/Admin/UIPages/AlgoliaApplication.cs b/src/Kentico.Xperience.Algolia/Admin/UIPages/AlgoliaApplication.cs
index 4f1df56..112c27b 100644
--- a/src/Kentico.Xperience.Algolia/Admin/UIPages/AlgoliaApplication.cs
+++ b/src/Kentico.Xperience.Algolia/Admin/UIPages/AlgoliaApplication.cs
@@ -7,7 +7,7 @@
identifier: AlgoliaApplicationPage.IDENTIFIER,
type: typeof(AlgoliaApplicationPage),
slug: "algolia",
- name: "Search",
+ name: "Algolia Search",
category: BaseApplicationCategories.DEVELOPMENT,
icon: Icons.Magnifier,
templateName: TemplateNames.SECTION_LAYOUT)]
diff --git a/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs b/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs
index 15c9ea9..6f3ad99 100644
--- a/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs
+++ b/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs
@@ -8,6 +8,7 @@
using Kentico.Xperience.Algolia.Admin;
using Kentico.Xperience.Algolia.Indexing;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
[assembly: RegisterModule(typeof(AlgoliaSearchModule))]
@@ -37,11 +38,17 @@ protected override void OnInit(ModuleInitParameters parameters)
var services = parameters.Services;
+ var options = services.GetRequiredService>();
+
+ if (!options.Value.IsConfigured)
+ {
+ return;
+ }
+
algoliaTaskLogger = services.GetRequiredService();
appSettingsService = services.GetRequiredService();
conversionService = services.GetRequiredService();
-
WebPageEvents.Publish.Execute += HandleEvent;
WebPageEvents.Delete.Execute += HandleEvent;
ContentItemEvents.Publish.Execute += HandleContentItemEvent;
@@ -102,7 +109,15 @@ private void HandleContentItemEvent(object? sender, CMSEventArgs e)
public static void AddRegisteredIndices()
{
+ var options = Service.Resolve>();
+
+ if (!options.Value.IsConfigured)
+ {
+ return;
+ }
+
var configurationStorageService = Service.Resolve();
+
var indices = configurationStorageService.GetAllIndexData();
AlgoliaIndexStore.Instance.SetIndicies(indices);
diff --git a/src/Kentico.Xperience.Algolia/AlgoliaStartupExtensions.cs b/src/Kentico.Xperience.Algolia/AlgoliaStartupExtensions.cs
index 678dde7..d827447 100644
--- a/src/Kentico.Xperience.Algolia/AlgoliaStartupExtensions.cs
+++ b/src/Kentico.Xperience.Algolia/AlgoliaStartupExtensions.cs
@@ -18,15 +18,31 @@ public static class AlgoliaStartupExtensions
///
/// The service collection.
/// The application configuration.
- private static IServiceCollection AddKenticoAlgoliaInternal(this IServiceCollection services, IConfiguration configuration) =>
- services.AddSingleton()
- .Configure(configuration.GetSection(AlgoliaOptions.CMS_ALGOLIA_SECTION_NAME))
- .AddSingleton(s =>
- {
- var options = s.GetRequiredService>();
+ private static IServiceCollection AddKenticoAlgoliaInternal(this IServiceCollection services, IConfiguration configuration)
+ {
+ var algoliaSection = configuration.GetSection(AlgoliaOptions.CMS_ALGOLIA_SECTION_NAME);
+ var algoliaOptions = algoliaSection.GetChildren();
- return new InsightsClient(options.Value.ApplicationId, options.Value.ApiKey);
- })
+ bool isConfigured = false;
+
+ if (algoliaOptions.Single(x => x.Key == nameof(AlgoliaOptions.SearchKey)).Value != ""
+ && algoliaOptions.Single(x => x.Key == nameof(AlgoliaOptions.ApiKey)).Value != ""
+ && algoliaOptions.Single(x => x.Key == nameof(AlgoliaOptions.ApplicationId)).Value != "")
+ {
+ isConfigured = true;
+ }
+
+ services
+ .Configure(algoliaSection)
+ .PostConfigure(options => options.IsConfigured = isConfigured);
+
+ if (!isConfigured)
+ {
+ return services;
+ }
+
+ return services
+ .AddSingleton()
.AddSingleton(s =>
{
var options = s.GetRequiredService>();
@@ -37,12 +53,12 @@ private static IServiceCollection AddKenticoAlgoliaInternal(this IServiceCollect
return new SearchClient(configuration);
})
- .AddSingleton()
- .AddSingleton()
- .AddSingleton()
- .AddSingleton()
- .AddSingleton();
-
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton();
+ }
///
/// Adds Algolia services and custom module to application with customized options provided by the
/// in the action.
diff --git a/src/Kentico.Xperience.Algolia/Indexing/AlgoliaOptions.cs b/src/Kentico.Xperience.Algolia/Indexing/AlgoliaOptions.cs
index 7e6648b..c073c76 100644
--- a/src/Kentico.Xperience.Algolia/Indexing/AlgoliaOptions.cs
+++ b/src/Kentico.Xperience.Algolia/Indexing/AlgoliaOptions.cs
@@ -10,6 +10,15 @@ public sealed class AlgoliaOptions
///
public const string CMS_ALGOLIA_SECTION_NAME = "CMSAlgoliaSearch";
+ ///
+ /// /// Turn off functionality if application is not configured in the appsettings
+ ///
+ public bool IsConfigured
+ {
+ get;
+ set;
+ } = false;
+
///
/// Algolia application ID.
///