diff --git a/.circleci/config.yml b/.circleci/config.yml index a0dbe00e273..1433bea522c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: browser-tools: circleci/browser-tools@1.4.6 - codecov: codecov/codecov@3.2.3 + codecov: codecov/codecov@3.3.0 executors: base: diff --git a/admin/app/components/solidus_admin/layout/navigation/account/component.html.erb b/admin/app/components/solidus_admin/layout/navigation/account/component.html.erb index 4b10ff51939..84b59dfe07e 100644 --- a/admin/app/components/solidus_admin/layout/navigation/account/component.html.erb +++ b/admin/app/components/solidus_admin/layout/navigation/account/component.html.erb @@ -1,7 +1,8 @@
> (order) do customer_email = order.user&.email diff --git a/admin/app/components/solidus_admin/orders/show/address/component.html.erb b/admin/app/components/solidus_admin/orders/show/address/component.html.erb index f3e1600f2ab..d97d4ebbefb 100644 --- a/admin/app/components/solidus_admin/orders/show/address/component.html.erb +++ b/admin/app/components/solidus_admin/orders/show/address/component.html.erb @@ -4,34 +4,26 @@ <%= render component("ui/modal").new(title: t(".title.#{@type}"), close_path: solidus_admin.order_path(@order)) do |modal| %> <%= form_for @order, url: solidus_admin.send("order_#{@type}_address_path", @order), html: { id: form_id } do |form| %>
-
+

<%= t(".subtitle.#{@type}") %>

- <% if @user&.addresses&.any? %> -
-target="addresses"> - - <%= t(".select_address") %> - <%= render component("ui/icon").new(name: 'arrow-down-s-fill', class: 'w-5 h-5') %> - - -
- <% @user.addresses.each do |address| %> - <%= tag.a( - href: solidus_admin.send("order_#{@type}_address_path", @order, address_id: address.id), - class: 'block text-black text-sm hover:bg-gray-50 p-2 mx-2 w-auto rounded-lg', - 'data-action': "#{stimulus_id}#close", - 'data-turbo-frame': address_frame_id - ) do %> - <%= format_address(address) %> - <% end %> - <% end %> -
-
+ <% if @addresses.present? %> + <%= render component('ui/dropdown').new( + text: t(".select_address"), + "data-#{stimulus_id}-target": "addresses", + class: "max-h-[26rem] overflow-y-auto" + ) do %> + <% @addresses.each do |address| %> + <%= tag.a( + format_address(address), + href: solidus_admin.send("order_#{@type}_address_path", @order, address_id: address.id), + 'data-turbo-frame': address_frame_id, + 'data-action': "#{component('ui/dropdown').stimulus_id}#close", + ) %> + <% end %> + <% end %> <% end %>
@@ -46,7 +38,7 @@ <%= render component("ui/forms/checkbox").new( name: "#{form.object_name}[#{use_attribute}]", - checked: form.object.send("#{@type}_address").new_record? || form.object.bill_address == form.object.ship_address, + checked: @address == (@type == 'ship' ? @order.bill_address : @order.ship_address), value: '1' ) %> diff --git a/admin/app/components/solidus_admin/orders/show/address/component.rb b/admin/app/components/solidus_admin/orders/show/address/component.rb index 4ab9208ebf5..343c70e4f9b 100644 --- a/admin/app/components/solidus_admin/orders/show/address/component.rb +++ b/admin/app/components/solidus_admin/orders/show/address/component.rb @@ -9,6 +9,7 @@ def initialize(order:, address:, user: nil, type: 'ship') @order = order @user = user @address = address + @addresses = user&.addresses.to_a.reject(&:new_record?) @type = validate_address_type(type) end diff --git a/admin/app/components/solidus_admin/products/index/component.rb b/admin/app/components/solidus_admin/products/index/component.rb index 5061741de40..eca8bee1509 100644 --- a/admin/app/components/solidus_admin/products/index/component.rb +++ b/admin/app/components/solidus_admin/products/index/component.rb @@ -71,7 +71,7 @@ def columns def image_column { - class_name: "w-[72px]", + col: { class: "w-[72px]" }, header: tag.span('aria-label': t('.product_image'), role: 'text'), data: ->(product) do image = product.gallery.images.first or return diff --git a/admin/app/components/solidus_admin/ui/dropdown/component.html.erb b/admin/app/components/solidus_admin/ui/dropdown/component.html.erb new file mode 100644 index 00000000000..d8c9c70aedc --- /dev/null +++ b/admin/app/components/solidus_admin/ui/dropdown/component.html.erb @@ -0,0 +1,50 @@ +
+> + " + data-action="keydown.esc-><%= stimulus_id %>#close" + > + <% if @text %> + <%= @text %> + <%= icon_tag "arrow-down-s-fill", class: SIZES.fetch(@size) %> + <% else %> + <%= icon_tag "more-line", class: SIZES.fetch(@size) %> + <% end %> + + +
+ <%= content %> +
+
diff --git a/admin/app/components/solidus_admin/ui/dropdown/component.js b/admin/app/components/solidus_admin/ui/dropdown/component.js new file mode 100644 index 00000000000..82080b800aa --- /dev/null +++ b/admin/app/components/solidus_admin/ui/dropdown/component.js @@ -0,0 +1,16 @@ +import { Controller } from '@hotwired/stimulus' +import { useClickOutside } from 'stimulus-use' + +export default class extends Controller { + connect() { + useClickOutside(this) + } + + clickOutside() { + this.close() + } + + close() { + this.element.removeAttribute('open') + } +} diff --git a/admin/app/components/solidus_admin/ui/dropdown/component.rb b/admin/app/components/solidus_admin/ui/dropdown/component.rb new file mode 100644 index 00000000000..e45707f3d01 --- /dev/null +++ b/admin/app/components/solidus_admin/ui/dropdown/component.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class SolidusAdmin::UI::Dropdown::Component < SolidusAdmin::BaseComponent + DIRECTIONS = { + left: "right-0", + right: "left-0", + } + + SIZES = { + s: "w-5 h-5", + m: "w-[22px] h-[22px]", + } + + def initialize(text: nil, size: :m, direction: :left, **attributes) + @text = text + @size = size + @attributes = attributes + @direction = direction + + @attributes[:"data-controller"] = "#{stimulus_id} #{attributes[:"data-controller"]}" + @attributes[:"data-action"] = "turbo:before-cache@window->#{stimulus_id}#close #{attributes[:"data-action"]}" + @attributes[:class] = " + #{@size == :m ? 'body-text' : 'body-small'} + #{@attributes[:class]} + " + end +end diff --git a/admin/app/components/solidus_admin/ui/dropdown/component.yml b/admin/app/components/solidus_admin/ui/dropdown/component.yml new file mode 100644 index 00000000000..fe3f3f93212 --- /dev/null +++ b/admin/app/components/solidus_admin/ui/dropdown/component.yml @@ -0,0 +1,2 @@ +en: + more: "More" diff --git a/admin/app/components/solidus_admin/ui/panel/component.html.erb b/admin/app/components/solidus_admin/ui/panel/component.html.erb index a89d6d72138..d74f69482d9 100644 --- a/admin/app/components/solidus_admin/ui/panel/component.html.erb +++ b/admin/app/components/solidus_admin/ui/panel/component.html.erb @@ -15,36 +15,10 @@ data-controller="<%= stimulus_id %>" > <% if menus? %> -
- "> - <%= render component("ui/icon").new( - name: "more-line", - class: "cursor-pointer w-[22px] h-[22px] hover:fill-gray-500 [[open]_&]:fill-gray-500" - ) %> - -
- <% menus.each do |menu| %> - <%= menu %> - <% end %> -
-
+ <%= render component('ui/dropdown').new( + size: :s, + class: "absolute top-0 right-0 m-6", + ).with_content(safe_join(menus)) %> <% end %> <% if @title %> diff --git a/admin/app/components/solidus_admin/ui/panel/component.rb b/admin/app/components/solidus_admin/ui/panel/component.rb index 2925ecebb15..b2f353eca07 100644 --- a/admin/app/components/solidus_admin/ui/panel/component.rb +++ b/admin/app/components/solidus_admin/ui/panel/component.rb @@ -21,9 +21,9 @@ class SolidusAdmin::UI::Panel::Component < SolidusAdmin::BaseComponent renders_many :menus, ->(name, url, **args) do if args[:method] - button_to(name, url, **args, class: "p-2 hover:bg-gray-25 rounded-sm text-black #{args[:class]}") + button_to(name, url, **args) else - link_to(name, url, **args, class: "p-2 hover:bg-gray-25 rounded-sm text-black #{args[:class]}") + link_to(name, url, **args) end end diff --git a/admin/app/components/solidus_admin/ui/table/component.html.erb b/admin/app/components/solidus_admin/ui/table/component.html.erb index 241ce89aa02..bf456657e1d 100644 --- a/admin/app/components/solidus_admin/ui/table/component.html.erb +++ b/admin/app/components/solidus_admin/ui/table/component.html.erb @@ -76,7 +76,7 @@ <% @columns.each do |column| %> - + "> <% end %> @@ -111,11 +111,13 @@ <% @rows.each do |row| %> + data-action="click-><%= stimulus_id %>#rowClicked" + data-<%= stimulus_id %>-url-param="<%= @row_url.call(row) %>" + <% end %> > <% @columns.each do |column| %> - <%= render_data_cell(column.data, row) %> + <%= render_data_cell(column, row) %> <% end %> <% end %> diff --git a/admin/app/components/solidus_admin/ui/table/component.js b/admin/app/components/solidus_admin/ui/table/component.js index 4f411ce4740..d8e4ca7bf54 100644 --- a/admin/app/components/solidus_admin/ui/table/component.js +++ b/admin/app/components/solidus_admin/ui/table/component.js @@ -84,14 +84,13 @@ export default class extends Controller { } rowClicked(event) { - if (event.target.closest('a') || event.target.tagName === 'BUTTON' || event.target.type === 'checkbox') return + // If the user clicked on a link, button, input or summary, skip the row url visit + if (event.target.closest("td").contains(event.target.closest("a,select,textarea,button,input,summary"))) return - const row = event.currentTarget - - if (this.modeValue === 'batch') { - this.toggleCheckbox(row) + if (this.modeValue === "batch") { + this.toggleCheckbox(event.currentTarget) } else { - this.navigateToRow(row) + window.Turbo.visit(event.params.url) } } @@ -104,12 +103,6 @@ export default class extends Controller { } } - navigateToRow(row) { - const url = row.dataset.primaryUrl - - if (url) window.location.href = url - } - render() { const selectedRows = this.checkboxTargets.filter((checkbox) => checkbox.checked) diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index 83df04be06e..8008d4f38cd 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -45,7 +45,7 @@ def initialize( prev_page_link: nil, next_page_link: nil ) - @columns = columns.map { Column.new(**_1) } + @columns = columns.map { Column.new(wrap: true, **_1) } @batch_actions = batch_actions.map { BatchAction.new(**_1) } @filters = filters.map { Filter.new(**_1) } @id = id @@ -86,7 +86,7 @@ def selectable_column "aria-label": t('.select_row'), ) }, - class_name: 'w-[52px]', + col: { class: 'w-[52px]' }, ) end @@ -148,21 +148,20 @@ def render_header_cell(cell, **attrs) }, **attrs) end - def render_data_cell(cell, data) + def render_data_cell(column, data) + cell = column.data cell = cell.call(data) if cell.respond_to?(:call) cell = data.public_send(cell) if cell.is_a?(Symbol) cell = cell.render_in(self) if cell.respond_to?(:render_in) + cell = tag.div(cell, class: "flex items-center gap-1.5 justify-start overflow-hidden") if column.wrap - tag.td( - tag.div(cell, class: "flex items-center gap-1.5"), - class: " - py-2 px-4 h-10 vertical-align-middle leading-none - [tr:last-child_&:first-child]:rounded-bl-lg [tr:last-child_&:last-child]:rounded-br-lg - ", - ) + tag.td(cell, class: " + py-2 px-4 h-10 vertical-align-middle leading-none + [tr:last-child_&:first-child]:rounded-bl-lg [tr:last-child_&:last-child]:rounded-br-lg + ") end - Column = Struct.new(:header, :data, :class_name, keyword_init: true) + Column = Struct.new(:header, :data, :col, :wrap, keyword_init: true) BatchAction = Struct.new(:display_name, :icon, :action, :method, keyword_init: true) # rubocop:disable Lint/StructNewOverride Filter = Struct.new(:presentation, :combinator, :attribute, :predicate, :options, keyword_init: true) private_constant :Column, :BatchAction, :Filter diff --git a/admin/app/components/solidus_admin/ui/thumbnail/component.rb b/admin/app/components/solidus_admin/ui/thumbnail/component.rb index 6198e4dbbad..7776e0a2ccd 100644 --- a/admin/app/components/solidus_admin/ui/thumbnail/component.rb +++ b/admin/app/components/solidus_admin/ui/thumbnail/component.rb @@ -7,23 +7,40 @@ class SolidusAdmin::UI::Thumbnail::Component < SolidusAdmin::BaseComponent l: 'h-20 w-20', }.freeze - def initialize(size: :m, **attributes) + def initialize(icon: nil, size: :m, **attributes) + @icon = icon @size = size @attributes = attributes end def call - tag.div( - tag.img( - **@attributes, - class: "object-contain h-full w-full", - ), - class: " - #{SIZES[@size]} - rounded border border-gray-100 - bg-white overflow-hidden - #{@attributes[:class]} - " - ) + icon = if @icon + icon_tag(@icon, class: "bg-gray-25 fill-gray-700 #{SIZES[@size]} p-2") + else + tag.img(**@attributes, class: "object-contain #{SIZES[@size]}") + end + + tag.div(icon, class: " + #{SIZES[@size]} + rounded border border-gray-100 + bg-white overflow-hidden + content-box + #{@attributes[:class]} + ") + end + + def self.for(record, **attrs) + case record + when Spree::PromotionAction then new(icon: "megaphone-line", **attrs) + when Spree::UnitCancel then new(icon: "close-circle-line", **attrs) + when Spree::TaxRate then new(icon: "percent-line", **attrs) + when Spree::LineItem then self.for(record.variant, **attrs) + when Spree::Product then self.for((record.images.first || record.master.images.first), **attrs) + when Spree::Variant then self.for((record.images.first || record.product), **attrs) + when Spree::Image then new(src: record.attachment&.url(:small), alt: record.alt, **attrs) + when Spree::Order then new(icon: "shopping-bag-line", **attrs) + when Spree::Shipment then new(icon: "truck-line", **attrs) + else new(icon: "question-line", **attrs) + end end end diff --git a/admin/app/components/solidus_admin/ui/toast/component.html.erb b/admin/app/components/solidus_admin/ui/toast/component.html.erb index 559fdc0dd5c..65a176f9e92 100644 --- a/admin/app/components/solidus_admin/ui/toast/component.html.erb +++ b/admin/app/components/solidus_admin/ui/toast/component.html.erb @@ -3,6 +3,7 @@ flex items-center justify-between rounded px-3 py-2 transform translate-y-full opacity-0 transition-all duration-500 + pointer-events-auto <%= SCHEMES.fetch(@scheme.to_sym).join(' ') %> " data-controller="<%= stimulus_id %>" diff --git a/admin/app/controllers/solidus_admin/addresses_controller.rb b/admin/app/controllers/solidus_admin/addresses_controller.rb index 83a8da3a91e..817d2c1f7be 100644 --- a/admin/app/controllers/solidus_admin/addresses_controller.rb +++ b/admin/app/controllers/solidus_admin/addresses_controller.rb @@ -4,18 +4,16 @@ module SolidusAdmin class AddressesController < BaseController include Spree::Core::ControllerHelpers::StrongParameters - before_action :load_order + before_action :load_order, :load_address before_action :validate_address_type def show - address = find_address || build_new_address - respond_to do |format| format.html do render component('orders/show/address').new( order: @order, user: @order.user, - address: address, + address: @address, type: address_type, ) end @@ -39,8 +37,7 @@ def update user: @order.user, address: @order.send("#{address_type}_address"), type: address_type, - status: :unprocessable_entity, - ) + ), status: :unprocessable_entity end end end @@ -48,18 +45,15 @@ def update private - def find_address + def load_address if params[:address_id].present? && @order.user - address = @order.user.addresses.find_by(id: params[:address_id]) - @order.send("#{address_type}_address=", address) if address + @address = + @order.user.addresses.find_by(id: params[:address_id]) || + @order.user.addresses.build(country: default_country) else - @order.send("#{address_type}_address") - end - end - - def build_new_address - @order.send("build_#{address_type}_address", country_id: default_country_id).tap do |address| - address.country_id ||= default_country_id if address.country.nil? + @address = + @order.public_send("#{address_type}_address") || + @order.public_send("build_#{address_type}_address", country: default_country) end end @@ -74,10 +68,10 @@ def validate_address_type end end - def default_country_id - @default_country_id ||= begin + def default_country + @default_country ||= begin country = Spree::Country.default - country.id if Spree::Country.available.exists?(id: country.id) + country if Spree::Country.available.exists?(id: country.id) end end diff --git a/admin/app/controllers/solidus_admin/orders_controller.rb b/admin/app/controllers/solidus_admin/orders_controller.rb index 8570029ffd8..9b45c6bce3b 100644 --- a/admin/app/controllers/solidus_admin/orders_controller.rb +++ b/admin/app/controllers/solidus_admin/orders_controller.rb @@ -20,6 +20,16 @@ def index end end + def new + order = Spree::Order.create!( + created_by: current_solidus_admin_user, + frontend_viewable: false, + store_id: current_store.try(:id) + ) + + redirect_to order_url(order), status: :see_other + end + def show load_order diff --git a/admin/app/views/layouts/solidus_admin/application.html.erb b/admin/app/views/layouts/solidus_admin/application.html.erb index 615cb0cab31..7c976011c2a 100644 --- a/admin/app/views/layouts/solidus_admin/application.html.erb +++ b/admin/app/views/layouts/solidus_admin/application.html.erb @@ -2,7 +2,12 @@ <%= favicon_link_tag 'solidus_admin/favicon.ico' %> + <%= solidus_admin_title %> + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= stylesheet_link_tag "inter-font", "data-turbo-track": "reload" %> <%= stylesheet_link_tag SolidusAdmin::Config.theme_path(session[:admin_light_theme]), media: '(prefers-color-scheme: light)', "data-turbo-track": "reload" %> <%= stylesheet_link_tag SolidusAdmin::Config.theme_path(session[:admin_dark_theme]), media: '(prefers-color-scheme: dark)', "data-turbo-track": "reload" %> diff --git a/admin/config/routes.rb b/admin/config/routes.rb index 6b45f676195..271e8b33b26 100644 --- a/admin/config/routes.rb +++ b/admin/config/routes.rb @@ -18,7 +18,7 @@ get 'states', to: 'countries#states' end - resources :orders, only: [:index, :show, :edit, :update] do + resources :orders, except: [:destroy] do resources :line_items, only: [:destroy, :create, :update] resource :customer resource :ship_address, only: [:show, :edit, :update], controller: "addresses", type: "ship" diff --git a/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview.rb new file mode 100644 index 00000000000..6bdbcf4b900 --- /dev/null +++ b/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +# @component "ui/dropdown" +class SolidusAdmin::UI::Dropdown::ComponentPreview < ViewComponent::Preview + include SolidusAdmin::Preview + + def overview + render_with_template + end + + # @param text text + # @param size select { choices: [s, m] } + # @param direction select { choices: [left, right] } + # @param open toggle + def playground(text: "text", size: :m, direction: :right, open: false) + render component("ui/dropdown").new( + text: text, + size: size.to_sym, + direction: direction.to_sym, + style: "float: #{direction == :left ? 'right' : 'left'}", + open: open, + ).with_content( + tag.span("Lorem ipsum dolor sit amet"), + ) + end +end diff --git a/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview/overview.html.erb b/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview/overview.html.erb new file mode 100644 index 00000000000..0bfdf48b970 --- /dev/null +++ b/admin/spec/components/previews/solidus_admin/ui/dropdown/component_preview/overview.html.erb @@ -0,0 +1,35 @@ +
+
+ More icon, direction right +
+ + <%= render current_component.new(direction: :right) do %> + <%= link_to "Link 1", "#" %> + <%= link_to "Link 2", "#" %> + <%= link_to "Link 3", "#" %> + <%= link_to "Link 4", "#" %> + <% end %> +
+ +
+
+ With text, direction right +
+ + <%= render current_component.new(direction: :right, text: "Select address") do %> + <%= link_to "Address 1", "#" %> + <%= link_to "Address 2", "#" %> + <%= link_to "Address 3", "#" %> + <%= link_to "Address 4", "#" %> + <% end %> +
+ +
+
+ Small size, long content +
+ + <%= render current_component.new(direction: :right, size: :s) do %> + <%= link_to "Address 1 Address 2 Address 3 Address 4", "#" %> + <% end %> +
diff --git a/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb index 28c7f99add7..d94b80022f8 100644 --- a/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/icon/component_preview.rb @@ -16,6 +16,6 @@ def playground(name: name_options.first) private def name_options - @name_options ||= current_component::NAMES.sample(10) + @name_options ||= current_component::NAMES.to_a.sample(10) end end diff --git a/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb b/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb index 411ebee7ee5..ed774adf1e6 100644 --- a/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb +++ b/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb @@ -1,45 +1,76 @@ -
-
- Empty -
- <% current_component::SIZES.keys.each do |size| %> - (size: <%= size.inspect %>) - <%= render current_component.new(size: size) %> - <% end %> -
+
+
+
+ Empty +
+ <% current_component::SIZES.keys.each do |size| %> + (size: <%= size.inspect %>) + <%= render current_component.new(size: size) %> + <% end %> +
-
-
- Square -
+
+
+ Square +
- <% current_component::SIZES.keys.each do |size| %> - (size: <%= size.inspect %>) - <%= render current_component.new(size: size, src: "https://placekitten.com/200/200") %> - <%= render current_component.new(size: size, src: "https://placekitten.com/20/20") %> - <% end %> -
+ <% current_component::SIZES.keys.each do |size| %> + (size: <%= size.inspect %>) + <%= render current_component.new(size: size, src: "https://placekitten.com/200/200") %> + <%= render current_component.new(size: size, src: "https://placekitten.com/20/20") %> + <% end %> +
-
-
- Portrait -
+
+
+ Portrait +
- <% current_component::SIZES.keys.each do |size| %> - (size: <%= size.inspect %>) - <%= render current_component.new(size: size, src: "https://placekitten.com/200/286") %> - <%= render current_component.new(size: size, src: "https://placekitten.com/20/28") %> - <% end %> + <% current_component::SIZES.keys.each do |size| %> + (size: <%= size.inspect %>) + <%= render current_component.new(size: size, src: "https://placekitten.com/200/286") %> + <%= render current_component.new(size: size, src: "https://placekitten.com/20/28") %> + <% end %> +
+ +
+
+ Landscape +
+ + <% current_component::SIZES.keys.each do |size| %> + (size: <%= size.inspect %>) + <%= render current_component.new(size: size, src: "https://placekitten.com/280/200") %> + <%= render current_component.new(size: size, src: "https://placekitten.com/28/20") %> + <% end %> +
-
-
- Landscape -
+

Auto thumbnail

+
+ <% product = Spree::Product.new(name: "A good product") %> + <% attachment = Object.new.tap { def _1.url(*) "https://placekitten.com/280/200"; end } %> + <% image = Spree::Image.new.tap { _1.define_singleton_method(:attachment) { attachment } } %> + <% [ + Spree::PromotionAction.new, + Spree::UnitCancel.new, + Spree::TaxRate.new, + image, + Spree::LineItem.new(variant: Spree::Variant.new(images: [image], product: product)), + Spree::Variant.new(images: [image], product: product), + Spree::Order.new, + Spree::Shipment.new, + Object.new, + ].each do |object| %> +
+
+ <%= object.class.name %> +
- <% current_component::SIZES.keys.each do |size| %> - (size: <%= size.inspect %>) - <%= render current_component.new(size: size, src: "https://placekitten.com/280/200") %> - <%= render current_component.new(size: size, src: "https://placekitten.com/28/20") %> + <% current_component::SIZES.keys.each do |size| %> + (size: <%= size.inspect %>) + <%= render current_component.for(object, size: size) %> + <% end %> +
<% end %>
diff --git a/admin/spec/components/solidus_admin/ui/dropdown/component_spec.rb b/admin/spec/components/solidus_admin/ui/dropdown/component_spec.rb new file mode 100644 index 00000000000..adda19a5ac0 --- /dev/null +++ b/admin/spec/components/solidus_admin/ui/dropdown/component_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe SolidusAdmin::UI::Dropdown::Component, type: :component do + it "renders the overview preview" do + render_preview(:overview) + end +end diff --git a/admin/spec/features/order_spec.rb b/admin/spec/features/order_spec.rb index ccd5efffeeb..5c94831c190 100644 --- a/admin/spec/features/order_spec.rb +++ b/admin/spec/features/order_spec.rb @@ -37,6 +37,65 @@ expect(page).to be_axe_clean end + it "allows setting and changing the addresses" do + create(:order, number: "R123456789", total: 19.99) + + visit "/admin/orders/R123456789/edit" + + expect(page).to have_content("Order R123456789") + open_customer_menu + click_on "Edit billing address" + expect(page).to have_css("dialog", wait: 30) + + within("dialog") do + fill_in "Name", with: "John Doe" + fill_in "Street Address", with: "1 John Doe Street" + fill_in "Street Address (cont'd)", with: "Apartment 2" + fill_in "City", with: "John Doe City" + fill_in "Zip Code", with: "12345" + fill_in "Phone", with: "555-555-5555" + select "United States", from: "order[bill_address_attributes][country_id]" + select "Alabama", from: "order[bill_address_attributes][state_id]" + click_on "Save" + end + + expect(page).to have_content("The address has been successfully updated.") + expect(page).to have_content("John Doe") + expect(page).to have_content("1 John Doe Street") + expect(page).to have_content("Apartment 2") + expect(page).to have_content("John Doe City") + expect(page).to have_content("12345") + expect(page).to have_content("United States") + expect(page).to have_content("Alabama") + expect(page).to have_content("555-555-5555") + + open_customer_menu + click_on "Edit shipping address" + expect(page).to have_css("dialog", wait: 30) + + within("dialog") do + fill_in "Name", with: "Jane Doe" + fill_in "Street Address", with: "1 Jane Doe Street" + fill_in "Street Address (cont'd)", with: "Apartment 3" + fill_in "City", with: "Jane Doe City" + fill_in "Zip Code", with: "54321" + fill_in "Phone", with: "555-555-5555" + select "United States", from: "order[ship_address_attributes][country_id]" + select "Alabama", from: "order[ship_address_attributes][state_id]" + click_on "Save" + end + + expect(page).to have_content("The address has been successfully updated.") + expect(page).to have_content("Jane Doe") + expect(page).to have_content("1 Jane Doe Street") + expect(page).to have_content("Apartment 3") + expect(page).to have_content("Jane Doe City") + expect(page).to have_content("54321") + expect(page).to have_content("United States") + expect(page).to have_content("Alabama") + expect(page).to have_content("555-555-5555") + end + context "in cart state" do it "allows managing the cart" do create(:product, name: "Just a product", slug: 'just-a-prod', price: 19.99) diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml index 8c0cd525e3a..3077f7b364d 100644 --- a/core/config/locales/en.yml +++ b/core/config/locales/en.yml @@ -1800,8 +1800,8 @@ en: name_on_card: Name on card name_or_sku: Name or SKU (enter at least first 4 characters of product name) navigation: - switch_to_legacy: Switch to legacy admin - switch_to_solidus_admin: Switch to new admin + switch_to_legacy: Show Legacy UI + switch_to_solidus_admin: Show Legacy UI negative_movement_absent_item: Cannot create negative movement for absent stock item. new: New new_adjustment: New Adjustment