-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.example.yaml
More file actions
686 lines (686 loc) · 19.4 KB
/
Table.example.yaml
File metadata and controls
686 lines (686 loc) · 19.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# Empty columns array
# Target: simulate a configuration where the table structure is defined but contains no columns.
# Expected behavior: displays a message explaining that the table cannot be displayed without columns,
# helping the user understand that at least one column definition is required for proper rendering.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-empty-columns
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
columns: []
data:
- - valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Alice"
---
# Empty data array
# Target: simulate the absence of table rows.
# Expected behavior: renders table headers only (no data rows shown).
# This checks that the component handles an explicitly empty dataset gracefully.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-empty-data
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
columns:
- valueKey: name
title: Name
- valueKey: age
title: Age
data: []
---
# Basic table with strings and numbers
# Target: confirm that basic JSON schema types render correctly as text cells.
# Expected behavior: table shows string and integer values with plain styling.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-basic
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
pageSize: 5
columns:
- valueKey: name
title: Name
- valueKey: age
title: Age
data:
- - valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Alice"
- valueKey: age
kind: jsonSchemaType
type: integer
numberValue: 30
- - valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Bob"
- valueKey: age
kind: jsonSchemaType
type: integer
numberValue: 42
---
# Mixed data types (string, boolean, decimal, array)
# Target: test rendering for all jsonSchemaType variations.
# Expected behavior: each data type is displayed as text, array values are stringified.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-mixed-types
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
columns:
- valueKey: name
title: Name
- valueKey: active
title: Active
- valueKey: balance
title: Balance
- valueKey: tags
title: Tags
data:
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Charlie"
- valueKey: active
kind: jsonSchemaType
type: boolean
booleanValue: true
- valueKey: balance
kind: jsonSchemaType
type: decimal
decimalValue: "1023.55"
- valueKey: tags
kind: jsonSchemaType
type: array
arrayValue: ["admin", "tester"]
---
# Table including icons
# Target: verify that cells of kind=icon are rendered as FontAwesome icons.
# Expected behavior: each row shows the corresponding icon in the last column.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-icons
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
columns:
- valueKey: name
title: Name
- valueKey: icon
title: Icon
color: blue
data:
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Deployment"
- valueKey: icon
kind: icon
stringValue: fa-rocket
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Warning"
- valueKey: icon
kind: icon
stringValue: fa-exclamation-triangle
---
# Table with widget reference
# Target: illustrate how widget references would be handled.
# Expected behavior: component attempts to render nested widget using resourceRefId.
# (This will fail here without a valid referenced widget endpoint, but demonstrates intent.)
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-nested-widget
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
columns:
- valueKey: name
title: Widget Name
- valueKey: widget
title: Widget
data:
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Markdown"
- valueKey: widget
kind: widget
resourceRefId: example-table-nested-widget-markdown
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Button"
- valueKey: widget
kind: widget
resourceRefId: example-table-nested-widget-button
resourcesRefs:
items:
- id: example-table-nested-widget-markdown
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-table-nested-widget-markdown
namespace: krateo-system
resource: markdowns
verb: GET
- id: example-table-nested-widget-button
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-table-nested-widget-button
namespace: krateo-system
resource: buttons
verb: GET
---
kind: Markdown
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-nested-widget-markdown
namespace: krateo-system
spec:
widgetData:
markdown: |
This is not text but a **Markdown** widget!
---
kind: Button
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-nested-widget-button
namespace: krateo-system
spec:
widgetData:
actions:
navigate:
- id: navigate-action-page
path: /dashboard
type: navigate
label: Navigate to composition
icon: fa-sun
type: primary
clickActionId: navigate-action-page
resourcesRefs:
items:
- id: dashboard-page
apiVersion: widgets.templates.krateo.io/v1beta1
name: dashboard-page
namespace: krateo-system
resource: pages
verb: GET
---
# Table with null and missing values
# Target: ensure that null or undefined cells render gracefully.
# Expected behavior: table displays '-' placeholders in cells without valid content.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-null-values
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
columns:
- valueKey: name
title: Name
- valueKey: status
title: Status
data:
-
- valueKey: name
kind: jsonSchemaType
type: null
- valueKey: status
kind: jsonSchemaType
type: string
stringValue: "Active"
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Ghost entry"
- valueKey: status
kind: jsonSchemaType
type: null
---
# Table with filter
# Target: demonstrate interaction between table and filter components using a common prefix.
# Expected behavior: the table automatically applies filter values shared via the same prefix,
# showing only the rows that match the current filter criteria. This validates that the widget
# integrates correctly with the global FiltersProvider context.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-with-filter
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
prefix: example-table-with-filter-prefix
columns:
- valueKey: name
title: Name
- valueKey: role
title: Role
- valueKey: users
title: Users
data:
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "frontend-pod"
- valueKey: role
kind: jsonSchemaType
type: string
stringValue: "frontend"
- valueKey: users
kind: jsonSchemaType
type: array
arrayValue: ["matteo", "marco", "luca", "giovanni"]
-
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "backend-pod"
- valueKey: role
kind: jsonSchemaType
type: string
stringValue: "backend"
- valueKey: users
kind: jsonSchemaType
type: array
arrayValue: ["pippo", "pluto", "paperino"]
---
kind: Filters
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-with-filter-filter
namespace: krateo-system
spec:
widgetData:
prefix: example-table-with-filter-prefix
fields:
- label: Pod Name
name:
- name
type: string
- label: Users
name:
- users
type: string
---
# Table with pagination
# Target: verify that pagination is correctly activated when the number of rows exceeds the configured pageSize.
# Expected behavior: the table displays only the first set of rows according to pageSize,
# with navigation controls available to move through the remaining pages.
# This ensures a clean and predictable layout even with large datasets.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-with-pagination
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
pageSize: 3
columns:
- valueKey: id
title: ID
- valueKey: name
title: Name
data:
-
- valueKey: id
kind: jsonSchemaType
type: integer
numberValue: 1
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Alpha"
-
- valueKey: id
kind: jsonSchemaType
type: integer
numberValue: 2
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Bravo"
-
- valueKey: id
kind: jsonSchemaType
type: integer
numberValue: 3
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Charlie"
-
- valueKey: id
kind: jsonSchemaType
type: integer
numberValue: 4
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Delta"
-
- valueKey: id
kind: jsonSchemaType
type: integer
numberValue: 5
- valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Echo"
---
# Table with data retrieved by RESTAction
# Target: confirm that data retrieved from RESTAction renders correctly as inside a table.
# Expected behavior: table shows correctly formatted values.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-restaction
namespace: krateo-system
spec:
widgetData:
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
columns:
- valueKey: name
title: Name
- valueKey: status
title: Status
data: []
pageSize: 10
widgetDataTemplate:
- forPath: data
expression: ${ .pods }
apiRef:
name: get-pods-for-table
namespace: krateo-system
---
apiVersion: templates.krateo.io/v1
kind: RESTAction
metadata:
name: get-pods-for-table
namespace: krateo-system
spec:
api:
- name: pods
path: "/api/v1/pods"
filter: >
{
"pods": (
.pods.items
| map(
[
{
"valueKey": "name",
"kind": "jsonSchemaType",
"type": "string",
"stringValue": .metadata.name
},
{
"valueKey": "status",
"kind": "jsonSchemaType",
"type": "string",
"stringValue": .status.phase
}
]
)
)
}
---
# Basic table with table actions
# Target: confirm that actions are rendered correctly.
# Expected behavior: table shows string and integer values with an additional column for actions.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-actions
namespace: krateo-system
spec:
widgetData:
actions:
navigate:
- id: navigate-markdown
path: ${ "example-markdown-" + .json.rowId}
type: navigate
- id: navigate-markdown-resourceRefId
resourceRefId: ${ "example-markdown-" + .json.rowId }
type: navigate
openDrawer:
- id: open-drawer-markdown
type: openDrawer
resourceRefId: ${ "example-markdown-" + .json.rowId }
size: default
title: Default Drawer Example
openModal:
- id: open-modal-markdown
type: openModal
resourceRefId: ${ "example-markdown-" + .json.rowId }
size: default
title: Default Modal Example
rest:
- id: create-config-map-rest
type: rest
resourceRefId: create-configmap-from-form
payload:
metadata:
name: static-name
payloadToOverride:
- name: metadata.name
value: ${ .json.rowId }
headers:
- "Content-Type: application/json"
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
pageSize: 5
columns:
- valueKey: name
title: Name
- valueKey: age
title: Age
- valueKey: rowId
title: Row ID
hidden: true
data:
- - valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Alice"
- valueKey: age
kind: jsonSchemaType
type: integer
numberValue: 30
- valueKey: rowId
kind: jsonSchemaType
type: string
stringValue: row-1
- - valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Bob"
- valueKey: age
kind: jsonSchemaType
type: integer
numberValue: 42
- valueKey: rowId
kind: jsonSchemaType
type: string
stringValue: row-2
tableActions:
- clickActionId: open-drawer-markdown
button:
label: open drawer
- clickActionId: open-modal-markdown
button:
label: open modal
- clickActionId: navigate-markdown
button:
label: navigate (path)
type: default
size: large
- clickActionId: navigate-markdown-resourceRefId
button:
label: navigate (resource ref id)
type: default
- clickActionId: create-config-map-rest
button:
label: create config map (rest)
type: default
resourcesRefs:
items:
- id: example-markdown-row-1
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-markdown-row-1
namespace: krateo-system
resource: markdowns
verb: GET
- id: example-markdown-row-2
apiVersion: widgets.templates.krateo.io/v1beta1
name: example-markdown-row-2
namespace: krateo-system
resource: markdowns
verb: GET
- id: create-configmap-from-form
apiVersion: v1
name: create-configmap-from-form
resource: configmaps
namespace: krateo-system
verb: POST
---
kind: Markdown
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-markdown-row-1
namespace: krateo-system
spec:
widgetData:
markdown: |
# Row 1
---
kind: Markdown
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-markdown-row-2
namespace: krateo-system
spec:
widgetData:
markdown: |
# Row 2
---
# Basic table with table actions and dynamic resources
# Target: confirm that actions are rendered correctly and resources are fetched.
# Expected behavior: table shows an additional column for actions. When clicking on buttons, resources exist.
kind: Table
apiVersion: widgets.templates.krateo.io/v1beta1
metadata:
name: example-table-actions-dynamic
namespace: krateo-system
spec:
apiRef:
name: get-example-markdowns
namespace: krateo-system
widgetData:
actions:
openModal:
- id: open-modal-markdown
type: openModal
resourceRefId: ${ "example-markdown-" + .json.rowId }
title: Default Modal Example
navigate:
- id: navigate-markdown
type: navigate
path: ${ "example-markdown-" + .json.rowId }
allowedResources: [barcharts, buttons, filters, flowcharts, linecharts, markdowns, paragraphs, piecharts, yamlviewers]
pageSize: 5
columns:
- valueKey: name
title: Name
- valueKey: age
title: Age
- valueKey: rowId
title: Row ID
hidden: true
data:
- - valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Alice"
- valueKey: age
kind: jsonSchemaType
type: integer
numberValue: 30
- valueKey: rowId
kind: jsonSchemaType
type: string
stringValue: row-1
- - valueKey: name
kind: jsonSchemaType
type: string
stringValue: "Bob"
- valueKey: age
kind: jsonSchemaType
type: integer
numberValue: 42
- valueKey: rowId
kind: jsonSchemaType
type: string
stringValue: row-2
tableActions:
- clickActionId: open-modal-markdown
button:
label: Open modal
- clickActionId: navigate-markdown
button:
label: Navigate
type: default
resourcesRefs:
items: []
resourcesRefsTemplate:
- iterator: ${ .markdowns }
template:
id: ${ .metadata.name }
apiVersion: ${ .apiVersion }
resource: markdowns
namespace: ${ .metadata.namespace }
name: ${ .metadata.name }
verb: GET
---
apiVersion: templates.krateo.io/v1
kind: RESTAction
metadata:
name: get-example-markdowns
namespace: krateo-system
spec:
api:
- name: markdowns
path: /apis/widgets.templates.krateo.io/v1beta1/namespaces/krateo-system/markdowns
filter: >
{
markdowns:
(.markdowns.items
| map(select(.metadata.name | startswith("example-markdown"))))
}