a review and proposal to alter how Widgets are mutated
fieldSets: [{
name: 'business-name',
header: 'Business name',
description: 'Enter the name of your business',
icon: 'sm-business',
fields: [{
label: 'Business Name',
property: 'businessName',
type: editorTypes.TEXT
}]
}]export default connectPropsToStores(Header1, {
businessName: [NestedProp.property]
});Manifest
Widget
{
types: {
businessNameBinding: {
kind: 'extensionBinding',
type: 'TEXT',
extensionName: 'BusinessInfo',
field: 'businessName',
defaultOnly: true,
defaultValue: {
kind: 'translatedValue',
value: 'fallbackForHeaderBusinessName'
},
arguments: {
maxCount: 50
}
}
},
props: {
businessName: {
kind: 'typeReferenceWithDisplayInfo',
type: 'businessNameBinding',
editingDisplay: {
titleId: {
kind: 'translatedValue',
value: 'titleForHeaderBusinessName'
},
descriptionId: {
kind: 'translatedValue',
value: 'descriptionForHeaderSiteName'
}
}
}
}
}Manifest
const Widget = connect(class extends SDK.Widget {
static propTypes = {
businessName: SDK.PropTypes.string.maxCount(50)
};
static defaultProps = {
businessName: [
SDK.Selectors.Website.businessName,
SDK.Intl("fallbackForHeaderBusinessName")
]
};
});Widget
const Mutator = createMutator(class extends SDK.Mutator {
static mutatorFields = ["businessName"];
static defaultProps = {
businessNameTitle: SDK.Intl("titleForHeaderBusinessName"),
businessNameDesc: SDK.Intl("descriptionForHeaderSiteName")
};
render() {
const { route } = this.state;
return (
<Route path="/">
<SDK.Mutators.Text
name="businessName"
title={ this.props.businessNameTitle }
description={ this.props.businessNameDesc }
/>
</Route>
);
}
}, Widget);Mutator