Skip to content

Commit

Permalink
Merge pull request #47 from Lombiq/issue/OSOE-532
Browse files Browse the repository at this point in the history
OSOE-532: Fixing analyzer violations
  • Loading branch information
sarahelsaig authored Jan 13, 2023
2 parents 641ef51 + 84859d6 commit 52ea6da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultE
if (actionRouteController == typeof(AdminController).ControllerName() &&
actionRouteArea == $"{nameof(OrchardCore)}.{nameof(OrchardCore.Tenants)}" &&
actionRouteValue is nameof(AdminController.Edit) &&
context.Result is ViewResult viewResult &&
context.Result is ViewResult &&
await _authorizationService.AuthorizeAsync(
_hca.HttpContext.User,
TenantAdminPermissions.LoginAsAdmin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,14 @@ public async Task EnableConditionallyEnabledFeaturesAsync(IFeatureInfo featureIn
.Select(keyValuePair => keyValuePair.Key)
.ToList();

// Handle multiple conditional features as well.
var conditionalFeatures = allFeatures.Where(feature => conditionalFeatureIds.Contains(feature.Id));

// During setup, Shell Descriptor can become out of sync with the DB when it comes to enabled features,
// but it's more accurate than IShellDescriptorManager's methods.
var shellDescriptor = await _shellDescriptorManager.GetShellDescriptorAsync();

// If Shell Descriptor's Features already contains a feature that is found in conditionalFeatures, remove it
// from the list.
var featuresToEnable = conditionalFeatures.ToList();
foreach (var feature in conditionalFeatures.Where(feature => shellDescriptor.Features.Contains(new ShellFeature(feature.Id))))
{
featuresToEnable.Remove(feature);
}
// from the list. Handle multiple conditional features as well.
var featuresToEnable = allFeatures.Where(feature =>
conditionalFeatureIds.Contains(feature.Id) && !shellDescriptor.Features.Contains(new ShellFeature(feature.Id)));

await _shellFeaturesManager.EnableFeaturesAsync(featuresToEnable, force: true);
}
Expand Down

0 comments on commit 52ea6da

Please sign in to comment.