From c3b98ba3c45d50ce7b464a44948d48aa12877407 Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Sat, 7 Dec 2024 20:48:21 +0100 Subject: [PATCH 1/2] #8819: Compile workflow should run at least one of the SpecFlow tests (#8820) * Using Title Casing in the Compile workflow's step names * Adding step to run the Setup with SpecFlow * Fixing typo * Fixing that upgrading Newtonsoft.Json to 13.x broke the SpecFlow test execution app --- .github/workflows/compile.yml | 25 +++++++++++-------- .../Hosting/Orchard.Web/Web.config | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index eb46871bea7..9ba1a9c85b8 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -16,13 +16,13 @@ jobs: shell: pwsh runs-on: windows-latest steps: - - name: Clone repository + - name: Clone Repository uses: actions/checkout@v4.1.1 - - name: Restore NuGet packages + - name: Restore NuGet Packages run: nuget restore src/Orchard.sln - - name: Add msbuild to PATH + - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v2 - name: Compile @@ -31,14 +31,19 @@ jobs: - name: Test run: msbuild Orchard.proj /m /v:minimal /t:Test - - name: Run Orchard setup + - name: Test Setup with SpecFlow + run: | + $nunitConsole = (Get-ChildItem -Path 'src/packages' -Recurse -Filter 'nunit-console.exe' | Select-Object -Last 1).FullName + & $nunitConsole 'build/Compile/Orchard.Specs.dll' /xml='build/Orchard.Specs.xml' /run=Orchard.Specs.SetupFeature.RootAndSetupFolderShowsSetupScreenAndFormValuesAreValidated + + - name: Run Orchard Setup with Orchard.exe run: | $commandFile = 'src/Orchard.Web/bin/setup-commands.txt' New-Item -Path $commandFile -ItemType File -Force Set-Content -Path $commandFile -Value 'setup /SiteName:Orchard /AdminUsername:admin /AdminPassword:Password1! /DatabaseProvider:SqlCe /Recipe:Default' & 'src/Orchard.Web/bin/Orchard.exe' @$commandFile - - name: Run code generation + - name: Run Code Generation run: | $commandFile = 'src/Orchard.Web/bin/codegen-commands.txt' New-Item -Path $commandFile -ItemType File -Force @@ -50,17 +55,17 @@ jobs: '@ & 'src/Orchard.Web/bin/Orchard.exe' @$commandFile - - name: Compile with generated projects + - name: Compile Again with Generated Projects run: msbuild Orchard.proj /m /v:minimal /t:Compile /p:TreatWarningsAsErrors=true -WarnAsError /NoWarn:CS2008 compile-node: - name: Compile client-side assets + name: Compile Client-side Assets defaults: run: shell: pwsh runs-on: windows-latest steps: - - name: Clone repository + - name: Clone Repository uses: actions/checkout@v4.1.1 - name: Setup NodeJS @@ -68,7 +73,7 @@ jobs: with: node-version: '7' - - name: Setup NPM packages + - name: Setup NPM Packages working-directory: ./src run: | npm install --loglevel warn @@ -77,7 +82,7 @@ jobs: $gulpVersion = (Get-Content Package.json -Raw | ConvertFrom-Json).devDependencies.gulp Start-Process npm -NoNewWindow -Wait -ArgumentList "install gulp@$gulpVersion -g --loglevel warn" - - name: Rebuild client-side assets + - name: Rebuild Client-side Assets working-directory: ./src run: | gulp rebuild diff --git a/src/Orchard.Specs/Hosting/Orchard.Web/Web.config b/src/Orchard.Specs/Hosting/Orchard.Web/Web.config index 593d2ac20f5..0c84ea8c46e 100644 --- a/src/Orchard.Specs/Hosting/Orchard.Web/Web.config +++ b/src/Orchard.Specs/Hosting/Orchard.Web/Web.config @@ -151,7 +151,7 @@ - + From 1c40b8ba9363f99cae56c724fbaa3564d2a0b335 Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Tue, 10 Dec 2024 09:30:58 +0100 Subject: [PATCH 2/2] #8808: Fixing Container admin navigation (#8809) * Fixing that Core.Containers "Show on admin menu" functionality shouldn't depend on the Orchard.Lists feature * Moving menu.list.png admin menu icon from Orchard.Lists to Core.Containers as menu.container.png to fix that Containers should have a default admin menu icon * Fixing conflict between lists and container admin navicon by applying the unused menu.list-definition.png to lists * Code styling and removing duplicate code --- src/Orchard.Web/Core/Containers/AdminMenu.cs | 93 +++++++++++++++++ .../Core/Containers/Styles/Web.config | 12 +++ .../Styles/images/menu.container.png} | Bin .../Styles/menu.container-admin.css | 7 ++ src/Orchard.Web/Core/Orchard.Core.csproj | 6 ++ .../Modules/Orchard.Lists/AdminMenu.cs | 97 ++---------------- .../Orchard.Lists/Orchard.Lists.csproj | 7 +- ...enu.list-definition.png => menu.lists.png} | Bin .../Orchard.Lists/Styles/menu.list-admin.css | 22 ---- .../Orchard.Lists/Styles/menu.lists-admin.css | 7 ++ 10 files changed, 135 insertions(+), 116 deletions(-) create mode 100644 src/Orchard.Web/Core/Containers/AdminMenu.cs create mode 100644 src/Orchard.Web/Core/Containers/Styles/Web.config rename src/Orchard.Web/{Modules/Orchard.Lists/Styles/images/menu.list.png => Core/Containers/Styles/images/menu.container.png} (100%) create mode 100644 src/Orchard.Web/Core/Containers/Styles/menu.container-admin.css rename src/Orchard.Web/Modules/Orchard.Lists/Styles/images/{menu.list-definition.png => menu.lists.png} (100%) delete mode 100644 src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.list-admin.css create mode 100644 src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.lists-admin.css diff --git a/src/Orchard.Web/Core/Containers/AdminMenu.cs b/src/Orchard.Web/Core/Containers/AdminMenu.cs new file mode 100644 index 00000000000..cc5fd9b527d --- /dev/null +++ b/src/Orchard.Web/Core/Containers/AdminMenu.cs @@ -0,0 +1,93 @@ +using System.Linq; +using Orchard.ContentManagement; +using Orchard.Core.Containers.Models; +using Orchard.Core.Containers.Services; +using Orchard.Localization; +using Orchard.Security; +using Orchard.UI.Navigation; +using Orchard.Utility.Extensions; + +namespace Orchard.Core.Containers { + public class AdminMenu : INavigationProvider { + private readonly IContainerService _containerService; + private readonly IContentManager _contentManager; + private readonly IAuthorizationService _authorizationService; + private readonly IWorkContextAccessor _workContextAccessor; + + public AdminMenu( + IContainerService containerService, + IContentManager contentManager, + IAuthorizationService authorizationService, + IWorkContextAccessor workContextAccessor) { + _containerService = containerService; + _contentManager = contentManager; + _authorizationService = authorizationService; + _workContextAccessor = workContextAccessor; + } + + public Localizer T { get; set; } + public string MenuName { get { return "admin"; } } + + public void GetNavigation(NavigationBuilder builder) { + builder.AddImageSet("container"); + + var containers = _containerService + .GetContainersQuery(VersionOptions.Latest) + .Where(x => x.ShowOnAdminMenu) + .List() + .Where(content => _authorizationService.TryCheckAccess( + Contents.Permissions.EditContent, + _workContextAccessor.GetContext().CurrentUser, + content)) + .ToList(); + + foreach (var container in containers) { + var closureContainer = container; + + if (!string.IsNullOrWhiteSpace(container.AdminMenuImageSet)) { + builder.AddImageSet(container.AdminMenuImageSet.Trim()); + } + + builder.Add(T(container.AdminMenuText), container.AdminMenuPosition, item => { + var containedItems = _containerService.GetContentItems(closureContainer.Id, VersionOptions.Latest).ToList(); + var actualContainer = closureContainer; + var position = 0; + + // If the list has just a single item that happens to be a container itself, + // we will treat that one as the actual container to provide a nice & quick way to manage that list. + if (containedItems.Count == 1) { + var containedItem = containedItems.First().As(); + + if (containedItem != null) { + actualContainer = containedItem; + foreach (var itemContentType in containedItem.ItemContentTypes) { + var closureItemContentType = itemContentType; + item.Add(T("New {0}", itemContentType.DisplayName), string.Format("1.{0}", position++), subItem => subItem + .Action("Create", "Admin", new { + id = closureItemContentType.Name, + containerid = containedItem.Id, + area = "Contents" + })); + } + } + } + + item.Action(_contentManager.GetItemMetadata(actualContainer).AdminRouteValues) + .AddClass("section-container") + .AddClass(closureContainer.AdminMenuText.HtmlClassify()) + .LinkToFirstChild(false); + + foreach (var itemContentType in closureContainer.ItemContentTypes) { + var closureItemContentType = itemContentType; + item.Add(T("New {0}", itemContentType.DisplayName), string.Format("1.{0}", position++), subItem => subItem + .Action("Create", "Admin", new { + id = closureItemContentType.Name, + containerid = container.Id, + area = "Contents" + })); + } + }); + } + } + } +} diff --git a/src/Orchard.Web/Core/Containers/Styles/Web.config b/src/Orchard.Web/Core/Containers/Styles/Web.config new file mode 100644 index 00000000000..93eab9a7372 --- /dev/null +++ b/src/Orchard.Web/Core/Containers/Styles/Web.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Styles/images/menu.list.png b/src/Orchard.Web/Core/Containers/Styles/images/menu.container.png similarity index 100% rename from src/Orchard.Web/Modules/Orchard.Lists/Styles/images/menu.list.png rename to src/Orchard.Web/Core/Containers/Styles/images/menu.container.png diff --git a/src/Orchard.Web/Core/Containers/Styles/menu.container-admin.css b/src/Orchard.Web/Core/Containers/Styles/menu.container-admin.css new file mode 100644 index 00000000000..a795a07ced9 --- /dev/null +++ b/src/Orchard.Web/Core/Containers/Styles/menu.container-admin.css @@ -0,0 +1,7 @@ +.menu-admin > .section-container > h3 > a { + background-image: url(images/menu.container.png) !important; +} + +.menu-admin > .section-container > h3 > a:hover { + background-position: 0 -30px !important; +} diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 67072601b4f..1dc161b1544 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -119,6 +119,7 @@ + @@ -318,6 +319,8 @@ + + @@ -610,6 +613,9 @@ + + Designer + diff --git a/src/Orchard.Web/Modules/Orchard.Lists/AdminMenu.cs b/src/Orchard.Web/Modules/Orchard.Lists/AdminMenu.cs index fbb99bd8dd1..eb2ad46272d 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/AdminMenu.cs +++ b/src/Orchard.Web/Modules/Orchard.Lists/AdminMenu.cs @@ -1,98 +1,15 @@ -using System; -using System.Linq; -using Orchard.ContentManagement; -using Orchard.Core.Containers.Models; -using Orchard.Core.Containers.Services; -using Orchard.Localization; -using Orchard.Security; +using Orchard.Localization; using Orchard.UI.Navigation; -using Orchard.Utility.Extensions; namespace Orchard.Lists { public class AdminMenu : INavigationProvider { - private readonly IContainerService _containerService; - private readonly IContentManager _contentManager; - private readonly IAuthorizationService _authorizationService; - private readonly IWorkContextAccessor _workContextAccessor; - - public AdminMenu( - IContainerService containerService, - IContentManager contentManager, - IAuthorizationService authorizationService, - IWorkContextAccessor workContextAccessor - ) { - _containerService = containerService; - _contentManager = contentManager; - _authorizationService = authorizationService; - _workContextAccessor = workContextAccessor; - } - public Localizer T { get; set; } public string MenuName { get { return "admin"; } } - public void GetNavigation(NavigationBuilder builder) { - builder.AddImageSet("list"); - - CreateListManagementMenuItem(builder); - CreateListMenuItems(builder); - } - - private void CreateListManagementMenuItem(NavigationBuilder builder) { - builder.Add(T("Lists"), "11", item => item - .Action("Index", "Admin", new {area = "Orchard.Lists"}).Permission(Permissions.ManageLists) - ); - } - - private void CreateListMenuItems(NavigationBuilder builder) { - var containers = _containerService - .GetContainersQuery(VersionOptions.Latest) - .Where(x => x.ShowOnAdminMenu) - .List() - .Where(x => _authorizationService.TryCheckAccess(Orchard.Core.Contents.Permissions.EditContent, _workContextAccessor.GetContext().CurrentUser, x)) - .ToList(); - - foreach (var container in containers) { - var closureContainer = container; - - if (!String.IsNullOrWhiteSpace(container.AdminMenuImageSet)) { - builder.AddImageSet(container.AdminMenuImageSet.Trim()); - } - - builder.Add(T(container.AdminMenuText), container.AdminMenuPosition, item => { - var containedItems = _containerService.GetContentItems(closureContainer.Id, VersionOptions.Latest).ToList(); - var actualContainer = closureContainer; - var position = 0; - - // If the list has just a single item that happens to be a container itself, - // we will treat that one as the actual container to provide a nice & quick way to manage that list. - if (containedItems.Count == 1) { - var containedItem = containedItems.First().As(); - - if (containedItem != null) { - actualContainer = containedItem; - foreach (var itemContentType in containedItem.ItemContentTypes) { - var closureItemContentType = itemContentType; - item.Add(T("New {0}", itemContentType.DisplayName), String.Format("1.{0}", position++), subItem => subItem - .Action("Create", "Admin", new { id = closureItemContentType.Name, containerid = containedItem.Id, area = "Contents" })); - } - } - } - - var containerMetadata = _contentManager.GetItemMetadata(actualContainer); - item.Action(containerMetadata.AdminRouteValues); - - item.Action(containerMetadata.AdminRouteValues); - item.AddClass("nav-list"); - item.AddClass(closureContainer.AdminMenuText.HtmlClassify()); - item.LinkToFirstChild(false); - - foreach (var itemContentType in closureContainer.ItemContentTypes) { - var closureItemContentType = itemContentType; - item.Add(T("New {0}", itemContentType.DisplayName), String.Format("1.{0}", position++), subItem => subItem - .Action("Create", "Admin", new { id = closureItemContentType.Name, containerid = container.Id, area = "Contents" })); - } - }); - } - } + public void GetNavigation(NavigationBuilder builder) => + builder + .AddImageSet("lists") + .Add(T("Lists"), "11", item => item + .Action("Index", "Admin", new { area = "Orchard.Lists" }).Permission(Permissions.ManageLists)); } -} \ No newline at end of file +} diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Orchard.Lists.csproj b/src/Orchard.Web/Modules/Orchard.Lists/Orchard.Lists.csproj index 2826072e4ab..f8b3eb32f9c 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Orchard.Lists.csproj +++ b/src/Orchard.Web/Modules/Orchard.Lists/Orchard.Lists.csproj @@ -115,6 +115,7 @@ + @@ -143,16 +144,14 @@ orchard-lists-admin.js - + - list-admin.css - @@ -272,4 +271,4 @@ - + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Styles/images/menu.list-definition.png b/src/Orchard.Web/Modules/Orchard.Lists/Styles/images/menu.lists.png similarity index 100% rename from src/Orchard.Web/Modules/Orchard.Lists/Styles/images/menu.list-definition.png rename to src/Orchard.Web/Modules/Orchard.Lists/Styles/images/menu.lists.png diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.list-admin.css b/src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.list-admin.css deleted file mode 100644 index 9d43ff04990..00000000000 --- a/src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.list-admin.css +++ /dev/null @@ -1,22 +0,0 @@ -.navicon-list, -.navicon-lists, -.section-new .subnavicon-list, -.nav-list > h3 > a, -.nav-list-definition > h3 > a { - background-image:url(images/menu.list.png) !important; -} - -.navicon-list:hover, -.navicon-lists:hover, -.nav-list > h3 > a:hover, -.nav-list-definition > h3 > a:hover { - background-position:0 -30px !important; -} - -.navicon-lists { - background-image:url(images/menu.list.png) !important; -} - -.navicon-lists:hover { - background-position:0 -30px !important; -} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.lists-admin.css b/src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.lists-admin.css new file mode 100644 index 00000000000..2199b6ee82f --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Lists/Styles/menu.lists-admin.css @@ -0,0 +1,7 @@ +.navicon-lists { + background-image: url(images/menu.lists.png) !important; +} + +.navicon-lists:hover { + background-position: 0 -30px !important; +}