@beseif-solutions/prow-core 1.2.0 → 1.2.1

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.
@@ -7,12 +7,14 @@ import { Source } from '../entities/source';
7
7
  export type LocalizedField = {
8
8
  label: string;
9
9
  help: string;
10
+ instructions?: string;
10
11
  ui?: Record<string, any>;
11
12
  };
12
13
  export type LocalizedProperties = {
13
14
  name: string;
14
15
  description: string;
15
16
  help?: Record<string, string>;
17
+ instructions?: string;
16
18
  };
17
19
  type TOptions = {
18
20
  fallback?: boolean;
@@ -98,6 +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.instructions = t(`${root}.${key}.instructions`, { fallback: true, optional: true });
101
102
  field.ui = t(`${root}.${key}.ui`, { fallback: true, optional: true }) || {};
102
103
  if (field.type === `dict` && field.items) {
103
104
  field.items = field.items.map((f) => localizeField(t, element, f, { parent: `${key}.items`, t: field.t }));
@@ -107,6 +108,7 @@ const localizeField = (t, element, field, recursive = {}) => {
107
108
  ...fc,
108
109
  label: t(`${root}.${key}.choices.${fc.key}.label`, { fallback: true }),
109
110
  help: t(`${root}.${key}.choices.${fc.key}.help`),
111
+ instructions: t(`${root}.${key}.choices.${fc.key}.instructions`, { fallback: true, optional: true }),
110
112
  ui: {
111
113
  ...t(`${root}.${key}.choices.${fc.key}.ui`, { fallback: true, optional: true }) || {},
112
114
  ...fc.group && {
@@ -131,10 +133,12 @@ const localizeFields = (t, element) => {
131
133
  exports.localizeFields = localizeFields;
132
134
  const localizeProperties = (t, element) => {
133
135
  const help = t(`${element.id}.help`, { fallback: true, optional: true });
136
+ const instructions = t(`${element.id}.instructions`, { fallback: true, optional: true });
134
137
  return {
135
138
  name: t(`${element.id}.name`, { fallback: true }),
136
139
  description: t(`${element.id}.description`),
137
140
  ...help && { help: help },
141
+ ...instructions && { instructions: instructions },
138
142
  };
139
143
  };
140
144
  exports.localizeProperties = localizeProperties;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beseif-solutions/prow-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Prow core functionalities and classes",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -11,6 +11,7 @@ import { Source } from '../entities/source';
11
11
  export type LocalizedField = {
12
12
  label: string,
13
13
  help: string,
14
+ instructions?: string,
14
15
  ui?: Record<string, any>,
15
16
  };
16
17
 
@@ -18,6 +19,7 @@ export type LocalizedProperties = {
18
19
  name: string,
19
20
  description: string,
20
21
  help?: Record<string, string>,
22
+ instructions?: string,
21
23
  };
22
24
 
23
25
  type TOptions = { fallback?: boolean, optional?: boolean };
@@ -143,6 +145,7 @@ const localizeField = (
143
145
 
144
146
  field.label = t(`${root}.${key}.label`, { fallback: true });
145
147
  field.help = t(`${root}.${key}.help`);
148
+ field.instructions = t(`${root}.${key}.instructions`, { fallback: true, optional: true });
146
149
  field.ui = t(`${root}.${key}.ui`, { fallback: true, optional: true }) || {};
147
150
 
148
151
  if (field.type === `dict` && field.items) {
@@ -152,6 +155,7 @@ const localizeField = (
152
155
  ...fc,
153
156
  label: t(`${root}.${key}.choices.${fc.key}.label`, { fallback: true }),
154
157
  help: t(`${root}.${key}.choices.${fc.key}.help`),
158
+ instructions: t(`${root}.${key}.choices.${fc.key}.instructions`, { fallback: true, optional: true }),
155
159
  ui: {
156
160
  ...t(`${root}.${key}.choices.${fc.key}.ui`, { fallback: true, optional: true }) || {},
157
161
  ...fc.group && {
@@ -184,10 +188,12 @@ export const localizeProperties = (
184
188
  element: Action | Trigger | Credentials | Provider | Source,
185
189
  ): LocalizedProperties => {
186
190
  const help = t<Record<string, any>>(`${element.id}.help`, { fallback: true, optional: true });
191
+ const instructions = t<string>(`${element.id}.instructions`, { fallback: true, optional: true });
187
192
  return {
188
193
  name: t(`${element.id}.name`, { fallback: true }),
189
194
  description: t(`${element.id}.description`),
190
195
  ...help && { help: help },
196
+ ...instructions && { instructions: instructions },
191
197
  };
192
198
  };
193
199