[nextjs] Secured variants generation for server components in Design Studio#369
[nextjs] Secured variants generation for server components in Design Studio#369
Conversation
…tch component data from secured endpoint in variant generation mode; enabled variant generation mode; update unit tests
📦 Package Size and Test Coverage Report
|
illiakovalenko
left a comment
There was a problem hiding this comment.
Looks good overall. Please see suggestions below for further refinement
| } | ||
| ); | ||
|
|
||
| if (componentDataResponse.status !== 200) { |
There was a problem hiding this comment.
Do we have a mechanism for handling unsuccessful requests?
| _updateServerComponentAction({ uid: component.uid!, previewComponent: eventArgs }); | ||
| _updateServerComponentAction({ | ||
| uid: component.uid!, | ||
| serverComponentPreviewEventArgs: eventArgs, |
There was a problem hiding this comment.
Can this property be simplified and renamed to eventArgs?
The method name itself already indicates that it operates within the server component scope.
| serverComponentPreviewEventArgs: eventArgs, | |
| eventArgs, |
| const generatedComponentData = await fetchGeneratedComponentFromCache( | ||
| componentUpdate.serverComponentPreviewEventArgs.message.cache.id, | ||
| componentUpdate.serverComponentPreviewEventArgs.message.cache.token, | ||
| process.env.SITECORE_EDGE_URL |
There was a problem hiding this comment.
Let's allow DesignLibraryApp to accept api property. You will be able to pass scConfig.api so you will have access to custom edge url as well. This is needed as well to support custom hostnames feature
There was a problem hiding this comment.
As we discussed, can be read from "ClientEvents" component via "useSitecore"
| * This enables dynamic rendering of server components inside Design Library | ||
| * @param {ComponentUpdateModel} componentUpdate - The component update model containing the UID and optional updated or preview component data. | ||
| * @returns A Promise that resolves when the cache has been updated. | ||
| */ |
There was a problem hiding this comment.
It would make sense to split this server action into two separate actions:
- one dedicated to handling the
updateevent, - another responsible for the initial
preview.
This separation should reduce ambiguity and make the intent and flow easier to understand and maintain.
Some properties should be renamed to improve clarity and consistency.
In addition, ComponentUpdateModel appears to be handling multiple concerns and could be split into more focused models. This would make the structure easier to understand and maintain going forward.
|
@yavorsk Please, update Changelog as well |
Description / Motivation
This PR enables and extends Design Studio's component generation features for server components in NexttJs app router application.
Testing Details
Types of changes