Skip to content

Commit

Permalink
feat(entities-plugins): add default values in protocols placeholder (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopoldthecoder authored Oct 16, 2024
1 parent 262e6f9 commit 81a12d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/entities/entities-plugins/src/components/PluginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ const defaultFormSchema: DefaultPluginsSchemaRecord = reactive({
default: [],
help: t('plugins.form.fields.protocols.help'),
label: t('plugins.form.fields.protocols.label'),
placeholder: t('plugins.form.fields.protocols.placeholder'),
required: true,
styleClasses: 'plugin-protocols-select',
type: 'multiselect',
Expand Down Expand Up @@ -852,7 +851,8 @@ const buildFormSchema = (parentKey: string, response: Record<string, any>, initi
// Field type is an input, determine input type, such as 'text', or 'number'
if (initialFormSchema[field].type === 'input') {
if (['string', 'number'].includes(typeof initialFormSchema[field].default)) {
if (['string', 'number'].includes(typeof initialFormSchema[field].default) && props.config.app === 'konnect') {
// Konnect API respects default values if the field is not set, so display them in the placeholder
initialFormSchema[field].placeholder = `Default: ${
initialFormSchema[field].default === '' ? '<empty string>' : initialFormSchema[field].default
}`
Expand Down Expand Up @@ -1274,6 +1274,13 @@ onBeforeMount(async () => {
defaultFormSchema.protocols.default = defaultValues
// Konnect API respects default values if the field is not set, so display them in the placeholder
defaultFormSchema.protocols.placeholder = props.config.app === 'konnect'
? t('plugins.form.fields.protocols.placeholderWithDefaultValues', {
protocols: defaultValues.join(', '),
})
: t('plugins.form.fields.protocols.placeholder')
if (elements.one_of?.length) {
defaultFormSchema.protocols.values = elements.one_of.map((value: string) => ({ label: value, value }))
}
Expand Down
1 change: 1 addition & 0 deletions packages/entities/entities-plugins/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@
"protocols": {
"label": "Protocols",
"placeholder": "Select valid protocols for the plugin",
"placeholderWithDefaultValues": "Select valid protocols for the plugin. Default protocols: {protocols}",
"help": "A list of the request protocols that will trigger this plugin. The default value, as well as the possible values allowed on this field, may change depending on the plugin type."
}
},
Expand Down

0 comments on commit 81a12d5

Please sign in to comment.