@openmfp/webcomponents 0.6.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.
- package/.github/workflows/pipeline.yaml +41 -0
- package/.storybook/main.ts +34 -0
- package/.storybook/preview.ts +29 -0
- package/.storybook/tsconfig.json +11 -0
- package/AGENTS.md +153 -0
- package/CODEOWNERS +6 -0
- package/CONTRIBUTING.md +95 -0
- package/LICENSE +201 -0
- package/LICENSES/Apache-2.0.txt +73 -0
- package/README.md +91 -0
- package/REUSE.toml +9 -0
- package/angular.json +157 -0
- package/docs/dashboard.md +358 -0
- package/docs/declarative-form.md +178 -0
- package/docs/declarative-table-card.md +235 -0
- package/docs/declarative-table.md +315 -0
- package/eslint.config.js +41 -0
- package/package.json +73 -0
- package/projects/ngx/cards/favorites/favorites.component.html +12 -0
- package/projects/ngx/cards/favorites/favorites.component.scss +50 -0
- package/projects/ngx/cards/favorites/favorites.component.ts +19 -0
- package/projects/ngx/cards/public-api.ts +4 -0
- package/projects/ngx/cards/service-status/service-status-card.component.html +15 -0
- package/projects/ngx/cards/service-status/service-status-card.component.scss +87 -0
- package/projects/ngx/cards/service-status/service-status-card.component.ts +36 -0
- package/projects/ngx/cards/stories/visited-service-card.stories.ts +149 -0
- package/projects/ngx/cards/visited-service-card/visited-service-card.component.html +17 -0
- package/projects/ngx/cards/visited-service-card/visited-service-card.component.scss +34 -0
- package/projects/ngx/cards/visited-service-card/visited-service-card.component.ts +22 -0
- package/projects/ngx/cards/whats-new/whats-new.component.html +10 -0
- package/projects/ngx/cards/whats-new/whats-new.component.scss +25 -0
- package/projects/ngx/cards/whats-new/whats-new.component.ts +46 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.html +28 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.scss +44 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.spec.ts +85 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.ts +58 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.html +29 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.scss +63 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.spec.ts +255 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.ts +75 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/dashboard-card-registry.spec.ts +76 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/dashboard-card-registry.ts +109 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/index.ts +4 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-angular-card.spec.ts +141 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-angular-card.ts +44 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-sap-card.spec.ts +142 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-sap-card.ts +52 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-wc-card.spec.ts +107 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-wc-card.ts +22 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.html +134 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.scss +88 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.spec.ts +354 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts +238 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/index.ts +1 -0
- package/projects/ngx/declarative-ui/dashboard/index.ts +5 -0
- package/projects/ngx/declarative-ui/dashboard/models/constants.ts +2 -0
- package/projects/ngx/declarative-ui/dashboard/models/dashboard.model.ts +50 -0
- package/projects/ngx/declarative-ui/dashboard/models/index.ts +1 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.html +28 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.scss +85 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.spec.ts +104 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.ts +23 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.html +62 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.scss +12 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.spec.ts +301 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.ts +166 -0
- package/projects/ngx/declarative-ui/form/declarative-form/index.ts +1 -0
- package/projects/ngx/declarative-ui/form/index.ts +2 -0
- package/projects/ngx/declarative-ui/form/models/form-field-definition.ts +15 -0
- package/projects/ngx/declarative-ui/form/models/index.ts +1 -0
- package/projects/ngx/declarative-ui/form/utils/set-property-by-path.ts +30 -0
- package/projects/ngx/declarative-ui/models/index.ts +2 -0
- package/projects/ngx/declarative-ui/models/resource.ts +5 -0
- package/projects/ngx/declarative-ui/models/ui-definition.ts +95 -0
- package/projects/ngx/declarative-ui/public-api.ts +4 -0
- package/projects/ngx/declarative-ui/stories/add-card-dialog.stories.ts +91 -0
- package/projects/ngx/declarative-ui/stories/background-lightblue.png +0 -0
- package/projects/ngx/declarative-ui/stories/dashboard.cards.ts +107 -0
- package/projects/ngx/declarative-ui/stories/dashboard.stories.ts +296 -0
- package/projects/ngx/declarative-ui/stories/declarative-form.stories.ts +149 -0
- package/projects/ngx/declarative-ui/stories/declarative-table-card.stories.ts +358 -0
- package/projects/ngx/declarative-ui/stories/declarative-table.stories.ts +363 -0
- package/projects/ngx/declarative-ui/stories/pods-table.config.ts +188 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.html +138 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.scss +21 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.spec.ts +345 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.ts +61 -0
- package/projects/ngx/declarative-ui/table/declarative-table/index.ts +1 -0
- package/projects/ngx/declarative-ui/table/index.ts +2 -0
- package/projects/ngx/declarative-ui/table/models/index.ts +14 -0
- package/projects/ngx/declarative-ui/table/models/table.model.ts +17 -0
- package/projects/ngx/declarative-ui/table/utils/cssRules.engine.spec.ts +146 -0
- package/projects/ngx/declarative-ui/table/utils/cssRules.engine.ts +69 -0
- package/projects/ngx/declarative-ui/table/utils/field-definition.utils.spec.ts +70 -0
- package/projects/ngx/declarative-ui/table/utils/field-definition.utils.ts +13 -0
- package/projects/ngx/declarative-ui/table/utils/proccess-fields.spec.ts +511 -0
- package/projects/ngx/declarative-ui/table/utils/proccess-fields.ts +71 -0
- package/projects/ngx/declarative-ui/table/utils/resource-field-by-path.spec.ts +372 -0
- package/projects/ngx/declarative-ui/table/utils/resource-field-by-path.ts +98 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-cell.constants.ts +5 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.html +1 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.scss +0 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.spec.ts +119 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.ts +35 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.html +7 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.scss +0 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.spec.ts +114 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.ts +19 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.html +7 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.scss +10 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.spec.ts +188 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.ts +16 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.html +59 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.scss +33 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.spec.ts +316 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.ts +115 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.html +156 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.scss +123 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.spec.ts +786 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.ts +286 -0
- package/projects/ngx/declarative-ui/table-card/index.ts +2 -0
- package/projects/ngx/declarative-ui/table-card/models/configs.ts +46 -0
- package/projects/ngx/declarative-ui/tsconfig.lib.json +11 -0
- package/projects/ngx/declarative-ui/tsconfig.lib.prod.json +9 -0
- package/projects/ngx/declarative-ui/tsconfig.spec.json +9 -0
- package/projects/ngx/ng-package.json +8 -0
- package/projects/ngx/package.json +22 -0
- package/projects/ngx/public-api.ts +2 -0
- package/projects/ngx/tsconfig.lib.json +11 -0
- package/projects/ngx/tsconfig.lib.prod.json +9 -0
- package/projects/webcomponents/main.ts +92 -0
- package/projects/webcomponents/tsconfig.app.json +9 -0
- package/projects/webcomponents-dashboard/main.ts +15 -0
- package/projects/webcomponents-dashboard/tsconfig.app.json +9 -0
- package/renovate.json +6 -0
- package/scripts/bundle-wc.mjs +79 -0
- package/tsconfig.json +37 -0
- package/tsconfig.spec.json +8 -0
- package/tsconfig.storybook.json +16 -0
- package/vitest.config.ts +26 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import type { GenericResource } from '../models';
|
|
2
|
+
import type { TableFieldDefinition } from '../table/models';
|
|
3
|
+
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input } from '@angular/core';
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/angular';
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Sample data
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
interface Pod extends GenericResource {
|
|
11
|
+
id: string;
|
|
12
|
+
metadata: { name: string; namespace: string; uid: string };
|
|
13
|
+
status: { phase: string; ready: boolean; restarts: number; message?: string };
|
|
14
|
+
spec: { nodeName: string; image: string };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const PODS: Pod[] = [
|
|
18
|
+
{
|
|
19
|
+
id: 'abc-001',
|
|
20
|
+
metadata: { name: 'api-server-7d9f', namespace: 'default', uid: 'abc-001' },
|
|
21
|
+
status: { phase: 'Running', ready: true, restarts: 0, message: undefined },
|
|
22
|
+
spec: { nodeName: 'node-1', image: 'nginx:1.25' },
|
|
23
|
+
isAvailable: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'abc-002',
|
|
27
|
+
metadata: { name: 'worker-5bc8', namespace: 'default', uid: 'abc-002' },
|
|
28
|
+
status: {
|
|
29
|
+
phase: 'Pending',
|
|
30
|
+
ready: false,
|
|
31
|
+
restarts: 3,
|
|
32
|
+
message: 'ImagePullBackOff',
|
|
33
|
+
},
|
|
34
|
+
spec: { nodeName: 'node-2', image: 'myapp:latest' },
|
|
35
|
+
isAvailable: false,
|
|
36
|
+
accessibleName: 'Pod unavailable: ImagePullBackOff',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'abc-003',
|
|
40
|
+
metadata: {
|
|
41
|
+
name: 'cache-redis-0',
|
|
42
|
+
namespace: 'kube-system',
|
|
43
|
+
uid: 'abc-003',
|
|
44
|
+
},
|
|
45
|
+
status: { phase: 'Running', ready: true, restarts: 1, message: undefined },
|
|
46
|
+
spec: { nodeName: 'node-1', image: 'redis:7' },
|
|
47
|
+
isAvailable: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'abc-004',
|
|
51
|
+
metadata: {
|
|
52
|
+
name: 'db-postgres-0',
|
|
53
|
+
namespace: 'production',
|
|
54
|
+
uid: 'abc-004',
|
|
55
|
+
},
|
|
56
|
+
status: {
|
|
57
|
+
phase: 'Failed',
|
|
58
|
+
ready: false,
|
|
59
|
+
restarts: 5,
|
|
60
|
+
message: 'CrashLoopBackOff',
|
|
61
|
+
},
|
|
62
|
+
spec: { nodeName: 'node-3', image: 'postgres:16' },
|
|
63
|
+
isAvailable: false,
|
|
64
|
+
accessibleName: 'Pod unavailable: CrashLoopBackOff',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'abc-005',
|
|
68
|
+
metadata: {
|
|
69
|
+
name: 'ingress-ctrl-xkp',
|
|
70
|
+
namespace: 'default',
|
|
71
|
+
uid: 'abc-005',
|
|
72
|
+
},
|
|
73
|
+
status: { phase: 'Running', ready: true, restarts: 0, message: undefined },
|
|
74
|
+
spec: { nodeName: 'node-2', image: 'nginx-ingress:1.9' },
|
|
75
|
+
isAvailable: true,
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Wrapper component (avoids attachShadow conflict)
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
@Component({
|
|
84
|
+
selector: 'mfp-declarative-table-story',
|
|
85
|
+
template: `
|
|
86
|
+
<mfp-wc-declarative-table
|
|
87
|
+
[columns]="columns"
|
|
88
|
+
[hasMore]="hasMore"
|
|
89
|
+
[paginationLimit]="paginationLimit"
|
|
90
|
+
[resources]="resources"
|
|
91
|
+
[totalItemsCount]="totalItemsCount"
|
|
92
|
+
[trackByProperty]="trackByProperty"
|
|
93
|
+
/>
|
|
94
|
+
`,
|
|
95
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
96
|
+
})
|
|
97
|
+
class DeclarativeTableStory {
|
|
98
|
+
@Input() columns: TableFieldDefinition[] = [];
|
|
99
|
+
@Input() resources: GenericResource[] = PODS;
|
|
100
|
+
@Input() trackByProperty = 'metadata.uid';
|
|
101
|
+
@Input() hasMore = false;
|
|
102
|
+
@Input() paginationLimit = 5;
|
|
103
|
+
@Input() totalItemsCount?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
// Meta
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
const meta: Meta<DeclarativeTableStory> = {
|
|
111
|
+
title: 'Declarative UI / DeclarativeTable',
|
|
112
|
+
component: DeclarativeTableStory,
|
|
113
|
+
tags: ['autodocs'],
|
|
114
|
+
parameters: {
|
|
115
|
+
layout: 'fullscreen',
|
|
116
|
+
},
|
|
117
|
+
argTypes: {
|
|
118
|
+
columns: { control: 'object' },
|
|
119
|
+
resources: { control: 'object' },
|
|
120
|
+
trackByProperty: { control: 'text' },
|
|
121
|
+
hasMore: { control: 'boolean' },
|
|
122
|
+
paginationLimit: { control: 'number' },
|
|
123
|
+
totalItemsCount: { control: 'number' },
|
|
124
|
+
},
|
|
125
|
+
args: {
|
|
126
|
+
resources: PODS,
|
|
127
|
+
trackByProperty: 'metadata.uid',
|
|
128
|
+
hasMore: false,
|
|
129
|
+
paginationLimit: 5,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default meta;
|
|
134
|
+
type Story = StoryObj<DeclarativeTableStory>;
|
|
135
|
+
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
// Stories
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
/** Minimal setup: three plain-text columns. */
|
|
141
|
+
export const Basic: Story = {
|
|
142
|
+
args: {
|
|
143
|
+
columns: [
|
|
144
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
145
|
+
{ label: 'Namespace', property: 'metadata.namespace' },
|
|
146
|
+
{ label: 'Node', property: 'spec.nodeName' },
|
|
147
|
+
] satisfies TableFieldDefinition[],
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Boolean icons, secret cell with inline copy button, and conditional colour
|
|
153
|
+
* rules. The copy icon appears next to the masked value on the same line.
|
|
154
|
+
*/
|
|
155
|
+
export const CellDisplayModes: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
columns: [
|
|
158
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
159
|
+
{
|
|
160
|
+
label: 'Ready',
|
|
161
|
+
property: 'status.ready',
|
|
162
|
+
uiSettings: { displayAs: 'boolIcon' },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
label: 'Phase',
|
|
166
|
+
property: 'status.phase',
|
|
167
|
+
uiSettings: {
|
|
168
|
+
cssRules: [
|
|
169
|
+
{
|
|
170
|
+
if: { condition: 'equals', value: 'Running' },
|
|
171
|
+
styles: { color: 'green' },
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
if: { condition: 'equals', value: 'Pending' },
|
|
175
|
+
styles: { color: 'darkorange' },
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
if: { condition: 'equals', value: 'Failed' },
|
|
179
|
+
styles: { color: 'red', fontWeight: 'bold' },
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
label: 'UID',
|
|
186
|
+
property: 'metadata.uid',
|
|
187
|
+
uiSettings: { displayAs: 'secret', withCopyButton: true },
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: 'Image',
|
|
191
|
+
property: 'spec.image',
|
|
192
|
+
uiSettings: { displayAs: 'tooltip', tooltipIcon: 'information' },
|
|
193
|
+
},
|
|
194
|
+
] satisfies TableFieldDefinition[],
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/** Two columns sharing the same group name are merged into one header. */
|
|
199
|
+
export const GroupedColumns: Story = {
|
|
200
|
+
args: {
|
|
201
|
+
columns: [
|
|
202
|
+
{
|
|
203
|
+
label: 'Name',
|
|
204
|
+
property: 'metadata.name',
|
|
205
|
+
group: { name: 'identity', label: 'Identity', delimiter: ' / ' },
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
label: 'Namespace',
|
|
209
|
+
property: 'metadata.namespace',
|
|
210
|
+
group: { name: 'identity' },
|
|
211
|
+
},
|
|
212
|
+
{ label: 'Phase', property: 'status.phase' },
|
|
213
|
+
{ label: 'Node', property: 'spec.nodeName' },
|
|
214
|
+
] satisfies TableFieldDefinition[],
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Group with a space delimiter and labelDisplay — values rendered as blue
|
|
220
|
+
* badge labels, separated by a single space. Also demonstrates the alert
|
|
221
|
+
* display type: a warning icon appears when the field value is falsy.
|
|
222
|
+
*/
|
|
223
|
+
export const GroupedWithLabelsAndAlert: Story = {
|
|
224
|
+
args: {
|
|
225
|
+
columns: [
|
|
226
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
227
|
+
{
|
|
228
|
+
property: 'spec.nodeName',
|
|
229
|
+
uiSettings: { labelDisplay: true },
|
|
230
|
+
group: {
|
|
231
|
+
name: 'placement',
|
|
232
|
+
label: 'Placement',
|
|
233
|
+
delimiter: ' ',
|
|
234
|
+
multiline: false,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
property: 'spec.image',
|
|
239
|
+
uiSettings: { labelDisplay: true },
|
|
240
|
+
group: { name: 'placement' },
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
label: 'OK',
|
|
244
|
+
property: 'status.message',
|
|
245
|
+
uiSettings: { displayAs: 'alert' },
|
|
246
|
+
},
|
|
247
|
+
{ label: 'Message', property: 'status.message', value: '—' },
|
|
248
|
+
] satisfies TableFieldDefinition[],
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* `uiSettings.columnWidth` sets the width of the header cell (and thus the
|
|
254
|
+
* whole column). Useful for icon-only columns like `alert` or `boolIcon` where
|
|
255
|
+
* the default `auto` width is wider than necessary.
|
|
256
|
+
*/
|
|
257
|
+
export const ColumnWidth: Story = {
|
|
258
|
+
args: {
|
|
259
|
+
columns: [
|
|
260
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
261
|
+
{
|
|
262
|
+
label: 'Alert',
|
|
263
|
+
property: 'status.message',
|
|
264
|
+
uiSettings: { displayAs: 'alert', columnWidth: '60px' },
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
label: 'Ready',
|
|
268
|
+
property: 'status.ready',
|
|
269
|
+
uiSettings: { displayAs: 'boolIcon', columnWidth: '60px' },
|
|
270
|
+
},
|
|
271
|
+
{ label: 'Phase', property: 'status.phase' },
|
|
272
|
+
] satisfies TableFieldDefinition[],
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/** JSONPath expression for deeply nested or array values. */
|
|
277
|
+
export const JsonPathExpression: Story = {
|
|
278
|
+
args: {
|
|
279
|
+
columns: [
|
|
280
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
281
|
+
{ label: 'Namespace', jsonPathExpression: '$.metadata.namespace' },
|
|
282
|
+
{ label: 'Image', jsonPathExpression: '$.spec.image' },
|
|
283
|
+
{ label: 'Restarts', jsonPathExpression: '$.status.restarts' },
|
|
284
|
+
] satisfies TableFieldDefinition[],
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/** Static fallback value shown when the resource field is absent. */
|
|
289
|
+
export const StaticFallback: Story = {
|
|
290
|
+
args: {
|
|
291
|
+
columns: [
|
|
292
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
293
|
+
{ label: 'Message', property: 'status.message', value: '—' },
|
|
294
|
+
] satisfies TableFieldDefinition[],
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/** Load-more pagination trigger. Click "Load More" to fire loadMoreResources. */
|
|
299
|
+
export const Pagination: Story = {
|
|
300
|
+
args: {
|
|
301
|
+
columns: [
|
|
302
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
303
|
+
{ label: 'Namespace', property: 'metadata.namespace' },
|
|
304
|
+
{ label: 'Phase', property: 'status.phase' },
|
|
305
|
+
] satisfies TableFieldDefinition[],
|
|
306
|
+
hasMore: true,
|
|
307
|
+
paginationLimit: 5,
|
|
308
|
+
totalItemsCount: 20,
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/** Button cell that fires buttonClick with { event, field, resource }. */
|
|
313
|
+
export const ButtonCell: Story = {
|
|
314
|
+
args: {
|
|
315
|
+
columns: [
|
|
316
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
317
|
+
{ label: 'Phase', property: 'status.phase' },
|
|
318
|
+
{
|
|
319
|
+
label: 'Actions',
|
|
320
|
+
property: 'metadata.name',
|
|
321
|
+
uiSettings: {
|
|
322
|
+
displayAs: 'button',
|
|
323
|
+
buttonSettings: {
|
|
324
|
+
text: 'Inspect',
|
|
325
|
+
icon: 'inspect',
|
|
326
|
+
design: 'Emphasized',
|
|
327
|
+
action: 'navigate',
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
] satisfies TableFieldDefinition[],
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/** Empty resources array triggers the illustrated empty-state message. */
|
|
336
|
+
export const EmptyState: Story = {
|
|
337
|
+
args: {
|
|
338
|
+
columns: [
|
|
339
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
340
|
+
{ label: 'Namespace', property: 'metadata.namespace' },
|
|
341
|
+
] satisfies TableFieldDefinition[],
|
|
342
|
+
resources: [],
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* isAvailable=false greys out the row and disables interaction.
|
|
348
|
+
* accessibleName is used as the tooltip text on the alert icon for unavailable pods.
|
|
349
|
+
*/
|
|
350
|
+
export const RowAvailability: Story = {
|
|
351
|
+
args: {
|
|
352
|
+
columns: [
|
|
353
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
354
|
+
{ label: 'Phase', property: 'status.phase' },
|
|
355
|
+
{ label: 'Node', property: 'spec.nodeName' },
|
|
356
|
+
{
|
|
357
|
+
label: 'Status',
|
|
358
|
+
property: 'isAvailable',
|
|
359
|
+
uiSettings: { displayAs: 'alert' },
|
|
360
|
+
},
|
|
361
|
+
] satisfies TableFieldDefinition[],
|
|
362
|
+
},
|
|
363
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { TableFieldDefinition } from '../../declarative-ui/table/models';
|
|
2
|
+
import type {
|
|
3
|
+
DeleteResourceConfirmationConfig,
|
|
4
|
+
ResourceFormConfig,
|
|
5
|
+
TableCardConfig,
|
|
6
|
+
TableConfig,
|
|
7
|
+
} from '..//table-card/models/configs';
|
|
8
|
+
|
|
9
|
+
export const TABLE_RESOURCES = [
|
|
10
|
+
{
|
|
11
|
+
id: 'abc-001',
|
|
12
|
+
metadata: { name: 'api-server-7d9f', namespace: 'default', uid: 'abc-001' },
|
|
13
|
+
status: { phase: 'Running', ready: true, restarts: 0, message: undefined },
|
|
14
|
+
spec: { nodeName: 'node-1', image: 'nginx:1.25' },
|
|
15
|
+
isAvailable: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'abc-002',
|
|
19
|
+
metadata: { name: 'worker-5bc8', namespace: 'default', uid: 'abc-002' },
|
|
20
|
+
status: {
|
|
21
|
+
phase: 'Pending',
|
|
22
|
+
ready: false,
|
|
23
|
+
restarts: 3,
|
|
24
|
+
message: 'ImagePullBackOff',
|
|
25
|
+
},
|
|
26
|
+
spec: { nodeName: 'node-2', image: 'myapp:latest' },
|
|
27
|
+
isAvailable: false,
|
|
28
|
+
accessibleName: 'Pod unavailable: ImagePullBackOff',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'abc-003',
|
|
32
|
+
metadata: {
|
|
33
|
+
name: 'cache-redis-0',
|
|
34
|
+
namespace: 'kube-system',
|
|
35
|
+
uid: 'abc-003',
|
|
36
|
+
},
|
|
37
|
+
status: { phase: 'Running', ready: true, restarts: 1, message: undefined },
|
|
38
|
+
spec: { nodeName: 'node-1', image: 'redis:7' },
|
|
39
|
+
isAvailable: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'abc-004',
|
|
43
|
+
metadata: {
|
|
44
|
+
name: 'db-postgres-0',
|
|
45
|
+
namespace: 'production',
|
|
46
|
+
uid: 'abc-004',
|
|
47
|
+
},
|
|
48
|
+
status: {
|
|
49
|
+
phase: 'Failed',
|
|
50
|
+
ready: false,
|
|
51
|
+
restarts: 5,
|
|
52
|
+
message: 'CrashLoopBackOff',
|
|
53
|
+
},
|
|
54
|
+
spec: { nodeName: 'node-3', image: 'postgres:16' },
|
|
55
|
+
isAvailable: false,
|
|
56
|
+
accessibleName: 'Pod unavailable: CrashLoopBackOff',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'abc-005',
|
|
60
|
+
metadata: {
|
|
61
|
+
name: 'ingress-ctrl-xkp',
|
|
62
|
+
namespace: 'default',
|
|
63
|
+
uid: 'abc-005',
|
|
64
|
+
},
|
|
65
|
+
status: { phase: 'Running', ready: true, restarts: 0, message: undefined },
|
|
66
|
+
spec: { nodeName: 'node-2', image: 'nginx-ingress:1.9' },
|
|
67
|
+
isAvailable: true,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export const TABLE_COLUMNS: TableFieldDefinition[] = [
|
|
72
|
+
{ label: 'Name', property: 'metadata.name' },
|
|
73
|
+
{ label: 'Namespace', property: 'metadata.namespace' },
|
|
74
|
+
{
|
|
75
|
+
label: 'Ready',
|
|
76
|
+
property: 'status.ready',
|
|
77
|
+
uiSettings: { displayAs: 'boolIcon', columnWidth: '56px' },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: 'Phase',
|
|
81
|
+
property: 'status.phase',
|
|
82
|
+
uiSettings: {
|
|
83
|
+
cssRules: [
|
|
84
|
+
{
|
|
85
|
+
if: { condition: 'equals', value: 'Running' },
|
|
86
|
+
styles: { color: 'green' },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
if: { condition: 'equals', value: 'Pending' },
|
|
90
|
+
styles: { color: 'darkorange' },
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
if: { condition: 'equals', value: 'Failed' },
|
|
94
|
+
styles: { color: 'red', fontWeight: 'bold' },
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: 'UID',
|
|
101
|
+
property: 'metadata.uid',
|
|
102
|
+
uiSettings: { displayAs: 'secret', withCopyButton: true },
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
property: 'spec.image',
|
|
106
|
+
uiSettings: { labelDisplay: true },
|
|
107
|
+
group: { name: 'placement', label: 'Placement', delimiter: ' ' },
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
property: 'spec.nodeName',
|
|
111
|
+
uiSettings: { labelDisplay: true },
|
|
112
|
+
group: { name: 'placement' },
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: 'Alert',
|
|
116
|
+
property: 'status.message',
|
|
117
|
+
uiSettings: { displayAs: 'alert', columnWidth: '42px' },
|
|
118
|
+
},
|
|
119
|
+
{ label: 'Message', property: 'status.message', value: '—' },
|
|
120
|
+
{
|
|
121
|
+
property: 'metadata.name',
|
|
122
|
+
uiSettings: {
|
|
123
|
+
displayAs: 'button',
|
|
124
|
+
buttonSettings: {
|
|
125
|
+
icon: 'inspect',
|
|
126
|
+
design: 'Transparent',
|
|
127
|
+
action: 'navigate',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
group: { name: 'actions', label: 'Actions', multiline: false },
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
export const POD_FORM_FIELDS = [
|
|
135
|
+
{ name: 'metadata.name', label: 'Name', required: true },
|
|
136
|
+
{
|
|
137
|
+
name: 'metadata.namespace',
|
|
138
|
+
label: 'Namespace',
|
|
139
|
+
required: true,
|
|
140
|
+
values: ['default', 'kube-system', 'production'],
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
export const POD_EDIT_FORM_FIELDS = [
|
|
145
|
+
{ name: 'metadata.name', label: 'Name', required: true, disabled: true },
|
|
146
|
+
{
|
|
147
|
+
name: 'metadata.namespace',
|
|
148
|
+
label: 'Namespace',
|
|
149
|
+
required: true,
|
|
150
|
+
values: ['default', 'kube-system', 'production'],
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
export const BASE_TABLE_CONFIG: TableConfig = {
|
|
155
|
+
fields: TABLE_COLUMNS,
|
|
156
|
+
paginationLimit: 5,
|
|
157
|
+
hasMore: false,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export const DELETE_CONFIRMATION_CONFIG: DeleteResourceConfirmationConfig = {
|
|
161
|
+
title: 'Delete Pod?',
|
|
162
|
+
message: 'This action cannot be undone. The pod will be permanently removed.',
|
|
163
|
+
confirmLabel: 'Delete',
|
|
164
|
+
cancelLabel: 'Cancel',
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const CREATE_FORM_CONFIG: ResourceFormConfig = {
|
|
168
|
+
fields: POD_FORM_FIELDS,
|
|
169
|
+
title: 'Create Pod',
|
|
170
|
+
confirmLabel: 'Create',
|
|
171
|
+
cancelLabel: 'Cancel',
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const EDIT_FORM_CONFIG: ResourceFormConfig = {
|
|
175
|
+
fields: POD_EDIT_FORM_FIELDS,
|
|
176
|
+
title: 'Edit Pod',
|
|
177
|
+
confirmLabel: 'Save',
|
|
178
|
+
cancelLabel: 'Cancel',
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export const TABLE_CARD_CONFIG: TableCardConfig = {
|
|
182
|
+
header: 'Pods',
|
|
183
|
+
headerTooltip: 'This table lists all pods running in the cluster.',
|
|
184
|
+
tableConfig: BASE_TABLE_CONFIG,
|
|
185
|
+
createResourceFormConfig: CREATE_FORM_CONFIG,
|
|
186
|
+
editResourceFormConfig: EDIT_FORM_CONFIG,
|
|
187
|
+
deleteResourceConfirmationConfig: DELETE_CONFIRMATION_CONFIG,
|
|
188
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<ui5-table test-id="generic-table">
|
|
2
|
+
<ui5-table-header-row slot="headerRow">
|
|
3
|
+
@for (column of viewColumns(); track columnTrackBy(column, $index)) {
|
|
4
|
+
@if (column.group) {
|
|
5
|
+
<ui5-table-header-cell
|
|
6
|
+
[attr.test-id]="'generic-table-header-' + column.property"
|
|
7
|
+
>{{ column.group.label ?? column.group.name }}</ui5-table-header-cell
|
|
8
|
+
>
|
|
9
|
+
} @else {
|
|
10
|
+
<ui5-table-header-cell
|
|
11
|
+
[attr.test-id]="'generic-table-header-' + column.property"
|
|
12
|
+
[width]="column.uiSettings?.columnWidth ?? 'auto'"
|
|
13
|
+
>{{ column.label }}</ui5-table-header-cell
|
|
14
|
+
>
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
</ui5-table-header-row>
|
|
18
|
+
|
|
19
|
+
@for (item of resources(); let i = $index; track rowTrackBy($index, item)) {
|
|
20
|
+
<ui5-table-row
|
|
21
|
+
[attr.test-id]="'generic-table-row-' + i"
|
|
22
|
+
[class.disabled]="!(item.isAvailable ?? true)"
|
|
23
|
+
[interactive]="item.isAvailable ?? true"
|
|
24
|
+
(click)="tableRowClicked.emit(item)"
|
|
25
|
+
>
|
|
26
|
+
@for (column of viewColumns(); track columnTrackBy(column, $index)) {
|
|
27
|
+
@if (column.group) {
|
|
28
|
+
<ui5-table-cell
|
|
29
|
+
[attr.test-id]="'generic-table-cell-' + i + '-' + column.property"
|
|
30
|
+
[class.multiline]="column.group.multiline ?? true"
|
|
31
|
+
>
|
|
32
|
+
@for (
|
|
33
|
+
field of column.group.fields;
|
|
34
|
+
let last = $last;
|
|
35
|
+
track columnTrackBy(field, $index)
|
|
36
|
+
) {
|
|
37
|
+
<span
|
|
38
|
+
class="group-value"
|
|
39
|
+
[attr.test-id]="
|
|
40
|
+
'generic-table-cell-' +
|
|
41
|
+
i +
|
|
42
|
+
'-' +
|
|
43
|
+
column.property +
|
|
44
|
+
'-' +
|
|
45
|
+
field.property
|
|
46
|
+
"
|
|
47
|
+
>
|
|
48
|
+
@if (field.label) {
|
|
49
|
+
<span>{{ field.label }}: </span>
|
|
50
|
+
}
|
|
51
|
+
<mfp-value-cell
|
|
52
|
+
[fieldDefinition]="field"
|
|
53
|
+
[resource]="item"
|
|
54
|
+
(buttonClick)="buttonClick.emit($event)"
|
|
55
|
+
/>
|
|
56
|
+
</span>
|
|
57
|
+
@if (!last && column.group.delimiter) {
|
|
58
|
+
<span>{{ column.group.delimiter }}</span>
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</ui5-table-cell>
|
|
62
|
+
} @else {
|
|
63
|
+
<ui5-table-cell
|
|
64
|
+
[attr.test-id]="'generic-table-cell-' + i + '-' + column.property"
|
|
65
|
+
>
|
|
66
|
+
<mfp-value-cell
|
|
67
|
+
[fieldDefinition]="column"
|
|
68
|
+
[resource]="item"
|
|
69
|
+
(buttonClick)="buttonClick.emit($event)"
|
|
70
|
+
/>
|
|
71
|
+
</ui5-table-cell>
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
</ui5-table-row>
|
|
75
|
+
} @empty {
|
|
76
|
+
<ui5-illustrated-message
|
|
77
|
+
name="NoData"
|
|
78
|
+
slot="noData"
|
|
79
|
+
test-id="generic-table-view-nodata"
|
|
80
|
+
>
|
|
81
|
+
<span slot="title">No Resources</span>
|
|
82
|
+
<span slot="subtitle">There are currently no items to show.</span>
|
|
83
|
+
</ui5-illustrated-message>
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@if (hasMore()) {
|
|
87
|
+
<ui5-table-growing
|
|
88
|
+
id="growing"
|
|
89
|
+
mode="Button"
|
|
90
|
+
slot="features"
|
|
91
|
+
text="Load more"
|
|
92
|
+
(ui5LoadMore)="loadMoreResources.emit()"
|
|
93
|
+
/>
|
|
94
|
+
}
|
|
95
|
+
</ui5-table>
|
|
96
|
+
|
|
97
|
+
<!-- Pagination Control -->
|
|
98
|
+
<div
|
|
99
|
+
class="pagination-footer"
|
|
100
|
+
style="
|
|
101
|
+
display: flex;
|
|
102
|
+
justify-content: space-between;
|
|
103
|
+
align-items: center;
|
|
104
|
+
padding: 0rem 1rem;
|
|
105
|
+
min-height: 3rem;
|
|
106
|
+
border-top: 1px solid var(--sapList_BorderColor);
|
|
107
|
+
"
|
|
108
|
+
>
|
|
109
|
+
<div style="display: flex; align-items: center; gap: 1.5rem">
|
|
110
|
+
<div style="display: flex; align-items: center; gap: 0.5rem">
|
|
111
|
+
<span
|
|
112
|
+
style="color: var(--sapTextColor); font-size: var(--sapFontSmallSize)"
|
|
113
|
+
>Items per load:</span
|
|
114
|
+
>
|
|
115
|
+
<ui5-select
|
|
116
|
+
style="width: 5rem"
|
|
117
|
+
(change)="paginationLimitChanged.emit(+$any($event)?.target?.value)"
|
|
118
|
+
[value]="paginationLimit().toString()"
|
|
119
|
+
>
|
|
120
|
+
<ui5-option value="5">5</ui5-option>
|
|
121
|
+
<ui5-option value="10">10</ui5-option>
|
|
122
|
+
<ui5-option value="50">50</ui5-option>
|
|
123
|
+
<ui5-option value="100">100</ui5-option>
|
|
124
|
+
</ui5-select>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<span
|
|
128
|
+
style="color: var(--sapTextColor); font-size: var(--sapFontSmallSize)"
|
|
129
|
+
>
|
|
130
|
+
Items loaded:
|
|
131
|
+
<b>{{
|
|
132
|
+
totalItemsCount() !== undefined
|
|
133
|
+
? resources().length + ' / ' + totalItemsCount()
|
|
134
|
+
: resources().length
|
|
135
|
+
}}</b>
|
|
136
|
+
</span>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.multiline {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.disabled {
|
|
6
|
+
filter: brightness(0.92);
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
|
|
9
|
+
ui5-table-cell:not(:first-child) {
|
|
10
|
+
color: var(--sapContent_DisabledTextColor, #6a6d70);
|
|
11
|
+
|
|
12
|
+
ui5-icon {
|
|
13
|
+
color: var(--sapContent_DisabledTextColor, #6a6d70);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.group-value {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
}
|