@backstage-community/plugin-tekton 3.22.2 → 3.25.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/components/Charts/PipelineBars.esm.js +33 -29
  3. package/dist/components/Charts/PipelineBars.esm.js.map +1 -1
  4. package/dist/components/Icons/CriticalRiskIcon.esm.js +8 -6
  5. package/dist/components/Icons/CriticalRiskIcon.esm.js.map +1 -1
  6. package/dist/components/Icons/EqualsIcon.esm.js +8 -6
  7. package/dist/components/Icons/EqualsIcon.esm.js.map +1 -1
  8. package/dist/components/Icons/LinkToSbomIcon.esm.js +5 -5
  9. package/dist/components/Icons/LinkToSbomIcon.esm.js.map +1 -1
  10. package/dist/components/Icons/OutputIcon.esm.js +6 -8
  11. package/dist/components/Icons/OutputIcon.esm.js.map +1 -1
  12. package/dist/components/Icons/SignedBadge.esm.js +3 -3
  13. package/dist/components/Icons/SignedBadge.esm.js.map +1 -1
  14. package/dist/components/Icons/ViewLogsIcon.esm.js +6 -8
  15. package/dist/components/Icons/ViewLogsIcon.esm.js.map +1 -1
  16. package/dist/components/PipelineRunList/PipelineRunColumnHeader.esm.js +43 -41
  17. package/dist/components/PipelineRunList/PipelineRunColumnHeader.esm.js.map +1 -1
  18. package/dist/components/PipelineRunList/PipelineRunList.esm.js +92 -68
  19. package/dist/components/PipelineRunList/PipelineRunList.esm.js.map +1 -1
  20. package/dist/components/PipelineRunList/PipelineRunListSearchBar.esm.js +13 -10
  21. package/dist/components/PipelineRunList/PipelineRunListSearchBar.esm.js.map +1 -1
  22. package/dist/components/PipelineRunList/PipelineRunOutput.esm.js +17 -11
  23. package/dist/components/PipelineRunList/PipelineRunOutput.esm.js.map +1 -1
  24. package/dist/components/PipelineRunList/PipelineRunRow.esm.js +39 -24
  25. package/dist/components/PipelineRunList/PipelineRunRow.esm.js.map +1 -1
  26. package/dist/components/PipelineRunList/PipelineRunRowActions.esm.js +88 -76
  27. package/dist/components/PipelineRunList/PipelineRunRowActions.esm.js.map +1 -1
  28. package/dist/components/PipelineRunList/PipelineRunSBOMLink.esm.js +4 -4
  29. package/dist/components/PipelineRunList/PipelineRunSBOMLink.esm.js.map +1 -1
  30. package/dist/components/PipelineRunList/PipelineRunTableBody.esm.js +9 -8
  31. package/dist/components/PipelineRunList/PipelineRunTableBody.esm.js.map +1 -1
  32. package/dist/components/PipelineRunList/PipelineRunTaskStatus.esm.js +2 -2
  33. package/dist/components/PipelineRunList/PipelineRunTaskStatus.esm.js.map +1 -1
  34. package/dist/components/PipelineRunList/PipelineRunVulnerabilities.esm.js +90 -20
  35. package/dist/components/PipelineRunList/PipelineRunVulnerabilities.esm.js.map +1 -1
  36. package/dist/components/PipelineRunList/PipelineTableHeader.esm.js +26 -19
  37. package/dist/components/PipelineRunList/PipelineTableHeader.esm.js.map +1 -1
  38. package/dist/components/PipelineRunList/PlrStatus.esm.js +2 -2
  39. package/dist/components/PipelineRunList/PlrStatus.esm.js.map +1 -1
  40. package/dist/components/PipelineRunList/ResourceBadge.esm.js +6 -2
  41. package/dist/components/PipelineRunList/ResourceBadge.esm.js.map +1 -1
  42. package/dist/components/PipelineRunLogs/PipelineRunLogDialog.esm.js +52 -40
  43. package/dist/components/PipelineRunLogs/PipelineRunLogDialog.esm.js.map +1 -1
  44. package/dist/components/PipelineRunLogs/PipelineRunLogDownloader.esm.js +31 -23
  45. package/dist/components/PipelineRunLogs/PipelineRunLogDownloader.esm.js.map +1 -1
  46. package/dist/components/PipelineRunLogs/PipelineRunLogViewer.esm.js +46 -24
  47. package/dist/components/PipelineRunLogs/PipelineRunLogViewer.esm.js.map +1 -1
  48. package/dist/components/PipelineRunLogs/PipelineRunLogs.esm.js +30 -20
  49. package/dist/components/PipelineRunLogs/PipelineRunLogs.esm.js.map +1 -1
  50. package/dist/components/PipelineRunLogs/PodLogsDownloadLink.esm.js +15 -9
  51. package/dist/components/PipelineRunLogs/PodLogsDownloadLink.esm.js.map +1 -1
  52. package/dist/components/PipelineRunLogs/TaskStatusStepper.esm.js +43 -36
  53. package/dist/components/PipelineRunLogs/TaskStatusStepper.esm.js.map +1 -1
  54. package/dist/components/PipelineRunOutput/PipelineRunOutputDialog.esm.js +32 -22
  55. package/dist/components/PipelineRunOutput/PipelineRunOutputDialog.esm.js.map +1 -1
  56. package/dist/components/Router.esm.js +2 -2
  57. package/dist/components/Router.esm.js.map +1 -1
  58. package/dist/components/Tekton/TektonCIComponent.esm.js +5 -4
  59. package/dist/components/Tekton/TektonCIComponent.esm.js.map +1 -1
  60. package/dist/components/common/ClusterSelector.esm.js +17 -13
  61. package/dist/components/common/ClusterSelector.esm.js.map +1 -1
  62. package/dist/components/common/ErrorPanel.esm.js +25 -17
  63. package/dist/components/common/ErrorPanel.esm.js.map +1 -1
  64. package/dist/components/common/PermissionAlert.esm.js +8 -2
  65. package/dist/components/common/PermissionAlert.esm.js.map +1 -1
  66. package/dist/components/common/StatusSelector.esm.js +19 -12
  67. package/dist/components/common/StatusSelector.esm.js.map +1 -1
  68. package/dist/components/common/TableExpandCollapse.esm.js +26 -21
  69. package/dist/components/common/TableExpandCollapse.esm.js.map +1 -1
  70. package/dist/components/pipeline-topology/PipelineLayout.esm.js +14 -13
  71. package/dist/components/pipeline-topology/PipelineLayout.esm.js.map +1 -1
  72. package/dist/components/pipeline-topology/PipelineRunVisualization.esm.js +2 -2
  73. package/dist/components/pipeline-topology/PipelineRunVisualization.esm.js.map +1 -1
  74. package/dist/components/pipeline-topology/PipelineTaskNode.esm.js +63 -59
  75. package/dist/components/pipeline-topology/PipelineTaskNode.esm.js.map +1 -1
  76. package/dist/components/pipeline-topology/PipelineVisualization.esm.js +9 -6
  77. package/dist/components/pipeline-topology/PipelineVisualization.esm.js.map +1 -1
  78. package/dist/components/pipeline-topology/PipelineVisualizationStepList.esm.js +28 -19
  79. package/dist/components/pipeline-topology/PipelineVisualizationStepList.esm.js.map +1 -1
  80. package/dist/components/pipeline-topology/PipelineVisualizationView.esm.js +11 -7
  81. package/dist/components/pipeline-topology/PipelineVisualizationView.esm.js.map +1 -1
  82. package/dist/components/pipeline-topology/TaskGroupEdge.esm.js +2 -2
  83. package/dist/components/pipeline-topology/TaskGroupEdge.esm.js.map +1 -1
  84. package/dist/components/pipeline-topology/pipelineComponentFactory.esm.js.map +1 -1
  85. package/dist/hooks/TektonResourcesContext.esm.js +12 -10
  86. package/dist/hooks/TektonResourcesContext.esm.js.map +1 -1
  87. package/dist/hooks/useDarkTheme.esm.js +2 -2
  88. package/dist/hooks/useDarkTheme.esm.js.map +1 -1
  89. package/dist/hooks/usePipelineRunScanResults.esm.js +2 -2
  90. package/dist/hooks/usePipelineRunScanResults.esm.js.map +1 -1
  91. package/dist/hooks/usePodLogsOfPipelineRun.esm.js +31 -50
  92. package/dist/hooks/usePodLogsOfPipelineRun.esm.js.map +1 -1
  93. package/dist/hooks/useTektonObjectsResponse.esm.js +11 -11
  94. package/dist/hooks/useTektonObjectsResponse.esm.js.map +1 -1
  95. package/dist/index.d.ts +50 -4
  96. package/dist/index.esm.js +1 -0
  97. package/dist/index.esm.js.map +1 -1
  98. package/dist/translation.esm.js +81 -0
  99. package/dist/translation.esm.js.map +1 -0
  100. package/package.json +19 -18
@@ -1 +1 @@
1
- {"version":3,"file":"PipelineTaskNode.esm.js","sources":["../../../src/components/pipeline-topology/PipelineTaskNode.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport { Tooltip } from '@patternfly/react-core';\nimport {\n DEFAULT_LAYER,\n DEFAULT_WHEN_OFFSET,\n GraphElement,\n Layer,\n Node,\n RunStatus,\n ScaleDetailsLevel,\n TaskNode,\n TOP_LAYER,\n useDetailsLevel,\n useHover,\n WhenDecorator,\n WithContextMenuProps,\n WithSelectionProps,\n} from '@patternfly/react-topology';\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { observer } from 'mobx-react';\n\nimport { PipelineTaskWithStatus, TaskRunKind } from '@janus-idp/shared-react';\n\nimport { NodeType } from '../../consts/pipeline-topology-const';\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n} from '../../consts/tekton-const';\nimport { TektonResourcesContext } from '../../hooks/TektonResourcesContext';\nimport { StepStatus } from '../../types/taskRun';\nimport { TektonResourcesContextData } from '../../types/types';\nimport { createStepStatus } from '../../utils/pipeline-step-utils';\nimport { getTaskStatus } from '../../utils/pipelineRun-utils';\nimport PipelineRunLogDialog from '../PipelineRunLogs/PipelineRunLogDialog';\nimport { PipelineVisualizationStepList } from './PipelineVisualizationStepList';\n\nimport './PipelineTaskNode.css';\n\ntype PipelineTaskNodeProps = {\n element: Node;\n} & WithContextMenuProps &\n WithSelectionProps &\n GraphElement;\n\nconst PipelineTaskNode = ({\n element,\n onContextMenu,\n contextMenuOpen,\n ...rest\n}: PipelineTaskNodeProps) => {\n const [open, setOpen] = React.useState<boolean>(false);\n const { watchResourcesData } = React.useContext<TektonResourcesContextData>(\n TektonResourcesContext,\n );\n const data = element.getData();\n const triggerRef = React.useRef<SVGGElement | null>(null);\n\n const pipelineRun = data.pipelineRun;\n const [hover, hoverRef] = useHover();\n const detailsLevel = useDetailsLevel();\n const isFinallyTask = element.getType() === NodeType.FINALLY_NODE;\n\n const pods = watchResourcesData?.pods?.data || [];\n const taskRuns = watchResourcesData?.taskruns?.data || [];\n const openDialog = () => {\n setOpen(true);\n };\n\n const closeDialog = () => {\n setOpen(false);\n };\n\n const computedTask: PipelineTaskWithStatus = data.task;\n const stepList =\n computedTask?.status?.steps || computedTask?.taskSpec?.steps || [];\n\n const taskStatus = getTaskStatus(data.pipelineRun, data.task);\n\n const stepStatusList: StepStatus[] = stepList.map((step: { name: string }) =>\n createStepStatus(step, taskStatus),\n );\n const succeededStepsCount = stepStatusList.filter(\n ({ status }) => status === RunStatus.Succeeded,\n ).length;\n\n const badge =\n stepStatusList.length > 0 && data.status\n ? `${succeededStepsCount}/${stepStatusList.length}`\n : null;\n\n const passedData = React.useMemo(() => {\n const newData = { ...data };\n Object.keys(newData).forEach(key => {\n if (newData[key] === undefined) {\n delete newData[key];\n }\n });\n return newData;\n }, [data]);\n\n const hasTaskIcon = !!(data.taskIconClass || data.taskIcon);\n const whenDecorator = data.whenStatus ? (\n <WhenDecorator\n element={element}\n status={data.whenStatus}\n leftOffset={\n hasTaskIcon\n ? DEFAULT_WHEN_OFFSET + (element.getBounds().height - 4) * 0.75\n : DEFAULT_WHEN_OFFSET\n }\n />\n ) : null;\n const activeTaskId = taskRuns.find(\n (tr: TaskRunKind) =>\n tr?.metadata?.labels?.[TEKTON_PIPELINE_RUN] ===\n pipelineRun?.metadata?.name &&\n tr?.metadata?.labels?.[TEKTON_PIPELINE_TASK] === data.task?.name,\n )?.metadata?.name;\n\n const taskNode = (\n <>\n <PipelineRunLogDialog\n pipelineRun={pipelineRun}\n open={open}\n closeDialog={closeDialog}\n pods={pods}\n taskRuns={taskRuns}\n activeTask={activeTaskId}\n />\n <TaskNode\n className=\"bs-tkn-pipeline-task-node\"\n element={element}\n onContextMenu={data.showContextMenu ? onContextMenu : undefined}\n contextMenuOpen={contextMenuOpen}\n scaleNode={\n (hover || contextMenuOpen) && detailsLevel !== ScaleDetailsLevel.high\n }\n hideDetailsAtMedium\n {...passedData}\n {...rest}\n badge={badge}\n truncateLength={element.getData()?.label?.length}\n onSelect={activeTaskId && openDialog}\n >\n {whenDecorator}\n </TaskNode>\n </>\n );\n\n return (\n <Layer\n id={\n detailsLevel !== ScaleDetailsLevel.high && (hover || contextMenuOpen)\n ? TOP_LAYER\n : DEFAULT_LAYER\n }\n >\n <g\n data-test={`task ${element.getLabel()}`}\n className=\"bs-tkn-pipeline-task-node\"\n ref={hoverRef as React.LegacyRef<SVGGElement>}\n >\n <Tooltip\n position=\"bottom\"\n enableFlip={false}\n content={\n <PipelineVisualizationStepList\n isSpecOverview={!data.status}\n taskName={element.getLabel()}\n steps={stepStatusList}\n isFinallyTask={isFinallyTask}\n />\n }\n triggerRef={triggerRef}\n >\n <g ref={triggerRef}>{taskNode}</g>\n </Tooltip>\n </g>\n </Layer>\n );\n};\n\nexport default React.memo(observer(PipelineTaskNode));\n"],"names":["React"],"mappings":";;;;;;;;;;;;;AA4DA,MAAM,mBAAmB,CAAC;AAAA,EACxB,OAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,GAAG;AACL,CAA6B,KAAA;AAC3B,EAAA,MAAM,CAAC,IAAM,EAAA,OAAO,CAAI,GAAAA,cAAA,CAAM,SAAkB,KAAK,CAAA;AACrD,EAAM,MAAA,EAAE,kBAAmB,EAAA,GAAIA,cAAM,CAAA,UAAA;AAAA,IACnC;AAAA,GACF;AACA,EAAM,MAAA,IAAA,GAAO,QAAQ,OAAQ,EAAA;AAC7B,EAAM,MAAA,UAAA,GAAaA,cAAM,CAAA,MAAA,CAA2B,IAAI,CAAA;AAExD,EAAA,MAAM,cAAc,IAAK,CAAA,WAAA;AACzB,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAS,EAAA;AACnC,EAAA,MAAM,eAAe,eAAgB,EAAA;AACrC,EAAA,MAAM,aAAgB,GAAA,OAAA,CAAQ,OAAQ,EAAA,KAAM,QAAS,CAAA,YAAA;AAErD,EAAA,MAAM,IAAO,GAAA,kBAAA,EAAoB,IAAM,EAAA,IAAA,IAAQ,EAAC;AAChD,EAAA,MAAM,QAAW,GAAA,kBAAA,EAAoB,QAAU,EAAA,IAAA,IAAQ,EAAC;AACxD,EAAA,MAAM,aAAa,MAAM;AACvB,IAAA,OAA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A,EAAG,KAAO,EAAA,MAAA;AAAA,MAC1C,UAAU,YAAgB,IAAA;AAAA,KAAA;AAAA,IAEzB;AAAA,GAEL,CAAA;AAGF,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IACE,YAAiB,KAAA,iBAAA,CAAkB,IAAS,KAAA,KAAA,IAAS,mBACjD,SACA,GAAA;AAAA,KAAA;AAAA,oBAGNA,cAAA,CAAA,aAAA;AAAA,MAAC,GAAA;AAAA,MAAA;AAAA,QACC,WAAW,EAAA,CAAA,KAAA,EAAQ,OAAQ,CAAA,QAAA,EAAU,CAAA,CAAA;AAAA,QACrC,SAAU,EAAA,2BAAA;AAAA,QACV,GAAK,EAAA;AAAA,OAAA;AAAA,sBAELA,cAAA,CAAA,aAAA;AAAA,QAAC,OAAA;AAAA,QAAA;AAAA,UACC,QAAS,EAAA,QAAA;AAAA,UACT,UAAY,EAAA,KAAA;AAAA,UACZ,OACE,kBAAAA,cAAA,CAAA,aAAA;AAAA,YAAC,6BAAA;AAAA,YAAA;AAAA,cACC,cAAA,EAAgB,CAAC,IAAK,CAAA,MAAA;AAAA,cACtB,QAAA,EAAU,QAAQ,QAAS,EAAA;AAAA,cAC3B,KAAO,EAAA,cAAA;AAAA,cACP;AAAA;AAAA,WACF;AAAA,UAEF;AAAA,SAAA;AAAA,wBAECA,cAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAE,GAAK,EAAA,UAAA,EAAA,EAAa,QAAS;AAAA;AAChC;AACF,GACF;AAEJ,CAAA;AAEA,yBAAeA,cAAM,CAAA,IAAA,CAAK,QAAS,CAAA,gBAAgB,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"PipelineTaskNode.esm.js","sources":["../../../src/components/pipeline-topology/PipelineTaskNode.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport type { LegacyRef } from 'react';\n\nimport { useState, useContext, useRef, useMemo, memo } from 'react';\n\nimport { Tooltip } from '@patternfly/react-core';\nimport {\n DEFAULT_LAYER,\n DEFAULT_WHEN_OFFSET,\n GraphElement,\n Layer,\n Node,\n RunStatus,\n ScaleDetailsLevel,\n TaskNode,\n TOP_LAYER,\n useDetailsLevel,\n useHover,\n WhenDecorator,\n WithContextMenuProps,\n WithSelectionProps,\n} from '@patternfly/react-topology';\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { observer } from 'mobx-react';\n\nimport { PipelineTaskWithStatus, TaskRunKind } from '@janus-idp/shared-react';\n\nimport { NodeType } from '../../consts/pipeline-topology-const';\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n} from '../../consts/tekton-const';\nimport { TektonResourcesContext } from '../../hooks/TektonResourcesContext';\nimport { StepStatus } from '../../types/taskRun';\nimport { TektonResourcesContextData } from '../../types/types';\nimport { createStepStatus } from '../../utils/pipeline-step-utils';\nimport { getTaskStatus } from '../../utils/pipelineRun-utils';\nimport PipelineRunLogDialog from '../PipelineRunLogs/PipelineRunLogDialog';\nimport { PipelineVisualizationStepList } from './PipelineVisualizationStepList';\n\nimport './PipelineTaskNode.css';\n\ntype PipelineTaskNodeProps = {\n element: Node;\n} & WithContextMenuProps &\n WithSelectionProps &\n GraphElement;\n\nconst PipelineTaskNode = ({\n element,\n onContextMenu,\n contextMenuOpen,\n ...rest\n}: PipelineTaskNodeProps) => {\n const [open, setOpen] = useState<boolean>(false);\n const { watchResourcesData } = useContext<TektonResourcesContextData>(\n TektonResourcesContext,\n );\n const data = element.getData();\n const triggerRef = useRef<SVGGElement | null>(null);\n\n const pipelineRun = data.pipelineRun;\n const [hover, hoverRef] = useHover();\n const detailsLevel = useDetailsLevel();\n const isFinallyTask = element.getType() === NodeType.FINALLY_NODE;\n\n const pods = watchResourcesData?.pods?.data || [];\n const taskRuns = watchResourcesData?.taskruns?.data || [];\n const openDialog = () => {\n setOpen(true);\n };\n\n const closeDialog = () => {\n setOpen(false);\n };\n\n const computedTask: PipelineTaskWithStatus = data.task;\n const stepList =\n computedTask?.status?.steps || computedTask?.taskSpec?.steps || [];\n\n const taskStatus = getTaskStatus(data.pipelineRun, data.task);\n\n const stepStatusList: StepStatus[] = stepList.map((step: { name: string }) =>\n createStepStatus(step, taskStatus),\n );\n const succeededStepsCount = stepStatusList.filter(\n ({ status }) => status === RunStatus.Succeeded,\n ).length;\n\n const badge =\n stepStatusList.length > 0 && data.status\n ? `${succeededStepsCount}/${stepStatusList.length}`\n : null;\n\n const passedData = useMemo(() => {\n const newData = { ...data };\n Object.keys(newData).forEach(key => {\n if (newData[key] === undefined) {\n delete newData[key];\n }\n });\n return newData;\n }, [data]);\n\n const hasTaskIcon = !!(data.taskIconClass || data.taskIcon);\n const whenDecorator = data.whenStatus ? (\n <WhenDecorator\n element={element}\n status={data.whenStatus}\n leftOffset={\n hasTaskIcon\n ? DEFAULT_WHEN_OFFSET + (element.getBounds().height - 4) * 0.75\n : DEFAULT_WHEN_OFFSET\n }\n />\n ) : null;\n const activeTaskId = taskRuns.find(\n (tr: TaskRunKind) =>\n tr?.metadata?.labels?.[TEKTON_PIPELINE_RUN] ===\n pipelineRun?.metadata?.name &&\n tr?.metadata?.labels?.[TEKTON_PIPELINE_TASK] === data.task?.name,\n )?.metadata?.name;\n\n const taskNode = (\n <>\n <PipelineRunLogDialog\n pipelineRun={pipelineRun}\n open={open}\n closeDialog={closeDialog}\n pods={pods}\n taskRuns={taskRuns}\n activeTask={activeTaskId}\n />\n <TaskNode\n className=\"bs-tkn-pipeline-task-node\"\n element={element}\n onContextMenu={data.showContextMenu ? onContextMenu : undefined}\n contextMenuOpen={contextMenuOpen}\n scaleNode={\n (hover || contextMenuOpen) && detailsLevel !== ScaleDetailsLevel.high\n }\n hideDetailsAtMedium\n {...passedData}\n {...rest}\n badge={badge}\n truncateLength={element.getData()?.label?.length}\n onSelect={activeTaskId && openDialog}\n >\n {whenDecorator}\n </TaskNode>\n </>\n );\n\n return (\n <Layer\n id={\n detailsLevel !== ScaleDetailsLevel.high && (hover || contextMenuOpen)\n ? TOP_LAYER\n : DEFAULT_LAYER\n }\n >\n <g\n data-test={`task ${element.getLabel()}`}\n className=\"bs-tkn-pipeline-task-node\"\n ref={hoverRef as LegacyRef<SVGGElement>}\n >\n <Tooltip\n position=\"bottom\"\n enableFlip={false}\n content={\n <PipelineVisualizationStepList\n isSpecOverview={!data.status}\n taskName={element.getLabel()}\n steps={stepStatusList}\n isFinallyTask={isFinallyTask}\n />\n }\n triggerRef={triggerRef}\n >\n <g ref={triggerRef}>{taskNode}</g>\n </Tooltip>\n </g>\n </Layer>\n );\n};\n\nexport default memo(observer(PipelineTaskNode));\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA8DA,MAAM,mBAAmB,CAAC;AAAA,EACxB,OAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,GAAG;AACL,CAA6B,KAAA;AAC3B,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAkB,KAAK,CAAA;AAC/C,EAAM,MAAA,EAAE,oBAAuB,GAAA,UAAA;AAAA,IAC7B;AAAA,GACF;AACA,EAAM,MAAA,IAAA,GAAO,QAAQ,OAAQ,EAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,OAA2B,IAAI,CAAA;AAElD,EAAA,MAAM,cAAc,IAAK,CAAA,WAAA;AACzB,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAS,EAAA;AACnC,EAAA,MAAM,eAAe,eAAgB,EAAA;AACrC,EAAA,MAAM,aAAgB,GAAA,OAAA,CA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8 +1,10 @@
1
- import React__default from 'react';
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { useDarkTheme } from '../../hooks/useDarkTheme.esm.js';
3
3
  import { getGraphDataModel } from '../../utils/pipeline-topology-utils.esm.js';
4
4
  import { PipelineLayout } from './PipelineLayout.esm.js';
5
5
  import './PipelineVisualization.css.esm.js';
6
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
7
+ import { tektonTranslationRef } from '../../translation.esm.js';
6
8
 
7
9
  const PipelineVisualization = ({
8
10
  pipelineRun,
@@ -10,14 +12,15 @@ const PipelineVisualization = ({
10
12
  }) => {
11
13
  useDarkTheme();
12
14
  const model = getGraphDataModel(pipelineRun ?? void 0, taskRuns ?? []);
13
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, !model || model.nodes.length === 0 && model.edges.length === 0 ? /* @__PURE__ */ React__default.createElement("div", { "data-testid": "pipeline-no-tasks" }, "This Pipeline Run has no tasks to visualize") : /* @__PURE__ */ React__default.createElement(
15
+ const { t } = useTranslationRef(tektonTranslationRef);
16
+ return /* @__PURE__ */ jsx(Fragment, { children: !model || model.nodes.length === 0 && model.edges.length === 0 ? /* @__PURE__ */ jsx("div", { "data-testid": "pipeline-no-tasks", children: t("pipelineVisualization.noTasksDescription") }) : /* @__PURE__ */ jsx(
14
17
  "div",
15
18
  {
16
19
  "data-testid": "pipelineRun-visualization",
17
- className: "bs-tkn-pipeline-visualization__layout"
18
- },
19
- /* @__PURE__ */ React__default.createElement(PipelineLayout, { model })
20
- ));
20
+ className: "bs-tkn-pipeline-visualization__layout",
21
+ children: /* @__PURE__ */ jsx(PipelineLayout, { model })
22
+ }
23
+ ) });
21
24
  };
22
25
 
23
26
  export { PipelineVisualization };
@@ -1 +1 @@
1
- {"version":3,"file":"PipelineVisualization.esm.js","sources":["../../../src/components/pipeline-topology/PipelineVisualization.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport { PipelineRunKind, TaskRunKind } from '@janus-idp/shared-react';\n\nimport { useDarkTheme } from '../../hooks/useDarkTheme';\nimport { getGraphDataModel } from '../../utils/pipeline-topology-utils';\nimport { PipelineLayout } from './PipelineLayout';\n\nimport './PipelineVisualization.css';\n\ntype PipelineVisualizationProps = {\n pipelineRun: PipelineRunKind | null;\n taskRuns: TaskRunKind[];\n};\n\nexport const PipelineVisualization = ({\n pipelineRun,\n taskRuns,\n}: PipelineVisualizationProps) => {\n useDarkTheme();\n\n const model = getGraphDataModel(pipelineRun ?? undefined, taskRuns ?? []);\n\n return (\n <>\n {!model || (model.nodes.length === 0 && model.edges.length === 0) ? (\n <div data-testid=\"pipeline-no-tasks\">\n This Pipeline Run has no tasks to visualize\n </div>\n ) : (\n <div\n data-testid=\"pipelineRun-visualization\"\n className=\"bs-tkn-pipeline-visualization__layout\"\n >\n <PipelineLayout model={model} />\n </div>\n )}\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;AA8BO,MAAM,wBAAwB,CAAC;AAAA,EACpC,WAAA;AAAA,EACA;AACF,CAAkC,KAAA;AAChC,EAAa,YAAA,EAAA;AAEb,EAAA,MAAM,QAAQ,iBAAkB,CAAA,WAAA,IAAe,MAAW,EAAA,QAAA,IAAY,EAAE,CAAA;AAExE,EAAA,mFAEK,CAAC,KAAA,IAAU,KAAM,CAAA,KAAA,CAAM,WAAW,CAAK,IAAA,KAAA,CAAM,KAAM,CAAA,MAAA,KAAW,oBAC5DA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,aAAY,EAAA,mBAAA,EAAA,EAAoB,6CAErC,CAEA,mBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,aAAY,EAAA,2BAAA;AAAA,MACZ,SAAU,EAAA;AAAA,KAAA;AAAA,oBAEVA,cAAA,CAAA,aAAA,CAAC,kBAAe,KAAc,EAAA;AAAA,GAGpC,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"PipelineVisualization.esm.js","sources":["../../../src/components/pipeline-topology/PipelineVisualization.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { PipelineRunKind, TaskRunKind } from '@janus-idp/shared-react';\n\nimport { useDarkTheme } from '../../hooks/useDarkTheme';\nimport { getGraphDataModel } from '../../utils/pipeline-topology-utils';\nimport { PipelineLayout } from './PipelineLayout';\n\nimport './PipelineVisualization.css';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../../translation';\n\ntype PipelineVisualizationProps = {\n pipelineRun: PipelineRunKind | null;\n taskRuns: TaskRunKind[];\n};\n\nexport const PipelineVisualization = ({\n pipelineRun,\n taskRuns,\n}: PipelineVisualizationProps) => {\n useDarkTheme();\n\n const model = getGraphDataModel(pipelineRun ?? undefined, taskRuns ?? []);\n const { t } = useTranslationRef(tektonTranslationRef);\n\n return (\n <>\n {!model || (model.nodes.length === 0 && model.edges.length === 0) ? (\n <div data-testid=\"pipeline-no-tasks\">\n {t('pipelineVisualization.noTasksDescription')}\n </div>\n ) : (\n <div\n data-testid=\"pipelineRun-visualization\"\n className=\"bs-tkn-pipeline-visualization__layout\"\n >\n <PipelineLayout model={model} />\n </div>\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA8BO,MAAM,wBAAwB,CAAC;AAAA,EACpC,WAAA;AAAA,EACA;AACF,CAAkC,KAAA;AAChC,EAAa,YAAA,EAAA;AAEb,EAAA,MAAM,QAAQ,iBAAkB,CAAA,WAAA,IAAe,MAAW,EAAA,QAAA,IAAY,EAAE,CAAA;AACxE,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,oBAAoB,CAAA;AAEpD,EAAA,uCAEK,QAAC,EAAA,CAAA,KAAA,IAAU,MAAM,KAAM,CAAA,MAAA,KAAW,KAAK,KAAM,CAAA,KAAA,CAAM,MAAW,KAAA,CAAA,uBAC5D,KAAI,EAAA,EAAA,aAAA,EAAY,qBACd,QAAE,EAAA,CAAA,CAAA,0CAA0C,GAC/C,CAEA,mBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,aAAY,EAAA,2BAAA;AAAA,MACZ,SAAU,EAAA,uCAAA;AAAA,MAEV,QAAA,kBAAA,GAAA,CAAC,kBAAe,KAAc,EAAA;AAAA;AAAA,GAGpC,EAAA,CAAA;AAEJ;;;;"}
@@ -1,12 +1,14 @@
1
- import React__default from 'react';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import classNames from 'classnames';
3
3
  import { Status } from '@janus-idp/shared-react';
4
4
  import './PipelineVisualizationStepList.css.esm.js';
5
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
6
+ import { tektonTranslationRef } from '../../translation.esm.js';
5
7
 
6
8
  const TooltipColoredStatusIcon = ({
7
9
  status
8
10
  }) => {
9
- const icon = /* @__PURE__ */ React__default.createElement(Status, { status, iconOnly: true });
11
+ const icon = /* @__PURE__ */ jsx(Status, { status, iconOnly: true });
10
12
  return icon;
11
13
  };
12
14
  const PipelineVisualizationStepList = ({
@@ -16,23 +18,30 @@ const PipelineVisualizationStepList = ({
16
18
  isFinallyTask,
17
19
  hideHeader
18
20
  }) => {
19
- return /* @__PURE__ */ React__default.createElement("div", { className: "bs-tkn-pipeline-visualization-step-list" }, !hideHeader && /* @__PURE__ */ React__default.createElement("div", { className: "bs-tkn-pipeline-visualization-step-list__task-name" }, taskName), isFinallyTask && /* @__PURE__ */ React__default.createElement("div", { className: "bs-tkn-pipeline-visualization-step-list__task-type" }, "Finally task"), steps?.map(({ duration, name, status }) => {
20
- return /* @__PURE__ */ React__default.createElement(
21
- "div",
22
- {
23
- className: classNames(
24
- "bs-tkn-pipeline-visualization-step-list__step",
25
- {
26
- "bs-tkn-pipeline-visualization-step-list__step--task-run": !isSpecOverview
27
- }
28
- ),
29
- key: name
30
- },
31
- !isSpecOverview ? /* @__PURE__ */ React__default.createElement("div", { className: "bs-tkn-pipeline-visualization-step-list__icon" }, /* @__PURE__ */ React__default.createElement(TooltipColoredStatusIcon, { status })) : /* @__PURE__ */ React__default.createElement("span", { className: "bs-tkn-pipeline-visualization-step-list__bullet" }, "\u2022"),
32
- /* @__PURE__ */ React__default.createElement("div", { className: "bs-tkn-pipeline-visualization-step-list__name" }, name),
33
- !isSpecOverview && /* @__PURE__ */ React__default.createElement("div", { className: "bs-tkn-pipeline-visualization-step-list__duration" }, duration)
34
- );
35
- }));
21
+ const { t } = useTranslationRef(tektonTranslationRef);
22
+ return /* @__PURE__ */ jsxs("div", { className: "bs-tkn-pipeline-visualization-step-list", children: [
23
+ !hideHeader && /* @__PURE__ */ jsx("div", { className: "bs-tkn-pipeline-visualization-step-list__task-name", children: taskName }),
24
+ isFinallyTask && /* @__PURE__ */ jsx("div", { className: "bs-tkn-pipeline-visualization-step-list__task-type", children: t("pipelineVisualization.stepList.finallyTaskTitle") }),
25
+ steps?.map(({ duration, name, status }) => {
26
+ return /* @__PURE__ */ jsxs(
27
+ "div",
28
+ {
29
+ className: classNames(
30
+ "bs-tkn-pipeline-visualization-step-list__step",
31
+ {
32
+ "bs-tkn-pipeline-visualization-step-list__step--task-run": !isSpecOverview
33
+ }
34
+ ),
35
+ children: [
36
+ !isSpecOverview ? /* @__PURE__ */ jsx("div", { className: "bs-tkn-pipeline-visualization-step-list__icon", children: /* @__PURE__ */ jsx(TooltipColoredStatusIcon, { status }) }) : /* @__PURE__ */ jsx("span", { className: "bs-tkn-pipeline-visualization-step-list__bullet", children: "\u2022" }),
37
+ /* @__PURE__ */ jsx("div", { className: "bs-tkn-pipeline-visualization-step-list__name", children: name }),
38
+ !isSpecOverview && /* @__PURE__ */ jsx("div", { className: "bs-tkn-pipeline-visualization-step-list__duration", children: duration })
39
+ ]
40
+ },
41
+ name
42
+ );
43
+ })
44
+ ] });
36
45
  };
37
46
 
38
47
  export { PipelineVisualizationStepList };
@@ -1 +1 @@
1
- {"version":3,"file":"PipelineVisualizationStepList.esm.js","sources":["../../../src/components/pipeline-topology/PipelineVisualizationStepList.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport { RunStatus } from '@patternfly/react-topology';\nimport classNames from 'classnames';\n\nimport { Status } from '@janus-idp/shared-react';\n\nimport { StepStatus } from '../../types/taskRun';\n\nimport './PipelineVisualizationStepList.css';\n\nexport type PipelineVisualizationStepListProps = {\n isSpecOverview: boolean;\n taskName: string;\n steps: StepStatus[];\n isFinallyTask?: boolean;\n hideHeader?: boolean;\n};\n\ntype TooltipColoredStatusIconProps = {\n status: RunStatus;\n};\n\nconst TooltipColoredStatusIcon = ({\n status,\n}: TooltipColoredStatusIconProps) => {\n const icon = <Status status={status} iconOnly />;\n return icon;\n};\n\nexport const PipelineVisualizationStepList = ({\n isSpecOverview,\n taskName,\n steps,\n isFinallyTask,\n hideHeader,\n}: PipelineVisualizationStepListProps) => {\n return (\n <div className=\"bs-tkn-pipeline-visualization-step-list\">\n {!hideHeader && (\n <div className=\"bs-tkn-pipeline-visualization-step-list__task-name\">\n {taskName}\n </div>\n )}\n {isFinallyTask && (\n <div className=\"bs-tkn-pipeline-visualization-step-list__task-type\">\n Finally task\n </div>\n )}\n {steps?.map(({ duration, name, status }) => {\n return (\n <div\n className={classNames(\n 'bs-tkn-pipeline-visualization-step-list__step',\n {\n 'bs-tkn-pipeline-visualization-step-list__step--task-run':\n !isSpecOverview,\n },\n )}\n key={name}\n >\n {!isSpecOverview ? (\n <div className=\"bs-tkn-pipeline-visualization-step-list__icon\">\n <TooltipColoredStatusIcon status={status} />\n </div>\n ) : (\n <span className=\"bs-tkn-pipeline-visualization-step-list__bullet\">\n &bull;\n </span>\n )}\n <div className=\"bs-tkn-pipeline-visualization-step-list__name\">\n {name}\n </div>\n {!isSpecOverview && (\n <div className=\"bs-tkn-pipeline-visualization-step-list__duration\">\n {duration}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["React"],"mappings":";;;;;AAsCA,MAAM,2BAA2B,CAAC;AAAA,EAChC;AACF,CAAqC,KAAA;AACnC,EAAA,MAAM,IAAO,mBAAAA,cAAA,CAAA,aAAA,CAAC,MAAO,EAAA,EAAA,MAAA,EAAgB,UAAQ,IAAC,EAAA,CAAA;AAC9C,EAAO,OAAA,IAAA;AACT,CAAA;AAEO,MAAM,gCAAgC,CAAC;AAAA,EAC5C,cAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAA0C,KAAA;AACxC,EACE,uBAAAA,cAAA,CAAA,aAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAU,yCACZ,EAAA,EAAA,CAAC,UACA,oBAAAA,cAAA,CAAA,aAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAU,oDACZ,EAAA,EAAA,QACH,CAED,EAAA,aAAA,iDACE,KAAI,EAAA,EAAA,SAAA,EAAU,oDAAqD,EAAA,EAAA,cAEpE,CAED,EAAA,KAAA,EAAO,GAAI,CAAA,CAAC,EAAE,QAAA,EAAU,IAAM,EAAA,MAAA,EAAa,KAAA;AAC1C,IACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAA,UAAA;AAAA,UACT,+CAAA;AAAA,UACA;AAAA,YACE,2DACE,CAAC;AAAA;AACL,SACF;AAAA,QACA,GAAK,EAAA;AAAA,OAAA;AAAA,MAEJ,CAAC,cAAA,mBACCA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,WAAU,+CACb,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,wBAAyB,EAAA,EAAA,MAAA,EAAgB,CAC5C,CAEA,mBAAAA,cAAA,CAAA,aAAA,CAAC,MAAK,EAAA,EAAA,SAAA,EAAU,qDAAkD,QAElE,CAAA;AAAA,sBAEDA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,SAAU,EAAA,+CAAA,EAAA,EACZ,IACH,CAAA;AAAA,MACC,CAAC,cACA,oBAAAA,cAAA,CAAA,aAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAU,uDACZ,QACH;AAAA,KAEJ;AAAA,GAEH,CACH,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"PipelineVisualizationStepList.esm.js","sources":["../../../src/components/pipeline-topology/PipelineVisualizationStepList.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { RunStatus } from '@patternfly/react-topology';\nimport classNames from 'classnames';\n\nimport { Status } from '@janus-idp/shared-react';\n\nimport { StepStatus } from '../../types/taskRun';\n\nimport './PipelineVisualizationStepList.css';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../../translation';\n\nexport type PipelineVisualizationStepListProps = {\n isSpecOverview: boolean;\n taskName: string;\n steps: StepStatus[];\n isFinallyTask?: boolean;\n hideHeader?: boolean;\n};\n\ntype TooltipColoredStatusIconProps = {\n status: RunStatus;\n};\n\nconst TooltipColoredStatusIcon = ({\n status,\n}: TooltipColoredStatusIconProps) => {\n const icon = <Status status={status} iconOnly />;\n return icon;\n};\n\nexport const PipelineVisualizationStepList = ({\n isSpecOverview,\n taskName,\n steps,\n isFinallyTask,\n hideHeader,\n}: PipelineVisualizationStepListProps) => {\n const { t } = useTranslationRef(tektonTranslationRef);\n return (\n <div className=\"bs-tkn-pipeline-visualization-step-list\">\n {!hideHeader && (\n <div className=\"bs-tkn-pipeline-visualization-step-list__task-name\">\n {taskName}\n </div>\n )}\n {isFinallyTask && (\n <div className=\"bs-tkn-pipeline-visualization-step-list__task-type\">\n {t('pipelineVisualization.stepList.finallyTaskTitle')}\n </div>\n )}\n {steps?.map(({ duration, name, status }) => {\n return (\n <div\n className={classNames(\n 'bs-tkn-pipeline-visualization-step-list__step',\n {\n 'bs-tkn-pipeline-visualization-step-list__step--task-run':\n !isSpecOverview,\n },\n )}\n key={name}\n >\n {!isSpecOverview ? (\n <div className=\"bs-tkn-pipeline-visualization-step-list__icon\">\n <TooltipColoredStatusIcon status={status} />\n </div>\n ) : (\n <span className=\"bs-tkn-pipeline-visualization-step-list__bullet\">\n &bull;\n </span>\n )}\n <div className=\"bs-tkn-pipeline-visualization-step-list__name\">\n {name}\n </div>\n {!isSpecOverview && (\n <div className=\"bs-tkn-pipeline-visualization-step-list__duration\">\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AkD,QAElE,EAAA,QAAA,EAAA,CAAA;AAAA,4BAED,GAAA,CAAA,KAAA,EAAA,EAAI,SAAU,EAAA,+CAAA,EACZ,QACH,EAAA,IAAA,EAAA,CAAA;AAAA,YACC,CAAC,cACA,oBAAA,GAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAU,qDACZ,QACH,EAAA,QAAA,EAAA;AAAA;AAAA,SAAA;AAAA,QAjBG;AAAA,OAmBP;AAAA,KAEH;AAAA,GACH,EAAA,CAAA;AAEJ;;;;"}
@@ -1,34 +1,38 @@
1
- import React__default from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useContext, useMemo } from 'react';
2
3
  import { Progress, EmptyState } from '@backstage/core-components';
3
4
  import { isEmpty } from 'lodash';
4
5
  import { TektonResourcesContext } from '../../hooks/TektonResourcesContext.esm.js';
5
6
  import { getPipelineRun } from '../../utils/pipelineRun-utils.esm.js';
6
7
  import { PipelineVisualization } from './PipelineVisualization.esm.js';
7
8
  import './PipelineVisualization.css.esm.js';
9
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
10
+ import { tektonTranslationRef } from '../../translation.esm.js';
8
11
 
9
12
  const PipelineVisualizationView = ({
10
13
  pipelineRun
11
14
  }) => {
12
- const { loaded, responseError, watchResourcesData } = React__default.useContext(
15
+ const { loaded, responseError, watchResourcesData } = useContext(
13
16
  TektonResourcesContext
14
17
  );
15
- const pipelineRunResource = React__default.useMemo(
18
+ const { t } = useTranslationRef(tektonTranslationRef);
19
+ const pipelineRunResource = useMemo(
16
20
  () => getPipelineRun(watchResourcesData?.pipelineruns?.data ?? [], pipelineRun),
17
21
  [watchResourcesData, pipelineRun]
18
22
  );
19
23
  if (!loaded)
20
- return /* @__PURE__ */ React__default.createElement("div", { "data-testid": "tekton-progress" }, /* @__PURE__ */ React__default.createElement(Progress, null));
24
+ return /* @__PURE__ */ jsx("div", { "data-testid": "tekton-progress", children: /* @__PURE__ */ jsx(Progress, {}) });
21
25
  if (loaded && (responseError || isEmpty(pipelineRunResource))) {
22
- return /* @__PURE__ */ React__default.createElement(
26
+ return /* @__PURE__ */ jsx(
23
27
  EmptyState,
24
28
  {
25
29
  missing: "data",
26
- description: "No Pipeline Run to visualize",
30
+ description: t("pipelineVisualization.emptyState.description"),
27
31
  title: ""
28
32
  }
29
33
  );
30
34
  }
31
- return /* @__PURE__ */ React__default.createElement(
35
+ return /* @__PURE__ */ jsx(
32
36
  PipelineVisualization,
33
37
  {
34
38
  pipelineRun: pipelineRunResource,
@@ -1 +1 @@
1
- {"version":3,"file":"PipelineVisualizationView.esm.js","sources":["../../../src/components/pipeline-topology/PipelineVisualizationView.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport { EmptyState, Progress } from '@backstage/core-components';\n\nimport { isEmpty } from 'lodash';\n\nimport { TektonResourcesContext } from '../../hooks/TektonResourcesContext';\nimport { getPipelineRun } from '../../utils/pipelineRun-utils';\nimport { PipelineVisualization } from './PipelineVisualization';\n\nimport './PipelineVisualization.css';\n\ntype PipelineVisualizationViewProps = {\n pipelineRun: string;\n};\n\nexport const PipelineVisualizationView = ({\n pipelineRun,\n}: PipelineVisualizationViewProps) => {\n const { loaded, responseError, watchResourcesData } = React.useContext(\n TektonResourcesContext,\n );\n\n const pipelineRunResource = React.useMemo(\n () =>\n getPipelineRun(watchResourcesData?.pipelineruns?.data ?? [], pipelineRun),\n [watchResourcesData, pipelineRun],\n );\n\n if (!loaded)\n return (\n <div data-testid=\"tekton-progress\">\n <Progress />\n </div>\n );\n\n if (loaded && (responseError || isEmpty(pipelineRunResource))) {\n return (\n <EmptyState\n missing=\"data\"\n description=\"No Pipeline Run to visualize\"\n title=\"\"\n />\n );\n }\n\n return (\n <PipelineVisualization\n pipelineRun={pipelineRunResource}\n taskRuns={watchResourcesData?.taskruns?.data ?? []}\n />\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;AA+BO,MAAM,4BAA4B,CAAC;AAAA,EACxC;AACF,CAAsC,KAAA;AACpC,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAe,EAAA,kBAAA,KAAuBA,cAAM,CAAA,UAAA;AAAA,IAC1D;AAAA,GACF;AAEA,EAAA,MAAM,sBAAsBA,cAAM,CAAA,OAAA;AAAA,IAChC,MACE,cAAe,CAAA,kBAAA,EAAoB,cAAc,IAAQ,IAAA,IAAI,WAAW,CAAA;AAAA,IAC1E,CAAC,oBAAoB,WAAW;AAAA,GAClC;AAEA,EAAA,IAAI,CAAC,MAAA;AACH,IAAA,oDACG,KAAI,EAAA,EAAA,aAAA,EAAY,iBACf,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,cAAS,CACZ,CAAA;AAGJ,EAAA,IAAI,MAAW,KAAA,aAAA,IAAiB,OAAQ,CAAA,mBAAmB,CAAI,CAAA,EAAA;AAC7D,IACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,MAAA;AAAA,QACR,WAAY,EAAA,8BAAA;AAAA,QACZ,KAAM,EAAA;AAAA;AAAA,KACR;AAAA;AAIJ,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,WAAa,EAAA,mBAAA;AAAA,MACb,QAAU,EAAA,kBAAA,EAAoB,QAAU,EAAA,IAAA,IAAQ;AAAC;AAAA,GACnD;AAEJ;;;;"}
1
+ {"version":3,"file":"PipelineVisualizationView.esm.js","sources":["../../../src/components/pipeline-topology/PipelineVisualizationView.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { useContext, useMemo } from 'react';\n\nimport { EmptyState, Progress } from '@backstage/core-components';\n\nimport { isEmpty } from 'lodash';\n\nimport { TektonResourcesContext } from '../../hooks/TektonResourcesContext';\nimport { getPipelineRun } from '../../utils/pipelineRun-utils';\nimport { PipelineVisualization } from './PipelineVisualization';\n\nimport './PipelineVisualization.css';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../../translation';\n\ntype PipelineVisualizationViewProps = {\n pipelineRun: string;\n};\n\nexport const PipelineVisualizationView = ({\n pipelineRun,\n}: PipelineVisualizationViewProps) => {\n const { loaded, responseError, watchResourcesData } = useContext(\n TektonResourcesContext,\n );\n const { t } = useTranslationRef(tektonTranslationRef);\n\n const pipelineRunResource = useMemo(\n () =>\n getPipelineRun(watchResourcesData?.pipelineruns?.data ?? [], pipelineRun),\n [watchResourcesData, pipelineRun],\n );\n\n if (!loaded)\n return (\n <div data-testid=\"tekton-progress\">\n <Progress />\n </div>\n );\n\n if (loaded && (responseError || isEmpty(pipelineRunResource))) {\n return (\n <EmptyState\n missing=\"data\"\n description={t('pipelineVisualization.emptyState.description')}\n title=\"\"\n />\n );\n }\n\n return (\n <PipelineVisualization\n pipelineRun={pipelineRunResource}\n taskRuns={watchResourcesData?.taskruns?.data ?? []}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAiCO,MAAM,4BAA4B,CAAC;AAAA,EACxC;AACF,CAAsC,KAAA;AACpC,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAe,EAAA,kBAAA,EAAuB,GAAA,UAAA;AAAA,IACpD;AAAA,GACF;AACA,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,oBAAoB,CAAA;AAEpD,EAAA,MAAM,mBAAsB,GAAA,OAAA;AAAA,IAC1B,MACE,cAAe,CAAA,kBAAA,EAAoB,cAAc,IAAQ,IAAA,IAAI,WAAW,CAAA;AAAA,IAC1E,CAAC,oBAAoB,WAAW;AAAA,GAClC;AAEA,EAAA,IAAI,CAAC,MAAA;AACH,IAAA,2BACG,KAAI,EAAA,EAAA,aAAA,EAAY,iBACf,EAAA,QAAA,kBAAA,GAAA,CAAC,YAAS,CACZ,EAAA,CAAA;AAGJ,EAAA,IAAI,MAAW,KAAA,aAAA,IAAiB,OAAQ,CAAA,mBAAmB,CAAI,CAAA,EAAA;AAC7D,IACE,uBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,MAAA;AAAA,QACR,WAAA,EAAa,EAAE,8CAA8C,CAAA;AAAA,QAC7D,KAAM,EAAA;AAAA;AAAA,KACR;AAAA;AAIJ,EACE,uBAAA,GAAA;AAAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,WAAa,EAAA,mBAAA;AAAA,MACb,QAAU,EAAA,kBAAA,EAAoB,QAAU,EAAA,IAAA,IAAQ;AAAC;AAAA,GACnD;AAEJ;;;;"}
@@ -1,9 +1,9 @@
1
- import React__default from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { TaskEdge } from '@patternfly/react-topology';
3
3
  import { observer } from 'mobx-react';
4
4
  import { GROUPED_PIPELINE_NODE_SEPARATION_HORIZONTAL } from '../../consts/pipeline-topology-const.esm.js';
5
5
 
6
- const TaskGroupEdge = (props) => /* @__PURE__ */ React__default.createElement(
6
+ const TaskGroupEdge = (props) => /* @__PURE__ */ jsx(
7
7
  TaskEdge,
8
8
  {
9
9
  nodeSeparation: GROUPED_PIPELINE_NODE_SEPARATION_HORIZONTAL,
@@ -1 +1 @@
1
- {"version":3,"file":"TaskGroupEdge.esm.js","sources":["../../../src/components/pipeline-topology/TaskGroupEdge.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport { Edge, TaskEdge } from '@patternfly/react-topology';\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { observer } from 'mobx-react';\n\nimport { GROUPED_PIPELINE_NODE_SEPARATION_HORIZONTAL } from '../../consts/pipeline-topology-const';\n\ninterface TaskEdgeProps {\n element: Edge;\n}\n\nconst TaskGroupEdge = (props: TaskEdgeProps) => (\n <TaskEdge\n nodeSeparation={GROUPED_PIPELINE_NODE_SEPARATION_HORIZONTAL}\n {...props}\n />\n);\n\nexport default observer(TaskGroupEdge);\n"],"names":["React"],"mappings":";;;;;AA2BA,MAAM,aAAA,GAAgB,CAAC,KACrB,qBAAAA,cAAA,CAAA,aAAA;AAAA,EAAC,QAAA;AAAA,EAAA;AAAA,IACC,cAAgB,EAAA,2CAAA;AAAA,IACf,GAAG;AAAA;AACN,CAAA;AAGF,sBAAe,SAAS,aAAa,CAAA;;;;"}
1
+ {"version":3,"file":"TaskGroupEdge.esm.js","sources":["../../../src/components/pipeline-topology/TaskGroupEdge.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { Edge, TaskEdge } from '@patternfly/react-topology';\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { observer } from 'mobx-react';\n\nimport { GROUPED_PIPELINE_NODE_SEPARATION_HORIZONTAL } from '../../consts/pipeline-topology-const';\n\ninterface TaskEdgeProps {\n element: Edge;\n}\n\nconst TaskGroupEdge = (props: TaskEdgeProps) => (\n <TaskEdge\n nodeSeparation={GROUPED_PIPELINE_NODE_SEPARATION_HORIZONTAL}\n {...props}\n />\n);\n\nexport default observer(TaskGroupEdge);\n"],"names":[],"mappings":";;;;;AAyBA,MAAM,aAAA,GAAgB,CAAC,KACrB,qBAAA,GAAA;AAAA,EAAC,QAAA;AAAA,EAAA;AAAA,IACC,cAAgB,EAAA,2CAAA;AAAA,IACf,GAAG;AAAA;AACN,CAAA;AAGF,sBAAe,SAAS,aAAa,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"pipelineComponentFactory.esm.js","sources":["../../../src/components/pipeline-topology/pipelineComponentFactory.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport {\n ComponentFactory,\n DagreLayout,\n DefaultTaskGroup,\n Graph,\n GraphComponent,\n GraphElement,\n LayoutFactory,\n ModelKind,\n PipelineDagreLayout,\n SpacerNode,\n TaskEdge,\n withPanZoom,\n} from '@patternfly/react-topology';\n\nimport { NodeType, PipelineLayout } from '../../consts/pipeline-topology-const';\nimport { getLayoutData } from '../../utils/pipeline-topology-utils';\nimport PipelineTaskNode from './PipelineTaskNode';\nimport TaskGroupEdge from './TaskGroupEdge';\n\nconst GROUPED_EDGE_TYPE = 'GROUPED_EDGE';\n\nexport const layoutFactory: LayoutFactory = (type: string, graph: Graph) => {\n switch (type) {\n case PipelineLayout.DAGRE_BUILDER:\n case PipelineLayout.DAGRE_BUILDER_SPACED:\n return new DagreLayout(graph, {\n // Hack to get around undesirable defaults\n linkDistance: 0,\n nodeDistance: 0,\n groupDistance: 0,\n collideDistance: 0,\n simulationSpeed: 0,\n chargeStrength: 0,\n allowDrag: false,\n layoutOnDrag: false,\n ...getLayoutData(type),\n });\n case PipelineLayout.DAGRE_VIEWER:\n return new PipelineDagreLayout(graph, { nodesep: 25 });\n default:\n return undefined;\n }\n};\n\nconst pipelineComponentFactory: ComponentFactory = (\n kind: ModelKind,\n type: string,\n): React.ComponentType<{ element: GraphElement }> | undefined => {\n if (kind === ModelKind.graph) {\n return withPanZoom()(GraphComponent) as React.ComponentType<{\n element: GraphElement;\n }>;\n }\n if (kind === ModelKind.edge) {\n return TaskEdge as React.ComponentType<{ element: GraphElement }>;\n }\n if (kind === ModelKind.node) {\n switch (type) {\n case NodeType.TASK_NODE:\n case NodeType.FINALLY_NODE:\n return PipelineTaskNode as React.ComponentType<any>;\n case 'task-group':\n case NodeType.FINALLY_GROUP:\n return DefaultTaskGroup as React.ComponentType<{\n element: GraphElement;\n }>;\n case NodeType.SPACER_NODE:\n return SpacerNode as React.ComponentType<{ element: GraphElement }>;\n case 'finally-spacer-edge':\n case NodeType.EDGE:\n return TaskEdge as React.ComponentType<{ element: GraphElement }>;\n case GROUPED_EDGE_TYPE:\n return TaskGroupEdge as React.ComponentType<{ element: GraphElement }>;\n default:\n return undefined;\n }\n }\n return undefined;\n};\n\nexport default pipelineComponentFactory;\n"],"names":[],"mappings":";;;;;;AAqCA,MAAM,iBAAoB,GAAA,cAAA;AAEb,MAAA,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QAAS,CAAA,IAAA;AACZ,QAAO,OAAA,QAAA;AAAA,MACT,KAAK,iBAAA;AACH,QAAO,OAAA,aAAA;AAAA,MACT;AACE,QAAO,OAAA,MAAA;AAAA;AACX;AAEF,EAAO,OAAA,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"pipelineComponentFactory.esm.js","sources":["../../../src/components/pipeline-topology/pipelineComponentFactory.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport type { ComponentType } from 'react';\n\nimport {\n ComponentFactory,\n DagreLayout,\n DefaultTaskGroup,\n Graph,\n GraphComponent,\n GraphElement,\n LayoutFactory,\n ModelKind,\n PipelineDagreLayout,\n SpacerNode,\n TaskEdge,\n withPanZoom,\n} from '@patternfly/react-topology';\n\nimport { NodeType, PipelineLayout } from '../../consts/pipeline-topology-const';\nimport { getLayoutData } from '../../utils/pipeline-topology-utils';\nimport PipelineTaskNode from './PipelineTaskNode';\nimport TaskGroupEdge from './TaskGroupEdge';\n\nconst GROUPED_EDGE_TYPE = 'GROUPED_EDGE';\n\nexport const layoutFactory: LayoutFactory = (type: string, graph: Graph) => {\n switch (type) {\n case PipelineLayout.DAGRE_BUILDER:\n case PipelineLayout.DAGRE_BUILDER_SPACED:\n return new DagreLayout(graph, {\n // Hack to get around undesirable defaults\n linkDistance: 0,\n nodeDistance: 0,\n groupDistance: 0,\n collideDistance: 0,\n simulationSpeed: 0,\n chargeStrength: 0,\n allowDrag: false,\n layoutOnDrag: false,\n ...getLayoutData(type),\n });\n case PipelineLayout.DAGRE_VIEWER:\n return new PipelineDagreLayout(graph, { nodesep: 25 });\n default:\n return undefined;\n }\n};\n\nconst pipelineComponentFactory: ComponentFactory = (\n kind: ModelKind,\n type: string,\n): ComponentType<{ element: GraphElement }> | undefined => {\n if (kind === ModelKind.graph) {\n return withPanZoom()(GraphComponent) as ComponentType<{\n element: GraphElement;\n }>;\n }\n if (kind === ModelKind.edge) {\n return TaskEdge as ComponentType<{ element: GraphElement }>;\n }\n if (kind === ModelKind.node) {\n switch (type) {\n case NodeType.TASK_NODE:\n case NodeType.FINALLY_NODE:\n return PipelineTaskNode as ComponentType<any>;\n case 'task-group':\n case NodeType.FINALLY_GROUP:\n return DefaultTaskGroup as ComponentType<{\n element: GraphElement;\n }>;\n case NodeType.SPACER_NODE:\n return SpacerNode as ComponentType<{ element: GraphElement }>;\n case 'finally-spacer-edge':\n case NodeType.EDGE:\n return TaskEdge as ComponentType<{ element: GraphElement }>;\n case GROUPED_EDGE_TYPE:\n return TaskGroupEdge as ComponentType<{ element: GraphElement }>;\n default:\n return undefined;\n }\n }\n return undefined;\n};\n\nexport default pipelineComponentFactory;\n"],"names":[],"mappings":";;;;;;AAqCA,MAAM,iBAAoB,GAAA,cAAA;AAEb,MAAA,aAAA,GAA+B,CAAC,IAAA,EAAc,KAAiB,KAAA;AAC1E,EAAA,QAAQ,IAAM;AAAA,IACZ,KAAK,cAAe,CAAA,aAAA;AAAA,IACpB,KAAK,cAAe,CAAA,oBAAA;AAClB,MAAO,OAAA,IAAI,YAAY,KAAO,EAAA;AAAA;AAAA,QAE5B,YAAc,EAAA,CAAA;AAAA,QACd,YAAc,EAAA,CAAA;AAAA,QACd,aAAe,EAAA,CAAA;AAAA,QACf,eAAiB,EAAA,CAAA;AAAA,QACjB,eAAiB,EAAA,CAAA;AAAA,QACjB,cAAgB,EAAA,CAAA;AAAA,QAChB,SAAW,EAAA,KAAA;AAAA,QACX,YAAc,EAAA,KAAA;AAAA,QACd,GAAG,cAAc,IAAI;AAAA,OACtB,CAAA;AAAA,IACH,KAAK,cAAe,CAAA,YAAA;AAClB,MAAA,OAAO,IAAI,mBAAoB,CAAA,KAAA,EAAO,EAAE,OAAA,EAAS,IAAI,CAAA;AAAA,IACvD;AACE,MAAO,OAAA,MAAA;AAAA;AAEb;AAEM,MAAA,wBAAA,GAA6C,CACjD,IAAA,EACA,IACyD,KAAA;AACzD,EAAI,IAAA,IAAA,KAAS,UAAU,KAAO,EAAA;AAC5B,IAAO,OAAA,WAAA,GAAc,cAAc,CAAA;AAAA;AAIrC,EAAI,IAAA,IAAA,KAAS,UAAU,IAAM,EAAA;AAC3B,IAAO,OAAA,QAAA;AAAA;AAET,EAAI,IAAA,IAAA,KAAS,UAAU,IAAM,EAAA;AAC3B,IAAA,QAAQ,IAAM;AAAA,MACZ,KAAK,QAAS,CAAA,SAAA;AAAA,MACd,KAAK,QAAS,CAAA,YAAA;AACZ,QAAO,OAAA,gBAAA;AAAA,MACT,KAAK,YAAA;AAAA,MACL,KAAK,QAAS,CAAA,aAAA;AACZ,QAAO,OAAA,gBAAA;AAAA,MAGT,KAAK,QAAS,CAAA,WAAA;AACZ,QAAO,OAAA,UAAA;AAAA,MACT,KAAK,qBAAA;AAAA,MACL,KAAK,QAAS,CAAA,IAAA;AACZ,QAAO,OAAA,QAAA;AAAA,MACT,KAAK,iBAAA;AACH,QAAO,OAAA,aAAA;AAAA,MACT;AACE,QAAO,OAAA,MAAA;AAAA;AACX;AAEF,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1,16 +1,18 @@
1
- import React__default from 'react';
1
+ import { createContext } from 'react';
2
2
  import { ComputedStatus } from '@janus-idp/shared-react';
3
3
 
4
- const TektonResourcesContext = React__default.createContext({
5
- clusters: [],
6
- selectedStatus: ComputedStatus.All,
7
- setSelectedCluster: () => {
8
- },
9
- setSelectedStatus: () => {
10
- },
11
- setIsExpanded: () => {
4
+ const TektonResourcesContext = createContext(
5
+ {
6
+ clusters: [],
7
+ selectedStatus: ComputedStatus.All,
8
+ setSelectedCluster: () => {
9
+ },
10
+ setSelectedStatus: () => {
11
+ },
12
+ setIsExpanded: () => {
13
+ }
12
14
  }
13
- });
15
+ );
14
16
 
15
17
  export { TektonResourcesContext };
16
18
  //# sourceMappingURL=TektonResourcesContext.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TektonResourcesContext.esm.js","sources":["../../src/hooks/TektonResourcesContext.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport { ComputedStatus } from '@janus-idp/shared-react';\n\nimport { TektonResourcesContextData } from '../types/types';\n\nexport const TektonResourcesContext =\n React.createContext<TektonResourcesContextData>({\n clusters: [],\n selectedStatus: ComputedStatus.All,\n setSelectedCluster: () => {},\n setSelectedStatus: () => {},\n setIsExpanded: () => {},\n });\n"],"names":["React"],"mappings":";;;AAqBa,MAAA,sBAAA,GACXA,eAAM,aAA0C,CAAA;AAAA,EAC9C,UAAU,EAAC;AAAA,EACX,gBAAgB,cAAe,CAAA,GAAA;AAAA,EAC/B,oBAAoB,MAAM;AAAA,GAAC;AAAA,EAC3B,mBAAmB,MAAM;AAAA,GAAC;AAAA,EAC1B,eAAe,MAAM;AAAA;AACvB,CAAC;;;;"}
1
+ {"version":3,"file":"TektonResourcesContext.esm.js","sources":["../../src/hooks/TektonResourcesContext.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { createContext } from 'react';\n\nimport { ComputedStatus } from '@janus-idp/shared-react';\n\nimport { TektonResourcesContextData } from '../types/types';\n\nexport const TektonResourcesContext = createContext<TektonResourcesContextData>(\n {\n clusters: [],\n selectedStatus: ComputedStatus.All,\n setSelectedCluster: () => {},\n setSelectedStatus: () => {},\n setIsExpanded: () => {},\n },\n);\n"],"names":[],"mappings":";;;AAqBO,MAAM,sBAAyB,GAAA,aAAA;AAAA,EACpC;AAAA,IACE,UAAU,EAAC;AAAA,IACX,gBAAgB,cAAe,CAAA,GAAA;AAAA,IAC/B,oBAAoB,MAAM;AAAA,KAAC;AAAA,IAC3B,mBAAmB,MAAM;AAAA,KAAC;AAAA,IAC1B,eAAe,MAAM;AAAA;AAAC;AAE1B;;;;"}
@@ -1,4 +1,4 @@
1
- import React__default from 'react';
1
+ import { useEffect } from 'react';
2
2
  import { useTheme } from '@material-ui/core/styles';
3
3
 
4
4
  const THEME_DARK = "dark";
@@ -7,7 +7,7 @@ const useDarkTheme = () => {
7
7
  const {
8
8
  palette: { type }
9
9
  } = useTheme();
10
- React__default.useEffect(() => {
10
+ useEffect(() => {
11
11
  const htmlTagElement = document.documentElement;
12
12
  if (type === THEME_DARK) {
13
13
  htmlTagElement.classList.add(THEME_DARK_CLASS);
@@ -1 +1 @@
1
- {"version":3,"file":"useDarkTheme.esm.js","sources":["../../src/hooks/useDarkTheme.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\n\nimport { useTheme } from '@material-ui/core/styles';\n\nconst THEME_DARK = 'dark';\nconst THEME_DARK_CLASS = 'pf-v6-theme-dark';\n\nexport const useDarkTheme = () => {\n const {\n palette: { type },\n } = useTheme();\n\n React.useEffect(() => {\n const htmlTagElement = document.documentElement;\n if (type === THEME_DARK) {\n htmlTagElement.classList.add(THEME_DARK_CLASS);\n } else {\n htmlTagElement.classList.remove(THEME_DARK_CLASS);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [type]);\n};\n"],"names":["React"],"mappings":";;;AAmBA,MAAM,UAAa,GAAA,MAAA;AACnB,MAAM,gBAAmB,GAAA,kBAAA;AAElB,MAAM,eAAe,MAAM;AAChC,EAAM,MAAA;AAAA,IACJ,OAAA,EAAS,EAAE,IAAK;AAAA,MACd,QAAS,EAAA;AAEb,EAAAA,cAAA,CAAM,UAAU,MAAM;AACpB,IAAA,MAAM,iBAAiB,QAAS,CAAA,eAAA;AAChC,IAAA,IAAI,SAAS,UAAY,EAAA;AACvB,MAAe,cAAA,CAAA,SAAA,CAAU,IAAI,gBAAgB,CAAA;AAAA,KACxC,MAAA;AACL,MAAe,cAAA,CAAA,SAAA,CAAU,OAAO,gBAAgB,CAAA;AAAA;AAClD,GAEF,EAAG,CAAC,IAAI,CAAC,CAAA;AACX;;;;"}
1
+ {"version":3,"file":"useDarkTheme.esm.js","sources":["../../src/hooks/useDarkTheme.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { useEffect } from 'react';\n\nimport { useTheme } from '@material-ui/core/styles';\n\nconst THEME_DARK = 'dark';\nconst THEME_DARK_CLASS = 'pf-v6-theme-dark';\n\nexport const useDarkTheme = () => {\n const {\n palette: { type },\n } = useTheme();\n\n useEffect(() => {\n const htmlTagElement = document.documentElement;\n if (type === THEME_DARK) {\n htmlTagElement.classList.add(THEME_DARK_CLASS);\n } else {\n htmlTagElement.classList.remove(THEME_DARK_CLASS);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [type]);\n};\n"],"names":[],"mappings":";;;AAmBA,MAAM,UAAa,GAAA,MAAA;AACnB,MAAM,gBAAmB,GAAA,kBAAA;AAElB,MAAM,eAAe,MAAM;AAChC,EAAM,MAAA;AAAA,IACJ,OAAA,EAAS,EAAE,IAAK;AAAA,MACd,QAAS,EAAA;AAEb,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,iBAAiB,QAAS,CAAA,eAAA;AAChC,IAAA,IAAI,SAAS,UAAY,EAAA;AACvB,MAAe,cAAA,CAAA,SAAA,CAAU,IAAI,gBAAgB,CAAA;AAAA,KACxC,MAAA;AACL,MAAe,cAAA,CAAA,SAAA,CAAU,OAAO,gBAAgB,CAAA;AAAA;AAClD,GAEF,EAAG,CAAC,IAAI,CAAC,CAAA;AACX;;;;"}
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { useMemo } from 'react';
2
2
 
3
3
  const SCAN_OUTPUT_SUFFIX = "SCAN_OUTPUT";
4
4
  const getPipelineRunScanResults = (pipelineRun) => (pipelineRun.status?.results || pipelineRun.status?.pipelineResults)?.reduce(
@@ -23,7 +23,7 @@ const getPipelineRunScanResults = (pipelineRun) => (pipelineRun.status?.results
23
23
  {}
24
24
  ) || {};
25
25
  const usePipelineRunScanResults = (pipelineRun) => {
26
- return React.useMemo(() => {
26
+ return useMemo(() => {
27
27
  if (!pipelineRun) {
28
28
  return {};
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"usePipelineRunScanResults.esm.js","sources":["../../src/hooks/usePipelineRunScanResults.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport * as React from 'react';\n\nimport { PipelineRunKind } from '@janus-idp/shared-react';\n\nimport { PipelineRunScanResults } from '../types/types';\n\nconst SCAN_OUTPUT_SUFFIX = 'SCAN_OUTPUT';\n\nexport const getPipelineRunScanResults = (\n pipelineRun: PipelineRunKind,\n): PipelineRunScanResults =>\n (pipelineRun.status?.results || pipelineRun.status?.pipelineResults)?.reduce(\n (acc, result) => {\n if (result.name?.endsWith(SCAN_OUTPUT_SUFFIX)) {\n if (!acc.vulnerabilities) {\n acc.vulnerabilities = { critical: 0, high: 0, medium: 0, low: 0 };\n }\n try {\n const taskVulnerabilities = JSON.parse(result.value);\n if (taskVulnerabilities.vulnerabilities) {\n acc.vulnerabilities.critical +=\n taskVulnerabilities.vulnerabilities.critical || 0;\n acc.vulnerabilities.high +=\n taskVulnerabilities.vulnerabilities.high || 0;\n acc.vulnerabilities.medium +=\n taskVulnerabilities.vulnerabilities.medium || 0;\n acc.vulnerabilities.low +=\n taskVulnerabilities.vulnerabilities.low || 0;\n }\n } catch (e) {\n // ignore\n }\n }\n return acc;\n },\n {} as PipelineRunScanResults,\n ) || {};\n\nexport const usePipelineRunScanResults = (\n pipelineRun: PipelineRunKind,\n): PipelineRunScanResults => {\n return React.useMemo(() => {\n if (!pipelineRun) {\n return {};\n }\n\n return getPipelineRunScanResults(pipelineRun);\n }, [pipelineRun]);\n};\n"],"names":[],"mappings":";;AAqBA,MAAM,kBAAqB,GAAA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AAW,CAAA;AAAA,GAC9C,EAAG,CAAC,WAAW,CAAC,CAAA;AAClB;;;;"}
1
+ {"version":3,"file":"usePipelineRunScanResults.esm.js","sources":["../../src/hooks/usePipelineRunScanResults.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { useMemo } from 'react';\n\nimport { PipelineRunKind } from '@janus-idp/shared-react';\n\nimport { PipelineRunScanResults } from '../types/types';\n\nconst SCAN_OUTPUT_SUFFIX = 'SCAN_OUTPUT';\n\nexport const getPipelineRunScanResults = (\n pipelineRun: PipelineRunKind,\n): PipelineRunScanResults =>\n (pipelineRun.status?.results || pipelineRun.status?.pipelineResults)?.reduce(\n (acc, result) => {\n if (result.name?.endsWith(SCAN_OUTPUT_SUFFIX)) {\n if (!acc.vulnerabilities) {\n acc.vulnerabilities = { critical: 0, high: 0, medium: 0, low: 0 };\n }\n try {\n const taskVulnerabilities = JSON.parse(result.value);\n if (taskVulnerabilities.vulnerabilities) {\n acc.vulnerabilities.critical +=\n taskVulnerabilities.vulnerabilities.critical || 0;\n acc.vulnerabilities.high +=\n taskVulnerabilities.vulnerabilities.high || 0;\n acc.vulnerabilities.medium +=\n taskVulnerabilities.vulnerabilities.medium || 0;\n acc.vulnerabilities.low +=\n taskVulnerabilities.vulnerabilities.low || 0;\n }\n } catch (e) {\n // ignore\n }\n }\n return acc;\n },\n {} as PipelineRunScanResults,\n ) || {};\n\nexport const usePipelineRunScanResults = (\n pipelineRun: PipelineRunKind,\n): PipelineRunScanResults => {\n return useMemo(() => {\n if (!pipelineRun) {\n return {};\n }\n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AI,CAAC,WAAa,EAAA;AAChB,MAAA,OAAO,EAAC;AAAA;AAGV,IAAA,OAAO,0BAA0B,WAAW,CAAA;AAAA,GAC9C,EAAG,CAAC,WAAW,CAAC,CAAA;AAClB;;;;"}
@@ -1,6 +1,5 @@
1
- import React__default from 'react';
2
- import useAsyncRetry from 'react-use/lib/useAsyncRetry';
3
- import useInterval from 'react-use/lib/useInterval';
1
+ import { useContext } from 'react';
2
+ import { useQuery } from '@tanstack/react-query';
4
3
  import { useApi } from '@backstage/core-plugin-api';
5
4
  import { kubernetesProxyApiRef } from '../types/types.esm.js';
6
5
  import { TektonResourcesContext } from './TektonResourcesContext.esm.js';
@@ -9,58 +8,40 @@ const usePodLogsOfPipelineRun = ({
9
8
  pod,
10
9
  intervalMs = 5e3
11
10
  }) => {
12
- const [loadingData, setLoadingData] = React__default.useState(true);
13
- const [, setPodInfo] = React__default.useState(pod?.metadata?.name ?? "");
14
11
  const kubernetesProxyApi = useApi(kubernetesProxyApiRef);
15
- const { clusters, selectedCluster } = React__default.useContext(TektonResourcesContext);
12
+ const { clusters, selectedCluster } = useContext(
13
+ TektonResourcesContext
14
+ );
16
15
  const currCluster = clusters.length > 0 && clusters[selectedCluster || 0] || "";
17
16
  const containersList = pod?.spec?.containers || [];
18
- const getLogs = React__default.useCallback(
19
- async (podScope) => {
20
- const { podName, podNamespace, containerName, clusterName } = podScope;
21
- return await kubernetesProxyApi.getPodLogs({
22
- podName,
23
- namespace: podNamespace,
24
- containerName,
25
- clusterName
26
- });
27
- },
28
- [kubernetesProxyApi]
29
- );
30
- const { value, error, loading, retry } = useAsyncRetry(async () => {
31
- const requests = [];
32
- containersList.map((container, _idx) => {
33
- if (pod?.metadata?.name && pod?.metadata?.namespace && container) {
34
- const podScope = {
35
- containerName: container.name,
36
- podName: pod.metadata.name,
37
- podNamespace: pod.metadata.namespace,
38
- clusterName: currCluster
39
- };
40
- requests.push(getLogs(podScope));
41
- }
42
- });
43
- return requests.length > 0 ? Promise.all(requests) : [];
44
- }, [containersList, pod, getLogs]);
17
+ const podKey = pod?.metadata?.name;
45
18
  const stopPolling = pod?.status?.phase === "Succeeded" || pod?.status?.phase === "Failed";
46
- useInterval(() => retry(), stopPolling ? null : intervalMs);
47
- React__default.useEffect(() => {
48
- let mounted = true;
49
- if (!loading && mounted) {
50
- setPodInfo((prevState) => {
51
- if (prevState === pod?.metadata?.name) {
52
- setLoadingData(false);
53
- return prevState;
19
+ const { data, error, isLoading, isFetching } = useQuery({
20
+ queryKey: ["podLogs", podKey, currCluster],
21
+ queryFn: async () => {
22
+ const requests = containersList.map((container) => {
23
+ if (pod?.metadata?.name && pod?.metadata?.namespace && container) {
24
+ return kubernetesProxyApi.getPodLogs({
25
+ podName: pod.metadata.name,
26
+ namespace: pod.metadata.namespace,
27
+ containerName: container.name,
28
+ clusterName: currCluster
29
+ });
54
30
  }
55
- setLoadingData(true);
56
- return pod?.metadata?.name || "";
57
- });
58
- }
59
- return () => {
60
- mounted = false;
61
- };
62
- }, [loading, pod]);
63
- return { value, error, loading: loadingData };
31
+ return Promise.resolve({ text: "" });
32
+ }).filter(Boolean);
33
+ return Promise.all(requests);
34
+ },
35
+ enabled: !!pod?.metadata?.name && containersList.length > 0,
36
+ refetchInterval: stopPolling ? false : intervalMs,
37
+ staleTime: 6e4
38
+ // Keep the data fresh for 1 minute instead of constantly refetching.
39
+ });
40
+ return {
41
+ value: data,
42
+ error,
43
+ loading: isLoading || isFetching
44
+ };
64
45
  };
65
46
 
66
47
  export { usePodLogsOfPipelineRun };
@@ -1 +1 @@
1
- {"version":3,"file":"usePodLogsOfPipelineRun.esm.js","sources":["../../src/hooks/usePodLogsOfPipelineRun.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport React from 'react';\nimport useAsyncRetry from 'react-use/lib/useAsyncRetry';\nimport useInterval from 'react-use/lib/useInterval';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { V1Container, V1Pod } from '@kubernetes/client-node';\n\nimport {\n kubernetesProxyApiRef,\n TektonResourcesContextData,\n} from '../types/types';\nimport { TektonResourcesContext } from './TektonResourcesContext';\n\nexport interface ContainerScope {\n podName: string;\n podNamespace: string;\n clusterName: string;\n containerName: string;\n}\n\ninterface PodLogsOptions {\n pod: V1Pod;\n intervalMs?: number;\n}\n\nexport const usePodLogsOfPipelineRun = ({\n pod,\n intervalMs = 5000,\n}: PodLogsOptions) => {\n const [loadingData, setLoadingData] = React.useState<boolean>(true);\n const [, setPodInfo] = React.useState<string>(pod?.metadata?.name ?? '');\n const kubernetesProxyApi = useApi(kubernetesProxyApiRef);\n const { clusters, selectedCluster } =\n React.useContext<TektonResourcesContextData>(TektonResourcesContext);\n const currCluster =\n (clusters.length > 0 && clusters[selectedCluster || 0]) || '';\n const containersList = pod?.spec?.containers || [];\n const getLogs = React.useCallback(\n async (podScope: ContainerScope): Promise<{ text: string }> => {\n const { podName, podNamespace, containerName, clusterName } = podScope;\n return await kubernetesProxyApi.getPodLogs({\n podName: podName,\n namespace: podNamespace,\n containerName: containerName,\n clusterName: clusterName,\n });\n },\n [kubernetesProxyApi],\n );\n\n const { value, error, loading, retry } = useAsyncRetry(async () => {\n const requests: Promise<{\n text: string;\n }>[] = [];\n containersList.map((container: V1Container, _idx: any) => {\n if (pod?.metadata?.name && pod?.metadata?.namespace && container) {\n const podScope = {\n containerName: container.name,\n podName: pod.metadata.name,\n podNamespace: pod.metadata.namespace,\n clusterName: currCluster,\n };\n requests.push(getLogs(podScope));\n }\n });\n return requests.length > 0 ? Promise.all(requests) : [];\n }, [containersList, pod, getLogs]);\n\n const stopPolling =\n pod?.status?.phase === 'Succeeded' || pod?.status?.phase === 'Failed';\n\n useInterval(() => retry(), stopPolling ? null : intervalMs);\n\n React.useEffect(() => {\n let mounted = true;\n if (!loading && mounted) {\n setPodInfo(prevState => {\n if (prevState === pod?.metadata?.name) {\n setLoadingData(false);\n return prevState;\n }\n setLoadingData(true);\n return pod?.metadata?.name || '';\n });\n }\n return () => {\n mounted = false;\n };\n }, [loading, pod]);\n\n return { value, error, loading: loadingData };\n};\n"],"names":["React"],"mappings":";;;;;;;AAyCO,MAAM,0BAA0B,CAAC;AAAA,EACtC,GAAA;AAAA,EACA,UAAa,GAAA;AACf,CAAsB,KAAA;AACpB,EAAA,MAAM,CAAC,WAAa,EAAA,cAAc,CAAI,GAAAA,cAAA,CAAM,SAAkB,IAAI,CAAA;AAClE,EAAM,MAAA,GAAG,UAAU,CAAA,GAAIA,eAAM,QAAiB,CAAA,GAAA,EAAK,QAAU,EAAA,IAAA,IAAQ,EAAE,CAAA;AACvE,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAA,MAAM,EAAE,QAAU,EAAA,eAAA,EAChB,GAAAA,cAAA,CAAM,WAAuC,sBAAsB,CAAA;AACrE,EAAA,MAAM,cACH,QAAS,CAAA,MAAA,GAAS,KAAK,QAAS,CAAA,eAAA,IAAmB,CAAC,CAAM,IAAA,EAAA;AAC7D,EAAA,MAAM,cAAiB,GAAA,GAAA,EAAK,IAAM,EAAA,UAAA,IAAc,EAAC;AACjD,EAAA,MAAM,UAAUA,cAAM,CAAA,WAAA;AAAA,IACpB,OAAO,QAAwD,KAAA;AAC7D,MAAA,MAAM,EAAE,OAAA,EAAS,YAAc,EAAA,aAAA,EAAe,aAAgB,GAAA,QAAA;AAC9D,MAAO,OAAA,MAAM,mBAAmB,UAAW,CAAA;AAAA,QACzC,OAAA;AAAA,QACA,SAAW,EAAA,YAAA;AAAA,QACX,aAAA;AAAA,QACA;AAAA,OACD,CAAA;AA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;AAET,QAAA,cAAA,CAAe,IAAI,CAAA;AACnB,QAAO,OAAA,GAAA,EAAK,UAAU,IAAQ,IAAA,EAAA;AAAA,OAC/B,CAAA;AAAA;AAEH,IAAA,OAAO,MAAM;AACX,MAAU,OAAA,GAAA,KAAA;AAAA,KACZ;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,GAAG,CAAC,CAAA;AAEjB,EAAA,OAAO,EAAE,KAAA,EAAO,KAAO,EAAA,OAAA,EAAS,WAAY,EAAA;AAC9C;;;;"}
1
+ {"version":3,"file":"usePodLogsOfPipelineRun.esm.js","sources":["../../src/hooks/usePodLogsOfPipelineRun.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { useContext } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { V1Container, V1Pod } from '@kubernetes/client-node';\n\nimport {\n kubernetesProxyApiRef,\n TektonResourcesContextData,\n} from '../types/types';\nimport { TektonResourcesContext } from './TektonResourcesContext';\n\nexport interface ContainerScope {\n podName: string;\n podNamespace: string;\n clusterName: string;\n containerName: string;\n}\n\ninterface PodLogsOptions {\n pod: V1Pod;\n intervalMs?: number;\n}\n\nexport const usePodLogsOfPipelineRun = ({\n pod,\n intervalMs = 5000,\n}: PodLogsOptions) => {\n const kubernetesProxyApi = useApi(kubernetesProxyApiRef);\n const { clusters, selectedCluster } = useContext<TektonResourcesContextData>(\n TektonResourcesContext,\n );\n const currCluster =\n (clusters.length > 0 && clusters[selectedCluster || 0]) || '';\n const containersList = pod?.spec?.containers || [];\n\n const podKey = pod?.metadata?.name;\n const stopPolling =\n pod?.status?.phase === 'Succeeded' || pod?.status?.phase === 'Failed';\n\n const { data, error, isLoading, isFetching } = useQuery({\n queryKey: ['podLogs', podKey, currCluster],\n queryFn: async () => {\n const requests = containersList\n .map((container: V1Container) => {\n if (pod?.metadata?.name && pod?.metadata?.namespace && container) {\n return kubernetesProxyApi.getPodLogs({\n podName: pod.metadata.name,\n namespace: pod.metadata.namespace,\n containerName: container.name,\n clusterName: currCluster,\n });\n }\n\n return Promise.resolve({ text: '' });\n })\n .filter(Boolean);\n\n return Promise.all(requests);\n },\n enabled: !!pod?.metadata?.name && containersList.length > 0,\n refetchInterval: stopPolling ? false : intervalMs,\n staleTime: 60000, // Keep the data fresh for 1 minute instead of constantly refetching.\n });\n\n return {\n value: data,\n error,\n loading: isLoading || isFetching,\n };\n};\n"],"names":[],"mappings":";;;;;;AAsCO,MAAM,0BAA0B,CAAC;AAAA,EACtC,GAAA;AAAA,EACA,UAAa,GAAA;AACf,CAAsB,KAAA;AACpB,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAM,MAAA,EAAE,QAAU,EAAA,eAAA,EAAoB,GAAA,UAAA;AAAA,IACpC;AAAA,GACF;AACA,EAAA,MAAM,cACH,QAAS,CAAA,MAAA,GAAS,KAAK,QAAS,CAAA,eAAA,IAAmB,CAAC,CAAM,IAAA,EAAA;AAC7D,EAAA,MAAM,cAAiB,GAAA,GAAA,EAAK,IAAM,EAAA,UAAA,IAAc,EAAC;AAEjD,EAAM,MAAA,MAAA,GAAS,KAAK,QAAU,EAAA,IAAA;AAC9B,EAAA,MAAM,cACJ,GAAK,EAAA,MAAA,EAAQ,UAAU,WAAe,IAAA,GAAA,EAAK,QAAQ,KAAU,KAAA,QAAA;AAE/D,EAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,SAAW,EAAA,UAAA,KAAe,QAAS,CAAA;AAAA,IACtD,QAAU,EAAA,CAAC,SAA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