diff --git a/.circleci/config.yml b/.circleci/config.yml index 5bf9a8e7202..1cfe68c16ab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -157,8 +157,8 @@ commands: cat /tmp/.gems-versions - restore_cache: keys: - - solidus-installer-v7-{{ checksum "/tmp/.ruby-versions" }}-{{ checksum "/tmp/.gems-versions" }} - - solidus-installer-v7-{{ checksum "/tmp/.ruby-versions" }}- + - solidus-installer-v8-{{ checksum "/tmp/.ruby-versions" }}-{{ checksum "/tmp/.gems-versions" }} + - solidus-installer-v8-{{ checksum "/tmp/.ruby-versions" }}- - run: name: "Prepare the rails application" command: | diff --git a/admin/app/components/solidus_admin/base_component.rb b/admin/app/components/solidus_admin/base_component.rb new file mode 100644 index 00000000000..e54f3c3a8b0 --- /dev/null +++ b/admin/app/components/solidus_admin/base_component.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require "solidus_admin/system/import" + +module SolidusAdmin + # BaseComponent is the base class for all components in Solidus Admin. + class BaseComponent < ViewComponent::Base + include ViewComponent::InlineTemplate + include SolidusAdmin::ContainerHelper + end +end diff --git a/admin/app/components/solidus_admin/main_nav_component.rb b/admin/app/components/solidus_admin/main_nav_component.rb new file mode 100644 index 00000000000..c8e43362d4f --- /dev/null +++ b/admin/app/components/solidus_admin/main_nav_component.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module SolidusAdmin + # Renders the main navigation of Solidus Admin. + class MainNavComponent < BaseComponent + include Import[ + "main_nav_item_component", + items: "main_nav_items" + ] + + erb_template <<~ERB + + ERB + + private + + def sorted_items + items.sort_by(&:position) + end + end +end diff --git a/admin/app/components/solidus_admin/main_nav_item_component.rb b/admin/app/components/solidus_admin/main_nav_item_component.rb new file mode 100644 index 00000000000..7f430080213 --- /dev/null +++ b/admin/app/components/solidus_admin/main_nav_item_component.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module SolidusAdmin + # Menu item within a {MainNavComponent} + class MainNavItemComponent < BaseComponent + with_collection_parameter :item + + attr_reader :item + + def initialize(item:) + @item = item + super + end + + erb_template <<~ERB + + <%= item.title %> + + ERB + end +end diff --git a/admin/app/controllers/solidus_admin/orders_controller.rb b/admin/app/controllers/solidus_admin/orders_controller.rb index c770fbf00e3..f82940f3b6d 100644 --- a/admin/app/controllers/solidus_admin/orders_controller.rb +++ b/admin/app/controllers/solidus_admin/orders_controller.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true module SolidusAdmin + # rubocop:disable Rails/ApplicationController class OrdersController < ActionController::Base layout 'solidus_admin/application' end + # rubocop:enable Rails/ApplicationController end diff --git a/admin/app/helpers/solidus_admin/container_helper.rb b/admin/app/helpers/solidus_admin/container_helper.rb new file mode 100644 index 00000000000..10397eaac79 --- /dev/null +++ b/admin/app/helpers/solidus_admin/container_helper.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "solidus_admin/container" + +module SolidusAdmin + module ContainerHelper + def container + SolidusAdmin::Container + end + + def component(name) + container.resolve("#{name}_component") + end + end +end diff --git a/admin/app/views/layouts/solidus_admin/application.html.erb b/admin/app/views/layouts/solidus_admin/application.html.erb index 4b57101556b..c407f39677a 100644 --- a/admin/app/views/layouts/solidus_admin/application.html.erb +++ b/admin/app/views/layouts/solidus_admin/application.html.erb @@ -5,6 +5,7 @@