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.

Fix: the Customers list's Tags filter offers the store's customer tags (#14727)

Damian Legawieca862b80014fc
diff --git a/.changeset/dashboard-customer-class-name.md b/.changeset/dashboard-customer-class-name.md
new file mode 100644
index 0000000000..d93ba439e7
--- /dev/null
+++ b/.changeset/dashboard-customer-class-name.md
@@ -0,0 +1,7 @@
+---
+"@spree/dashboard": patch
+"@spree/dashboard-core": patch
+"@spree/admin-sdk": patch
+---
+
+The dashboard now refers to customers by their 6.0 class name, `Spree::Customer`, instead of the pre-6.0 `Spree::User`. This fixes the Customers list's Tags filter, which always showed "No results", along with customer permission checks and customer custom fields. `client.customFields('Spree::Customer', id)` is now supported; `'Spree::User'` keeps working until 6.1.
diff --git a/docs/developer/dashboard/customization/slots.mdx b/docs/developer/dashboard/customization/slots.mdx
index a2a58ce7fd..f2796645a8 100644
--- a/docs/developer/dashboard/customization/slots.mdx
+++ b/docs/developer/dashboard/customization/slots.mdx
@@ -70,7 +70,7 @@ import { usePermissions } from '@spree/dashboard'
function AdminOnlyMenuItem() {
const { permissions } = usePermissions()
- if (!permissions.can('manage', 'Spree::User')) return null
+ if (!permissions.can('manage', 'Spree::Customer')) return null
return <DropdownMenuItem>…</DropdownMenuItem>
}
```
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index 1b0f05827a..d02c1ac09b 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -515,6 +515,8 @@ const CUSTOM_FIELD_OWNER_PATHS = {
'Spree::Product': '/products',
'Spree::Variant': '/variants',
'Spree::Order': '/orders',
+ 'Spree::Customer': '/customers',
+ // Pre-6.0 customer class name, kept so existing callers still resolve.
'Spree::User': '/customers',
'Spree::Category': '/categories',
'Spree::Collection': '/collections',
@@ -4526,7 +4528,7 @@ export class AdminClient {
this.request<void>('DELETE', `/customers/${customerId}/store_credits/${id}`, options),
},
- customFields: this.parentScopedCustomFields(CUSTOM_FIELD_OWNER_PATHS['Spree::User']),
+ customFields: this.parentScopedCustomFields(CUSTOM_FIELD_OWNER_PATHS['Spree::Customer']),
}
// ============================================
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index c64bdfd24e..5cc1e5b11e 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -2549,6 +2549,8 @@ export type CustomFieldOwnerType =
| 'Spree::Product'
| 'Spree::Variant'
| 'Spree::Order'
+ | 'Spree::Customer'
+ /** @deprecated Use `'Spree::Customer'` — removed in Spree 6.1. */
| 'Spree::User'
| 'Spree::Category'
| 'Spree::Collection'
diff --git a/packages/admin-sdk/tests/custom-fields.test.ts b/packages/admin-sdk/tests/custom-fields.test.ts
index d307563e0d..f9fa05f387 100644
--- a/packages/admin-sdk/tests/custom-fields.test.ts
+++ b/packages/admin-sdk/tests/custom-fields.test.ts
@@ -106,8 +106,8 @@ describe('custom fields', () => {
expect(echoed).toEqual({ parent: 'products', parent_id: 'prod_1' })
})
- it('routes Spree::User to /customers (not /users)', async () => {
- const accessor = client.customFields('Spree::User', 'cus_1')
+ it('routes Spree::Customer to /customers', async () => {
+ const accessor = client.customFields('Spree::Customer', 'cus_1')
const result = await accessor.list()
expect(result.data[0].id).toBe('cf_1')
const echoed = (result.data[0] as { _route?: { parent: string; parent_id: string } })._route
diff --git a/packages/dashboard-core/src/lib/permissions.ts b/packages/dashboard-core/src/lib/permissions.ts
index 29ac2e4d95..9f5cdca201 100644
--- a/packages/dashboard-core/src/lib/permissions.ts
+++ b/packages/dashboard-core/src/lib/permissions.ts
@@ -15,7 +15,7 @@ export const Subject = {
Order: 'Spree::Order',
SavedReport: 'Spree::SavedReport',
ReportExport: 'Spree::Exports::Report',
- Customer: 'Spree::User',
+ Customer: 'Spree::Customer',
CustomerGroup: 'Spree::CustomerGroup',
AdminUser: 'Spree::AdminUser',
ApiKey: 'Spree::ApiKey',
diff --git a/packages/dashboard-core/src/lib/table-registry.ts b/packages/dashboard-core/src/lib/table-registry.ts
index 1d7da83964..760ba4ef5f 100644
--- a/packages/dashboard-core/src/lib/table-registry.ts
+++ b/packages/dashboard-core/src/lib/table-registry.ts
@@ -85,13 +85,13 @@ export interface ResourceFilterConfig<R extends { id: string } = { id: string }>
/**
* Models that `TagCombobox` can target for tag autocomplete. The three
- * first-class taggables (Product, User, Order) get autocomplete hints, but
+ * first-class taggables (Product, Customer, Order) get autocomplete hints, but
* the union is open — apps can pass any Ruby class string the backend's
* `TagsController#allowed_taggable_types` accepts (override that method
* server-side to extend). Use `Subject.Product` etc. to avoid stringly-typed
* callsites for the built-ins.
*/
-export type TaggableType = 'Spree::Product' | 'Spree::User' | 'Spree::Order' | (string & {})
+export type TaggableType = 'Spree::Product' | 'Spree::Customer' | 'Spree::Order' | (string & {})
/**
* Column definition. Discriminated union on `filterType`:
diff --git a/packages/dashboard/e2e/customers.spec.ts b/packages/dashboard/e2e/customers.spec.ts
index 6d88532390..729890c0ee 100644
--- a/packages/dashboard/e2e/customers.spec.ts
+++ b/packages/dashboard/e2e/customers.spec.ts
@@ -378,6 +378,15 @@ test.describe('customers', () => {
await page.getByRole('dialog').getByRole('button', { name: /^add$/i }).click()
await expect(page.getByText(/added tags to 2 customers/i)).toBeVisible({ timeout: 15_000 })
+
+ // The new tag is offered by the list's Tags filter.
+ await gotoIndex(page, CUSTOMERS_PATH(creds.store_id), CTA)
+ await page.getByRole('button', { name: /add filter/i }).click()
+ await page
+ .locator('[data-slot="filter-panel-item"]')
+ .getByText(/^tags$/i)
+ .click()
+ await expect(page.getByText(tagName, { exact: true })).toBeVisible({ timeout: 15_000 })
})
// The detail page's Customer Groups card edits one customer's membership by
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 7abb612867..6484b93026 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -1256,7 +1256,7 @@
"Spree::Order": "الطلبات",
"Spree::Product": "المنتجات",
"Spree::Taxon": "الفئات",
- "Spree::User": "العملاء",
+ "Spree::Customer": "العملاء",
"Spree::Variant": "المتغيرات"
},
"read_only_help": "لا يمكن تغيير المالك بعد وجود قيم لهذا الحقل."
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index 50519882e4..be610f3190 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -1238,7 +1238,7 @@
"Spree::Order": "Bestellungen",
"Spree::Product": "Produkte",
"Spree::Taxon": "Kategorien",
- "Spree::User": "Kunden",
+ "Spree::Customer": "Kunden",
"Spree::Variant": "Varianten"
},
"read_only_help": "Der Eigentümer kann nicht mehr geändert werden, sobald Werte für dieses Feld vorhanden sind."
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index d7e7da5414..e640699ee4 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -1238,7 +1238,7 @@
"Spree::Order": "Orders",
"Spree::Product": "Products",
"Spree::Taxon": "Categories",
- "Spree::User": "Customers",
+ "Spree::Customer": "Customers",
"Spree::Variant": "Variants"
},
"read_only_help": "The owner can't be changed once values exist for this field."
diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.json
index 889041f2c2..5ecba0150d 100644
--- a/packages/dashboard/src/locales/es.json
+++ b/packages/dashboard/src/locales/es.json
@@ -1223,7 +1223,7 @@
"Spree::Order": "Pedidos",
"Spree::Product": "Productos",
"Spree::Taxon": "Categorías",
- "Spree::User": "Clientes",
+ "Spree::Customer": "Clientes",
"Spree::Variant": "Variantes"
},
"read_only_help": "El propietario no se puede cambiar una vez que existen valores para este campo."
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 36c1282959..dca6fc08e1 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -1238,7 +1238,7 @@
"Spree::Order": "Commandes",
"Spree::Product": "Produits",
"Spree::Taxon": "Catégories",
- "Spree::User": "Clients",
+ "Spree::Customer": "Clients",
"Spree::Variant": "Variantes"
},
"read_only_help": "Le propriétaire ne peut pas être modifié une fois que des valeurs existent pour ce champ."
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index ec0b10a972..bf73bbf818 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -1256,7 +1256,7 @@
"Spree::Order": "Zamówienia",
"Spree::Product": "Produkty",
"Spree::Taxon": "Kategorie",
- "Spree::User": "Klienci",
+ "Spree::Customer": "Klienci",
"Spree::Variant": "Warianty"
},
"read_only_help": "Właściciela nie można zmienić, gdy istnieją już wartości dla tego pola."
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index 164cf8aa89..ecdf03f0b7 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -1233,7 +1233,7 @@
"Spree::Order": "订单",
"Spree::Product": "商品",
"Spree::Taxon": "分类",
- "Spree::User": "客户",
+ "Spree::Customer": "客户",
"Spree::Variant": "变体"
},
"read_only_help": "一旦此字段存在值,所属对象便无法更改。"
diff --git a/packages/dashboard/src/schemas/custom-field-definition.ts b/packages/dashboard/src/schemas/custom-field-definition.ts
index 7537bff7aa..17b281553a 100644
--- a/packages/dashboard/src/schemas/custom-field-definition.ts
+++ b/packages/dashboard/src/schemas/custom-field-definition.ts
@@ -48,7 +48,7 @@ export const DEFAULT_RESOURCE_TYPES = [
'Spree::Product',
'Spree::Variant',
'Spree::Order',
- 'Spree::User',
+ 'Spree::Customer',
// Category custom-field definitions are stored under Spree::Taxon (the API
// exposes taxons as categories — the custom_fields controller maps the
// category route segment to the Spree::Taxon class). Listing Spree::Category