-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Generic Site settings Deployment Step #6570
Conversation
Just implemented it in OrchardCore.Admin with AdminSetting for the moment. Please tell me if it is the correct way to do it:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agriffard good start :)
We're going to have to move it to generics, i.e. GenericDriver<AdminSiteSettings>
or the drivers are going to be fired multiple times for each registration. Same with the stepfactory.
And it's going to have to go into a Core project to sort out referencing.
This is easier to explain over skype. I should be free later on if you want?
src/OrchardCore.Modules/OrchardCore.Settings/Deployment/GenericSiteSettingsDeploymentStep.cs
Outdated
Show resolved
Hide resolved
For infos. But also will have to be generics, and I think in this case we can get away with out a custom factory, just a generic class, but would have to check |
Added OrchardCore.Settings.Core with generic SiteSettingsDeploymentStep, source and driver. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agriffard should be updated and working now.
For infos, @sebastienros , this had to be made to use generics, not for the step factory, but for the DisplayDriver
which needs to be a specific type, in order to only fire for that specific type.
It doesn't make me happy to use generics, but it is the right solution in this case, I think
Additionally we can't have a simple extension method to register these, because of the string localizer, which I believe needs to visibly show a variable var S = ...
in the Startup
class where we want to register these localized strings.
so
services.AddSiteSettingsPropertyDeployment<AdminSettings>(() => S["Admin settings"));
would (probably) not be found by the extractor
and
services.AddSiteSettingsPropertyDeployment<AdminSettings>((sp) => {
var S = sp.GetRequiredService<IStringLocalizer<Startup>>();
return S["Admin settings");
},
... (for the `Description`)
... etc
);
is to wordy for an extension method to be useful, I figure
<h5>@Model.Title</h5> | ||
|
||
<div class="form-group"> | ||
<span class="hint">@Model.Description</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to test here we don't get double encoding. Should be ok, but just put an accent in one of the localized values, and check the page source after to make sure the encoding is correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested is all good
@@ -189,6 +193,14 @@ public override void ConfigureServices(IServiceCollection services) | |||
services.AddScoped<IDisplayDriver<User>, UserButtonsDisplayDriver>(); | |||
|
|||
services.AddScoped<IThemeSelector, UsersThemeSelector>(); | |||
|
|||
services.AddTransient<IDeploymentSource, SiteSettingsPropertyDeploymentSource<LoginSettings>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to go in a separate startup with RequiresFeatures
just for the default login settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, please check.
...OrchardCore/OrchardCore.Settings.Core/Deployment/SiteSettingsPropertyDeploymentStepDriver.cs
Outdated
Show resolved
Hide resolved
...rchardCore/OrchardCore.Settings.Core/Deployment/SiteSettingsPropertyDeploymentStepFactory.cs
Show resolved
Hide resolved
Merged dev, and added the Taxonomy Filters settings too |
Do we keep the GraphQL settings? |
@agriffard I have evaluated and updated your list on #5558 Some of the ones you have done here, have their own recipe step, so cannot be included in a generic design. Others have secrets, so also must be custom. GraphQL is not a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agriffard I think it's good - but I've helped write some of it, so I would think that ;)
Can we demo tomorrow or review Thursday? I would like to be sure we're doing the right thing with the generics, and the localization
@@ -19,6 +19,7 @@ | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement\OrchardCore.DisplayManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Module.Targets\OrchardCore.Module.Targets.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Settings.Core\OrchardCore.Settings.Core.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this reference
@@ -16,6 +16,7 @@ | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement\OrchardCore.DisplayManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Settings.Core\OrchardCore.Settings.Core.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this reference
@@ -21,6 +21,7 @@ | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Settings.Core\OrchardCore.Settings.Core.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -18,6 +18,7 @@ | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Settings.Core\OrchardCore.Settings.Core.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -17,6 +17,7 @@ | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Settings.Core\OrchardCore.Settings.Core.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -18,6 +18,7 @@ | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Settings.Core\OrchardCore.Settings.Core.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -18,6 +18,7 @@ | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" /> | |||
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Settings.Core\OrchardCore.Settings.Core.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
<h5>@Model.Title</h5> | ||
|
||
<div class="form-group"> | ||
<span class="hint">@Model.Description</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested is all good
|
||
var siteSettings = await _siteService.GetSiteSettingsAsync(); | ||
|
||
result.Steps.Add(new JObject( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should find the property if it exists already, so it is only one step that is being added.
I will do this, while I am checking the registration with both attributes (i.e. Feature
and RequiresFeature
works ok)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agriffard have changed it to look for an existings Settings
property rather than creating a new one every time.
output changes from
"steps": [
{
"name": "Settings", <-- first Settings step
"AdminSettings": {
"DisplayMenuFilter": false
}
},
{
"name": "Settings", <-- second Settings step
"LoginSettings": {
"UseSiteTheme": false,
"UseExternalProviderIfOnlyOneDefined": false,
"DisableLocalLogin": false,
"UseScriptToSyncRoles": false,
"SyncRolesScript": null
}
}
]
"steps": [
{
"name": "Settings", <-- Single Settings step
"AdminSettings": {
"DisplayMenuFilter": false
},
"LoginSettings": {
"UseSiteTheme": false,
"UseExternalProviderIfOnlyOneDefined": false,
"DisableLocalLogin": false,
"UseScriptToSyncRoles": false,
"SyncRolesScript": null
},
"HttpsSettings": {
"EnableStrictTransportSecurity": false,
"RequireHttps": false,
"RequireHttpsPermanent": false,
"SslPort": null
}
}
]
An optimization, and makes it clearer that all the steps are contained in one
If you are happy with the change let me know, and I think we can merge it.
I've checked the Feature
and RequiresFeature
are working fine together. i.e. if you disable deployment but still have registration the startup doesn't fire.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great
I prefixed the Factory key with the name instead of suffixing it : Thanks to this, the steps will be sorted a bit more alphabetically in the modal. |
Cool, can you do the same in the
so the match I have a vague memory this is important ;) |
Fixes #5325, #5558
/cc @sebastienros @deanmarcussen As explained during today's meeting.