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
Added a connected status to the agents list
Damian Legawiec7fa254960088
diff --git a/packages/admin-sdk/src/types/generated/OauthApplication.ts b/packages/admin-sdk/src/types/generated/OauthApplication.tsindex 7fc2f74285..3494bbb48d 100644--- a/packages/admin-sdk/src/types/generated/OauthApplication.ts+++ b/packages/admin-sdk/src/types/generated/OauthApplication.ts@@ -1,4 +1,4 @@-// Typelizer digest b23eb8b9833e0f3b8e67ee33fdfca25b+// Typelizer digest b436bcaf3d61f07f2270eb13b4c0cb2c//// DO NOT MODIFY: This file was automatically generated by Typelizer.@@ -9,6 +9,7 @@ interface OauthApplication {created_at: string;updated_at: string;client_id: string;+ connected: boolean;scopes: Array<string>;last_authorized_at: string | null;authorized_at: string | null;diff --git a/packages/admin-sdk/src/zod/generated/OauthApplication.ts b/packages/admin-sdk/src/zod/generated/OauthApplication.tsindex ce682c2d64..fecdbec443 100644--- a/packages/admin-sdk/src/zod/generated/OauthApplication.ts+++ b/packages/admin-sdk/src/zod/generated/OauthApplication.ts@@ -8,6 +8,7 @@ export const OauthApplicationSchema = z.object({created_at: z.string(),updated_at: z.string(),client_id: z.string(),+ connected: z.boolean(),scopes: z.array(z.string()),last_authorized_at: z.string().nullable(),authorized_at: z.string().nullable(),diff --git a/packages/dashboard-starter/src/routeTree.gen.ts b/packages/dashboard-starter/src/routeTree.gen.tsindex c89b616e1d..73f9c5d857 100644--- a/packages/dashboard-starter/src/routeTree.gen.ts+++ b/packages/dashboard-starter/src/routeTree.gen.ts@@ -68,6 +68,7 @@ import { Route as SettingsCustomFieldDefinitionsRouteImport } from './../../dashimport { Route as SettingsIntegrationsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/integrations'import { Route as SettingsMarketplaceRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/marketplace'import { Route as SettingsMarketsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/markets'+import { Route as SettingsOauthClientsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/oauth-clients'import { Route as SettingsPackageTypesRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/package-types'import { Route as SettingsPaymentMethodsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/payment-methods'import { Route as SettingsPayoutsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/payouts'@@ -409,6 +410,11 @@ const SettingsMarketsRoute = SettingsMarketsRouteImport.update({path: '/markets',getParentRoute: () => SettingsRoute,} as any)+const SettingsOauthClientsRoute = SettingsOauthClientsRouteImport.update({+ id: '/oauth-clients',+ path: '/oauth-clients',+ getParentRoute: () => SettingsRoute,+} as any)const SettingsPackageTypesRoute = SettingsPackageTypesRouteImport.update({id: '/package-types',path: '/package-types',@@ -694,6 +700,7 @@ export interface FileRoutesByFullPath {'/$storeId/settings/integrations': typeof SettingsIntegrationsRoute'/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute'/$storeId/settings/markets': typeof SettingsMarketsRoute+ '/$storeId/settings/oauth-clients': typeof SettingsOauthClientsRoute'/$storeId/settings/package-types': typeof SettingsPackageTypesRoute'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute'/$storeId/settings/payouts': typeof SettingsPayoutsRoute@@ -796,6 +803,7 @@ export interface FileRoutesByTo {'/$storeId/settings/integrations': typeof SettingsIntegrationsRoute'/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute'/$storeId/settings/markets': typeof SettingsMarketsRoute+ '/$storeId/settings/oauth-clients': typeof SettingsOauthClientsRoute'/$storeId/settings/package-types': typeof SettingsPackageTypesRoute'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute'/$storeId/settings/payouts': typeof SettingsPayoutsRoute@@ -902,6 +910,7 @@ export interface FileRoutesById {'/_authenticated/$storeId/settings/integrations': typeof SettingsIntegrationsRoute'/_authenticated/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute'/_authenticated/$storeId/settings/markets': typeof SettingsMarketsRoute+ '/_authenticated/$storeId/settings/oauth-clients': typeof SettingsOauthClientsRoute'/_authenticated/$storeId/settings/package-types': typeof SettingsPackageTypesRoute'/_authenticated/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute'/_authenticated/$storeId/settings/payouts': typeof SettingsPayoutsRoute@@ -1008,6 +1017,7 @@ export interface FileRouteTypes {| '/$storeId/settings/integrations'| '/$storeId/settings/marketplace'| '/$storeId/settings/markets'+ | '/$storeId/settings/oauth-clients'| '/$storeId/settings/package-types'| '/$storeId/settings/payment-methods'| '/$storeId/settings/payouts'@@ -1110,6 +1120,7 @@ export interface FileRouteTypes {| '/$storeId/settings/integrations'| '/$storeId/settings/marketplace'| '/$storeId/settings/markets'+ | '/$storeId/settings/oauth-clients'| '/$storeId/settings/package-types'| '/$storeId/settings/payment-methods'| '/$storeId/settings/payouts'@@ -1215,6 +1226,7 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/settings/integrations'| '/_authenticated/$storeId/settings/marketplace'| '/_authenticated/$storeId/settings/markets'+ | '/_authenticated/$storeId/settings/oauth-clients'| '/_authenticated/$storeId/settings/package-types'| '/_authenticated/$storeId/settings/payment-methods'| '/_authenticated/$storeId/settings/payouts'@@ -1696,6 +1708,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof SettingsMarketsRouteImportparentRoute: typeof SettingsRoute}+ '/_authenticated/$storeId/settings/oauth-clients': {+ id: '/_authenticated/$storeId/settings/oauth-clients'+ path: '/oauth-clients'+ fullPath: '/$storeId/settings/oauth-clients'+ preLoaderRoute: typeof SettingsOauthClientsRouteImport+ parentRoute: typeof SettingsRoute+ }'/_authenticated/$storeId/settings/package-types': {id: '/_authenticated/$storeId/settings/package-types'path: '/package-types'@@ -2017,6 +2036,7 @@ interface SettingsRouteChildren {SettingsIntegrationsRoute: typeof SettingsIntegrationsRouteSettingsMarketplaceRoute: typeof SettingsMarketplaceRouteSettingsMarketsRoute: typeof SettingsMarketsRoute+ SettingsOauthClientsRoute: typeof SettingsOauthClientsRouteSettingsPackageTypesRoute: typeof SettingsPackageTypesRouteSettingsPaymentMethodsRoute: typeof SettingsPaymentMethodsRouteSettingsPayoutsRoute: typeof SettingsPayoutsRoute@@ -2053,6 +2073,7 @@ const SettingsRouteChildren: SettingsRouteChildren = {SettingsIntegrationsRoute: SettingsIntegrationsRoute,SettingsMarketplaceRoute: SettingsMarketplaceRoute,SettingsMarketsRoute: SettingsMarketsRoute,+ SettingsOauthClientsRoute: SettingsOauthClientsRoute,SettingsPackageTypesRoute: SettingsPackageTypesRoute,SettingsPaymentMethodsRoute: SettingsPaymentMethodsRoute,SettingsPayoutsRoute: SettingsPayoutsRoute,diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex c726d85abc..6711942faf 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -4141,11 +4141,16 @@"name": "الوكيل","access": "الوصول","authorized_by": "وافق عليه",- "last_authorized": "آخر تفويض"+ "last_authorized": "آخر تفويض",+ "status": "الحالة"},"revoke_confirm": {"title": "إلغاء الوصول؟","message": "سيتوقف {{name}} عن العمل فورًا. وسيحتاج أي شخص يستخدمه إلى الاتصال من جديد."+ },+ "status": {+ "connected": "متصل",+ "not_connected": "غير متصل"}},"oauth_clients": {diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex 9e30ec61de..fe6b4a9001 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -4113,11 +4113,16 @@"name": "Agent","access": "Zugriff","authorized_by": "Genehmigt von",- "last_authorized": "Letzte Autorisierung"+ "last_authorized": "Letzte Autorisierung",+ "status": "Status"},"revoke_confirm": {"title": "Zugriff widerrufen?","message": "{{name}} funktioniert ab sofort nicht mehr. Wer es nutzt, muss sich erneut verbinden."+ },+ "status": {+ "connected": "Verbunden",+ "not_connected": "Nicht verbunden"}},"oauth_clients": {diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 67e1159a08..1ea348239d 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -4113,11 +4113,16 @@"name": "Agent","access": "Access","authorized_by": "Approved by",- "last_authorized": "Last authorized"+ "last_authorized": "Last authorized",+ "status": "Status"},"revoke_confirm": {"title": "Revoke access?","message": "{{name}} will stop working immediately. Anyone using it will need to connect again."+ },+ "status": {+ "connected": "Connected",+ "not_connected": "Not connected"}},"oauth_clients": {diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.jsonindex b3b550038a..a9c46221ec 100644--- a/packages/dashboard/src/locales/es.json+++ b/packages/dashboard/src/locales/es.json@@ -729,11 +729,16 @@"name": "Agente","access": "Acceso","authorized_by": "Aprobado por",- "last_authorized": "Última autorización"+ "last_authorized": "Última autorización",+ "status": "Estado"},"revoke_confirm": {"title": "¿Revocar el acceso?","message": "{{name}} dejará de funcionar de inmediato. Quien lo use tendrá que conectarse de nuevo."+ },+ "status": {+ "connected": "Conectado",+ "not_connected": "No conectado"}},"oauth_clients": {diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 2de5e3542e..8e1ce6129d 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -4113,11 +4113,16 @@"name": "Agent","access": "Accès","authorized_by": "Autorisé par",- "last_authorized": "Dernière autorisation"+ "last_authorized": "Dernière autorisation",+ "status": "Statut"},"revoke_confirm": {"title": "Révoquer l’accès ?","message": "{{name}} cessera de fonctionner immédiatement. Toute personne qui l’utilise devra se connecter à nouveau."+ },+ "status": {+ "connected": "Connecté",+ "not_connected": "Non connecté"}},"oauth_clients": {diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex 5c5feca880..c6fe42241b 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -4167,11 +4167,16 @@"name": "Agent","access": "Dostęp","authorized_by": "Zatwierdzone przez",- "last_authorized": "Ostatnia autoryzacja"+ "last_authorized": "Ostatnia autoryzacja",+ "status": "Status"},"revoke_confirm": {"title": "Odebrać dostęp?","message": "{{name}} przestanie działać natychmiast. Każdy, kto z niej korzysta, będzie musiał połączyć się ponownie."+ },+ "status": {+ "connected": "Połączony",+ "not_connected": "Niepołączony"}},"oauth_clients": {diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex a472acacfe..f33279e175 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -4103,11 +4103,16 @@"name": "代理","access": "访问权限","authorized_by": "批准人",- "last_authorized": "最后授权时间"+ "last_authorized": "最后授权时间",+ "status": "状态"},"revoke_confirm": {"title": "撤销访问权限?","message": "{{name}} 将立即停止工作。使用它的人需要重新连接。"+ },+ "status": {+ "connected": "已连接",+ "not_connected": "未连接"}},"oauth_clients": {diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/connected-apps.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/connected-apps.tsxindex 52c262527f..87d8ca0c0c 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/connected-apps.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/connected-apps.tsx@@ -69,7 +69,9 @@ function ConnectedAppsSettingsPage() {key: 'revoke',label: t('admin.pages.settings.connected_apps.revoke'),destructive: true,- visible: permissions.can('update', Subject.OauthApplication),+ // Nothing to revoke on a registration nobody has connected.+ visible:+ application.connected && permissions.can('update', Subject.OauthApplication),disabled: revoke.isPending,onSelect: () => handleRevoke(application),},diff --git a/packages/dashboard/src/tables/oauth-applications.tsx b/packages/dashboard/src/tables/oauth-applications.tsxindex 1f817c9da0..17a457a17d 100644--- a/packages/dashboard/src/tables/oauth-applications.tsx+++ b/packages/dashboard/src/tables/oauth-applications.tsx@@ -1,6 +1,6 @@import type { OauthApplication } from '@spree/admin-sdk'import { defineTable } from '@spree/dashboard-core'-import { RelativeTime, ResourceNameCell } from '@spree/dashboard-ui'+import { RelativeTime, ResourceNameCell, StatusBadge } from '@spree/dashboard-ui'import { PlugIcon } from '@spree/dashboard-ui/icons'import i18n from 'i18next'import { ScopeList } from '../components/spree/api-keys/api-key-table'@@ -17,6 +17,28 @@ defineTable<OauthApplication>('oauth-applications', {default: true,render: (application) => <ResourceNameCell id={application.id} name={application.name} />,},+ {+ key: 'connected',+ label: i18n.t('admin.pages.settings.connected_apps.table.status'),+ default: true,+ // A registration nobody connected and one whose access was revoked+ // both show no permissions, so without this the row looks unchanged+ // after a merchant presses Revoke.+ render: (application) =>+ application.connected ? (+ <StatusBadge+ status="connected"+ tone="success"+ label={i18n.t('admin.pages.settings.connected_apps.status.connected')}+ />+ ) : (+ <StatusBadge+ status="not_connected"+ tone="neutral"+ label={i18n.t('admin.pages.settings.connected_apps.status.not_connected')}+ />+ ),+ },{key: 'scopes',label: i18n.t('admin.pages.settings.connected_apps.table.access'),diff --git a/spree/api/app/serializers/spree/api/v3/admin/oauth_application_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/oauth_application_serializer.rbindex 758b4803d9..58ae2efe93 100644--- a/spree/api/app/serializers/spree/api/v3/admin/oauth_application_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/oauth_application_serializer.rb@@ -15,6 +15,7 @@ module Spreeclass OauthApplicationSerializer < V3::BaseSerializertypelize name: :string,client_id: :string,+ connected: :boolean,scopes: [:string, multi: true],last_authorized_at: [:string, nullable: true],authorized_at: [:string, nullable: true],@@ -25,6 +26,11 @@ module Spreeattribute :client_id, &:uid+ # A registration nobody has connected and one whose access was+ # revoked both carry no scopes, so the list alone cannot tell them+ # apart — and a merchant pressing Revoke has to see that it worked.+ attribute :connected, &:connected?+attribute :scopes do |application|application.live_token_scopesenddiff --git a/spree/api/spec/requests/spree/api/v3/admin/oauth/applications_spec.rb b/spree/api/spec/requests/spree/api/v3/admin/oauth/applications_spec.rbindex 2d10f633f8..7daa5089af 100644--- a/spree/api/spec/requests/spree/api/v3/admin/oauth/applications_spec.rb+++ b/spree/api/spec/requests/spree/api/v3/admin/oauth/applications_spec.rb@@ -75,6 +75,21 @@ RSpec.describe 'Admin connected applications', type: :request doexpect(row['scopes']).to be_emptyend+ # A registration nobody connected and one whose access was revoked both+ # carry no scopes, so without a status the row looks unchanged after a+ # merchant presses Revoke.+ it 'says whether anything can still reach the store' do+ token_for(admin)++ row = list['data'].find { |candidate| candidate['name'] == 'Claude' }+ expect(row['connected']).to be(true)++ Spree::OauthAccessToken.last.update!(revoked_at: Time.current)++ revoked = list['data'].find { |candidate| candidate['name'] == 'Claude' }+ expect(revoked['connected']).to be(false)+ end+it 'reports what the live tokens grant, not the registration' dotoken_for(admin, scopes: 'read_products write_orders')diff --git a/spree/core/app/models/spree/oauth_application.rb b/spree/core/app/models/spree/oauth_application.rbindex 9e0eb75054..3dbe1f966e 100644--- a/spree/core/app/models/spree/oauth_application.rb+++ b/spree/core/app/models/spree/oauth_application.rb@@ -35,6 +35,18 @@ module Spreeinverse_of: :application,dependent: nil+ # Whether anything can still reach the store with this registration.+ #+ # The screen lists every registered client, so a row with no live token+ # may be one nobody has connected yet or one whose access was revoked —+ # and an empty permission list reads the same either way. A merchant+ # pressing Revoke has to see that it worked.+ #+ # @return [Boolean]+ def connected?+ live_access_tokens.any?+ end+# What this application may currently do, as permission keys.## Read from the tokens rather than the registration: a client is