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

Fix SectionDisplayDriver prefix #15123

Merged
merged 3 commits into from
Jan 22, 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
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