@beseif-solutions/prow-core 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,7 +98,7 @@ const localizeField = (t, element, field, recursive = {}) => {
98
98
  const root = field.t || recursive.t || `${element}.fields`;
99
99
  field.label = t(`${root}.${key}.label`, { fallback: true });
100
100
  field.help = t(`${root}.${key}.help`);
101
- field.ui = t(`${root}.${key}.ui`, { fallback: true, optional: true });
101
+ field.ui = t(`${root}.${key}.ui`, { fallback: true, optional: true }) || {};
102
102
  if (field.type === `dict` && field.items) {
103
103
  field.items = field.items.map((f) => localizeField(t, element, f, { parent: `${key}.items`, t: field.t }));
104
104
  }
@@ -107,7 +107,16 @@ const localizeField = (t, element, field, recursive = {}) => {
107
107
  ...fc,
108
108
  label: t(`${root}.${key}.choices.${fc.key}.label`, { fallback: true }),
109
109
  help: t(`${root}.${key}.choices.${fc.key}.help`),
110
- ...fc.group && { group: t(`${root}.${key}.groups.${fc.group}`, { fallback: true }) },
110
+ ui: {
111
+ ...t(`${root}.${key}.choices.${fc.key}.ui`, { fallback: true, optional: true }) || {},
112
+ ...fc.group && {
113
+ group: {
114
+ key: fc.group,
115
+ label: t(`${root}.${key}.groups.${fc.group}.label`, { fallback: true }),
116
+ help: t(`${root}.${key}.groups.${fc.group}.help`),
117
+ },
118
+ },
119
+ },
111
120
  }));
112
121
  }
113
122
  return field;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beseif-solutions/prow-core",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Prow core functionalities and classes",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -143,16 +143,25 @@ const localizeField = (
143
143
 
144
144
  field.label = t(`${root}.${key}.label`, { fallback: true });
145
145
  field.help = t(`${root}.${key}.help`);
146
- field.ui = t(`${root}.${key}.ui`, { fallback: true, optional: true });
146
+ field.ui = t(`${root}.${key}.ui`, { fallback: true, optional: true }) || {};
147
147
 
148
148
  if (field.type === `dict` && field.items) {
149
149
  field.items = field.items.map((f) => localizeField(t, element, f, { parent: `${key}.items`, t: field.t }));
150
150
  } else if (`format` in field && field.format === `select` && _.isArray(field.choices)) {
151
- field.choices = field.choices.map((fc: SelectFieldChoice<any, LocalizedField>) => ({
151
+ field.choices = field.choices.map((fc: SelectFieldChoice<any, {}>): SelectFieldChoice<any, LocalizedField> => ({
152
152
  ...fc,
153
153
  label: t(`${root}.${key}.choices.${fc.key}.label`, { fallback: true }),
154
154
  help: t(`${root}.${key}.choices.${fc.key}.help`),
155
- ...fc.group && { group: t(`${root}.${key}.groups.${fc.group}`, { fallback: true }) },
155
+ ui: {
156
+ ...t(`${root}.${key}.choices.${fc.key}.ui`, { fallback: true, optional: true }) || {},
157
+ ...fc.group && {
158
+ group: {
159
+ key: fc.group,
160
+ label: t(`${root}.${key}.groups.${fc.group}.label`, { fallback: true }),
161
+ help: t(`${root}.${key}.groups.${fc.group}.help`),
162
+ },
163
+ },
164
+ },
156
165
  }));
157
166
  }
158
167