Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Admin: Open source Option Types/Values/Developer tools (#12244)
Damian Legawiec76e0d1e186f4
diff --git a/admin/app/controllers/spree/admin/oauth_applications_controller.rb b/admin/app/controllers/spree/admin/oauth_applications_controller.rbnew file mode 100644index 0000000000..21de825d17--- /dev/null+++ b/admin/app/controllers/spree/admin/oauth_applications_controller.rb@@ -0,0 +1,27 @@+module Spree+ module Admin+ class OauthApplicationsController < ResourceController+ before_action :set_default_scopes, only: [:new, :edit]++ private++ def collection+ return @collection if @collection.present?++ @collection = super++ params[:q] ||= {}+ @search = @collection.ransack(params[:q])+ @collection = @search.result.page(params[:page]).per(500)+ end++ def create_turbo_stream_enabled?+ true+ end++ def set_default_scopes+ @object.scopes = 'admin' if @object.scopes.blank?+ end+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/option_types_controller.rb b/admin/app/controllers/spree/admin/option_types_controller.rbnew file mode 100644index 0000000000..d0f4908ed7--- /dev/null+++ b/admin/app/controllers/spree/admin/option_types_controller.rb@@ -0,0 +1,23 @@+module Spree+ module Admin+ class OptionTypesController < ResourceController+ before_action :setup_new_option_value, only: :edit++ private++ def collection+ return @collection if @collection.present?++ @collection = super++ params[:q] ||= {}+ @search = @collection.ransack(params[:q])+ @collection = @search.result.all+ end++ def setup_new_option_value+ @option_type.option_values.build if @option_type.option_values.empty?+ end+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/option_values_controller.rb b/admin/app/controllers/spree/admin/option_values_controller.rbnew file mode 100644index 0000000000..1b9d1cb3af--- /dev/null+++ b/admin/app/controllers/spree/admin/option_values_controller.rb@@ -0,0 +1,17 @@+module Spree+ module Admin+ class OptionValuesController < ResourceController+ belongs_to 'spree/option_type', find_by: :id++ private++ def update_turbo_stream_enabled?+ true+ end++ def location_after_save+ spree.edit_admin_option_type_path(@parent)+ end+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/roles_controller.rb b/admin/app/controllers/spree/admin/roles_controller.rbnew file mode 100644index 0000000000..4adbce634f--- /dev/null+++ b/admin/app/controllers/spree/admin/roles_controller.rb@@ -0,0 +1,6 @@+module Spree+ module Admin+ class RolesController < ResourceController+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/shipping_categories_controller.rb b/admin/app/controllers/spree/admin/shipping_categories_controller.rbnew file mode 100644index 0000000000..e9d1677027--- /dev/null+++ b/admin/app/controllers/spree/admin/shipping_categories_controller.rb@@ -0,0 +1,6 @@+module Spree+ module Admin+ class ShippingCategoriesController < ResourceController+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/webhooks_subscribers_controller.rb b/admin/app/controllers/spree/admin/webhooks_subscribers_controller.rbnew file mode 100644index 0000000000..5b249a9b0a--- /dev/null+++ b/admin/app/controllers/spree/admin/webhooks_subscribers_controller.rb@@ -0,0 +1,48 @@+module Spree+ module Admin+ class WebhooksSubscribersController < ResourceController+ create.before :process_subscriptions+ update.before :process_subscriptions++ def index+ params[:q] ||= {}+ params[:q][:s] ||= 'created_at desc'++ search = Webhooks::Subscriber.accessible_by(current_ability).ransack(params[:q])+ @webhooks_subscribers = search.result.+ includes(:events).+ page(params[:page]).+ per(params[:per_page])+ end++ def show+ @webhooks_subscriber = Webhooks::Subscriber.find(params[:id])+ @events = @webhooks_subscriber.events.order(created_at: :desc).page(params[:page]).per(params[:per_page])+ end++ private++ def resource+ @resource ||= Spree::Admin::Resource.new 'spree/admin/webhooks/subscribers', 'subscribers', nil+ end++ def process_subscriptions+ params[:webhooks_subscriber][:subscriptions] = if params[:subscribe_to_all_events] == 'true'+ ['*']+ else+ selected_events+ end++ params[:webhooks_subscriber] = params[:webhooks_subscriber].except(*supported_events.keys)+ end++ def selected_events+ supported_events.select { |resource, _events| params[:webhooks_subscriber][resource] == 'true' }.values.flatten+ end++ def supported_events+ @supported_events ||= Spree::Webhooks::Subscriber.supported_events+ end+ end+ end+enddiff --git a/admin/app/views/spree/admin/oauth_applications/_form.html.erb b/admin/app/views/spree/admin/oauth_applications/_form.html.erbnew file mode 100644index 0000000000..4d8751fbff--- /dev/null+++ b/admin/app/views/spree/admin/oauth_applications/_form.html.erb@@ -0,0 +1,11 @@+<div class="form-group">+ <%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>+ <%= f.text_field :name, class: 'form-control', required: true %>+ <%= f.error_message_on :name %>+</div>++<div class="form-group">+ <%= f.label :scopes, raw(Spree.t(:scopes) + required_span_tag) %>+ <%= f.select :scopes, [['Read Only', 'admin read'], ['Read & Write', 'admin write']], { selected: @oauth_application.scopes.to_s }, { class: 'custom-select' } %>+ <%= f.error_message_on :scopes %>+</div>diff --git a/admin/app/views/spree/admin/oauth_applications/create.turbo_stream.erb b/admin/app/views/spree/admin/oauth_applications/create.turbo_stream.erbnew file mode 100644index 0000000000..b07d9e6036--- /dev/null+++ b/admin/app/views/spree/admin/oauth_applications/create.turbo_stream.erb@@ -0,0 +1,41 @@+<%= turbo_stream.replace "new_oauth_application" do %>+ <div class="card">+ <div class="card-body">+ <div data-controller="clipboard" class="mb-3">+ <div class="form-group">+ <%= label_tag :client_id, 'Client ID' %>+ <div class="input-group">+ <%= text_area_tag :client_id, @object.uid, class: 'form-control', rows: 1, data: { clipboard_target: 'source', action: 'clipboard#copy' }, readonly: true %>+ <div class="input-append">+ <button data-action="clipboard#copy" class="btn btn-light">+ <%= icon 'clone.svg', class: 'mr-2' %>+ <%= Spree.t(:copy_to_clipboard, scope: :admin ) %>+ </button>+ </div>+ </div>+ </div>+ </div>++ <div data-controller="clipboard" class="mb-3">+ <div class="form-group">+ <%= label_tag :client_secret, 'Client Secret' %>+ <div class="input-group">+ <%= text_area_tag :client_secret, @object.plaintext_secret, class: 'form-control', rows: 1, data: { clipboard_target: 'source', action: 'clipboard#copy' }, readonly: true %>+ <div class="input-append">+ <button data-action="clipboard#copy" class="btn btn-light">+ <%= icon 'clone.svg', class: 'mr-2' %>+ <%= Spree.t(:copy_to_clipboard, scope: :admin ) %>+ </button>+ </div>+ </div>+ <div class="alert alert-warning mt-3">+ This is your application's secret token, copy it now and keep it safe. It won't be shown again.+ </div>+ </div>+ </div>+ </div>+ <div class="card-footer">+ <%= link_to 'Back to list', spree.admin_oauth_applications_url, class: 'btn btn-light' %>+ </div>+ </div>+<% end %>diff --git a/admin/app/views/spree/admin/oauth_applications/edit.html.erb b/admin/app/views/spree/admin/oauth_applications/edit.html.erbnew file mode 100644index 0000000000..2b23aa1952--- /dev/null+++ b/admin/app/views/spree/admin/oauth_applications/edit.html.erb@@ -0,0 +1,19 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_oauth_applications_url %>+ <%= @oauth_application.name.capitalize %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @oauth_application } %>++<div class="row">+ <div class="col-lg-6">+ <%= form_for [:admin, @oauth_application] do |f| %>+ <div class="card mb-4">+ <div class="card-body">+ <%= render 'form', f: f %>+ </div>+ </div>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+ <% end %>+ </div>+</div>diff --git a/admin/app/views/spree/admin/oauth_applications/index.html.erb b/admin/app/views/spree/admin/oauth_applications/index.html.erbnew file mode 100644index 0000000000..8dc9d1cece--- /dev/null+++ b/admin/app/views/spree/admin/oauth_applications/index.html.erb@@ -0,0 +1,75 @@+<%= render 'spree/admin/shared/developers_nav' %>++<%= content_for(:title, 'API Keys') %>++<% content_for :page_actions do %>+ <%= button_link_to 'New API key', new_object_url, class: "btn-primary", icon: 'plus', id: 'admin_new_role_link' %>+<% end if can? :create, Spree::OauthApplication %>++<%= content_for :page_alerts do %>+ <div class="alert alert-info mb-3">+ <p>+ Here you can manage API keys to access the <%= link_to 'Platform API', 'https://developers.getvendo.com/reference/authentication-2' %>.+ For headless storefronts you don't need an API key, please use the <%= link_to 'Storefront API', 'https://developers.getvendo.com/reference/api-getting-started' %>.+ </p>+ </div>+<% end %>++<% if @oauth_applications.any? %>+ <div class="table-responsive rounded border mt-4 bg-white shadow-xs">+ <table class="table">+ <thead class="text-muted">+ <tr data-hook="admin_roles_index_headers">+ <th><%= Spree.t(:name) %></th>+ <th>Client ID</th>+ <th><%= Spree.t('admin.oauth_applications.scopes') %></th>+ <th><%= Spree.t('admin.oauth_applications.last_used') %></th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody>+ <% @oauth_applications.each do |application| %>+ <tr id="<%= spree_dom_id application %>" data-hook="admin_roles_index_rows">+ <td class="w-20"><%= application.name %></td>+ <td class="w-40">+ <div class="input-group" data-controller="password-toggle">+ <%= button_tag class: 'btn hover-gray px-1', data: { action: 'click->password-toggle#password' } do %>+ <%= icon 'eye', class: 'mr-0' %>+ <% end %>+ <%= password_field_tag :password, application.uid, class: 'form-control-plaintext', data: { password_toggle_target: 'unhide' }, readonly: true %>+ </div>+ </td>+ <td class="w-15">+ <% if application.scopes.include?('write') %>+ <span class="badge badge-warning">+ <%= icon('pencil', class: 'mr-1') %>+ Read & Write+ </span>+ <% else %>+ <span class="badge badge-light">+ <%= icon('eye', class: 'mr-1') %>+ Read Only+ </span>+ <% end %>+ </td>+ <td class="w-15">+ <% if application.last_used_at %>+ <%= application.last_used_at.to_s %>+ <% else %>+ <span class="text-muted"><%= Spree.t('admin.oauth_applications.never') %></span>+ <% end %>+ </td>+ <td class="actions w-10">+ <%= link_to_edit(application, no_text: true) if can? :edit, application %>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+ </div>+<% else %>+ <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">+ <%= Spree.t(:no_resource_found, resource: 'API keys') %>,+ <%= link_to_with_icon('plus', Spree.t(:add_one), new_object_url, class: 'btn btn-link') if can? :create, Spree::OauthApplication %>+ </div>+<% end %>diff --git a/admin/app/views/spree/admin/oauth_applications/new.html.erb b/admin/app/views/spree/admin/oauth_applications/new.html.erbnew file mode 100644index 0000000000..0abdf22d5f--- /dev/null+++ b/admin/app/views/spree/admin/oauth_applications/new.html.erb@@ -0,0 +1,25 @@+<%= content_for :title do %>+ <%= Spree.t('admin.oauth_applications.new') %>+<% end %>++<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_oauth_applications_url %>+ <%= Spree.t('admin.oauth_applications.new') %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @oauth_application } %>++<div class="row">+ <div class="col-lg-6">+ <%= turbo_frame_tag 'new_oauth_application' do %>+ <%= form_for [:admin, @oauth_application] do |f| %>+ <div class="card mb-4">+ <div class="card-body">+ <%= render 'form', f: f %>+ </div>+ </div>+ <%= render 'spree/admin/shared/new_resource_links' %>+ <% end %>+ <% end %>+ </div>+</div>\ No newline at end of filediff --git a/admin/app/views/spree/admin/option_types/_filter.html.erb b/admin/app/views/spree/admin/option_types/_filter.html.erbnew file mode 100644index 0000000000..eeb21da5f6--- /dev/null+++ b/admin/app/views/spree/admin/option_types/_filter.html.erb@@ -0,0 +1,9 @@+<%= search_form_for [:admin, @search] do |f| %>+ <div class="form-group">+ <%= f.label :name_cont, Spree.t(:name) %>+ <%= f.text_field :name_cont, class: "form-control js-quick-search-target js-filterable" %>+ </div>+ <div class="form-actions">+ <%= button Spree.t(:search), 'search' %>+ </div>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/option_types/_form.html.erb b/admin/app/views/spree/admin/option_types/_form.html.erbnew file mode 100644index 0000000000..0e8493b7cc--- /dev/null+++ b/admin/app/views/spree/admin/option_types/_form.html.erb@@ -0,0 +1,89 @@+<div class="card mb-4">+ <div class="card-header">+ <h5 class="mb-0"><%= Spree.t(:general_information) %></h5>+ </div>+ <div class="card-body" data-controller="slug-form">+ <div class="row">+ <div class="col-md-6">+ <div class="form-group">+ <%= f.label :presentation, raw(Spree.t(:presentation) + required_span_tag) %>+ <%= f.text_field :presentation, class: "form-control", required: true, autofocus: f.object.new_record?, data: { slug_form_target: :name, action: 'slug-form#updateUrlFromName' } %>+ <%= f.error_message_on :presentation %>+ <p class="text-muted form-text mt-2 mb-0">+ This is used to display the option type on the storefront.+ </p>+ </div>+ </div>++ <div class="col-md-6">+ <div class="form-group">+ <%= f.label :name, Spree.t(:internal_name) %>+ <%= f.text_field :name, class: "form-control", data: { slug_form_target: :url } %>+ <%= f.error_message_on :name %>+ <p class="text-muted form-text mt-2 mb-0">+ This is used internally to identify the option type. <strong>It must be unique.</strong>+ </p>+ </div>+ </div>+ </div>+ <div class="row">+ <div class="col-12 col-md-6">+ <div class="form-group mb-0">+ <div class="custom-control custom-checkbox mb-3">+ <%= f.check_box :filterable, class: "custom-control-input", id: "option_type_filterable" %>+ <%= f.label :filterable, Spree.t(:filterable), class: "custom-control-label", for: "option_type_filterable" %>+ </div>+ <small class="form-text text-muted">+ <%= raw Spree.t('option_type_filterable_info') %>+ </small>+ </div>+ </div>+ </div>+ </div>+ </div>++ <template data-nested-form-target="template">+ <%= f.fields_for :option_values, Spree::OptionValue.new, child_index: 'NEW_RECORD' do |option_value_form| %>+ <%= render "option_value_fields", f: option_value_form %>+ <% end %>+ </template>++ <div class="card mb-4">+ <div class="card-header d-flex justify-content-between align-items-center">+ <h5 class="mb-0"><%= Spree.t(:option_values) %></h5>+ </div>+ <div class="card-body p-0">+ <div class="table-responsive">+ <table class="table table-condensed">+ <thead data-hook="option_header" class="text-muted border-bottom">+ <tr>+ <th></th>+ <th><%= raw(Spree.t(:presentation) + required_span_tag) %></th>+ <th><%= raw(Spree.t(:internal_name) + required_span_tag) %></th>+ <th></th>+ </tr>+ </thead>+ <tbody id="option_values" data-controller="sortable" data-sortable-handle-value=".move-handle" data-sortable-resource-name-value="option_value" data-sortable-response-kind-value="turbo-stream">+ <% @option_type.option_values.build if @option_type.option_values.empty? %>+ <%= f.fields_for :option_values do |option_value_form| %>+ <%= render partial: 'option_value_fields', locals: { f: option_value_form, option_type: @option_type } %>+ <% end %>++ <!-- Inserted elements will be injected before that target. -->+ <tr data-nested-form-target="target"></tr>++ <tr>+ <td></td>+ <td colspan="2" class="text-center">+ <button type="button" data-action="nested-form#add" class="btn btn-link" id="add_option_value_button">+ <%= icon('plus') %>+ <%= Spree.t(:add_one) %>+ </button>+ </td>+ <td></td>+ </tr>+ </tbody>+ </table>+ </div>+ </div>+ </div>diff --git a/admin/app/views/spree/admin/option_types/_option_type.html.erb b/admin/app/views/spree/admin/option_types/_option_type.html.erbnew file mode 100644index 0000000000..73ca760b62--- /dev/null+++ b/admin/app/views/spree/admin/option_types/_option_type.html.erb@@ -0,0 +1,19 @@+<tr id="<%= spree_dom_id option_type %>" data-controller="row-link" data-sortable-update-url="<%= spree.admin_option_type_path(option_type) %>">+ <td class="move-handle text-center w-5">+ <%= icon('grip-vertical', class: 'rounded hover-gray p-2') %>+ </td>+ <td class="w-20 cursor-pointer" data-action="click->row-link#openLink"><code><%= option_type.name %></code></td>+ <td class="w-35 cursor-pointer font-weight-bold" data-action="click->row-link#openLink"><%= option_type.presentation %></td>+ <td class="w-10 cursor-pointer" data-action="click->row-link#openLink">+ <%= active_badge(option_type.filterable) %>+ </td>+ <td class="w-10 cursor-pointer" data-action="click->row-link#openLink">+ <%= option_type.option_values.count %>+ </td>+ <td class="w-10 cursor-pointer" data-action="click->row-link#openLink">+ <%= option_type.products.count %>+ </td>+ <td class="w-10 actions cursor-pointer">+ <%= link_to_edit option_type, data: { row_link_target: :link } %>+ </td>+</tr>diff --git a/admin/app/views/spree/admin/option_types/_option_value_fields.html.erb b/admin/app/views/spree/admin/option_types/_option_value_fields.html.erbnew file mode 100644index 0000000000..9958a40b56--- /dev/null+++ b/admin/app/views/spree/admin/option_types/_option_value_fields.html.erb@@ -0,0 +1,29 @@+<tr class="nested-form-wrapper"+ data-new-record="<%= f.object.new_record? %>"+ data-controller="slug-form"+ <% if f.object.id.present? %>+ id="spree_<%= dom_id(f.object) %>"+ data-sortable-update-url="<%= spree.admin_option_type_option_value_path(option_type, f.object) %>"+ <% else %>+ id="spree_new_option_value"+ <% end %>+ >+ <td class="w-5 <%= f.object.id.present? ? 'move-handle text-center' : 'text-center' %>">+ <% if f.object.id.present? %>+ <%= icon('grip-vertical', class: 'rounded hover-gray p-2') %>+ <% end %>+ <%= f.hidden_field :id %>+ </td>+ <td class="w-45 presentation">+ <%= f.text_field :presentation, class: "form-control", data: { slug_form_target: :name, action: 'slug-form#updateUrlFromName' } %>+ </td>+ <td class="w-40 name">+ <%= f.text_field :name, class: "form-control", data: { slug_form_target: :url } %>+ </td>+ <td class="w-10 actions">+ <button type="button" class="btn btn-danger btn-sm remove_option_value_button" data-action="nested-form#remove">+ <%= icon('trash', class: 'mr-0') %>+ </button>+ <%= f.hidden_field :_destroy %>+ </td>+</tr>diff --git a/admin/app/views/spree/admin/option_types/edit.html.erb b/admin/app/views/spree/admin/option_types/edit.html.erbnew file mode 100644index 0000000000..029aae44f0--- /dev/null+++ b/admin/app/views/spree/admin/option_types/edit.html.erb@@ -0,0 +1,11 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_option_types_url %>+ <%= @option_type.name %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @option_type } %>++<%= form_for [:admin, @option_type], data: { controller: 'nested-form', nested_form_wrapper_selector_value: '.nested-form-wrapper' } do |f| %>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+<% end %>diff --git a/admin/app/views/spree/admin/option_types/index.html.erb b/admin/app/views/spree/admin/option_types/index.html.erbnew file mode 100644index 0000000000..4d0df7fd8d--- /dev/null+++ b/admin/app/views/spree/admin/option_types/index.html.erb@@ -0,0 +1,56 @@+<% content_for :page_title do %>+ <%= Spree.t(:options) %>+<% end %>++<% content_for :page_actions do %>+ <span id="new_ot_link">+ <%= button_link_to Spree.t(:new_option_type), new_object_url, { class: "btn-primary", icon: 'plus', id: 'new_option_type_link' } %>+ </span>+<% end if can?(:create, Spree::OptionType) %>++<%= content_for(:page_alerts) do %>+ <div class="alert alert-info">+ Options are used to group certain attributes. For example, you can create an option named "shirt size" and then create an option value named "small" and "medium" for this option.+ </div>+<% end %>++<div id="new_option_type"></div>+ <% content_for :table_filter do %>+ <%= render partial: 'spree/admin/option_types/filter' %>+ <% end %>++<% if @option_types.any? %>+ <div class="table-responsive">+ <table class="table" id="listing_option_types">+ <thead class="text-muted">+ <tr data-hook="option_header">+ <th class="no-border handel-head"></th>+ <th><%= Spree.t(:internal_name) %></th>+ <th>+ <%= Spree.t(:presentation) %>+ <%= help_bubble('How this option is presented to customers') %>+ </th>+ <th>+ <%= Spree.t(:filterable) %>+ <%= help_bubble('Whether this option can be used in product filters') %>+ </th>+ <th>+ <%= Spree.t(:option_values) %>+ </th>+ <th>+ <%= Spree.t(:products) %>+ </th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody data-controller="sortable" data-sortable-handle-value=".move-handle" data-sortable-resource-name-value="option_type" data-sortable-response-kind-value="turbo-stream">+ <%= render partial: 'spree/admin/option_types/option_type', collection: @option_types %>+ </tbody>+ </table>+ </div>+<% else %>+ <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center">+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::OptionType)) %>+ <%= link_to_with_icon 'plus', Spree.t(:add_one), new_object_url, class: 'btn btn-link' if can?(:create, Spree::OptionType) %>+ </div>+<% end %>diff --git a/admin/app/views/spree/admin/option_types/new.html.erb b/admin/app/views/spree/admin/option_types/new.html.erbnew file mode 100644index 0000000000..38a4d7b977--- /dev/null+++ b/admin/app/views/spree/admin/option_types/new.html.erb@@ -0,0 +1,11 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_option_types_path %>+ <%= Spree.t(:new_option_type) %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @option_type } %>++<%= form_for [:admin, @option_type], data: { controller: 'nested-form', nested_form_wrapper_selector_value: '.nested-form-wrapper' } do |f| %>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/new_resource_links' %>+<% end %>diff --git a/admin/app/views/spree/admin/option_types/update.turbo_stream.erb b/admin/app/views/spree/admin/option_types/update.turbo_stream.erbnew file mode 100644index 0000000000..d9fb79328e--- /dev/null+++ b/admin/app/views/spree/admin/option_types/update.turbo_stream.erb@@ -0,0 +1 @@+<%= turbo_render_alerts %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/option_values/destroy.turbo_stream.erb b/admin/app/views/spree/admin/option_values/destroy.turbo_stream.erbnew file mode 100644index 0000000000..b9045b9623--- /dev/null+++ b/admin/app/views/spree/admin/option_values/destroy.turbo_stream.erb@@ -0,0 +1 @@+<%= turbo_stream.remove spree_dom_id(@option_value) %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/roles/_form.html.erb b/admin/app/views/spree/admin/roles/_form.html.erbnew file mode 100644index 0000000000..ef287d490a--- /dev/null+++ b/admin/app/views/spree/admin/roles/_form.html.erb@@ -0,0 +1,6 @@+<div class="form-group">+ <%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>+ <%= f.text_field :name, class: 'form-control' %>+ <%= f.error_message_on :name %>+<% end %>+diff --git a/admin/app/views/spree/admin/roles/edit.html.erb b/admin/app/views/spree/admin/roles/edit.html.erbnew file mode 100644index 0000000000..87b6d8f5c8--- /dev/null+++ b/admin/app/views/spree/admin/roles/edit.html.erb@@ -0,0 +1,13 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_roles_url %>+ <%= @role.name.capitalize %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @role } %>++<%= form_for [:admin, @role] do |f| %>+ <fieldset>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+ </fieldset>+<% end %>diff --git a/admin/app/views/spree/admin/roles/index.html.erb b/admin/app/views/spree/admin/roles/index.html.erbnew file mode 100644index 0000000000..184fcd0d3b--- /dev/null+++ b/admin/app/views/spree/admin/roles/index.html.erb@@ -0,0 +1,35 @@+<% content_for :page_title do %>+ <%= Spree.t(:roles) %>+<% end %>++<% content_for :page_actions do %>+ <%= button_link_to Spree.t(:new_role), new_object_url, class: "btn-primary", icon: 'plus', id: 'admin_new_role_link' %>+<% end if can? :create, Spree::Role %>++<% if @roles.any? %>+ <div class="table-responsive card-lg p-0">+ <table class="table">+ <thead class="text-muted">+ <tr data-hook="admin_roles_index_headers">+ <th><%= Spree.t(:role_id) %></th>+ <th class="actions"></th>+ </tr>+ </thead>+ <tbody>+ <% @roles.each do |role| %>+ <tr id="<%= spree_dom_id role %>" data-hook="admin_roles_index_rows">+ <td><%= role.name %></td>+ <td class="actions">+ <%= link_to_edit(role, no_text: true) if can? :edit, role %>+ </td>+ </tr>+ <% end %>+ </tbody>+ </table>+ </div>+<% else %>+ <div class="alert alert-warning">+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Role)) %>+ <%= link_to_with_icon('plus', Spree.t(:add_one), new_object_url, class: 'btn btn-link') if can? :create, Spree::Role %>+ </div>+<% end %>diff --git a/admin/app/views/spree/admin/roles/new.html.erb b/admin/app/views/spree/admin/roles/new.html.erbnew file mode 100644index 0000000000..d5704a6301--- /dev/null+++ b/admin/app/views/spree/admin/roles/new.html.erb@@ -0,0 +1,15 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_roles_url %>+ <%= Spree.t(:new_role) %>+<% end %>++<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @role } %>++<%= form_for [:admin, @role] do |f| %>+ <div class="card mb-4">+ <div class="card-body">+ <%= render 'form', f: f %>+ </div>+ </div>+ <%= render 'spree/admin/shared/new_resource_links' %>+<% end %>diff --git a/admin/app/views/spree/admin/shared/_developers_nav.html.erb b/admin/app/views/spree/admin/shared/_developers_nav.html.erbnew file mode 100644index 0000000000..bfa5bec5a4--- /dev/null+++ b/admin/app/views/spree/admin/shared/_developers_nav.html.erb@@ -0,0 +1,7 @@+<%= content_for :page_title do %>+ <%= Spree.t(:developers) %>+<% end %>+<%= content_for :page_tabs do %>+ <%= nav_pill_list_item(:api_keys, label: Spree.t(:api_keys), url: spree.admin_oauth_applications_path) %>+ <%= nav_pill_list_item(:webhooks, label: Spree.t(:webhooks), url: spree.admin_webhooks_subscribers_path) %>+<% end %>diff --git a/admin/app/views/spree/admin/shared/_shipping_nav.html.erb b/admin/app/views/spree/admin/shared/_shipping_nav.html.erbnew file mode 100644index 0000000000..1bc1c4a697--- /dev/null+++ b/admin/app/views/spree/admin/shared/_shipping_nav.html.erb@@ -0,0 +1,4 @@+<%= content_for(:page_tabs) do %>+ <%= nav_pill_list_item(:shipping_methods, url: spree.admin_shipping_methods_path, active: controller_name == 'shipping_methods' && action_name == 'index') if can?(:manage, Spree::ShippingMethod) %>+ <%= nav_pill_list_item(:shipping_categories, url: spree.admin_shipping_categories_path) if can?(:manage, Spree::ShippingCategory) %>+<% end %>diff --git a/admin/app/views/spree/admin/webhook_events/_webhook_event.html.erb b/admin/app/views/spree/admin/webhook_events/_webhook_event.html.erbnew file mode 100644index 0000000000..9c625462b7--- /dev/null+++ b/admin/app/views/spree/admin/webhook_events/_webhook_event.html.erb@@ -0,0 +1,17 @@+<tr id="<%= spree_dom_id webhook_event %>">+ <td><span class="badge badge-light"><%= webhook_event.name %></span></td>+ <td><%= active_badge(webhook_event.success) %></td>+ <td><%= local_time(webhook_event.created_at) %></td>+ <td>+ <% if webhook_event.response_code%>+ <code><%= webhook_event.response_code %></code></td>+ <% end %>+ <td>+ <% if webhook_event.execution_time %>+ <code><%= webhook_event.execution_time %>ms</code>+ <% end %>+ </td>+ <td>+ <%= sanitize webhook_event.request_errors&.gsub('[SPREE WEBHOOKS]', '') if webhook_event.request_errors.present? && !webhook_event.success? %>+ </td>+</tr>\ No newline at end of filediff --git a/admin/app/views/spree/admin/webhooks_subscribers/_form.html.erb b/admin/app/views/spree/admin/webhooks_subscribers/_form.html.erbnew file mode 100644index 0000000000..0aad346fa1--- /dev/null+++ b/admin/app/views/spree/admin/webhooks_subscribers/_form.html.erb@@ -0,0 +1,66 @@+<div class="row">+ <div class="col-12 col-lg-6">+ <div class="card mb-4">+ <div class="card-header">+ <h5 class="card-title">+ <%= Spree.t(:general_settings) %>+ </h5>+ </div>+ <div class="card-body pb-0">+ <div class="row">+ <div class="form-group col-12">+ <%= f.label :url, raw(Spree.t('admin.url') + required_span_tag) %>+ <%= f.text_field :url, class: 'form-control', placeholder: 'https://example.com/endpoint' %>+ <%= f.error_message_on :url %>+ </div>+ <div class="form-group col-3">+ <div class="custom-control custom-switch">+ <%= f.check_box :active, class: 'custom-control-input' %>+ <%= f.label :active, class: 'custom-control-label' %>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+ <div class="col-12 col-lg-6">+ <div class="card mb-4">+ <div class="card-header">+ <h5 class="card-title">+ <%= Spree.t('admin.webhooks_subscribers.webhooks_events') %>+ </h5>+ </div>+ <div class="card-body pb-0" data-controller="webhooks-subscriber-events">+ <div class="form-group">+ <div>+ <div class="radio my-2">+ <%= radio_button_tag :subscribe_to_all_events, true,+ subscribe_to_all_events?,+ {+ 'data-action' => 'webhooks-subscriber-events#hideCheckboxes',+ 'data-webhooks-subscriber-events-target' => 'subscribeToAll',+ class: 'events' } %>+ <%= label_tag :subscribe_to_all_events_true, Spree.t('admin.webhooks_subscribers.subscribe_to_all_events') %>+ </div>+ <div class="radio my-2">+ <%= radio_button_tag :subscribe_to_all_events, false,+ !subscribe_to_all_events?,+ { 'data-action' => 'webhooks-subscriber-events#showCheckboxes',+ class: 'events' } %>+ <%= label_tag :subscribe_to_all_events_false, Spree.t('admin.webhooks_subscribers.select_events') %>+ </div>+ </div>+ <br/>+ <div data-webhooks-subscriber-events-target="eventsCheckboxesContainer" class="<%= subscribe_to_all_events? ? 'd-none' : '' %>">+ <div class="row" >+ <% Spree::Webhooks::Subscriber.supported_events.each_with_index do |se, index| %>+ <% record, _ = se %>+ <%= event_checkbox_for(record, f) %>+ <% end %>+ </div>+ </div>+ </div>+ </div>+ </div>+ </div>+</div>diff --git a/admin/app/views/spree/admin/webhooks_subscribers/_webhooks_subscriber.html.erb b/admin/app/views/spree/admin/webhooks_subscribers/_webhooks_subscriber.html.erbnew file mode 100644index 0000000000..4bc07c43d2--- /dev/null+++ b/admin/app/views/spree/admin/webhooks_subscribers/_webhooks_subscriber.html.erb@@ -0,0 +1,16 @@+<tr id="<%= spree_dom_id webhooks_subscriber %>" data-controller="row-link" class="cursor-pointer">+ <td data-action="click->row-link#openLink">+ <%= webhooks_subscriber.url %>+ </td>+ <td data-action="click->row-link#openLink"><%= active_badge(webhooks_subscriber.active) %></td>+ <td class="w-20" data-action="click->row-link#openLink">+ <% webhooks_subscriber.subscriptions&.sort&.each do |subscription| %>+ <span class="badge badge-light"><%= subscription %></span>+ <% end %>+ </td>+ <td data-action="click->row-link#openLink"><%= local_time(webhooks_subscriber.latest_event_at) %></td>+ <td class="actions">+ <%= link_to_with_icon 'eye', Spree.t(:view), admin_webhooks_subscriber_path(webhooks_subscriber), class: "btn btn-light btn-sm", data: { row_link_target: 'link' } %>+ <%= link_to_edit(webhooks_subscriber) if can? :edit, webhooks_subscriber %>+ </td>+</tr>diff --git a/admin/app/views/spree/admin/webhooks_subscribers/edit.html.erb b/admin/app/views/spree/admin/webhooks_subscribers/edit.html.erbnew file mode 100644index 0000000000..451ee10d4e--- /dev/null+++ b/admin/app/views/spree/admin/webhooks_subscribers/edit.html.erb@@ -0,0 +1,9 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_webhooks_subscribers_path %>+ <%= @webhooks_subscriber.url %>+<% end %>+<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @webhooks_subscriber } %>+<%= form_for [:admin, @webhooks_subscriber] do |f| %>+ <%= render 'form', f: f %>+ <%= render 'spree/admin/shared/edit_resource_links', f: f %>+<% end %>diff --git a/admin/app/views/spree/admin/webhooks_subscribers/index.html.erb b/admin/app/views/spree/admin/webhooks_subscribers/index.html.erbnew file mode 100644index 0000000000..020a37530d--- /dev/null+++ b/admin/app/views/spree/admin/webhooks_subscribers/index.html.erb@@ -0,0 +1,29 @@+<%= render 'spree/admin/shared/developers_nav' %>++<% content_for :page_actions do %>+ <%= button_link_to Spree.t('admin.webhooks_subscribers.new_webhooks_subscriber'), new_object_url, class: "btn-primary", icon: 'add.svg', id: 'admin_new_webhooks_subscriber_link' %>+<% end if can?(:create, Spree::Webhooks::Subscriber) %>+<% if @webhooks_subscribers.any? %>+ <div class="border rounded bg-white">+ <table class="table">+ <thead class="text-muted">+ <tr>+ <th><%= Spree.t('admin.url') %></th>+ <th><%= Spree.t('admin.active') %></th>+ <th><%= Spree.t('admin.webhooks_subscribers.subscriptions') %></th>+ <th><%= Spree.t('admin.webhooks_subscribers.time_of_last_event') %></th>+ <th></th>+ </tr>+ </thead>+ <tbody>+ <%= render partial: 'spree/admin/webhooks_subscribers/webhooks_subscriber', collection: @webhooks_subscribers, cached: spree_base_cache_scope %>+ </tbody>+ </table>+ </div>+ <%= render 'spree/admin/shared/index_table_options', collection: @webhooks_subscribers, simple: true %>+<% else %>+ <div class="text-center no-objects-found m-5">+ <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Webhooks::Subscriber)) %>+ <%= link_to_with_icon('plus', Spree.t(:add_one), new_object_url) if can? :create, Spree::Webhooks::Subscriber %>!+ </div>+<% end %>diff --git a/admin/app/views/spree/admin/webhooks_subscribers/new.html.erb b/admin/app/views/spree/admin/webhooks_subscribers/new.html.erbnew file mode 100644index 0000000000..0fb2373261--- /dev/null+++ b/admin/app/views/spree/admin/webhooks_subscribers/new.html.erb@@ -0,0 +1,11 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_webhooks_subscribers_path %>+ <%= Spree.t('admin.webhooks_subscribers.new_webhooks_subscriber') %>+<% end %>+<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @webhooks_subscriber } %>+<%= form_for [:admin, @webhooks_subscriber] do |f| %>+ <fieldset>+ <%= render partial: 'form', locals: { f: f } %>+ <%= render partial: 'spree/admin/shared/new_resource_links' %>+ </fieldset>+<% end %>diff --git a/admin/app/views/spree/admin/webhooks_subscribers/show.html.erb b/admin/app/views/spree/admin/webhooks_subscribers/show.html.erbnew file mode 100644index 0000000000..496ce76e0b--- /dev/null+++ b/admin/app/views/spree/admin/webhooks_subscribers/show.html.erb@@ -0,0 +1,54 @@+<% content_for :page_title do %>+ <%= page_header_back_button spree.admin_webhooks_subscribers_path %>+ <%= @webhooks_subscriber.url %>+<% end %>+<fieldset class="card mb-4">+ <table class="table card-body pb-0">+ <tr>+ <td><strong class="text-uppercase"><%= Spree.t('admin.url') %></strong></td>+ <td><%= external_link_to @webhooks_subscriber.url, @webhooks_subscriber.url %></td>+ </tr>+ <tr>+ <td><strong><%= Spree.t('admin.active') %></strong></td>+ <td><%= active_badge(@webhooks_subscriber.active) %></td>+ </tr>+ <tr>+ <td><strong><%= Spree.t('admin.webhooks_subscribers.subscriptions') %></strong></td>+ <td>+ <% @webhooks_subscriber.subscriptions&.sort&.each do |subscription| %>+ <span class="badge badge-light"><%= subscription %></span>+ <% end %>+ </td>+ </tr>+ </table>+</fieldset>+<% if @events.any? %>+ <div class="card mb-4">+ <div class="card-header">+ <h5 class="card-title">+ <%= Spree.t('admin.webhooks_subscribers.webhooks_events') %>+ </h5>+ </div>+ <table class="table card-body pb-0">+ <thead class="text-muted">+ <tr>+ <th><%= Spree.t('admin.name') %></th>+ <th><%= Spree.t('admin.successful') %></th>+ <th><%= Spree.t('admin.created_at') %></th>+ <th><%= Spree.t('admin.response_code') %></th>+ <th><%= Spree.t('admin.execution_time') %></th>+ <th><%= Spree.t('admin.errors') %></th>+ <th></th>+ </tr>+ </thead>+ <tbody>+ <%= render partial: 'spree/admin/webhook_events/webhook_event', collection: @events, cached: spree_base_cache_scope %>+ </tbody>+ </table>+ <%= render 'spree/admin/shared/index_table_options', collection: @events, simple: true %>+ </div>+<% else %>+ <div class="text-center no-objects-found m-5">+ <%= Spree.t('admin.webhooks_subscribers.no_events') %>+ </div>+<% end %>diff --git a/admin/config/routes.rb b/admin/config/routes.rbindex 9a46882930..bbc779f1e0 100644--- a/admin/config/routes.rb+++ b/admin/config/routes.rb@@ -1,7 +1,10 @@Spree::Core::Engine.add_routes donamespace :admin, path: Spree.admin_path do# product catalog- resources :properties+ resources :properties, except: :show+ resources :option_types, except: :show do+ resources :option_values, only: [:update]+ end# media libraryresources :assets, only: [:create, :edit, :update, :destroy] do@@ -32,5 +35,12 @@ Spree::Core::Engine.add_routes doput :mark_as_defaultendend++ # account management+ resources :roles, except: :show++ # developer tools+ resources :oauth_applications+ resources :webhooks_subscribersendenddiff --git a/core/lib/generators/spree/install/install_generator.rb b/core/lib/generators/spree/install/install_generator.rbindex 417893373d..534526a6d1 100644--- a/core/lib/generators/spree/install/install_generator.rb+++ b/core/lib/generators/spree/install/install_generator.rb@@ -75,8 +75,8 @@ module Spreeenddef install_admin- if @install_admin && Spree::Core::Engine.backend_available?- generate 'spree:backend:install'+ if @install_admin && Spree::Core::Engine.admin_available?+ generate 'spree:admin:install'endend