-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Property Value Preset builder caller args #20111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property Value Preset builder caller args #20111
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the Property Value Preset API by adding contextual awareness through additional properties in the callArgs
argument. This allows the API to react to specific contextual information like Document Type ID, Property Alias, and other values.
Key changes:
- Enhanced the
UmbPropertyValuePresetApiCallArgs
interface with new contextual properties - Updated the property value preset builder controllers to pass entity information to preset APIs
- Modified test files to provide required entity context when calling the create method
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
types.ts | Adds new interface UmbPropertyValuePresetApiCallArgsEntityBase and enhances UmbPropertyValuePresetApiCallArgs with contextual properties |
property-value-preset-variant-builder.controller.ts | Adds TODO comment about breaking changes for segment control |
property-value-preset-variant-builder.controller.test.ts | Updates test calls to include required entity context parameters |
property-value-preset-builder.controller.ts | Implements entity context handling, adds deprecation warnings, and constructs full callArgs |
property-value-preset-builder.controller.test.ts | Updates all test method calls to provide entity context |
content-detail-workspace-base.ts | Passes entity type, unique, and content type unique to preset builder |
block-manager.context.ts | Provides block-specific entity context to preset builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested it out with some console.logs, and can see the expected data coming through - including all that I needed to achieve the task I was looking to implement. Should it be possible to type this arguments though other than with any
?
async processValue(
value: undefined | UmbIntegerPropertyEditorUiValue,
config: UmbPropertyEditorConfig,
typeArgs: any,
callArgs: any) {
...
}
@AndyButland I see now that my example used In actual implementations, they have to define the right types, making this a bit of a complex DX as the Developer would need to find those types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to work as expected.
To test, I've modified UmbIntegerPropertyValuePreset
as follows (just to log out the values provided):
async processValue(
value: undefined | UmbIntegerPropertyEditorUiValue,
config: UmbPropertyEditorConfig,
typeArgs: UmbPropertyTypePresetModelTypeModel,
callArgs: UmbPropertyValuePresetApiCallArgs) {
console.log(value);
console.log(config);
console.log(typeArgs);
console.log(callArgs);
const min = Number(config.find((x) => x.alias === 'min')?.value ?? 0);
const minVerified = isNaN(min) ? 0 : Math.round(min);
return value !== undefined ? value : minVerified;
}
Then when I create a new document that has an integer property I see:

Which is great, as we have the information now about the property and document to be able to make decisions based on that for what the preset will be.
Docs PR is here: umbraco/UmbracoDocs#7403 |
Implement a few additional properties for the callArgs argument for
processValue
of Value Presets API.This turned out to be necessary because neither are property value presets being created in the context of the property, and it's also being processed before the entity data is available.
This gives contextual awareness for the API, so it can react to things like the Document Type ID(unique) or the Property Alias or a few other values.
resulting in these properties being available in the 4 argument to processValue, also called
callArgs
:(Example data from my own manual test)
can be recieved using this method as your processValue:
This is implemented in a none-breaking way, but should be broken for v.17, therefore added TODOs to revisit for v.17