Repository navigation
fix: enforce the UCP permission matrix - #313
Johannes Berthel (joberthel) wants to merge 1 commit into
Conversation
392c73b to
e235cb0
Compare
e235cb0 to
fba01d8
Compare
Dominik Grothaus (dgrothaus-sw)
left a comment
There was a problem hiding this comment.
todo: The German changelog should use core's name for the tab.
The German Administration calls the Insights tab „Statistiken“, as in sw-sales-channel.detail.productExport.tabInsights. „Agentic-Commerce-Insights“ doesn't appear anywhere in the UI.
| } | ||
|
|
||
| if (this.isUcpConfigRoute && !this.acl.can('sales_channel.editor')) { | ||
| if (!this.acl.can('ucp.editor') || !this.ucpState.loaded) { |
There was a problem hiding this comment.
issue: Save does nothing when the UCP config failed to load.
ucpState.loaded only turns true once getConfig has answered. After a failed request it stays false. allowSaving still enables Save for a ucp.editor on this tab. A click then returns here without a request, a notification or a spinner.
Could you keep Save disabled until ucpState.loaded is true on this route?
|
|
||
| const salesChannelId = this.salesChannel?.id; | ||
| const form = ucpNormalizeConfig(this.ucpState.form); | ||
| const hasUcpChanges = JSON.stringify(form) !== JSON.stringify(ucpNormalizeConfig(this.ucpState.savedForm)); |
There was a problem hiding this comment.
nitpick (non-blocking): This adds a third copy of the UCP dirty check to onSave.
The same comparison is at lines 514 and 556. I suggest a hasUcpChanges(form) method that all three branches call.
| {% block sw_sales_channel_detail_content_tab_product_export_insights %}{% endblock %} | ||
| {% block sw_sales_channel_detail_content_tab_agentic_commerce_integration %}{% endblock %} | ||
|
|
||
| {% block sw_sales_channel_detail_content_view %} |
There was a problem hiding this comment.
issue (blocking): This block copies core's whole content view to add one condition.
Core's sw_sales_channel_detail_content_view already passes these props and listeners. Core also has its own branch for the legacy router on 6.5. With the copy, Agentic Commerce channels miss every prop or listener that core adds to this block later.
{% parent %} gives the same result without the copy:
{% block sw_sales_channel_detail_content_view %}
<template v-if="!isAgenticCommerce || shouldRenderAgenticCommerceContent">
{% parent %}
</template>
<div
v-else
class="sw-sales-channel-detail__content-denied"
…
</div>
{% endblock %}supportsVueRouterViewSlot and the two new imports can then go.
|
|
||
| created() { | ||
| this.fetchData(); | ||
| if (this.canViewInsights) { |
There was a problem hiding this comment.
suggestion (non-blocking): The new ucp.viewer checks in this component can't be reached.
The route already requires ucp.viewer. Core's router guard redirects to the privilege error page before the component is created. Could you drop the checks in created(), in fetchData() and on the root element?
| }, | ||
| }; | ||
|
|
||
| registerOrOverride('sw-sales-channel-detail-product-export-insights', productExportInsightsOverride); |
There was a problem hiding this comment.
issue: Below 6.7.10, this registers a broken component under core's name.
Core ships sw-sales-channel-detail-product-export-insights from 6.7.10.0 on. Before that, registerOrOverride() registers this config on its own. The result has no template. Its fetchData() calls a $super that doesn't exist.
Where core ships the component, the override never runs for an Agentic Commerce channel without ucp.viewer. shouldRenderAgenticCommerceContent shows the denied banner in its place. Please remove this file and its spec.
| }); | ||
|
|
||
| await goToAdminRoute(withoutUcpViewer, insightsRoute); | ||
| await expect(insightsCards(withoutUcpViewer)).toHaveCount(0); |
There was a problem hiding this comment.
issue: The direct navigation only checks that nothing is there.
toHaveCount(0) and the request filter both pass as soon as the skeleton is gone. Cards or requests that come a moment later don't fail the test. Could you first wait for the denied banner or the privilege error page, depending on the route?
pr313-ucp-permissions.webm
UCP Administration permissions do not consistently match the actions users need to perform. In particular, users with
ucp.editorcannot save UCP settings unless they also havesales_channel.editor.To reproduce on a Shopware installation with the plugin active:
ucp.editorandsales_channel.viewer, but withoutsales_channel.editor.ucp.viewer, including by navigating directly to the Insights route.Previously, the UCP editor could not save without sales-channel edit access, and Insights access was not consistently restricted by
ucp.viewer.With this change, UCP editors can save UCP settings without
sales_channel.editor. Viewers and key rotators see the configuration in read-only mode, and Agentic Commerce Insights requireucp.viewer, including on direct navigation. Product-export Insights keep their existing core permissions.Closes #205.
# next versionin both changelogs.