Skip to content

Commit

Permalink
Fix SectionDisplayDriver prefix (#15123)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Jan 22, 2024
1 parent 70bf068 commit 49b57fd
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public override IDisplayResult Edit(AzureAISearchSettings settings)
.ToList();
}).Location("Content:2#Azure AI Search;5")
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, AzureAISearchIndexPermissionHelper.ManageAzureAISearchIndexes))
.Prefix(Prefix)
.OnGroup(SearchConstants.SearchSettingsGroupId);

public override async Task<IDisplayResult> UpdateAsync(AzureAISearchSettings section, BuildEditorContext context)
Expand Down Expand Up @@ -106,16 +105,6 @@ public override async Task<IDisplayResult> UpdateAsync(AzureAISearchSettings sec
return Edit(section);
}

protected override void BuildPrefix(ISite model, string htmlFieldPrefix)
{
Prefix = typeof(AzureAISearchSettings).Name;

if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = htmlFieldPrefix + "." + Prefix;
}
}

private static bool AreTheSame(string[] a, string[] b)
{
if (a == null && b == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public override IDisplayResult Edit(ElasticSettings settings)
];
}).Location("Content:2#Elasticsearch;10")
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, Permissions.ManageElasticIndexes))
.Prefix(Prefix)
.OnGroup(SearchConstants.SearchSettingsGroupId);

public override async Task<IDisplayResult> UpdateAsync(ElasticSettings section, BuildEditorContext context)
Expand Down Expand Up @@ -116,14 +115,4 @@ public override async Task<IDisplayResult> UpdateAsync(ElasticSettings section,

return await EditAsync(section, context);
}

protected override void BuildPrefix(ISite model, string htmlFieldPrefix)
{
Prefix = typeof(ElasticSettings).Name;

if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = htmlFieldPrefix + "." + Prefix;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public override async Task<IDisplayResult> EditAsync(LuceneSettings settings, Bu
model.SearchIndexes = (await _luceneIndexSettingsService.GetSettingsAsync()).Select(x => x.IndexName);
model.AllowLuceneQueriesInSearch = settings.AllowLuceneQueriesInSearch;
}).Location("Content:2#Lucene;15")
.Prefix(Prefix)
.OnGroup(SearchConstants.SearchSettingsGroupId);
}

Expand Down Expand Up @@ -68,15 +67,5 @@ public override async Task<IDisplayResult> UpdateAsync(LuceneSettings section, B

return await EditAsync(section, context);
}

protected override void BuildPrefix(ISite model, string htmlFieldPrefix)
{
Prefix = typeof(LuceneSettings).Name;

if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = htmlFieldPrefix + "." + Prefix;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public override async Task<IDisplayResult> EditAsync(SearchSettings settings, Bu
model.Placeholder = settings.Placeholder;
model.PageTitle = settings.PageTitle;
model.ProviderName = settings.ProviderName;
}).Location("Content:2").OnGroup(SearchConstants.SearchSettingsGroupId);
}).Location("Content:2")
.OnGroup(SearchConstants.SearchSettingsGroupId);
}

public override async Task<IDisplayResult> UpdateAsync(SearchSettings section, BuildEditorContext context)
Expand Down Expand Up @@ -81,16 +82,5 @@ public override async Task<IDisplayResult> UpdateAsync(SearchSettings section, B

return await EditAsync(section, context);
}

protected override void BuildPrefix(ISite model, string htmlFieldPrefix)
{
Prefix = typeof(SearchSettings).Name;

if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = htmlFieldPrefix + "." + Prefix;
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public override IDisplayResult Edit(SmsSettings settings)
}).Location("Content:1#Providers")
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, SmsPermissions.ManageSmsSettings))
.Prefix(Prefix)
.OnGroup(SmsSettings.GroupId);

public override async Task<IDisplayResult> UpdateAsync(SmsSettings settings, BuildEditorContext context)
Expand Down Expand Up @@ -90,14 +89,4 @@ public override async Task<IDisplayResult> UpdateAsync(SmsSettings settings, Bui

return Edit(settings);
}

protected override void BuildPrefix(ISite model, string htmlFieldPrefix)
{
Prefix = typeof(SmsSettings).Name;

if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = htmlFieldPrefix + "." + Prefix;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public override IDisplayResult Edit(TwilioSettings settings)
model.HasAuthToken = !string.IsNullOrEmpty(settings.AuthToken);
}).Location("Content:5#Twilio")
.RenderWhen(() => _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, SmsPermissions.ManageSmsSettings))
.Prefix(Prefix)
.OnGroup(SmsSettings.GroupId);
}

Expand Down Expand Up @@ -150,14 +149,4 @@ public override async Task<IDisplayResult> UpdateAsync(ISite site, TwilioSetting

return Edit(settings);
}

protected override void BuildPrefix(ISite model, string htmlFieldPrefix)
{
Prefix = typeof(TwilioSettings).Name;

if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = htmlFieldPrefix + "." + Prefix;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,17 @@ private TSection GetSection(TModel model)
? property.ToObject<TSection>()
: new TSection();
}

protected override void BuildPrefix(TModel model, string htmlFieldPrefix)
{
if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = $"{htmlFieldPrefix}.{typeof(TModel).Name}.{typeof(TSection).Name}";
}
else
{
Prefix = $"{typeof(TModel).Name}.{typeof(TSection).Name}";
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Threading.Tasks;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
Expand Down Expand Up @@ -115,11 +114,13 @@ public virtual Task<IDisplayResult> UpdateAsync(TModel model, IUpdateModel updat

protected virtual void BuildPrefix(TModel model, string htmlFieldPrefix)
{
Prefix = typeof(TModel).Name;

if (!string.IsNullOrEmpty(htmlFieldPrefix))
{
Prefix = htmlFieldPrefix + "." + Prefix;
Prefix = $"{htmlFieldPrefix}.{typeof(TModel).Name}";
}
else
{
Prefix = typeof(TModel).Name;
}
}
}
Expand Down

0 comments on commit 49b57fd

Please sign in to comment.