Skip to content

armgit / spree

Public Imported from GitHub
0

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.

V-3100 CHG hardcoded urls (#12716)

brozekae5421d24b75
diff --git a/admin/app/javascript/spree/admin/controllers/asset_uploader_controller.js b/admin/app/javascript/spree/admin/controllers/asset_uploader_controller.js
index 2dcde944ac..f845799c27 100644
--- a/admin/app/javascript/spree/admin/controllers/asset_uploader_controller.js
+++ b/admin/app/javascript/spree/admin/controllers/asset_uploader_controller.js
@@ -11,7 +11,8 @@ export default class extends Controller {
viewableType: String,
multiple: { type: Boolean, default: false },
type: { type: String, default: 'image' },
- allowedFileTypes: { type: Array, default: [] }
+ allowedFileTypes: { type: Array, default: [] },
+ adminAssetsPath: String
}
connect() {
@@ -43,7 +44,7 @@ export default class extends Controller {
}
handleSuccessResult(response) {
- post('/admin/assets', {
+ post(this.adminAssetsPathValue, {
body: JSON.stringify({
asset: {
type: this.assetClassValue,
diff --git a/admin/app/javascript/spree/admin/controllers/variants_form_controller.js b/admin/app/javascript/spree/admin/controllers/variants_form_controller.js
index 3f59b8b0ce..47cc5db20b 100644
--- a/admin/app/javascript/spree/admin/controllers/variants_form_controller.js
+++ b/admin/app/javascript/spree/admin/controllers/variants_form_controller.js
@@ -37,7 +37,8 @@ export default class extends CheckboxSelectAll {
currentStockLocationId: String,
stockLocations: Array,
optionValuesSelectOptions: Array,
- locale: String
+ locale: String,
+ adminPath: String
}
connect() {
@@ -724,7 +725,7 @@ export default class extends CheckboxSelectAll {
this.lastOptionNameId = targetInput.value
if (this.lastOptionNameId) {
- const response = await get(`/admin/option_types/${this.lastOptionNameId}/option_values/select_options`)
+ const response = await get(`${this.adminPathValue}/option_types/${this.lastOptionNameId}/option_values/select_options`)
if (response.ok) {
this.currentOptionValues[this.lastOptionNameId] = await response.json
diff --git a/admin/app/javascript/spree/admin/helpers/trix/video_embed.js b/admin/app/javascript/spree/admin/helpers/trix/video_embed.js
index d0fac3c691..7e44291b85 100644
--- a/admin/app/javascript/spree/admin/helpers/trix/video_embed.js
+++ b/admin/app/javascript/spree/admin/helpers/trix/video_embed.js
@@ -90,7 +90,7 @@ document.addEventListener("trix-attachment-remove", async function(event) {
const { attachment } = event
const { sgid } = attachment.attachment.attributes.values
- destroy(`/admin/action_text/video_embeds/${sgid}`, { responseKind: 'json' })
+ destroy(`${Spree.adminPath}/action_text/video_embeds/${sgid}`, { responseKind: 'json' })
})
function initializeTrixEditor(editor) {
@@ -129,7 +129,7 @@ function initializeTrixEditor(editor) {
errorMessage.innerHTML = ''
- const response = await post('/admin/action_text/video_embeds', { body: JSON.stringify({ url: input.value }), responseKind: 'json' })
+ const response = await post(`${Spree.adminPath}/action_text/video_embeds`, { body: JSON.stringify({ url: input.value }), responseKind: 'json' })
if (response.ok) {
const { sgid, content } = await response.json
diff --git a/admin/app/views/spree/admin/products/form/_variants.html.erb b/admin/app/views/spree/admin/products/form/_variants.html.erb
index 7182cddcf1..d96d58f38c 100644
--- a/admin/app/views/spree/admin/products/form/_variants.html.erb
+++ b/admin/app/views/spree/admin/products/form/_variants.html.erb
@@ -15,6 +15,7 @@
data-variants-form-currencies-value="<%= supported_currencies.map(&:to_s).to_json %>"
data-variants-form-current-stock-location-id-value="<%= default_stock_location_for_product(@product).id %>"
data-variants-form-stock-locations-value="<%= available_stock_locations_for_product(@product).ids.map(&:to_s).to_json %>"
+ data-variants-form-admin-path-value="<%= spree.admin_path %>"
<% if @product_options.present? %> data-variants-form-options-value="<%= @product_options.to_json %>" <% end %>
<% if @product_available_options.present? %> data-variants-form-available-options-value="<%= @product_available_options.to_json %>" <% end %>
<% if @product_stock.present? %> data-variants-form-stock-value="<%= @product_stock.to_json %>" <% end %>
diff --git a/admin/app/views/spree/admin/shared/_head.html.erb b/admin/app/views/spree/admin/shared/_head.html.erb
index 601cd81343..0c8d3632b1 100644
--- a/admin/app/views/spree/admin/shared/_head.html.erb
+++ b/admin/app/views/spree/admin/shared/_head.html.erb
@@ -51,4 +51,9 @@
<%= render 'spree/shared/google_places_api_loader' %>
-<%= render_admin_partials(:head_partials) %>
\ No newline at end of file
+<%= render_admin_partials(:head_partials) %>
+
+<script>
+ window.Spree = window.Spree || {}
+ Spree.adminPath = '<%= spree.admin_path %>'
+</script>
diff --git a/admin/app/views/spree/admin/variants/form/_media.html.erb b/admin/app/views/spree/admin/variants/form/_media.html.erb
index 6dcce38700..5429009a53 100644
--- a/admin/app/views/spree/admin/variants/form/_media.html.erb
+++ b/admin/app/views/spree/admin/variants/form/_media.html.erb
@@ -19,6 +19,7 @@
asset_uploader_viewable_id_value: viewable&.id,
asset_uploader_viewable_type_value: 'Spree::Variant',
asset_uploader_allowed_file_types_value: allowed_file_types_for_upload,
+ asset_uploader_admin_assets_path_value: spree.admin_assets_path,
action: 'asset-uploader#open',
media_form_target: 'addButton'
} do %>
diff --git a/storefront/app/javascript/spree/storefront/controllers/wished_item_controller.js b/storefront/app/javascript/spree/storefront/controllers/wished_item_controller.js
index fc79cd97aa..04ca8a59eb 100644
--- a/storefront/app/javascript/spree/storefront/controllers/wished_item_controller.js
+++ b/storefront/app/javascript/spree/storefront/controllers/wished_item_controller.js
@@ -6,6 +6,8 @@ export default class extends Controller {
static targets = ['add', 'remove']
static values = {
variantId: String,
+ createWishlistPath: String,
+ destroyWishlistPath: String
}
connect() {
@@ -27,7 +29,7 @@ export default class extends Controller {
const headers = {}
- const response = await post('/account/wishlist/wished_items', {
+ const response = await post(this.createWishlistPathValue, {
body: body,
headers: headers,
responseKind: 'turbo-stream'
@@ -45,7 +47,7 @@ export default class extends Controller {
const headers = {}
- const response = await destroy(`/account/wishlist/wished_items/${this.variantIdValue}`, {
+ const response = await destroy(this.destroyWishlistPathValue, {
headers: headers,
responseKind: 'turbo-stream'
})
diff --git a/storefront/app/views/themes/default/spree/products/_add_to_wishlist.html.erb b/storefront/app/views/themes/default/spree/products/_add_to_wishlist.html.erb
index 4cf88d1d06..eff1e1d407 100644
--- a/storefront/app/views/themes/default/spree/products/_add_to_wishlist.html.erb
+++ b/storefront/app/views/themes/default/spree/products/_add_to_wishlist.html.erb
@@ -6,6 +6,8 @@
<div class="wished-item-<%= variant.id %> h-full"
data-controller="wished-item"
data-wished-item-variant-id-value="<%= variant.id %>"
+ data-wished-item-create-wishlist-path-value="<%= spree.account_wishlist_wished_items_path %>"
+ data-wished-item-destroy-wishlist-path-value="<%= spree.account_wishlist_wished_item_path(variant.id) %>"
>
<%= button_tag type: 'submit',
class: "#{css_classes} disabled:animate-pulse",