Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:

jobs:
Rspec:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand All @@ -21,7 +21,7 @@ jobs:
- "3.4"
- "4.0"
alchemy:
- "8.3-stable"
- "8.4-stable"
- "main"
solidus:
- "v4.5"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gem "solidus_core", github: "solidusio/solidus", branch: solidus_branch
gem "solidus_backend", github: "solidusio/solidus", branch: solidus_branch
gem "solidus_frontend", github: "solidusio/solidus_frontend", branch: "main"

alchemy_branch = ENV.fetch("ALCHEMY_BRANCH", "8.3-stable")
alchemy_branch = ENV.fetch("ALCHEMY_BRANCH", "8.4-stable")
gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: alchemy_branch
gem "alchemy-devise", github: "AlchemyCMS/alchemy-devise", branch: alchemy_branch

Expand Down
28 changes: 16 additions & 12 deletions app/javascript/alchemy_solidus/components/product_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class ProductSelect extends RemoteSelect {
}

/**
* Parses server response into select2 results object
* Parses server response into a results object
* @param {object} response
* @returns {object}
* @private
Expand Down Expand Up @@ -48,24 +48,28 @@ export default class ProductSelect extends RemoteSelect {
}

/**
* result which is visible if a product was selected
* slots of a dropdown option
* @param {object} product
* @returns {string}
* @private
* @param {string} term
* @returns {object}
* @protected
*/
_renderResult(product) {
return product.name
_entry(product, term) {
return {
primary: this._hightlightTerm(product.name, term)
}
}

/**
* html template for each list entry
* slots of the selected product shown in the control
* @param {object} product
* @param {string} term
* @returns {string}
* @private
* @returns {object}
* @protected
*/
_renderListEntry(product, term) {
return this._hightlightTerm(product.name, term)
_selectedEntry(product) {
return {
primary: product.name
}
}
}

Expand Down
28 changes: 16 additions & 12 deletions app/javascript/alchemy_solidus/components/taxon_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class TaxonSelect extends RemoteSelect {
}

/**
* Parses server response into select2 results object
* Parses server response into a results object
* @param {object} response
* @returns {object}
* @private
Expand All @@ -24,24 +24,28 @@ export default class TaxonSelect extends RemoteSelect {
}

/**
* result which is visible if a taxon was selected
* slots of a dropdown option
* @param {object} taxon
* @returns {string}
* @private
* @param {string} term
* @returns {object}
* @protected
*/
_renderResult(taxon) {
return taxon.text || taxon.pretty_name
_entry(taxon, term) {
return {
primary: this._hightlightTerm(taxon.pretty_name, term)
}
}

/**
* html template for each list entry
* slots of the selected taxon shown in the control
* @param {object} taxon
* @param {string} term
* @returns {string}
* @private
* @returns {object}
* @protected
*/
_renderListEntry(taxon, term) {
return this._hightlightTerm(taxon.pretty_name, term)
_selectedEntry(taxon) {
return {
primary: taxon.text || taxon.pretty_name
}
}
}

Expand Down
47 changes: 20 additions & 27 deletions app/javascript/alchemy_solidus/components/variant_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class VariantSelect extends RemoteSelect {
}

/**
* Search query send to server from select2
* Search query send to server
* @param {string} term
* @param {number} page
* @returns {object}
Expand All @@ -28,7 +28,7 @@ export default class VariantSelect extends RemoteSelect {
}

/**
* Parses server response into select2 results object
* Parses server response into a results object
* @param {object} response
* @returns {object}
* @private
Expand All @@ -41,38 +41,31 @@ export default class VariantSelect extends RemoteSelect {
}

/**
* result which is visible if a variant was selected
* slots of a dropdown option
* @param {object} variant
* @returns {string}
* @private
* @param {string} term
* @returns {object}
* @protected
*/
_renderResult(variant) {
return variant.options_text
? `${variant.name} - ${variant.options_text}`
: variant.name
_entry(variant, term) {
return {
primary: this._hightlightTerm(variant.name, term),
secondary: variant.options_text,
secondaryAside: variant.sku
}
}

/**
* html template for each list entry
* slots of the selected variant shown in the control
* @param {object} variant
* @param {string} term
* @returns {string}
* @private
* @returns {object}
* @protected
*/
_renderListEntry(variant, term) {
const name = this._hightlightTerm(variant.name, term)
const sku = this._hightlightTerm(variant.sku, term)
return `
<div class="variant-select-result">
<div>
<span>${name}</span>
</div>
<div>
<span>${variant.options_text}</span>
<span>${sku}</span>
</div>
</div>
`
_selectedEntry(variant) {
return {
primary: variant.name,
secondary: variant.options_text
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- insert_after '[data-hook="admin_user_form_roles"]' -->

<%= f.field_container :alchemy_roles do %>
<%= label_tag nil, t(".alchemy_roles") %>
<%= admin_hint t(".alchemy_roles"), t(:alchemy_roles_html, scope: [:spree, :hints, "spree/user"]) %>
<%= f.collection_select :alchemy_roles, Alchemy.config.user_roles, :to_s, :capitalize,
{include_blank: false},
multiple: true, disabled: cannot?(:update_role, @user),
class: "select2 fullwidth" %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Alchemy
module Solidus
module SpreeAdminUsersControllerPatch
private

def permitted_user_attributes
attributes = super
attributes << {alchemy_roles: []} if can?(:update_role, @user)
attributes
end

if defined?(::Spree::Admin::UsersController)
::Spree::Admin::UsersController.prepend self
end
end
end
end
2 changes: 1 addition & 1 deletion app/patches/models/alchemy/solidus/alchemy_user_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.prepended(klass)
end

def spree_roles
if admin?
if alchemy_admin?
::Spree::Role.where(name: "admin")
else
::Spree::Role.none
Expand Down
9 changes: 1 addition & 8 deletions app/patches/models/alchemy/solidus/spree_user_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@ def alchemy_display_name
email
end

def alchemy_roles
if has_spree_role?(:admin)
%w[admin]
else
[]
end
end

if defined?(::Spree::User)
::Spree::User.prepend self
::Spree::User.include Alchemy::UserMethods
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions config/locales/alchemy_solidus.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@ de:
users: Benutzer
pictures: Bilder
attachments: Dateien
users:
form:
alchemy_roles: Alchemy Rollen
hints:
spree/user:
alchemy_roles_html: |
<p>Diese Rollen steuern den Zugriff zum Alchemy CMS.</p>
<ul>
<li><kbd>Mitglied</kbd> beschreibt regulär angemeldete Kunden und ermöglicht den Zugriff auf regulär gesicherte Seiten. Sie <strong>ermöglicht nicht</strong> auf den Admin Bereich zuzugreifen.</li>
<li><kbd>Autor</kbd> ermöglicht Seiteninhalte zu bearbeiten, aber keine Seiten zu erstellen.</li>
<li><kbd>Editor</kbd> ermöglicht vollen Zugriff auf Seiten und Sprachen.</li>
<li><kbd>Admin</kbd> ermöglicht <strong>vollen Zugriff auf alles</strong>.</li>
</ul>
33 changes: 33 additions & 0 deletions config/locales/alchemy_solidus.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
en:
alchemy:
choose_product_to_link: Choose a product to link to
link_overlay_tab_label:
product: Product
solidus:
search_variant: Search a variant by name or sku
search_product: Search a product by name
search_taxon: Search a taxon by name
spree:
admin:
tab:
cms: CMS
pages: Pages
sites: Sites
languages: Languages
tags: Tags
users: Users
pictures: Pictures
attachments: Attachments
users:
form:
alchemy_roles: Alchemy Roles
hints:
spree/user:
alchemy_roles_html: |
<p>These roles allow access to Alchemy CMS.</p>
<ul>
<li><kbd>Member</kbd> describes regular logged in customers and allows to visit regularly restricted pages. It <strong>does not</strong> grant access to the CMS backend.</li>
<li><kbd>Author</kbd> grants access to edit content but not to create pages.</li>
<li><kbd>Editor</kbd> grants access to fully manage pages and languages.</li>
<li><kbd>Admin</kbd> grants access <strong>to manage everything</strong>.</li>
</ul>
24 changes: 24 additions & 0 deletions config/locales/alchemy_solidus.it.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
it:
spree:
admin:
tab:
cms: CMS
pages: "Pagine"
sites: "Siti"
languages: "Lingue"
tags: "Tags"
pictures: "Immagini"
attachments: "File"
users:
form:
alchemy_roles: Alchemy Ruoli
hints:
spree/user:
alchemy_roles_html: |
<p>Questi ruoli consentono l'accesso ad Alchemy CMS.</p>
<ul>
<li><kbd>Membro</kbd> indica i normali clienti autenticati e consente di visitare le pagine ad accesso limitato. <strong>Non</strong> concede l'accesso al backend del CMS.</li>
<li><kbd>Autore</kbd> concede l'accesso alla modifica dei contenuti, ma non alla creazione di pagine.</li>
<li><kbd>Editore</kbd> concede l'accesso alla gestione completa di pagine e lingue.</li>
<li><kbd>Amministratore</kbd> concede l'accesso <strong>alla gestione di tutto</strong>.</li>
</ul>
20 changes: 0 additions & 20 deletions config/locales/alchemy_solidus_en.yml

This file was deleted.

11 changes: 0 additions & 11 deletions config/locales/alchemy_solidus_it.yml

This file was deleted.

5 changes: 0 additions & 5 deletions config/locales/en.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class SetAlchemyRolesOn<%= @table_name.camelcase %>Table < ActiveRecord::Migration[7.2]
def up
Spree::User.find_each do |user|
alchemy_roles = if user.has_spree_role?(:admin)
"admin"
elsif user.has_spree_role?(:user)
"member"
end
user.update_column(:alchemy_roles, alchemy_roles)
end
end

def down
Spree::User.find_each do |user|
user.update_column(:alchemy_roles, nil)
end
end
end
Loading
Loading