Skip to content

Commit

Permalink
fix(plugin/form): schema hint propagation (#939)
Browse files Browse the repository at this point in the history
Fix `hint` text in custom schemas not being respected.
  • Loading branch information
kaiarrowood authored Nov 22, 2023
1 parent ccf6c26 commit 4ff96cc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/entities/entities-plugins/src/components/PluginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -531,21 +531,25 @@ const buildFormSchema = (parentKey: string, response: Record<string, any>, initi
if (scheme.elements && scheme.type === 'array') {
const elements = scheme.elements
if (elements.type === 'string' && !elements.one_of) {
const { help, label } = initialFormSchema[field]
const { help, label, hint } = initialFormSchema[field]
initialFormSchema[field] = { ...JSON.parse(JSON.stringify(ArrayStringFieldSchema)), help, label }
initialFormSchema[field] = { help, label, hint, ...JSON.parse(JSON.stringify(ArrayStringFieldSchema)) }
}
}
if (scheme.hint) {
initialFormSchema[field].hint = scheme.hint
}
// Custom frontend schema override
if (pluginSchema && !pluginSchema.overwriteDefault) {
Object.keys(pluginSchema).forEach(plugin => {
// Check if current plugin matches any of custom schema keys
if (plugin === field) {
// Use custom defined schema instead of building from default && set field label
const { help, label } = initialFormSchema[field]
const { help, label, hint } = initialFormSchema[field]
initialFormSchema[field] = { help, label, ...(pluginSchema[plugin as keyof typeof pluginSchema] as Record<string, any>) }
initialFormSchema[field] = { help, label, hint, ...(pluginSchema[plugin as keyof typeof pluginSchema] as Record<string, any>) }
}
})
}
Expand Down

0 comments on commit 4ff96cc

Please sign in to comment.