Skip to content

Give the store panel its own view components and base class - #774

Merged
KrzysztofPajak merged 2 commits into
fix/cms-store-scopefrom
refactor/store-components-own-namespace
Aug 10, 2026
Merged

Give the store panel its own view components and base class#774
KrzysztofPajak merged 2 commits into
fix/cms-store-scopefrom
refactor/store-components-own-namespace

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Stacked on #773 — it touches StorePage.cs, which that PR also edits. Base retargets to develop once #773 merges.

Issue

Two of the eleven view components in Grand.Web.Store are unfinished copies of their vendor counterparts:

  • Components/StorePage.cs declares namespace Grand.Web.Vendor.Components while living in the store project, and derives from BaseVendorViewComponent.
  • Components/StoreWidget.cs has the right namespace but also derives from BaseVendorViewComponent.

The other nine use Grand.Web.Store.Components and BaseAdminViewComponent.

Reproduce: grep -h "class .*ViewComponent" src/Web/Grand.Web.Store/Components/*.cs — nine BaseAdminViewComponent, two BaseVendorViewComponent.

Solution

Both moved to the namespace and base class the other nine already use.

This changes no behaviour, and the reason is worth stating so the next reader does not go looking for one. The [Area] attribute those base classes carry is inert for a view component: MVC resolves a component's view from the area of the request being served, not from an attribute on the component class. All three base classes are therefore interchangeable at runtime, which is exactly why the mismatch survived. What it cost was readability — two files claiming to belong to a panel they are not part of, in the corner of the codebase where Admin, Store and Vendor are already hard to tell apart.

Not done here, worth a decision separately: Grand.Web.Store has no BaseStoreViewComponent, so its components inherit the admin one. Adding it would be more honest than the status quo, but it touches all eleven files and buys nothing at runtime.

Breaking changes

None. StorePageViewComponent and StoreWidgetViewComponent are resolved by component name (vc:store-page, and the widget zone invocations), not by namespace, and neither type is referenced by name anywhere outside its own file.

Testing

  1. dotnet build ./GrandNode.sln — succeeds, no new warnings.
  2. dotnet test src/Tests/Grand.Web.Store.Tests — 17 pass.
  3. Log into the store panel and open the dashboard: the portal info block (vc:store-page system-name="StorePortalInfo") renders, and widget zones on store panel pages still render their widgets.

Step 3 needs a store manager account and was not exercised on my side — see the note below.

🤖 Generated with Claude Code

KrzysztofPajak and others added 2 commits August 9, 2026 22:28
Two of the eleven view components in Grand.Web.Store were unfinished
copies of their vendor counterparts. StorePageViewComponent declared
namespace Grand.Web.Vendor.Components while living in the store project,
and both it and StoreWidgetViewComponent derived from
BaseVendorViewComponent. The other nine use Grand.Web.Store.Components
and BaseAdminViewComponent.

No behaviour changes. The [Area] attribute those base classes carry is
inert for a view component - MVC resolves a component's view from the
area of the request being served, not from an attribute on the component
class - which is why the mismatch went unnoticed. What it cost was
readability: two files claimed to belong to a panel they are not part
of, in the area of the codebase where Admin, Store and Vendor are
already hard to tell apart.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Grand.Web.Store had no base of its own, so its eleven view components
inherited BaseAdminViewComponent - and two of them BaseVendorViewComponent.
BaseStoreViewComponent joins its two siblings in Grand.Web.Common, where
the store project already looks for them, and all eleven now use it.

Still no behaviour change, and the existing code is what proves it: the
nine components that carried [Area("Admin")] render views that exist only
under Areas/Store/Views/Shared/Components - Grand.Web.Admin has no view
for any of them. A view component resolves its view from the area of the
request being served, so the attribute never took part. Moving it from
"Admin" to "Store" therefore cannot move where these views are found; it
only stops the class from claiming the wrong panel.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@KrzysztofPajak KrzysztofPajak changed the title Put the store panel's view components back in the store panel Give the store panel its own view components and base class Aug 10, 2026
@KrzysztofPajak
KrzysztofPajak merged commit 7301013 into fix/cms-store-scope Aug 10, 2026
1 check passed
@KrzysztofPajak
KrzysztofPajak deleted the refactor/store-components-own-namespace branch August 10, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant