Skip to content

Commit e6ec5e3

Browse files
authored
Merge pull request #257 from devtron-labs/fix/fallback-schema
fix: fallback schema & RJSF schema support for hidden property
2 parents 98534d3 + 42b934d commit e6ec5e3

File tree

7 files changed

+41
-389
lines changed

7 files changed

+41
-389
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.2.6",
3+
"version": "0.2.6-patch-1",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/RJSF/templates/ObjectFieldTemplate.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ const Field = ({
5353
if (!hiddenSchemaProp) {
5454
return true
5555
}
56-
const value = JSONPath({ path: hiddenSchemaProp.match, json: formData })?.[0]
57-
const isHidden = value === undefined || hiddenSchemaProp.condition === value
58-
// NOTE: if should be hidden then filter it out i.e return false
59-
return !isHidden
56+
try {
57+
const value = JSONPath({ path: hiddenSchemaProp.match, json: formData })?.[0]
58+
const isHidden = value === undefined || hiddenSchemaProp.condition === value
59+
return !isHidden
60+
} catch {
61+
return true
62+
}
6063
})
6164
// NOTE: we probably should use uiSchema instead?
6265
.sort((prop) => (schema.properties?.[prop.name]?.type === 'boolean' ? -1 : 1))
Lines changed: 28 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -1,270 +1,73 @@
11
{
22
"type": "object",
33
"properties": {
4-
"args": {
5-
"type": "object",
6-
"title": "Arguments",
7-
"properties": {
8-
"value": {
9-
"type": "array",
10-
"items": {
11-
"type": "string"
12-
},
13-
"title": "Value",
14-
"hidden": {
15-
"condition": false,
16-
"match": "enabled"
17-
}
18-
},
19-
"enabled": {
20-
"type": "boolean",
21-
"title": "Enabled"
22-
}
23-
}
24-
},
25-
"command": {
26-
"type": "object",
27-
"title": "Command",
28-
"properties": {
29-
"value": {
30-
"type": "array",
31-
"items": {
32-
"type": "string"
33-
},
34-
"title": "Value",
35-
"hidden": {
36-
"condition": false,
37-
"match": "enabled"
38-
}
39-
},
40-
"enabled": {
41-
"type": "boolean",
42-
"title": "Enabled"
43-
}
44-
}
45-
},
46-
"ingress": {
47-
"type": "object",
48-
"title": "HTTP Requests Routes",
49-
"properties": {
50-
"className": {
51-
"type": "string",
52-
"title": "Class",
53-
"hidden": {
54-
"condition": false,
55-
"match": "enabled"
56-
}
57-
},
58-
"hosts": {
59-
"type": "array",
60-
"items": {
61-
"type": "object",
62-
"properties": {
63-
"host": {
64-
"type": "string"
65-
},
66-
"paths": {
67-
"type": "array",
68-
"items": {
69-
"type": "string"
70-
}
71-
}
72-
}
73-
},
74-
"hidden": {
75-
"condition": false,
76-
"match": "enabled"
4+
"ContainerPort": {
5+
"type": "array",
6+
"description": "Defines ports on which application services will be exposed to other services",
7+
"items": {
8+
"type": "object",
9+
"properties": {
10+
"port": {
11+
"type": "integer",
12+
"description": "Port at which your application will run"
7713
}
78-
},
79-
"enabled": {
80-
"type": "boolean",
81-
"title": "Enable HTTP Requests Routes"
8214
}
83-
}
15+
},
16+
"title": "Container Port"
8417
},
8518
"resources": {
8619
"type": "object",
8720
"title": "Resources (CPU & RAM)",
21+
"description": "Minimum and maximum RAM and CPU available to the application",
8822
"properties": {
8923
"limits": {
9024
"type": "object",
25+
"description": "Maximum RAM and CPU available to the application",
9126
"required": ["cpu", "memory"],
9227
"properties": {
9328
"cpu": {
94-
"type": "string"
29+
"type": "string",
30+
"description": "Maximum allowed CPU limit"
9531
},
9632
"memory": {
97-
"type": "string"
33+
"type": "string",
34+
"description": "Maximum allowed memory limit"
9835
}
9936
}
10037
},
10138
"requests": {
10239
"type": "object",
40+
"description": "Minimum RAM and CPU available to the application",
10341
"properties": {
10442
"cpu": {
105-
"type": "string"
43+
"type": "string",
44+
"description": "Minimum CPU value"
10645
},
10746
"memory": {
108-
"type": "string"
47+
"type": "string",
48+
"description": "Minimum memory value"
10949
}
11050
}
11151
}
11252
}
11353
},
114-
"autoscaling": {
115-
"type": "object",
116-
"title": "Autoscaling",
117-
"properties": {
118-
"MaxReplicas": {
119-
"type": ["integer", "string"],
120-
"title": "Maximum Replicas",
121-
"pattern": "^[a-zA-Z0-9-+\/*%_\\s]+$",
122-
"hidden": {
123-
"condition": false,
124-
"match": "enabled"
125-
}
126-
},
127-
"MinReplicas": {
128-
"type": ["integer", "string"],
129-
"title": "Minimum Replicas",
130-
"pattern": "^[a-zA-Z0-9-+\/*%_\\s]+$",
131-
"hidden": {
132-
"condition": false,
133-
"match": "enabled"
134-
}
135-
},
136-
"TargetCPUUtilizationPercentage": {
137-
"type": ["integer", "string"],
138-
"title": "Target CPU Utilization Percentage",
139-
"pattern": "^[a-zA-Z0-9-+\/*%_\\s]+$",
140-
"hidden": {
141-
"condition": false,
142-
"match": "enabled"
143-
}
144-
},
145-
"TargetMemoryUtilizationPercentage": {
146-
"type": ["integer", "string"],
147-
"title": "TargetMemoryUtilizationPercentage",
148-
"pattern": "^[a-zA-Z0-9-+\/*%_\\s]+$",
149-
"hidden": {
150-
"condition": false,
151-
"match": "enabled"
152-
}
153-
},
154-
"enabled": {
155-
"type": "boolean",
156-
"title": "Enabled"
157-
}
158-
}
159-
},
16054
"EnvVariables": {
16155
"type": "array",
56+
"description": "Contains environment variables needed by the containers",
16257
"items": {
16358
"type": "object",
16459
"properties": {
165-
"key": {
166-
"type": "string"
167-
},
168-
"value": {
169-
"type": "string"
170-
}
171-
}
172-
},
173-
"title": "Environment Variables"
174-
},
175-
"ContainerPort": {
176-
"type": "array",
177-
"items": {
178-
"type": "object",
179-
"properties": {
180-
"port": {
181-
"type": ["integer", "string"]
182-
},
183-
"servicePort": {
184-
"type": ["integer", "string"]
185-
}
186-
},
187-
"required": ["port", "servicePort"]
188-
},
189-
"title": "Container Port"
190-
},
191-
"service": {
192-
"type": "object",
193-
"title": "Service",
194-
"properties": {
195-
"type": {
196-
"type": "string",
197-
"title": "Type"
198-
},
199-
"annotations": {
200-
"type": "object",
201-
"additionalProperties": {
202-
"type": "string"
203-
},
204-
"title": "Annotations"
205-
}
206-
}
207-
},
208-
"ReadinessProbe": {
209-
"type": "object",
210-
"title": "Readiness Probe",
211-
"properties": {
212-
"Path": {
213-
"type": "string"
214-
},
215-
"port": {
216-
"type": ["integer", "string"]
217-
}
218-
}
219-
},
220-
"LivenessProbe": {
221-
"type": "object",
222-
"title": "Liveness Probe",
223-
"properties": {
224-
"Path": {
225-
"type": "string"
226-
},
227-
"port": {
228-
"type": ["integer", "string"]
229-
}
230-
}
231-
},
232-
"tolerations": {
233-
"type": "array",
234-
"items": {
235-
"type": "object",
236-
"properties": {
237-
"key": {
238-
"type": "string"
239-
},
240-
"operator": {
60+
"name": {
24161
"type": "string",
242-
"pattern": "Equal|Exists"
62+
"description": "Name of the environment variables"
24363
},
24464
"value": {
245-
"type": "string"
246-
},
247-
"effect": {
24865
"type": "string",
249-
"pattern": "NoSchedule|PreferNoSchedule|NoExecute"
250-
}
251-
}
252-
}
253-
},
254-
"serviceAccount": {
255-
"type": "object",
256-
"properties": {
257-
"create": {
258-
"type": "boolean"
259-
},
260-
"name": {
261-
"type": "string",
262-
"hidden": {
263-
"condition": false,
264-
"match": "create"
66+
"description": "Value of the environment variables"
26567
}
26668
}
267-
}
69+
},
70+
"title": "Environment Variables"
26871
}
26972
}
27073
}

0 commit comments

Comments
 (0)