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/disable through appsettings #14

Merged
merged 7 commits into from
May 16, 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
19 changes: 18 additions & 1 deletion docs/Usage-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ See [Managing search index aliases](Managing-Aliases.md)

See [Search index querying](Search-index-querying.md)

## Disable indexing

You can disable indexing. This might be useful if there are any problems with differing Kentico version between this integration
and your application. You can do so in the `appsettings.json`. This option defaults to true and therefore does not need to be specified when you want to enable indexing.

```json
"CMSAzureSearch": {
"SearchServiceEnabled" : false, // Add this line to disable indexing
"SearchServiceEndPoint": "<your application url>",
"SearchServiceAdminApiKey": "<your application admin key>",
"SearchServiceQueryApiKey": "<your application query key>"
}
```

This disables reindexing through the rebuild hook and after web page and content item events. The administration UI module is still accessible, but does not show any data.
Disabling indexing does not delete AzureSearch data from database. Already indexed data can still be accessed from your application.

## Upgrades and Uninstalling

See [Uninstall](Uninstall.md)
See [Uninstall](Uninstall.md)
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using CMS.Base;
using CMS.Base;
using CMS.ContactManagement;
bkapustik marked this conversation as resolved.
Show resolved Hide resolved
using CMS.Core;
using CMS.DataEngine;
Expand Down Expand Up @@ -40,9 +36,9 @@ public class SampleDataGeneratorApplication : OverviewPageBase

private readonly IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer;
private readonly IEventLogService eventLogService;
private readonly IConsentInfoProvider consentInfoProvider;
private readonly IBizFormInfoProvider bizFormInfoProvider;
private readonly IContactGroupInfoProvider contactGroupInfoProvider;
private readonly IInfoProvider<ConsentInfo> consentInfoProvider;
private readonly IInfoProvider<BizFormInfo> bizFormInfoProvider;
private readonly IInfoProvider<ContactGroupInfo> contactGroupInfoProvider;
private readonly ISettingsKeyInfoProvider settingsKeyInfoProvider;
private readonly IInfoProvider<WebsiteChannelInfo> websiteChannelInfoProvider;

Expand All @@ -60,9 +56,9 @@ public class SampleDataGeneratorApplication : OverviewPageBase
public SampleDataGeneratorApplication(
IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer,
IEventLogService eventLogService,
IConsentInfoProvider consentInfoProvider,
IBizFormInfoProvider bizFormInfoProvider,
IContactGroupInfoProvider contactGroupInfoProvider,
IInfoProvider<ConsentInfo> consentInfoProvider,
IInfoProvider<BizFormInfo> bizFormInfoProvider,
IInfoProvider<ContactGroupInfo> contactGroupInfoProvider,
ISettingsKeyInfoProvider settingsKeyInfoProvider,
IInfoProvider<WebsiteChannelInfo> websiteChannelInfoProvider)
{
Expand Down Expand Up @@ -131,12 +127,10 @@ private void EnableDataProtectionSamples()
}


private OverviewCard GetGdprCard()
private OverviewCard GetGdprCard() => new()
{
return new OverviewCard
{
Headline = "Set up data protection (GDPR) demo",
Actions = new[]
Headline = "Set up data protection (GDPR) demo",
Actions = new[]
{
new Kentico.Xperience.Admin.Base.Action(ActionType.Command)
{
Expand All @@ -145,16 +139,15 @@ private OverviewCard GetGdprCard()
ButtonColor = ButtonColor.Secondary
}
},
Components = new List<IOverviewCardComponent>()
Components = new List<IOverviewCardComponent>()
{
new StringContentCardComponent
{
Content = @"Generates data and enables demonstration of giving consents, personal data portability, right to access, and right to be forgotten features.
Once enabled, the demo functionality cannot be disabled. Use on demo instances only."
}
}
};
}
};


private async Task SetChannelDefaultCookieLevelToEssential(int websiteChannelId)
Expand Down
2 changes: 1 addition & 1 deletion examples/DancingGoat/Components/ComponentIdentifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public static class ComponentIdentifiers
public const string ARTICLE_TEMPLATE = "DancingGoat.Article";
public const string ARTICLE_WITH_SIDEBAR_TEMPLATE = "DancingGoat.ArticleWithSidebar";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

using Kentico.Forms.Web.Mvc;

[assembly: RegisterFormSection("DancingGoat.TitledSection", "Section with title", "~/Components/FormSections/TitledSection/_TitledSection.cshtml", Description = "Single-column section with one zone and an editable title", IconClass = "icon-rectangle-a", PropertiesType = typeof(TitledSectionProperties))]
[assembly: RegisterFormSection("DancingGoat.TitledSection", "Section with title", "~/Components/FormSections/TitledSection/_TitledSection.cshtml", Description = "Single-column section with one zone and an editable title", IconClass = "icon-rectangle-a", PropertiesType = typeof(TitledSectionProperties))]
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public sealed class ColorPickerEditorViewModel : InlineEditorViewModel
/// </summary>
public string ColorCssClass { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public abstract class InlineEditorViewModel
/// </summary>
public string PropertyName { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public sealed class TextEditorViewModel : InlineEditorViewModel
/// </summary>
public string PlaceholderText { get; set; } = "Type your text";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;

using CMS.ContactManagement;
using CMS.ContactManagement;
using CMS.DataEngine;

using DancingGoat.Personalization;
Expand Down Expand Up @@ -46,4 +43,4 @@ public override bool Evaluate()
return contact.IsInAnyContactGroup(SelectedContactGroups.Select(c => c.ObjectCodeName).ToArray());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public class ThemeSectionProperties : ISectionProperties
[DropDownComponent(Label = "Color scheme", Order = 1, Options = ";None\nsection-white;Flat white\nsection-cappuccino;Cappuccino")]
public string Theme { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public class ThreeColumnSectionProperties : ThemeSectionProperties
[TextInputComponent(Label = "Title", Order = 1)]
public string Title { get; set; }
}
}
}
12 changes: 3 additions & 9 deletions examples/DancingGoat/Components/Sections/ZoneRestrictions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using DancingGoat.Widgets;

using Kentico.PageBuilder.Web.Mvc;

using DancingGoat.Widgets;

namespace DancingGoat.Sections
{
/// <summary>
Expand Down Expand Up @@ -51,11 +48,8 @@ public static IEnumerable<string> GetWideZoneRestrictions()
}


private static IEnumerable<string> GetWidgetsIdentifiers()
{
return new ComponentDefinitionProvider<WidgetDefinition>()
private static IEnumerable<string> GetWidgetsIdentifiers() => new ComponentDefinitionProvider<WidgetDefinition>()
.GetAll()
.Select(definition => definition.Identifier);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using CMS.Websites;
using CMS.Websites;

using DancingGoat.Models;

Expand Down Expand Up @@ -41,7 +37,7 @@ public ArticlesViewComponent(

public async Task<ViewViewComponentResult> InvokeAsync(WebPageRelatedItem articlesSectionItem)
{
var languageName = currentLanguageRetriever.Get();
string languageName = currentLanguageRetriever.Get();

var articlesSection = await articlesSectionRepository.GetArticlesSection(articlesSectionItem.WebPageGuid, languageName);
if (articlesSection == null)
Expand All @@ -59,11 +55,11 @@ public async Task<ViewViewComponentResult> InvokeAsync(WebPageRelatedItem articl
models.Add(model);
}

var url = (await urlRetriever.Retrieve(articlesSection, languageName)).RelativePath;
string url = (await urlRetriever.Retrieve(articlesSection, languageName)).RelativePath;

var viewModel = ArticlesSectionViewModel.GetViewModel(models, url);

return View("~/Components/ViewComponents/Articles/Default.cshtml", viewModel);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace DancingGoat.ViewComponents
/// </summary>
public class BannerViewComponent : ViewComponent
{
public ViewViewComponentResult Invoke(BannerViewModel banner)
{
return View("~/Components/ViewComponents/Banner/Default.cshtml", banner);
}
public ViewViewComponentResult Invoke(BannerViewModel banner) => View("~/Components/ViewComponents/Banner/Default.cshtml", banner);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace DancingGoat.ViewComponents
/// </summary>
public class CafeViewComponent : ViewComponent
{
public ViewViewComponentResult Invoke(CafeViewModel cafe)
{
return View("~/Components/ViewComponents/Cafe/Default.cshtml", cafe);
}
public ViewViewComponentResult Invoke(CafeViewModel cafe) => View("~/Components/ViewComponents/Cafe/Default.cshtml", cafe);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;

using DancingGoat.Models;
using DancingGoat.Models;

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewComponents;
Expand All @@ -11,11 +8,8 @@ namespace DancingGoat.ViewComponents
/// <summary>
/// Cafe card section view component.
/// </summary>
public class CafeCardSectionViewComponent: ViewComponent
public class CafeCardSectionViewComponent : ViewComponent
{
public ViewViewComponentResult Invoke(IEnumerable<CafeViewModel> cafes)
{
return View("~/Components/ViewComponents/CafeCardSection/Default.cshtml", cafes.Take(3));
}
public ViewViewComponentResult Invoke(IEnumerable<CafeViewModel> cafes) => View("~/Components/ViewComponents/CafeCardSection/Default.cshtml", cafes.Take(3));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Threading.Tasks;

using DancingGoat.Models;
using DancingGoat.Models;

using Kentico.Content.Web.Mvc.Routing;

Expand All @@ -23,7 +21,7 @@ public CompanyAddressViewComponent(ContactRepository contactRepository, IPreferr

public async Task<IViewComponentResult> InvokeAsync()
{
var languageName = currentLanguageRetriever.Get();
string languageName = currentLanguageRetriever.Get();
var contact = await contactRepository.GetContact(languageName, HttpContext.RequestAborted);
var model = ContactViewModel.GetViewModel(contact);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DancingGoat.Models;
using DancingGoat.Search;

using Kentico.Content.Web.Mvc.Routing;

using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using CMS.Helpers;
using CMS.Helpers;
using CMS.Websites;
using CMS.Websites.Routing;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Linq;
using System.Threading.Tasks;

using DancingGoat.Models;
using DancingGoat.Models;

using Kentico.Content.Web.Mvc.Routing;

Expand All @@ -23,7 +20,7 @@ public SocialLinksViewComponent(SocialLinkRepository socialLinkRepository, IPref

public async Task<IViewComponentResult> InvokeAsync()
{
var languageName = currentLanguageRetriever.Get();
string languageName = currentLanguageRetriever.Get();

var socialLinks = await socialLinkRepository.GetSocialLinks(languageName, HttpContext.RequestAborted);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Threading.Tasks;

using CMS.ContactManagement;
using CMS.ContactManagement;
using CMS.DataEngine;
using CMS.DataProtection;
using CMS.Websites;
using CMS.Websites.Routing;
Expand All @@ -17,7 +16,7 @@ namespace DancingGoat.ViewComponents
{
public class TrackingConsentViewComponent : ViewComponent
{
private readonly IConsentInfoProvider consentInfoProvider;
private readonly IInfoProvider<ConsentInfo> consentInfoProvider;
private readonly IConsentAgreementService consentAgreementService;
private readonly IPreferredLanguageRetriever currentLanguageRetriever;
private readonly IWebPageDataContextRetriever webPageDataContextRetriever;
Expand All @@ -26,7 +25,7 @@ public class TrackingConsentViewComponent : ViewComponent


public TrackingConsentViewComponent(
IConsentInfoProvider consentInfoProvider,
IInfoProvider<ConsentInfo> consentInfoProvider,
IConsentAgreementService consentAgreementService,
IPreferredLanguageRetriever currentLanguageRetriever,
IWebPageDataContextRetriever webPageDataContextRetriever,
Expand All @@ -48,7 +47,7 @@ public async Task<IViewComponentResult> InvokeAsync()

if (consent != null)
{
var currentLanguage = currentLanguageRetriever.Get();
string currentLanguage = currentLanguageRetriever.Get();
var consentModel = new ConsentViewModel
{
ConsentShortText = (await consent.GetConsentTextAsync(currentLanguage)).ShortText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public class CTAButtonWidgetViewModel
/// </summary>
public bool OpenInNewTab { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;

using CMS.ContentEngine;
using CMS.ContentEngine;

using Kentico.PageBuilder.Web.Mvc;
using Kentico.Xperience.Admin.Base.FormAnnotations;
Expand All @@ -23,4 +21,4 @@ public class CardWidgetProperties : IWidgetProperties
/// </summary>
public string Text { get; set; }
}
}
}
Loading
Loading