@backstage-community/plugin-tekton-react 0.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @backstage-community/plugin-tekton-react
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 477b7e1: Migrate shared-react usage to tekton-react
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @backstage-community/plugin-tekton-react
2
+
3
+ Welcome to the web library package for the tekton plugin!
4
+
5
+ _This plugin was created through the Backstage CLI_
@@ -0,0 +1,54 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const HorizontalStackedBars = ({
4
+ id,
5
+ barGap,
6
+ height,
7
+ inline,
8
+ values,
9
+ width,
10
+ onClick
11
+ }) => {
12
+ const rootStyle = {
13
+ display: inline ? "inline-block" : "block",
14
+ height,
15
+ width,
16
+ overflow: "hidden",
17
+ cursor: onClick ? "pointer" : "default"
18
+ };
19
+ const barsStyle = {
20
+ display: "flex",
21
+ flexDirection: "row",
22
+ height: "100%",
23
+ width: `calc(100% + ${barGap}px)`,
24
+ outline: "none"
25
+ };
26
+ return (
27
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
28
+ /* @__PURE__ */ jsx(
29
+ "div",
30
+ {
31
+ id: `horizontal-stacked-bars-${id}`,
32
+ "data-testid": `horizontal-stacked-bars-${id}`,
33
+ style: rootStyle,
34
+ onClick,
35
+ children: /* @__PURE__ */ jsx("div", { style: barsStyle, children: values.map(({ color, name, size }) => /* @__PURE__ */ jsx(
36
+ "div",
37
+ {
38
+ style: {
39
+ background: color,
40
+ flexGrow: size,
41
+ height: "100%",
42
+ boxShadow: `inset ${barGap}px 0 0 #fff`,
43
+ transition: "flex-grow 300ms linear"
44
+ }
45
+ },
46
+ name
47
+ )) })
48
+ }
49
+ )
50
+ );
51
+ };
52
+
53
+ export { HorizontalStackedBars };
54
+ //# sourceMappingURL=HorizontalStackedBars.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalStackedBars.esm.js","sources":["../../../src/components/pipeline/HorizontalStackedBars.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CSSProperties } from 'react';\n\n/**\n * The stacked value for the horizontal stacked bars.\n *\n * @public\n */\nexport type StackedValue = {\n color: string;\n name: string;\n size: number;\n};\n\n/**\n * Props for the HorizontalStackedBars component.\n *\n * @public\n */\nexport type HorizontalStackedBarsProps = {\n id: string;\n barGap?: number;\n height?: number | string;\n inline?: boolean;\n values: StackedValue[];\n width?: number | string;\n onClick?: () => void;\n};\n\n/**\n * The HorizontalStackedBars component is used to display a horizontal stacked bar chart.\n *\n * @public\n */\nexport const HorizontalStackedBars = ({\n id,\n barGap,\n height,\n inline,\n values,\n width,\n onClick,\n}: HorizontalStackedBarsProps) => {\n const rootStyle: CSSProperties = {\n display: inline ? 'inline-block' : 'block',\n height,\n width,\n overflow: 'hidden',\n cursor: onClick ? 'pointer' : 'default',\n };\n\n const barsStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'row',\n height: '100%',\n width: `calc(100% + ${barGap}px)`,\n outline: 'none',\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <div\n id={`horizontal-stacked-bars-${id}`}\n data-testid={`horizontal-stacked-bars-${id}`}\n style={rootStyle}\n onClick={onClick}\n >\n <div style={barsStyle}>\n {values.map(({ color, name, size }) => (\n <div\n key={name}\n style={{\n background: color,\n flexGrow: size,\n height: '100%',\n boxShadow: `inset ${barGap}px 0 0 #fff`,\n transition: 'flex-grow 300ms linear',\n }}\n />\n ))}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;AAiDO,MAAM,wBAAwB,CAAC;AAAA,EACpC,EAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,KAAkC;AAChC,EAAA,MAAM,SAAA,GAA2B;AAAA,IAC/B,OAAA,EAAS,SAAS,cAAA,GAAiB,OAAA;AAAA,IACnC,MAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA,EAAU,QAAA;AAAA,IACV,MAAA,EAAQ,UAAU,SAAA,GAAY;AAAA,GAChC;AAEA,EAAA,MAAM,SAAA,GAA2B;AAAA,IAC/B,OAAA,EAAS,MAAA;AAAA,IACT,aAAA,EAAe,KAAA;AAAA,IACf,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,eAAe,MAAM,CAAA,GAAA,CAAA;AAAA,IAC5B,OAAA,EAAS;AAAA,GACX;AAEA,EAAA;AAAA;AAAA,oBAEE,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAA,EAAI,2BAA2B,EAAE,CAAA,CAAA;AAAA,QACjC,aAAA,EAAa,2BAA2B,EAAE,CAAA,CAAA;AAAA,QAC1C,KAAA,EAAO,SAAA;AAAA,QACP,OAAA;AAAA,QAEA,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,SAAA,EACT,QAAA,EAAA,MAAA,CAAO,GAAA,CAAI,CAAC,EAAE,KAAA,EAAO,IAAA,EAAM,IAAA,EAAK,qBAC/B,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YAEC,KAAA,EAAO;AAAA,cACL,UAAA,EAAY,KAAA;AAAA,cACZ,QAAA,EAAU,IAAA;AAAA,cACV,MAAA,EAAQ,MAAA;AAAA,cACR,SAAA,EAAW,SAAS,MAAM,CAAA,WAAA,CAAA;AAAA,cAC1B,UAAA,EAAY;AAAA;AACd,WAAA;AAAA,UAPK;AAAA,SASR,CAAA,EACH;AAAA;AAAA;AACF;AAEJ;;;;"}
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Fragment } from 'react';
3
+ import { ComputedStatus } from '../../types/pipeline/computedStatus.esm.js';
4
+ import { getRunStatusColor } from '../../utils/pipeline/pipeline.esm.js';
5
+
6
+ const TaskStatusTooltip = ({ taskStatus }) => {
7
+ return /* @__PURE__ */ jsx(
8
+ "div",
9
+ {
10
+ style: {
11
+ display: "inline-grid",
12
+ gridTemplateColumns: "1rem auto",
13
+ gridGap: "0.5rem",
14
+ textAlign: "left"
15
+ },
16
+ children: Object.keys(ComputedStatus).map((status) => {
17
+ const { message, color } = getRunStatusColor(status);
18
+ if (!taskStatus[status]) {
19
+ return null;
20
+ }
21
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ /* @__PURE__ */ jsx(
23
+ "div",
24
+ {
25
+ style: {
26
+ backgroundColor: color,
27
+ height: "1rem",
28
+ width: "1rem"
29
+ }
30
+ }
31
+ ),
32
+ /* @__PURE__ */ jsx("div", { children: status === ComputedStatus.PipelineNotStarted || status === ComputedStatus.FailedToStart ? message : `${taskStatus[status]} ${message}` })
33
+ ] }, status);
34
+ })
35
+ }
36
+ );
37
+ };
38
+
39
+ export { TaskStatusTooltip };
40
+ //# sourceMappingURL=TaskStatusTooltip.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskStatusTooltip.esm.js","sources":["../../../src/components/pipeline/TaskStatusTooltip.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment } from 'react';\n\nimport { ComputedStatus, TaskStatusTypes } from '../../types';\nimport { getRunStatusColor } from '../../utils';\n\n/**\n * Props for the TaskStatusTooltip component.\n *\n * @public\n */\nexport interface TaskStatusToolTipProps {\n /** The task status. */\n taskStatus: TaskStatusTypes;\n}\n\n/**\n * The TaskStatusTooltip component is used to display a tooltip with the status of a task.\n *\n * @param taskStatus - The task status.\n * @public\n */\nexport const TaskStatusTooltip = ({ taskStatus }: TaskStatusToolTipProps) => {\n return (\n <div\n style={{\n display: 'inline-grid',\n gridTemplateColumns: '1rem auto',\n gridGap: '0.5rem',\n textAlign: 'left',\n }}\n >\n {Object.keys(ComputedStatus).map(status => {\n const { message, color } = getRunStatusColor(status);\n\n if (!taskStatus[status as keyof TaskStatusTypes]) {\n return null;\n }\n\n return (\n <Fragment key={status}>\n <div\n style={{\n backgroundColor: color,\n height: '1rem',\n width: '1rem',\n }}\n />\n <div>\n {status === ComputedStatus.PipelineNotStarted ||\n status === ComputedStatus.FailedToStart\n ? message\n : `${taskStatus[status as keyof TaskStatusTypes]} ${message}`}\n </div>\n </Fragment>\n );\n })}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;AAqCO,MAAM,iBAAA,GAAoB,CAAC,EAAE,UAAA,EAAW,KAA8B;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,aAAA;AAAA,QACT,mBAAA,EAAqB,WAAA;AAAA,QACrB,OAAA,EAAS,QAAA;AAAA,QACT,SAAA,EAAW;AAAA,OACb;AAAA,MAEC,QAAA,EAAA,MAAA,CAAO,IAAA,CAAK,cAAc,CAAA,CAAE,IAAI,CAAA,MAAA,KAAU;AACzC,QAAA,MAAM,EAAE,OAAA,EAAS,KAAA,EAAM,GAAI,kBAAkB,MAAM,CAAA;AAEnD,QAAA,IAAI,CAAC,UAAA,CAAW,MAA+B,CAAA,EAAG;AAChD,UAAA,OAAO,IAAA;AAAA,QACT;AAEA,QAAA,4BACG,QAAA,EAAA,EACC,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,KAAA;AAAA,YAAA;AAAA,cACC,KAAA,EAAO;AAAA,gBACL,eAAA,EAAiB,KAAA;AAAA,gBACjB,MAAA,EAAQ,MAAA;AAAA,gBACR,KAAA,EAAO;AAAA;AACT;AAAA,WACF;AAAA,0BACA,GAAA,CAAC,KAAA,EAAA,EACE,QAAA,EAAA,MAAA,KAAW,cAAA,CAAe,sBAC3B,MAAA,KAAW,cAAA,CAAe,aAAA,GACtB,OAAA,GACA,GAAG,UAAA,CAAW,MAA+B,CAAC,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA,EAC/D;AAAA,SAAA,EAAA,EAba,MAcf,CAAA;AAAA,MAEJ,CAAC;AAAA;AAAA,GACH;AAEJ;;;;"}
@@ -0,0 +1,11 @@
1
+ const colors = {
2
+ skipped: "#8a8d90",
3
+ cancelled: "#6a6e73",
4
+ pending: "#8bc1f7",
5
+ running: "#06c",
6
+ success: "#38812f",
7
+ failure: "#c9190b"
8
+ };
9
+
10
+ export { colors };
11
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/constants/index.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const colors = {\n skipped: '#8a8d90',\n cancelled: '#6a6e73',\n pending: '#8bc1f7',\n running: '#06c',\n success: '#38812f',\n failure: '#c9190b',\n};\n"],"names":[],"mappings":"AAgBO,MAAM,MAAA,GAAS;AAAA,EACpB,OAAA,EAAS,SAAA;AAAA,EACT,SAAA,EAAW,SAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,MAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS;AACX;;;;"}
@@ -0,0 +1,610 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { V1ObjectMeta, V1PersistentVolumeClaimTemplate, V1ConfigMap, V1Secret } from '@kubernetes/client-node';
3
+
4
+ /**
5
+ * The stacked value for the horizontal stacked bars.
6
+ *
7
+ * @public
8
+ */
9
+ type StackedValue = {
10
+ color: string;
11
+ name: string;
12
+ size: number;
13
+ };
14
+ /**
15
+ * Props for the HorizontalStackedBars component.
16
+ *
17
+ * @public
18
+ */
19
+ type HorizontalStackedBarsProps = {
20
+ id: string;
21
+ barGap?: number;
22
+ height?: number | string;
23
+ inline?: boolean;
24
+ values: StackedValue[];
25
+ width?: number | string;
26
+ onClick?: () => void;
27
+ };
28
+ /**
29
+ * The HorizontalStackedBars component is used to display a horizontal stacked bar chart.
30
+ *
31
+ * @public
32
+ */
33
+ declare const HorizontalStackedBars: ({ id, barGap, height, inline, values, width, onClick, }: HorizontalStackedBarsProps) => react_jsx_runtime.JSX.Element;
34
+
35
+ /**
36
+ * The parameters for the task.
37
+ *
38
+ * @public
39
+ */
40
+ type TektonParam = {
41
+ default?: string | string[];
42
+ description?: string;
43
+ name: string;
44
+ type?: string;
45
+ };
46
+ /**
47
+ * The resources for the task.
48
+ *
49
+ * @public
50
+ */
51
+ type TektonResource = {
52
+ name: string;
53
+ optional?: boolean;
54
+ type: string;
55
+ };
56
+ /**
57
+ * The workspaces for the task.
58
+ *
59
+ * @public
60
+ */
61
+ type TektonWorkspace = {
62
+ name: string;
63
+ description?: string;
64
+ mountPath?: string;
65
+ readOnly?: boolean;
66
+ optional?: boolean;
67
+ };
68
+ /**
69
+ * The resource group for the task.
70
+ *
71
+ * @public
72
+ */
73
+ type TektonResourceGroup<ResourceType> = {
74
+ inputs?: ResourceType[];
75
+ outputs?: ResourceType[];
76
+ };
77
+ /**
78
+ * The steps for the task.
79
+ *
80
+ * @public
81
+ */
82
+ type TektonTaskSteps = {
83
+ name: string;
84
+ args?: string[];
85
+ command?: string[];
86
+ image?: string;
87
+ resources?: {}[] | {};
88
+ env?: {
89
+ name: string;
90
+ value?: string;
91
+ }[];
92
+ script?: string;
93
+ workingDir?: string;
94
+ volumeMounts?: {
95
+ name: string;
96
+ mountPath: string;
97
+ }[];
98
+ };
99
+ /**
100
+ * The results for the task.
101
+ *
102
+ * @public
103
+ */
104
+ type TaskResult = {
105
+ name: string;
106
+ description?: string;
107
+ };
108
+ /**
109
+ * The specification for the task.
110
+ *
111
+ * @public
112
+ */
113
+ type TektonTaskSpec = {
114
+ metadata?: {};
115
+ description?: string;
116
+ steps: TektonTaskSteps[];
117
+ params?: TektonParam[];
118
+ resources?: TektonResourceGroup<TektonResource>;
119
+ results?: TaskResult[];
120
+ workspaces?: TektonWorkspace[];
121
+ };
122
+ /**
123
+ * The results for the task run.
124
+ *
125
+ * @public
126
+ */
127
+ type TektonResultsRun = {
128
+ name: string;
129
+ type?: string;
130
+ value: string;
131
+ };
132
+ /**
133
+ * The reference for the task.
134
+ *
135
+ * @public
136
+ */
137
+ type PipelineTaskRef = {
138
+ kind?: string;
139
+ name: string;
140
+ };
141
+ /**
142
+ * The workspace for the task.
143
+ *
144
+ * @public
145
+ */
146
+ type PipelineTaskWorkspace = {
147
+ name: string;
148
+ workspace: string;
149
+ optional?: boolean;
150
+ };
151
+ /**
152
+ * The resource for the task.
153
+ *
154
+ * @public
155
+ */
156
+ type PipelineTaskResource = {
157
+ name: string;
158
+ resource?: string;
159
+ from?: string[];
160
+ };
161
+ /**
162
+ * The parameters for the task.
163
+ *
164
+ * @public
165
+ */
166
+ type PipelineTaskParam = {
167
+ name: string;
168
+ value: any;
169
+ };
170
+ /**
171
+ * The when expression for the task.
172
+ *
173
+ * @public
174
+ */
175
+ type WhenExpression = {
176
+ input: string;
177
+ operator: string;
178
+ values: string[];
179
+ };
180
+ /**
181
+ * The result for the task.
182
+ *
183
+ * @public
184
+ */
185
+ type PipelineResult = {
186
+ name: string;
187
+ value: string;
188
+ description?: string;
189
+ };
190
+ /**
191
+ * The task for the pipeline.
192
+ *
193
+ * @public
194
+ */
195
+ type PipelineTask = {
196
+ name: string;
197
+ params?: PipelineTaskParam[];
198
+ resources?: TektonResourceGroup<PipelineTaskResource>;
199
+ runAfter?: string[];
200
+ taskRef?: PipelineTaskRef;
201
+ taskSpec?: TektonTaskSpec;
202
+ when?: WhenExpression[];
203
+ workspaces?: PipelineTaskWorkspace[];
204
+ };
205
+ /**
206
+ * The specification for the pipeline.
207
+ *
208
+ * @public
209
+ */
210
+ type PipelineSpec = {
211
+ params?: TektonParam[];
212
+ resources?: TektonResource[];
213
+ serviceAccountName?: string;
214
+ tasks: PipelineTask[];
215
+ workspaces?: TektonWorkspace[];
216
+ finally?: PipelineTask[];
217
+ results?: PipelineResult[];
218
+ };
219
+ /**
220
+ * The condition for the pipeline.
221
+ *
222
+ * @public
223
+ */
224
+ type Condition = {
225
+ type: string;
226
+ status: string;
227
+ reason?: string;
228
+ message?: string;
229
+ lastTransitionTime?: string;
230
+ };
231
+
232
+ /**
233
+ * The reasons for the terminated status.
234
+ *
235
+ * @public
236
+ */
237
+ declare enum TerminatedReasons {
238
+ /** Task has been completed */
239
+ Completed = "Completed"
240
+ }
241
+ /**
242
+ * The computed status of a task.
243
+ *
244
+ * @public
245
+ */
246
+ declare enum ComputedStatus {
247
+ /** All statuses */
248
+ All = "All",
249
+ /** Task is being cancelled */
250
+ Cancelling = "Cancelling",
251
+ /** Task has succeeded */
252
+ Succeeded = "Succeeded",
253
+ /** Task has failed */
254
+ Failed = "Failed",
255
+ /** Task is running */
256
+ Running = "Running",
257
+ /** Task is in progress */
258
+ 'In Progress' = "In Progress",
259
+ /** Task failed to start */
260
+ FailedToStart = "FailedToStart",
261
+ /** Task is not started */
262
+ PipelineNotStarted = "PipelineNotStarted",
263
+ /** Task has been skipped */
264
+ Skipped = "Skipped",
265
+ /** Task has been cancelled */
266
+ Cancelled = "Cancelled",
267
+ /** Task is pending */
268
+ Pending = "Pending",
269
+ /** Task is idle */
270
+ Idle = "Idle",
271
+ /** Task is other */
272
+ Other = "Other"
273
+ }
274
+ /**
275
+ * The reasons for the succeed condition.
276
+ *
277
+ * @public
278
+ */
279
+ declare enum SucceedConditionReason {
280
+ /** Pipeline run has been cancelled */
281
+ PipelineRunCancelled = "StoppedRunFinally",
282
+ /** Pipeline run has been stopped */
283
+ PipelineRunStopped = "CancelledRunFinally",
284
+ /** Task run has been cancelled */
285
+ TaskRunCancelled = "TaskRunCancelled",
286
+ /** Task has been cancelled */
287
+ Cancelled = "Cancelled",
288
+ /** Pipeline run is stopping */
289
+ PipelineRunStopping = "PipelineRunStopping",
290
+ /** Pipeline run is pending */
291
+ PipelineRunPending = "PipelineRunPending",
292
+ /** Task run is stopping */
293
+ TaskRunStopping = "TaskRunStopping",
294
+ /** Task run has been created container config error */
295
+ CreateContainerConfigError = "CreateContainerConfigError",
296
+ /** Task run has exceeded node resources */
297
+ ExceededNodeResources = "ExceededNodeResources",
298
+ /** Task run has exceeded resource quota */
299
+ ExceededResourceQuota = "ExceededResourceQuota",
300
+ /** Task run has been condition check failed */
301
+ ConditionCheckFailed = "ConditionCheckFailed"
302
+ }
303
+ /**
304
+ * The message for the status.
305
+ *
306
+ * @public
307
+ */
308
+ type StatusMessage = {
309
+ message: string;
310
+ color: string;
311
+ };
312
+ /**
313
+ * The task status types.
314
+ *
315
+ * @public
316
+ */
317
+ type TaskStatusTypes = {
318
+ PipelineNotStarted: number;
319
+ Pending: number;
320
+ Running: number;
321
+ Succeeded: number;
322
+ Cancelled: number;
323
+ Failed: number;
324
+ Skipped: number;
325
+ };
326
+
327
+ /**
328
+ * The step for the task run.
329
+ *
330
+ * @public
331
+ */
332
+ type PLRTaskRunStep = {
333
+ container: string;
334
+ imageID?: string;
335
+ name: string;
336
+ waiting?: {
337
+ reason: string;
338
+ };
339
+ running?: {
340
+ startedAt: string;
341
+ };
342
+ terminated?: {
343
+ containerID: string;
344
+ exitCode: number;
345
+ finishedAt: string;
346
+ reason: string;
347
+ startedAt: string;
348
+ message?: string;
349
+ };
350
+ };
351
+ /**
352
+ * The parameters for the pipeline run.
353
+ *
354
+ * @public
355
+ */
356
+ type PipelineRunParam = {
357
+ name: string;
358
+ value: string | string[];
359
+ input?: string;
360
+ output?: string;
361
+ resource?: object;
362
+ };
363
+ /**
364
+ * The workspace for the pipeline run.
365
+ *
366
+ * @public
367
+ */
368
+ type PipelineRunWorkspace = {
369
+ name: string;
370
+ [volumeType: string]: {};
371
+ };
372
+ /**
373
+ * The embedded resource parameter for the pipeline run.
374
+ *
375
+ * @public
376
+ */
377
+ type PipelineRunEmbeddedResourceParam = {
378
+ name: string;
379
+ value: string;
380
+ };
381
+ /**
382
+ * The embedded resource for the pipeline run.
383
+ *
384
+ * @public
385
+ */
386
+ type PipelineRunEmbeddedResource = {
387
+ name: string;
388
+ resourceSpec: {
389
+ params: PipelineRunEmbeddedResourceParam[];
390
+ type: string;
391
+ };
392
+ };
393
+ /**
394
+ * The reference resource for the pipeline run.
395
+ *
396
+ * @public
397
+ */
398
+ type PipelineRunReferenceResource = {
399
+ name: string;
400
+ resourceRef: {
401
+ name: string;
402
+ };
403
+ };
404
+ /**
405
+ * The resource for the pipeline run.
406
+ *
407
+ * @public
408
+ */
409
+ type PipelineRunResource = PipelineRunReferenceResource | PipelineRunEmbeddedResource;
410
+ /**
411
+ * The data for the task run.
412
+ *
413
+ * @public
414
+ */
415
+ type PLRTaskRunData = {
416
+ pipelineTaskName: string;
417
+ status?: {
418
+ completionTime?: string;
419
+ conditions: Condition[];
420
+ podName: string;
421
+ startTime: string;
422
+ steps?: PLRTaskRunStep[];
423
+ taskSpec?: TektonTaskSpec;
424
+ taskResults?: {
425
+ name: string;
426
+ value: string;
427
+ type?: string;
428
+ }[];
429
+ };
430
+ };
431
+ /**
432
+ * The task runs for the pipeline run.
433
+ *
434
+ * @public
435
+ */
436
+ type PLRTaskRuns = {
437
+ [taskRunName: string]: PLRTaskRunData;
438
+ };
439
+ /**
440
+ * The status for the pipeline run.
441
+ *
442
+ * @public
443
+ */
444
+ type PipelineRunStatus = {
445
+ succeededCondition?: string;
446
+ creationTimestamp?: string;
447
+ conditions?: Condition[];
448
+ startTime?: string;
449
+ completionTime?: string;
450
+ taskRuns?: PLRTaskRuns;
451
+ pipelineSpec: PipelineSpec;
452
+ skippedTasks?: {
453
+ name: string;
454
+ }[];
455
+ pipelineResults?: TektonResultsRun[];
456
+ results?: TektonResultsRun[];
457
+ };
458
+ /**
459
+ * The kind for the pipeline run.
460
+ *
461
+ * @public
462
+ */
463
+ type PipelineRunKind = {
464
+ apiVersion?: string;
465
+ kind?: string;
466
+ metadata?: V1ObjectMeta;
467
+ spec: {
468
+ pipelineRef?: {
469
+ name: string;
470
+ };
471
+ pipelineSpec?: PipelineSpec;
472
+ params?: PipelineRunParam[];
473
+ workspaces?: PipelineRunWorkspace[];
474
+ resources?: PipelineRunResource[];
475
+ serviceAccountName?: string;
476
+ timeout?: string;
477
+ status?: string;
478
+ };
479
+ status?: PipelineRunStatus;
480
+ };
481
+ /**
482
+ * The task with status for the pipeline run.
483
+ *
484
+ * @public
485
+ */
486
+ type PipelineTaskWithStatus = PipelineTask & {
487
+ status: {
488
+ reason: string;
489
+ completionTime?: string;
490
+ conditions: Condition[];
491
+ podName?: string;
492
+ startTime?: string;
493
+ steps?: PLRTaskRunStep[];
494
+ taskSpec?: TektonTaskSpec;
495
+ taskResults?: {
496
+ name: string;
497
+ value: string;
498
+ }[];
499
+ duration?: string;
500
+ };
501
+ };
502
+
503
+ /**
504
+ * The volume type for the task run.
505
+ *
506
+ * @public
507
+ */
508
+ type VolumeTypePVC = {
509
+ claimName: string;
510
+ };
511
+ /**
512
+ * The workspace for the task run.
513
+ *
514
+ * @public
515
+ */
516
+ type TaskRunWorkspace = {
517
+ name: string;
518
+ volumeClaimTemplate?: V1PersistentVolumeClaimTemplate;
519
+ persistentVolumeClaim?: VolumeTypePVC;
520
+ configMap?: V1ConfigMap;
521
+ emptyDir?: {};
522
+ secret?: V1Secret;
523
+ subPath?: string;
524
+ };
525
+ /**
526
+ * The status for the task run.
527
+ *
528
+ * @public
529
+ */
530
+ type TaskRunStatus = {
531
+ completionTime?: string;
532
+ conditions?: Condition[];
533
+ podName?: string;
534
+ startTime?: string;
535
+ steps?: PLRTaskRunStep[];
536
+ taskResults?: TektonResultsRun[];
537
+ results?: TektonResultsRun[];
538
+ };
539
+ /**
540
+ * The kind for the task run.
541
+ *
542
+ * @public
543
+ */
544
+ type TaskRunKind = {
545
+ apiVersion?: string;
546
+ kind?: string;
547
+ metadata?: V1ObjectMeta;
548
+ spec: {
549
+ taskRef?: PipelineTaskRef;
550
+ taskSpec?: TektonTaskSpec;
551
+ serviceAccountName?: string;
552
+ params?: PipelineTaskParam[];
553
+ resources?: TektonResource[] | {};
554
+ timeout?: string;
555
+ workspaces?: TaskRunWorkspace[];
556
+ };
557
+ status?: TaskRunStatus;
558
+ };
559
+
560
+ /**
561
+ * Props for the TaskStatusTooltip component.
562
+ *
563
+ * @public
564
+ */
565
+ interface TaskStatusToolTipProps {
566
+ /** The task status. */
567
+ taskStatus: TaskStatusTypes;
568
+ }
569
+ /**
570
+ * The TaskStatusTooltip component is used to display a tooltip with the status of a task.
571
+ *
572
+ * @param taskStatus - The task status.
573
+ * @public
574
+ */
575
+ declare const TaskStatusTooltip: ({ taskStatus }: TaskStatusToolTipProps) => react_jsx_runtime.JSX.Element;
576
+
577
+ /**
578
+ * The function to get the status color for the run.
579
+ *
580
+ * @public
581
+ */
582
+ declare const getRunStatusColor: (status: string) => StatusMessage;
583
+ /**
584
+ * The function to get the status for the pipeline run.
585
+ *
586
+ * @public
587
+ */
588
+ declare const pipelineRunStatus: (pipelineRun: PipelineRunKind | TaskRunKind | PipelineTaskWithStatus | null) => ComputedStatus | null;
589
+ /**
590
+ * The function to filter the pipeline run.
591
+ *
592
+ * @public
593
+ */
594
+ declare const pipelineRunFilterReducer: (pipelineRun: PipelineRunKind | TaskRunKind) => ComputedStatus;
595
+ /**
596
+ * The function to update the task status.
597
+ *
598
+ * @public
599
+ */
600
+ declare const updateTaskStatus: (pipelinerun: PipelineRunKind | null, taskRuns: TaskRunKind[]) => TaskStatusTypes;
601
+
602
+ /**
603
+ * The function to get the task runs for the pipeline run.
604
+ *
605
+ * @public
606
+ */
607
+ declare const getTaskRunsForPipelineRun: (pipelinerun: PipelineRunKind | null, taskRuns: TaskRunKind[]) => TaskRunKind[];
608
+
609
+ export { ComputedStatus, HorizontalStackedBars, SucceedConditionReason, TaskStatusTooltip, TerminatedReasons, getRunStatusColor, getTaskRunsForPipelineRun, pipelineRunFilterReducer, pipelineRunStatus, updateTaskStatus };
610
+ export type { Condition, HorizontalStackedBarsProps, PLRTaskRunData, PLRTaskRunStep, PLRTaskRuns, PipelineResult, PipelineRunEmbeddedResource, PipelineRunEmbeddedResourceParam, PipelineRunKind, PipelineRunParam, PipelineRunReferenceResource, PipelineRunResource, PipelineRunStatus, PipelineRunWorkspace, PipelineSpec, PipelineTask, PipelineTaskParam, PipelineTaskRef, PipelineTaskResource, PipelineTaskWithStatus, PipelineTaskWorkspace, StackedValue, StatusMessage, TaskResult, TaskRunKind, TaskRunStatus, TaskRunWorkspace, TaskStatusToolTipProps, TaskStatusTypes, TektonParam, TektonResource, TektonResourceGroup, TektonResultsRun, TektonTaskSpec, TektonTaskSteps, TektonWorkspace, VolumeTypePVC, WhenExpression };
@@ -0,0 +1,6 @@
1
+ export { HorizontalStackedBars } from './components/pipeline/HorizontalStackedBars.esm.js';
2
+ export { TaskStatusTooltip } from './components/pipeline/TaskStatusTooltip.esm.js';
3
+ export { ComputedStatus, SucceedConditionReason, TerminatedReasons } from './types/pipeline/computedStatus.esm.js';
4
+ export { getRunStatusColor, pipelineRunFilterReducer, pipelineRunStatus, updateTaskStatus } from './utils/pipeline/pipeline.esm.js';
5
+ export { getTaskRunsForPipelineRun } from './utils/pipeline/task-run.esm.js';
6
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,37 @@
1
+ var TerminatedReasons = /* @__PURE__ */ ((TerminatedReasons2) => {
2
+ TerminatedReasons2["Completed"] = "Completed";
3
+ return TerminatedReasons2;
4
+ })(TerminatedReasons || {});
5
+ var ComputedStatus = /* @__PURE__ */ ((ComputedStatus2) => {
6
+ ComputedStatus2["All"] = "All";
7
+ ComputedStatus2["Cancelling"] = "Cancelling";
8
+ ComputedStatus2["Succeeded"] = "Succeeded";
9
+ ComputedStatus2["Failed"] = "Failed";
10
+ ComputedStatus2["Running"] = "Running";
11
+ ComputedStatus2["In Progress"] = "In Progress";
12
+ ComputedStatus2["FailedToStart"] = "FailedToStart";
13
+ ComputedStatus2["PipelineNotStarted"] = "PipelineNotStarted";
14
+ ComputedStatus2["Skipped"] = "Skipped";
15
+ ComputedStatus2["Cancelled"] = "Cancelled";
16
+ ComputedStatus2["Pending"] = "Pending";
17
+ ComputedStatus2["Idle"] = "Idle";
18
+ ComputedStatus2["Other"] = "Other";
19
+ return ComputedStatus2;
20
+ })(ComputedStatus || {});
21
+ var SucceedConditionReason = /* @__PURE__ */ ((SucceedConditionReason2) => {
22
+ SucceedConditionReason2["PipelineRunCancelled"] = "StoppedRunFinally";
23
+ SucceedConditionReason2["PipelineRunStopped"] = "CancelledRunFinally";
24
+ SucceedConditionReason2["TaskRunCancelled"] = "TaskRunCancelled";
25
+ SucceedConditionReason2["Cancelled"] = "Cancelled";
26
+ SucceedConditionReason2["PipelineRunStopping"] = "PipelineRunStopping";
27
+ SucceedConditionReason2["PipelineRunPending"] = "PipelineRunPending";
28
+ SucceedConditionReason2["TaskRunStopping"] = "TaskRunStopping";
29
+ SucceedConditionReason2["CreateContainerConfigError"] = "CreateContainerConfigError";
30
+ SucceedConditionReason2["ExceededNodeResources"] = "ExceededNodeResources";
31
+ SucceedConditionReason2["ExceededResourceQuota"] = "ExceededResourceQuota";
32
+ SucceedConditionReason2["ConditionCheckFailed"] = "ConditionCheckFailed";
33
+ return SucceedConditionReason2;
34
+ })(SucceedConditionReason || {});
35
+
36
+ export { ComputedStatus, SucceedConditionReason, TerminatedReasons };
37
+ //# sourceMappingURL=computedStatus.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computedStatus.esm.js","sources":["../../../src/types/pipeline/computedStatus.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The reasons for the terminated status.\n *\n * @public\n */\nexport enum TerminatedReasons {\n /** Task has been completed */\n Completed = 'Completed',\n}\n\n/**\n * The computed status of a task.\n *\n * @public\n */\nexport enum ComputedStatus {\n /** All statuses */\n All = 'All',\n /** Task is being cancelled */\n Cancelling = 'Cancelling',\n /** Task has succeeded */\n Succeeded = 'Succeeded',\n /** Task has failed */\n Failed = 'Failed',\n /** Task is running */\n Running = 'Running',\n /** Task is in progress */\n 'In Progress' = 'In Progress',\n /** Task failed to start */\n FailedToStart = 'FailedToStart',\n /** Task is not started */\n PipelineNotStarted = 'PipelineNotStarted',\n /** Task has been skipped */\n Skipped = 'Skipped',\n /** Task has been cancelled */\n Cancelled = 'Cancelled',\n /** Task is pending */\n Pending = 'Pending',\n /** Task is idle */\n Idle = 'Idle',\n /** Task is other */\n Other = 'Other',\n}\n\n/**\n * The reasons for the succeed condition.\n *\n * @public\n */\nexport enum SucceedConditionReason {\n /** Pipeline run has been cancelled */\n PipelineRunCancelled = 'StoppedRunFinally',\n /** Pipeline run has been stopped */\n PipelineRunStopped = 'CancelledRunFinally',\n /** Task run has been cancelled */\n TaskRunCancelled = 'TaskRunCancelled',\n /** Task has been cancelled */\n Cancelled = 'Cancelled',\n /** Pipeline run is stopping */\n PipelineRunStopping = 'PipelineRunStopping',\n /** Pipeline run is pending */\n PipelineRunPending = 'PipelineRunPending',\n /** Task run is stopping */\n TaskRunStopping = 'TaskRunStopping',\n /** Task run has been created container config error */\n CreateContainerConfigError = 'CreateContainerConfigError',\n /** Task run has exceeded node resources */\n ExceededNodeResources = 'ExceededNodeResources',\n /** Task run has exceeded resource quota */\n ExceededResourceQuota = 'ExceededResourceQuota',\n /** Task run has been condition check failed */\n ConditionCheckFailed = 'ConditionCheckFailed',\n}\n\n/**\n * The message for the status.\n *\n * @public\n */\nexport type StatusMessage = {\n message: string;\n color: string;\n};\n\n/**\n * The task status types.\n *\n * @public\n */\nexport type TaskStatusTypes = {\n PipelineNotStarted: number;\n Pending: number;\n Running: number;\n Succeeded: number;\n Cancelled: number;\n Failed: number;\n Skipped: number;\n};\n"],"names":["TerminatedReasons","ComputedStatus","SucceedConditionReason"],"mappings":"AAqBO,IAAK,iBAAA,qBAAAA,kBAAAA,KAAL;AAEL,EAAAA,mBAAA,WAAA,CAAA,GAAY,WAAA;AAFF,EAAA,OAAAA,kBAAAA;AAAA,CAAA,EAAA,iBAAA,IAAA,EAAA;AAUL,IAAK,cAAA,qBAAAC,eAAAA,KAAL;AAEL,EAAAA,gBAAA,KAAA,CAAA,GAAM,KAAA;AAEN,EAAAA,gBAAA,YAAA,CAAA,GAAa,YAAA;A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
+ import { colors } from '../../constants/index.esm.js';
2
+ import { ComputedStatus, SucceedConditionReason } from '../../types/pipeline/computedStatus.esm.js';
3
+ import { getTaskRunsForPipelineRun } from './task-run.esm.js';
4
+
5
+ const getRunStatusColor = (status) => {
6
+ switch (status) {
7
+ case ComputedStatus.Succeeded:
8
+ return { message: "Succeeded", color: colors.success };
9
+ case ComputedStatus.Failed:
10
+ return { message: "Failed", color: colors.failure };
11
+ case ComputedStatus.FailedToStart:
12
+ return {
13
+ message: "PipelineRun failed to start",
14
+ color: colors.failure
15
+ };
16
+ case ComputedStatus.Running:
17
+ case ComputedStatus["In Progress"]:
18
+ return { message: "Running", color: colors.running };
19
+ case ComputedStatus.Skipped:
20
+ return { message: "Skipped", color: colors.skipped };
21
+ case ComputedStatus.Cancelled:
22
+ return { message: "Cancelled", color: colors.cancelled };
23
+ case ComputedStatus.Cancelling:
24
+ return { message: "Cancelling", color: colors.cancelled };
25
+ case ComputedStatus.Idle:
26
+ case ComputedStatus.Pending:
27
+ return { message: "Pending", color: colors.pending };
28
+ default:
29
+ return {
30
+ message: "PipelineRun not started yet",
31
+ color: colors.pending
32
+ };
33
+ }
34
+ };
35
+ const getSucceededStatus = (status) => {
36
+ if (status === "True") {
37
+ return ComputedStatus.Succeeded;
38
+ } else if (status === "False") {
39
+ return ComputedStatus.Failed;
40
+ }
41
+ return ComputedStatus.Running;
42
+ };
43
+ const pipelineRunStatus = (pipelineRun) => {
44
+ const conditions = pipelineRun?.status?.conditions || [];
45
+ if (conditions.length === 0) return null;
46
+ const succeedCondition = conditions.find((c) => c.type === "Succeeded");
47
+ const cancelledCondition = conditions.find(
48
+ (c) => c.reason === "Cancelled"
49
+ );
50
+ const failedCondition = conditions.find((c) => c.reason === "Failed");
51
+ if ([
52
+ SucceedConditionReason.PipelineRunStopped,
53
+ SucceedConditionReason.PipelineRunCancelled
54
+ ].includes(
55
+ pipelineRun?.spec?.status
56
+ ) && !cancelledCondition && !failedCondition) {
57
+ return ComputedStatus.Cancelling;
58
+ }
59
+ if (!succeedCondition?.status) {
60
+ return null;
61
+ }
62
+ const status = getSucceededStatus(succeedCondition.status);
63
+ if (succeedCondition.reason && succeedCondition.reason !== status) {
64
+ switch (succeedCondition.reason) {
65
+ case SucceedConditionReason.PipelineRunCancelled:
66
+ case SucceedConditionReason.TaskRunCancelled:
67
+ case SucceedConditionReason.Cancelled:
68
+ case SucceedConditionReason.PipelineRunStopped:
69
+ return ComputedStatus.Cancelled;
70
+ case SucceedConditionReason.PipelineRunStopping:
71
+ case SucceedConditionReason.TaskRunStopping:
72
+ return ComputedStatus.Failed;
73
+ case SucceedConditionReason.CreateContainerConfigError:
74
+ case SucceedConditionReason.ExceededNodeResources:
75
+ case SucceedConditionReason.ExceededResourceQuota:
76
+ case SucceedConditionReason.PipelineRunPending:
77
+ return ComputedStatus.Pending;
78
+ case SucceedConditionReason.ConditionCheckFailed:
79
+ return ComputedStatus.Skipped;
80
+ default:
81
+ return status;
82
+ }
83
+ }
84
+ return status;
85
+ };
86
+ const pipelineRunFilterReducer = (pipelineRun) => {
87
+ const status = pipelineRunStatus(pipelineRun);
88
+ return status || ComputedStatus.Other;
89
+ };
90
+ const updateTaskStatus = (pipelinerun, taskRuns) => {
91
+ const skippedTaskLength = pipelinerun?.status?.skippedTasks?.length || 0;
92
+ const PLRTaskRuns = getTaskRunsForPipelineRun(pipelinerun, taskRuns);
93
+ const taskStatus = {
94
+ PipelineNotStarted: 0,
95
+ Pending: 0,
96
+ Running: 0,
97
+ Succeeded: 0,
98
+ Failed: 0,
99
+ Cancelled: 0,
100
+ Skipped: skippedTaskLength
101
+ };
102
+ if (!PLRTaskRuns || PLRTaskRuns.length === 0) {
103
+ return taskStatus;
104
+ }
105
+ PLRTaskRuns.forEach((taskRun) => {
106
+ const status = taskRun && pipelineRunFilterReducer(taskRun);
107
+ if (status === "Succeeded") {
108
+ taskStatus[ComputedStatus.Succeeded]++;
109
+ } else if (status === "Running") {
110
+ taskStatus[ComputedStatus.Running]++;
111
+ } else if (status === "Failed") {
112
+ taskStatus[ComputedStatus.Failed]++;
113
+ } else if (status === "Cancelled") {
114
+ taskStatus[ComputedStatus.Cancelled]++;
115
+ } else {
116
+ taskStatus[ComputedStatus.Pending]++;
117
+ }
118
+ });
119
+ return {
120
+ ...taskStatus
121
+ };
122
+ };
123
+
124
+ export { getRunStatusColor, pipelineRunFilterReducer, pipelineRunStatus, updateTaskStatus };
125
+ //# sourceMappingURL=pipeline.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.esm.js","sources":["../../../src/utils/pipeline/pipeline.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { colors } from '../../constants';\nimport {\n ComputedStatus,\n PipelineRunKind,\n PipelineTaskWithStatus,\n StatusMessage,\n SucceedConditionReason,\n TaskRunKind,\n TaskStatusTypes,\n} from '../../types';\nimport { getTaskRunsForPipelineRun } from './task-run';\n\n/**\n * The function to get the status color for the run.\n *\n * @public\n */\nexport const getRunStatusColor = (status: string): StatusMessage => {\n switch (status) {\n case ComputedStatus.Succeeded:\n return { message: 'Succeeded', color: colors.success };\n case ComputedStatus.Failed:\n return { message: 'Failed', color: colors.failure };\n case ComputedStatus.FailedToStart:\n return {\n message: 'PipelineRun failed to start',\n color: colors.failure,\n };\n case ComputedStatus.Running:\n case ComputedStatus['In Progress']:\n return { message: 'Running', color: colors.running };\n\n case ComputedStatus.Skipped:\n return { message: 'Skipped', color: colors.skipped };\n case ComputedStatus.Cancelled:\n return { message: 'Cancelled', color: colors.cancelled };\n case ComputedStatus.Cancelling:\n return { message: 'Cancelling', color: colors.cancelled };\n case ComputedStatus.Idle:\n case ComputedStatus.Pending:\n return { message: 'Pending', color: colors.pending };\n default:\n return {\n message: 'PipelineRun not started yet',\n color: colors.pending,\n };\n }\n};\n\nconst getSucceededStatus = (status: string): ComputedStatus => {\n if (status === 'True') {\n return ComputedStatus.Succeeded;\n } else if (status === 'False') {\n return ComputedStatus.Failed;\n }\n return ComputedStatus.Running;\n};\n\n/**\n * The function to get the status for the pipeline run.\n *\n * @public\n */\nexport const pipelineRunStatus = (\n pipelineRun: PipelineRunKind | TaskRunKind | PipelineTaskWithStatus | null,\n) => {\n const conditions = pipelineRun?.status?.conditions || [];\n if (conditions.length === 0) return null;\n\n const succeedCondition = conditions.find((c: any) => c.type === 'Succeeded');\n const cancelledCondition = conditions.find(\n (c: any) => c.reason === 'Cancelled',\n );\n const failedCondition = conditions.find((c: any) => c.reason === 'Failed');\n\n if (\n [\n SucceedConditionReason.PipelineRunStopped,\n SucceedConditionReason.PipelineRunCancelled,\n ].includes(\n (pipelineRun as PipelineRunKind)?.spec?.status as SucceedConditionReason,\n ) &&\n !cancelledCondition &&\n !failedCondition\n ) {\n return ComputedStatus.Cancelling;\n }\n\n if (!succeedCondition?.status) {\n return null;\n }\n\n const status = getSucceededStatus(succeedCondition.status);\n\n if (succeedCondition.reason && succeedCondition.reason !== status) {\n switch (succeedCondition.reason) {\n case SucceedConditionReason.PipelineRunCancelled:\n case SucceedConditionReason.TaskRunCancelled:\n case SucceedConditionReason.Cancelled:\n case SucceedConditionReason.PipelineRunStopped:\n return ComputedStatus.Cancelled;\n case SucceedConditionReason.PipelineRunStopping:\n case SucceedConditionReason.TaskRunStopping:\n return ComputedStatus.Failed;\n case SucceedConditionReason.CreateContainerConfigError:\n case SucceedConditionReason.ExceededNodeResources:\n case SucceedConditionReason.ExceededResourceQuota:\n case SucceedConditionReason.PipelineRunPending:\n return ComputedStatus.Pending;\n case SucceedConditionReason.ConditionCheckFailed:\n return ComputedStatus.Skipped;\n default:\n return status;\n }\n }\n return status;\n};\n\n/**\n * The function to filter the pipeline run.\n *\n * @public\n */\nexport const pipelineRunFilterReducer = (\n pipelineRun: PipelineRunKind | TaskRunKind,\n): ComputedStatus => {\n const status = pipelineRunStatus(pipelineRun);\n return status || ComputedStatus.Other;\n};\n\n/**\n * The function to update the task status.\n *\n * @public\n */\nexport const updateTaskStatus = (\n pipelinerun: PipelineRunKind | null,\n taskRuns: TaskRunKind[],\n): TaskStatusTypes => {\n const skippedTaskLength = pipelinerun?.status?.skippedTasks?.length || 0;\n const PLRTaskRuns = getTaskRunsForPipelineRun(pipelinerun, taskRuns);\n const taskStatus: TaskStatusTypes = {\n PipelineNotStarted: 0,\n Pending: 0,\n Running: 0,\n Succeeded: 0,\n Failed: 0,\n Cancelled: 0,\n Skipped: skippedTaskLength,\n };\n\n if (!PLRTaskRuns || PLRTaskRuns.length === 0) {\n return taskStatus;\n }\n\n PLRTaskRuns.forEach((taskRun: TaskRunKind) => {\n const status = taskRun && pipelineRunFilterReducer(taskRun);\n if (status === 'Succeeded') {\n taskStatus[ComputedStatus.Succeeded]++;\n } else if (status === 'Running') {\n taskStatus[ComputedStatus.Running]++;\n } else if (status === 'Failed') {\n taskStatus[ComputedStatus.Failed]++;\n } else if (status === 'Cancelled') {\n taskStatus[ComputedStatus.Cancelled]++;\n } else {\n taskStatus[ComputedStatus.Pending]++;\n }\n });\n\n return {\n ...taskStatus,\n };\n};\n"],"names":[],"mappings":";;;;AAiCO,MAAM,iBAAA,GAAoB,CAAC,MAAA,KAAkC;AAClE,EAAA,QAAQ,MAAA;AAAQ,IACd,KAAK,cAAA,CAAe,SAAA;AAClB,MAAA,OAAO,EAAE,OAAA,EAAS,WAAA,EAAa,KAAA,EAAO,OAAO,OAAA,EAAQ;AAAA,IACvD,KAAK,cAAA,CAAe,MAAA;AAClB,MAAA,OAAO,EAAE,OAAA,EAAS,QAAA,EAAU,KAAA,EAAO,OAAO,OAAA,EAAQ;AAAA,IACpD,K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AAA,CAAW,eAAe,SAAS,CAAA,EAAA;AAAA,IACrC,CAAA,MAAA,IAAW,WAAW,SAAA,EAAW;AAC/B,MAAA,UAAA,CAAW,eAAe,OAAO,CAAA,EAAA;AAAA,IACnC,CAAA,MAAA,IAAW,WAAW,QAAA,EAAU;AAC9B,MAAA,UAAA,CAAW,eAAe,MAAM,CAAA,EAAA;AAAA,IAClC,CAAA,MAAA,IAAW,WAAW,WAAA,EAAa;AACjC,MAAA,UAAA,CAAW,eAAe,SAAS,CAAA,EAAA;AAAA,IACrC,CAAA,MAAO;AACL,MAAA,UAAA,CAAW,eAAe,OAAO,CAAA,EAAA;AAAA,IACnC;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO;AAAA,IACL,GAAG;AAAA,GACL;AACF;;;;"}
@@ -0,0 +1,18 @@
1
+ const getTaskRunsForPipelineRun = (pipelinerun, taskRuns) => {
2
+ if (!taskRuns || taskRuns.length === 0) {
3
+ return [];
4
+ }
5
+ const associatedTaskRuns = taskRuns.reduce(
6
+ (acc, taskRun) => {
7
+ if (taskRun?.metadata?.ownerReferences?.[0]?.name === pipelinerun?.metadata?.name) {
8
+ acc.push(taskRun);
9
+ }
10
+ return acc;
11
+ },
12
+ []
13
+ );
14
+ return associatedTaskRuns;
15
+ };
16
+
17
+ export { getTaskRunsForPipelineRun };
18
+ //# sourceMappingURL=task-run.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-run.esm.js","sources":["../../../src/utils/pipeline/task-run.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PipelineRunKind, TaskRunKind } from '../../types';\n\n/**\n * The function to get the task runs for the pipeline run.\n *\n * @public\n */\nexport const getTaskRunsForPipelineRun = (\n pipelinerun: PipelineRunKind | null,\n taskRuns: TaskRunKind[],\n): TaskRunKind[] => {\n if (!taskRuns || taskRuns.length === 0) {\n return [];\n }\n const associatedTaskRuns = taskRuns.reduce(\n (acc: TaskRunKind[], taskRun: TaskRunKind) => {\n if (\n taskRun?.metadata?.ownerReferences?.[0]?.name ===\n pipelinerun?.metadata?.name\n ) {\n acc.push(taskRun);\n }\n return acc;\n },\n [],\n );\n\n return associatedTaskRuns;\n};\n"],"names":[],"mappings":"AAuBO,MAAM,yBAAA,GAA4B,CACvC,WAAA,EACA,QAAA,KACkB;AAClB,EAAA,IAAI,CAAC,QAAA,IAAY,QAAA,CAAS,MAAA,KAAW,CAAA,EAAG;AACtC,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,MAAM,qBAAqB,QAAA,CAAS,MAAA;AAAA,IAClC,CAAC,KAAoB,OAAA,KAAyB;AAC5C,MAAA,IACE,OAAA,EAAS,UAAU,eAAA,GAAkB,CAAC,GAAG,IAAA,KACzC,WAAA,EAAa,UAAU,IAAA,EACvB;AACA,QAAA,GAAA,CAAI,KAAK,OAAO,CAAA;AAAA,MAClB;AACA,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA;AAAC,GACH;AAEA,EAAA,OAAO,kBAAA;AACT;;;;"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@backstage-community/plugin-tekton-react",
3
+ "version": "0.1.0",
4
+ "license": "Apache-2.0",
5
+ "description": "Web library for the tekton plugin",
6
+ "main": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "main": "dist/index.esm.js",
11
+ "types": "dist/index.d.ts"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/backstage/community-plugins",
16
+ "directory": "workspaces/tekton/plugins/tekton-react"
17
+ },
18
+ "backstage": {
19
+ "role": "web-library",
20
+ "pluginId": "tekton",
21
+ "pluginPackages": [
22
+ "@backstage-community/plugin-tekton",
23
+ "@backstage-community/plugin-tekton-common",
24
+ "@backstage-community/plugin-tekton-react"
25
+ ]
26
+ },
27
+ "sideEffects": false,
28
+ "scripts": {
29
+ "start": "backstage-cli package start",
30
+ "build": "backstage-cli package build",
31
+ "lint": "backstage-cli package lint",
32
+ "test": "backstage-cli package test",
33
+ "clean": "backstage-cli package clean",
34
+ "prepack": "backstage-cli package prepack",
35
+ "postpack": "backstage-cli package postpack"
36
+ },
37
+ "dependencies": {
38
+ "@backstage/core-plugin-api": "^1.12.0",
39
+ "@kubernetes/client-node": "1.0.0-rc7",
40
+ "@material-ui/core": "^4.9.13"
41
+ },
42
+ "peerDependencies": {
43
+ "react": "^16.13.1 || ^17.0.0 || ^18.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "@backstage/cli": "^0.34.5",
47
+ "@backstage/test-utils": "^1.7.13",
48
+ "@testing-library/jest-dom": "^6.0.0",
49
+ "@testing-library/react": "^14.0.0",
50
+ "react": "^16.13.1 || ^17.0.0 || ^18.0.0"
51
+ },
52
+ "files": [
53
+ "dist"
54
+ ],
55
+ "typesVersions": {
56
+ "*": {
57
+ "package.json": [
58
+ "package.json"
59
+ ]
60
+ }
61
+ },
62
+ "module": "./dist/index.esm.js"
63
+ }