@backstage-community/plugin-tekton 3.41.0 → 3.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @backstage-community/plugin-tekton
2
2
 
3
+ ## 3.41.1
4
+
5
+ ### Patch Changes
6
+
7
+ - f805ea0: Added spacing to the pipeline run log viewer dialog between the task sidebar and log content area
8
+ - 4b8f04b: Hide the CI/CD tab on entity pages when the tekton annotation is not present
9
+
3
10
  ## 3.41.0
4
11
 
5
12
  ### Minor Changes
package/dist/alpha.esm.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { createFrontendPlugin } from '@backstage/frontend-plugin-api';
3
3
  import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
4
+ import { isTektonCIAvailable } from './utils/isTektonCIAvailable.esm.js';
4
5
 
5
6
  const tektonEntityContent = EntityContentBlueprint.make({
6
7
  name: "tektonEntityContent",
7
8
  params: {
8
9
  path: "/tekton",
9
10
  title: "Tekton",
11
+ filter: isTektonCIAvailable,
10
12
  loader: () => import('./components/Router.esm.js').then((m) => /* @__PURE__ */ jsx(m.Router, {}))
11
13
  }
12
14
  });
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.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 */\nimport { createFrontendPlugin } from '@backstage/frontend-plugin-api';\nimport { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';\n\nconst tektonEntityContent = EntityContentBlueprint.make({\n name: 'tektonEntityContent',\n params: {\n path: '/tekton',\n title: 'Tekton',\n loader: () => import('./components/Router').then(m => <m.Router />),\n },\n});\n\n/**\n * The Tekton backstage NFS plugin.\n * @alpha\n */\nexport default createFrontendPlugin({\n pluginId: 'tekton',\n extensions: [tektonEntityContent],\n});\n"],"names":[],"mappings":";;;;AAkBA,MAAM,mBAAA,GAAsB,uBAAuB,IAAA,CAAK;AAAA,EACtD,IAAA,EAAM,qBAAA;AAAA,EACN,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,SAAA;AAAA,IACN,KAAA,EAAO,QAAA;AAAA,IACP,MAAA,EAAQ,MAAM,OAAO,4BAAqB,CAAA,CAAE,IAAA,CAAK,CAAA,CAAA,qBAAK,GAAA,CAAC,CAAA,CAAE,MAAA,EAAF,EAAS,CAAE;AAAA;AAEtE,CAAC,CAAA;AAMD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,QAAA;AAAA,EACV,UAAA,EAAY,CAAC,mBAAmB;AAClC,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.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 */\nimport { createFrontendPlugin } from '@backstage/frontend-plugin-api';\nimport { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport { isTektonCIAvailable } from './utils/isTektonCIAvailable';\n\nconst tektonEntityContent = EntityContentBlueprint.make({\n name: 'tektonEntityContent',\n params: {\n path: '/tekton',\n title: 'Tekton',\n filter: isTektonCIAvailable,\n loader: () => import('./components/Router').then(m => <m.Router />),\n },\n});\n\n/**\n * The Tekton backstage NFS plugin.\n * @alpha\n */\nexport default createFrontendPlugin({\n pluginId: 'tekton',\n extensions: [tektonEntityContent],\n});\n"],"names":[],"mappings":";;;;;AAmBA,MAAM,mBAAA,GAAsB,uBAAuB,IAAA,CAAK;AAAA,EACtD,IAAA,EAAM,qBAAA;AAAA,EACN,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,SAAA;AAAA,IACN,KAAA,EAAO,QAAA;AAAA,IACP,MAAA,EAAQ,mBAAA;AAAA,IACR,MAAA,EAAQ,MAAM,OAAO,4BAAqB,CAAA,CAAE,IAAA,CAAK,CAAA,CAAA,qBAAK,GAAA,CAAC,CAAA,CAAE,MAAA,EAAF,EAAS,CAAE;AAAA;AAEtE,CAAC,CAAA;AAMD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,QAAA;AAAA,EACV,UAAA,EAAY,CAAC,mBAAmB;AAClC,CAAC,CAAA;;;;"}
@@ -1,5 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useMemo } from 'react';
3
+ import { useTheme } from '@mui/material/styles';
3
4
  import { Flex, FlexItem } from '@patternfly/react-core';
4
5
  import { TEKTON_PIPELINE_RUN, TEKTON_PIPELINE_TASKRUN, TEKTON_PIPELINE_TASK } from '../../consts/tekton-const.esm.js';
5
6
  import PodLogsDownloadLink from './PodLogsDownloadLink.esm.js';
@@ -17,6 +18,7 @@ const PipelineRunLogDownloader = ({ pods, pipelineRun, activeTask }) => {
17
18
  ),
18
19
  [filteredPods]
19
20
  );
21
+ const theme = useTheme();
20
22
  const { t } = useTranslationRef(tektonTranslationRef);
21
23
  const activeTaskPod = sortedPods.find(
22
24
  (sp) => sp.metadata?.labels?.[TEKTON_PIPELINE_TASKRUN] === activeTask
@@ -26,6 +28,7 @@ const PipelineRunLogDownloader = ({ pods, pipelineRun, activeTask }) => {
26
28
  {
27
29
  "data-testid": "pipelinerun-logs-downloader",
28
30
  justifyContent: { default: "justifyContentFlexEnd" },
31
+ style: { marginBottom: theme.spacing(2) },
29
32
  children: [
30
33
  /* @__PURE__ */ jsx(FlexItem, { children: /* @__PURE__ */ jsx(
31
34
  PodLogsDownloadLink,
@@ -1 +1 @@
1
- {"version":3,"file":"PipelineRunLogDownloader.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogDownloader.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 { FC } from 'react';\n\nimport { useMemo } from 'react';\n\nimport { V1Pod } from '@kubernetes/client-node';\nimport { Flex, FlexItem } from '@patternfly/react-core';\n\nimport { PipelineRunKind } from '@backstage-community/plugin-tekton-react';\n\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n TEKTON_PIPELINE_TASKRUN,\n} from '../../consts/tekton-const';\nimport PodLogsDownloadLink from './PodLogsDownloadLink';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../../translations/index.ts';\n\nconst PipelineRunLogDownloader: FC<{\n pods: V1Pod[];\n pipelineRun: PipelineRunKind;\n activeTask: string | undefined;\n}> = ({ pods, pipelineRun, activeTask }) => {\n const filteredPods: V1Pod[] = pods?.filter(\n (p: V1Pod) =>\n p?.metadata?.labels?.[TEKTON_PIPELINE_RUN] ===\n pipelineRun?.metadata?.name,\n );\n\n const sortedPods: V1Pod[] = useMemo(\n () =>\n Array.from(filteredPods)?.sort(\n (a: V1Pod, b: V1Pod) =>\n new Date(a?.status?.startTime as Date).getTime() -\n new Date(b?.status?.startTime as Date).getTime(),\n ),\n [filteredPods],\n );\n const { t } = useTranslationRef(tektonTranslationRef);\n\n const activeTaskPod: V1Pod =\n sortedPods.find(\n (sp: V1Pod) =>\n sp.metadata?.labels?.[TEKTON_PIPELINE_TASKRUN] === activeTask,\n ) ?? sortedPods[sortedPods.length - 1];\n\n return sortedPods.length > 0 ? (\n <Flex\n data-testid=\"pipelinerun-logs-downloader\"\n justifyContent={{ default: 'justifyContentFlexEnd' }}\n >\n <FlexItem>\n <PodLogsDownloadLink\n data-testid=\"download-task-logs\"\n pods={activeTaskPod ? [activeTaskPod] : []}\n fileName={`${\n activeTaskPod?.metadata?.labels?.[TEKTON_PIPELINE_TASK] ?? 'task'\n }.log`}\n downloadTitle={t('pipelineRunLogs.downloader.downloadTaskLogs')}\n />\n </FlexItem>\n <FlexItem>\n <PodLogsDownloadLink\n data-testid=\"download-pipelinerun-logs\"\n pods={sortedPods}\n fileName={`${pipelineRun?.metadata?.name ?? 'pipelinerun'}.log`}\n downloadTitle={t(\n 'pipelineRunLogs.downloader.downloadPipelineRunLogs',\n )}\n />\n </FlexItem>\n </Flex>\n ) : null;\n};\nexport default PipelineRunLogDownloader;\n"],"names":[],"mappings":";;;;;;;;;AAiCA,MAAM,2BAID,CAAC,EAAE,IAAA,EAAM,WAAA,EAAa,YAAW,KAAM;AAC1C,EAAA,MAAM,eAAwB,IAAA,EAAM,MAAA;AAAA,IAClC,CAAC,MACC,CAAA,EAAG,QAAA,EAAU,SAAS,mBAAmB,CAAA,KACzC,aAAa,QAAA,EAAU;AAAA,GAC3B;AAEA,EAAA,MAAM,UAAA,GAAsB,OAAA;AAAA,IAC1B,MACE,KAAA,CAAM,IAAA,CAAK,YAAY,CAAA,EAAG,IAAA;AAAA,MACxB,CAAC,CAAA,EAAU,CAAA,KACT,IAAI,IAAA,CAAK,GAAG,MAAA,EAAQ,SAAiB,CAAA,CAAE,OAAA,KACvC,IAAI,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ACE,IAAA;AACN;;;;"}
1
+ {"version":3,"file":"PipelineRunLogDownloader.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogDownloader.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 { FC } from 'react';\n\nimport { useMemo } from 'react';\n\nimport { V1Pod } from '@kubernetes/client-node';\nimport { useTheme } from '@mui/material/styles';\nimport { Flex, FlexItem } from '@patternfly/react-core';\n\nimport { PipelineRunKind } from '@backstage-community/plugin-tekton-react';\n\nimport {\n TEKTON_PIPELINE_RUN,\n TEKTON_PIPELINE_TASK,\n TEKTON_PIPELINE_TASKRUN,\n} from '../../consts/tekton-const';\nimport PodLogsDownloadLink from './PodLogsDownloadLink';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../../translations/index.ts';\n\nconst PipelineRunLogDownloader: FC<{\n pods: V1Pod[];\n pipelineRun: PipelineRunKind;\n activeTask: string | undefined;\n}> = ({ pods, pipelineRun, activeTask }) => {\n const filteredPods: V1Pod[] = pods?.filter(\n (p: V1Pod) =>\n p?.metadata?.labels?.[TEKTON_PIPELINE_RUN] ===\n pipelineRun?.metadata?.name,\n );\n\n const sortedPods: V1Pod[] = useMemo(\n () =>\n Array.from(filteredPods)?.sort(\n (a: V1Pod, b: V1Pod) =>\n new Date(a?.status?.startTime as Date).getTime() -\n new Date(b?.status?.startTime as Date).getTime(),\n ),\n [filteredPods],\n );\n const theme = useTheme();\n const { t } = useTranslationRef(tektonTranslationRef);\n\n const activeTaskPod: V1Pod =\n sortedPods.find(\n (sp: V1Pod) =>\n sp.metadata?.labels?.[TEKTON_PIPELINE_TASKRUN] === activeTask,\n ) ?? sortedPods[sortedPods.length - 1];\n\n return sortedPods.length > 0 ? (\n <Flex\n data-testid=\"pipelinerun-logs-downloader\"\n justifyContent={{ default: 'justifyContentFlexEnd' }}\n style={{ marginBottom: theme.spacing(2) }}\n >\n <FlexItem>\n <PodLogsDownloadLink\n data-testid=\"download-task-logs\"\n pods={activeTaskPod ? [activeTaskPod] : []}\n fileName={`${\n activeTaskPod?.metadata?.labels?.[TEKTON_PIPELINE_TASK] ?? 'task'\n }.log`}\n downloadTitle={t('pipelineRunLogs.downloader.downloadTaskLogs')}\n />\n </FlexItem>\n <FlexItem>\n <PodLogsDownloadLink\n data-testid=\"download-pipelinerun-logs\"\n pods={sortedPods}\n fileName={`${pipelineRun?.metadata?.name ?? 'pipelinerun'}.log`}\n downloadTitle={t(\n 'pipelineRunLogs.downloader.downloadPipelineRunLogs',\n )}\n />\n </FlexItem>\n </Flex>\n ) : null;\n};\nexport default PipelineRunLogDownloader;\n"],"names":[],"mappings":";;;;;;;;;;AAkCA,MAAM,2BAID,CAAC,EAAE,IAAA,EAAM,WAAA,EAAa,YAAW,KAAM;AAC1C,EAAA,MAAM,eAAwB,IAAA,EAAM,MAAA;AAAA,IAClC,CAAC,MACC,CAAA,EAAG,QAAA,EAAU,SAAS,mBAAmB,CAAA,KACzC,aAAa,QAAA,EAAU;AAAA,GAC3B;AAEA,EAAA,MAAM,UAAA,GAAsB,OAAA;AAAA,IAC1B,MACE,KAAA,CAAM,IAAA,CAAK,YAAY,CAAA,EAAG,IAAA;AAAA,MACxB,CAAC,CAAA,EAAU,CAAA,KACT,IAAI,IAAA,CAAK,GAAG,MAAA,EAAQ,SAAiB,CAAA,CAAE,OAAA,KACvC,IAAI,IAAA,CAAK,GAAG,MAAA,EAAQ,SAAiB,EAAE,OAAA;AAAQ,KACnD;AAAA,IACF,CAAC,YAAY;AAAA,GACf;AACA,EAAA,MAA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F,GACE,IAAA;AACN;;;;"}
@@ -53,8 +53,8 @@ const PipelineRunLogs = ({
53
53
  }),
54
54
  [pods, podName]
55
55
  );
56
- return /* @__PURE__ */ jsxs(Grid, { container: true, children: [
57
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, children: /* @__PURE__ */ jsx(Paper, { children: /* @__PURE__ */ jsx(
56
+ return /* @__PURE__ */ jsxs(Grid, { container: true, sx: { gap: 2 }, children: [
57
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 3, children: /* @__PURE__ */ jsx(Paper, { sx: { paddingX: 2 }, children: /* @__PURE__ */ jsx(
58
58
  TaskStatusStepper,
59
59
  {
60
60
  steps: sortedTaskRuns,
@@ -62,7 +62,7 @@ const PipelineRunLogs = ({
62
62
  onUserStepChange: setActiveTask
63
63
  }
64
64
  ) }) }),
65
- /* @__PURE__ */ jsxs(Grid, { item: true, xs: 9, children: [
65
+ /* @__PURE__ */ jsxs(Grid, { item: true, xs: true, children: [
66
66
  !currentStepId && /* @__PURE__ */ jsx(Progress, {}),
67
67
  /* @__PURE__ */ jsx("div", { style: { height: "80vh" }, children: !podData ? /* @__PURE__ */ jsx(
68
68
  Paper,
@@ -1 +1 @@
1
- {"version":3,"file":"PipelineRunLogs.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogs.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 { useState, useEffect, useMemo } from 'react';\n\nimport { LogViewer, Progress } from '@backstage/core-components';\n\nimport { V1Pod } from '@kubernetes/client-node';\nimport Grid from '@mui/material/Grid';\nimport Paper from '@mui/material/Paper';\n\nimport {\n getTaskRunsForPipelineRun,\n pipelineRunFilterReducer,\n PipelineRunKind,\n TaskRunKind,\n} from '@backstage-community/plugin-tekton-react';\n\nimport { getActiveTaskRun, getSortedTaskRuns } from '../../utils/taskRun-utils';\nimport { PipelineRunLogViewer } from './PipelineRunLogViewer';\nimport { TaskStatusStepper } from './TaskStatusStepper';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../../translations/index.ts';\n\ntype PipelineRunLogsProps = {\n pipelineRun: PipelineRunKind;\n taskRuns: TaskRunKind[];\n pods: V1Pod[];\n activeTask?: string;\n setActiveTask: (t: string) => void;\n};\nexport const PipelineRunLogs = ({\n pipelineRun,\n taskRuns,\n pods,\n activeTask,\n setActiveTask,\n}: PipelineRunLogsProps) => {\n const PLRTaskRuns = getTaskRunsForPipelineRun(pipelineRun, taskRuns);\n const sortedTaskRuns = getSortedTaskRuns(PLRTaskRuns);\n const taskRunFromYaml = PLRTaskRuns?.reduce(\n (acc: { [value: string]: TaskRunKind }, value) => {\n if (value?.metadata?.name) {\n acc[value.metadata.name] = value;\n }\n return acc;\n },\n {},\n );\n\n const completed = pipelineRunFilterReducer(pipelineRun);\n const [lastActiveStepId, setLastActiveStepId] = useState<string>('');\n const { t } = useTranslationRef(tektonTranslationRef);\n\n useEffect(() => {\n const mostRecentFailedOrActiveStep = sortedTaskRuns.find(tr =>\n ['Failed', 'Running'].includes(tr.status),\n );\n\n if (completed && !mostRecentFailedOrActiveStep && !activeTask) {\n setLastActiveStepId(sortedTaskRuns[sortedTaskRuns.length - 1]?.id);\n return;\n }\n\n setLastActiveStepId(\n !activeTask ? (mostRecentFailedOrActiveStep?.id as string) : '',\n );\n }, [sortedTaskRuns, completed, activeTask]);\n\n const currentStepId = activeTask || lastActiveStepId;\n const activeItem = getActiveTaskRun(sortedTaskRuns, currentStepId);\n const podName =\n activeItem && taskRunFromYaml?.[currentStepId]?.status?.podName;\n const podData = useMemo(\n () =>\n pods.find(pod => {\n return pod?.metadata?.name === podName;\n }),\n [pods, podName],\n );\n\n return (\n <Grid container>\n <Grid item xs={3}>\n <Paper>\n <TaskStatusStepper\n steps={sortedTaskRuns}\n currentStepId={currentStepId}\n onUserStepChange={setActiveTask}\n />\n </Paper>\n </Grid>\n <Grid item xs={9}>\n {!currentStepId && <Progress />}\n <div style={{ height: '80vh' }}>\n {!podData ? (\n <Paper\n elevation={1}\n style={{ height: '100%', width: '100%', minHeight: '30rem' }}\n >\n <LogViewer text={t('pipelineRunLogs.noLogs')} />\n </Paper>\n ) : (\n <PipelineRunLogViewer pod={podData} />\n )}\n </div>\n </Grid>\n </Grid>\n );\n};\n\nexport default PipelineRunLogs;\n"],"names":["PipelineRunLogViewer"],"mappings":";;;;;;;;;;;;;AA2CO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,WAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,KAA4B;AAC1B,EAAA,MAAM,WAAA,GAAc,yBAAA,CAA0B,WAAA,EAAa,QAAQ,CAAA;AACnE,EAAA,MAAM,cAAA,GAAiB,kBAAkB,WAAW,CAAA;AACpD,EAAA,MAAM,kBAAkB,WAAA,EAAa,MAAA;AAAA,IACnC,CAAC,KAAuC,KAAA,KAAU;AAChD,MAAA,IAAI,KAAA,EAAO,UAAU,IAAA,EAAM;AACzB,QAAA,GAAA,CAAI,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA,GAAI,KAAA;AAAA,MAC7B;AACA,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA;AAAC,GACH;AAEA,EAAA,MAAM,SAAA,GAAY,yBAAyB,WAAW,CAAA;AACtD,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAiB,EAAE,CAAA;AACnE,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,oBAAoB,CAAA;AAEp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AAA,OAEtB,CAAA,EACF,CAAA;AAAA,oBACA,IAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAI,CAAA,EACZ,QAAA,EAAA;AAAA,MAAA,CAAC,aAAA,wBAAkB,QAAA,EAAA,EAAS,CAAA;AAAA,sBAC7B,GAAA,CAAC,SAAI,KAAA,EAAO,EAAE,QAAQ,MAAA,EAAO,EAC1B,WAAC,OAAA,mBACA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,SAAA,EAAW,CAAA;AAAA,UACX,OAAO,EAAE,MAAA,EAAQ,QAAQ,KAAA,EAAO,MAAA,EAAQ,WAAW,OAAA,EAAQ;AAAA,UAE3D,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,IAAA,EAAM,CAAA,CAAE,wBAAwB,CAAA,EAAG;AAAA;AAAA,OAChD,mBAEA,GAAA,CAACA,mCAAA,EAAA,EAAqB,GAAA,EAAK,SAAS,CAAA,EAExC;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"PipelineRunLogs.esm.js","sources":["../../../src/components/PipelineRunLogs/PipelineRunLogs.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 { useState, useEffect, useMemo } from 'react';\n\nimport { LogViewer, Progress } from '@backstage/core-components';\n\nimport { V1Pod } from '@kubernetes/client-node';\nimport Grid from '@mui/material/Grid';\nimport Paper from '@mui/material/Paper';\n\nimport {\n getTaskRunsForPipelineRun,\n pipelineRunFilterReducer,\n PipelineRunKind,\n TaskRunKind,\n} from '@backstage-community/plugin-tekton-react';\n\nimport { getActiveTaskRun, getSortedTaskRuns } from '../../utils/taskRun-utils';\nimport { PipelineRunLogViewer } from './PipelineRunLogViewer';\nimport { TaskStatusStepper } from './TaskStatusStepper';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { tektonTranslationRef } from '../../translations/index.ts';\n\ntype PipelineRunLogsProps = {\n pipelineRun: PipelineRunKind;\n taskRuns: TaskRunKind[];\n pods: V1Pod[];\n activeTask?: string;\n setActiveTask: (t: string) => void;\n};\nexport const PipelineRunLogs = ({\n pipelineRun,\n taskRuns,\n pods,\n activeTask,\n setActiveTask,\n}: PipelineRunLogsProps) => {\n const PLRTaskRuns = getTaskRunsForPipelineRun(pipelineRun, taskRuns);\n const sortedTaskRuns = getSortedTaskRuns(PLRTaskRuns);\n const taskRunFromYaml = PLRTaskRuns?.reduce(\n (acc: { [value: string]: TaskRunKind }, value) => {\n if (value?.metadata?.name) {\n acc[value.metadata.name] = value;\n }\n return acc;\n },\n {},\n );\n\n const completed = pipelineRunFilterReducer(pipelineRun);\n const [lastActiveStepId, setLastActiveStepId] = useState<string>('');\n const { t } = useTranslationRef(tektonTranslationRef);\n\n useEffect(() => {\n const mostRecentFailedOrActiveStep = sortedTaskRuns.find(tr =>\n ['Failed', 'Running'].includes(tr.status),\n );\n\n if (completed && !mostRecentFailedOrActiveStep && !activeTask) {\n setLastActiveStepId(sortedTaskRuns[sortedTaskRuns.length - 1]?.id);\n return;\n }\n\n setLastActiveStepId(\n !activeTask ? (mostRecentFailedOrActiveStep?.id as string) : '',\n );\n }, [sortedTaskRuns, completed, activeTask]);\n\n const currentStepId = activeTask || lastActiveStepId;\n const activeItem = getActiveTaskRun(sortedTaskRuns, currentStepId);\n const podName =\n activeItem && taskRunFromYaml?.[currentStepId]?.status?.podName;\n const podData = useMemo(\n () =>\n pods.find(pod => {\n return pod?.metadata?.name === podName;\n }),\n [pods, podName],\n );\n\n return (\n <Grid container sx={{ gap: 2 }}>\n <Grid item xs={3}>\n <Paper sx={{ paddingX: 2 }}>\n <TaskStatusStepper\n steps={sortedTaskRuns}\n currentStepId={currentStepId}\n onUserStepChange={setActiveTask}\n />\n </Paper>\n </Grid>\n <Grid item xs>\n {!currentStepId && <Progress />}\n <div style={{ height: '80vh' }}>\n {!podData ? (\n <Paper\n elevation={1}\n style={{ height: '100%', width: '100%', minHeight: '30rem' }}\n >\n <LogViewer text={t('pipelineRunLogs.noLogs')} />\n </Paper>\n ) : (\n <PipelineRunLogViewer pod={podData} />\n )}\n </div>\n </Grid>\n </Grid>\n );\n};\n\nexport default PipelineRunLogs;\n"],"names":["PipelineRunLogViewer"],"mappings":";;;;;;;;;;;;;AA2CO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,WAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,KAA4B;AAC1B,EAAA,MAAM,WAAA,GAAc,yBAAA,CAA0B,WAAA,EAAa,QAAQ,CAAA;AACnE,EAAA,MAAM,cAAA,GAAiB,kBAAkB,WAAW,CAAA;AACpD,EAAA,MAAM,kBAAkB,WAAA,EAAa,MAAA;AAAA,IACnC,CAAC,KAAuC,KAAA,KAAU;AAChD,MAAA,IAAI,KAAA,EAAO,UAAU,IAAA,EAAM;AACzB,QAAA,GAAA,CAAI,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA,GAAI,KAAA;AAAA,MAC7B;AACA,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA;AAAC,GACH;AAEA,EAAA,MAAM,SAAA,GAAY,yBAAyB,WAAW,CAAA;AACtD,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAiB,EAAE,CAAA;AACnE,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,oBAAoB,CAAA;AAEpD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,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,EAAO,cAAA;AAAA,QACP,aAAA;AAAA,QACA,gBAAA,EAAkB;AAAA;AAAA,OAEtB,CAAA,EACF,CAAA;AAAA,oBACA,IAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAE,IAAA,EACV,QAAA,EAAA;AAAA,MAAA,CAAC,aAAA,wBAAkB,QAAA,EAAA,EAAS,CAAA;AAAA,sBAC7B,GAAA,CAAC,SAAI,KAAA,EAAO,EAAE,QAAQ,MAAA,EAAO,EAC1B,WAAC,OAAA,mBACA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,SAAA,EAAW,CAAA;AAAA,UACX,OAAO,EAAE,MAAA,EAAQ,QAAQ,KAAA,EAAO,MAAA,EAAQ,WAAW,OAAA,EAAQ;AAAA,UAE3D,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,IAAA,EAAM,CAAA,CAAE,wBAAwB,CAAA,EAAG;AAAA;AAAA,OAChD,mBAEA,GAAA,CAACA,mCAAA,EAAA,EAAqB,GAAA,EAAK,SAAS,CAAA,EAExC;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -16,7 +16,7 @@ const usePodLogsOfPipelineRun = ({
16
16
  const containersList = pod?.spec?.containers || [];
17
17
  const podKey = pod?.metadata?.name;
18
18
  const stopPolling = pod?.status?.phase === "Succeeded" || pod?.status?.phase === "Failed";
19
- const { data, error, isLoading, isFetching } = useQuery({
19
+ const { data, error, isLoading } = useQuery({
20
20
  queryKey: ["podLogs", podKey, currCluster],
21
21
  queryFn: async () => {
22
22
  const requests = containersList.map((container) => {
@@ -40,7 +40,7 @@ const usePodLogsOfPipelineRun = ({
40
40
  return {
41
41
  value: data,
42
42
  error,
43
- loading: isLoading || isFetching
43
+ loading: isLoading
44
44
  };
45
45
  };
46
46
 
@@ -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 { useContext } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { kubernetesProxyApiRef } from '@backstage/plugin-kubernetes-react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { V1Container, V1Pod } from '@kubernetes/client-node';\n\nimport { TektonResourcesContextData } 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":";;;;;;AAoCO,MAAM,0BAA0B,CAAC;AAAA,EACtC,GAAA;AAAA,EACA,UAAA,GAAa;AACf,CAAA,KAAsB;AACpB,EAAA,MAAM,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAA,MAAM,EAAE,QAAA,EAAU,eAAA,EAAgB,GAAI,UAAA;AAAA,IACpC;AAAA,GACF;AACA,EAAA,MAAM,cACH,QAAA,CAAS,MAAA,GAAS,KAAK,QAAA,CAAS,eAAA,IAAmB,CAAC,CAAA,IAAM,EAAA;AAC7D,EAAA,MAAM,cAAA,GAAiB,GAAA,EAAK,IAAA,EAAM,UAAA,IAAc,EAAC;AAEjD,EAAA,MAAM,MAAA,GAAS,KAAK,QAAA,EAAU,IAAA;AAC9B,EAAA,MAAM,cACJ,GAAA,EAAK,MAAA,EAAQ,UAAU,WAAA,IAAe,GAAA,EAAK,QAAQ,KAAA,KAAU,QAAA;AAE/D,EAAA,MAAM,EAAE,IAAA,EAAM,KAAA,EAAO,SAAA,EAAW,UAAA,KAAe,QAAA,CAAS;AAAA,IACtD,QAAA,EAAU,CAAC,SAAA,EAAW,MAAA,EAAQ,WAAW,CAAA;AAAA,IACzC,SAAS,YAAY;AACnB,MAAA,MAAM,QAAA,GAAW,cAAA,CACd,GAAA,CAAI,CAAC,SAAA,KAA2B;AAC/B,QAAA,IAAI,KAAK,QAAA,EAAU,IAAA,IAAQ,GAAA,EAAK,QAAA,EAAU,aAAa,SAAA,EAAW;AAChE,UAAA,OAAO,mBAAmB,UAAA,CAAW;AAAA,YACnC,OAAA,EAAS,IAAI,QAAA,CAAS,IAAA;AAAA,YACtB,SAAA,EAAW,IAAI,QAAA,CAAS,SAAA;AAAA,YACxB,eAAe,SAAA,CAAU,IAAA;AAAA,YACzB,WAAA,EAAa;AAAA,WACd,CAAA;AAAA,QACH;AAEA,QAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,EAAE,IAAA,EAAM,IAAI,CAAA;AAAA,MACrC,CAAC,CAAA,CACA,MAAA,CAAO,OAAO,CAAA;AAEjB,MAAA,OAAO,OAAA,CAAQ,IAAI,QAAQ,CAAA;AAAA,IAC7B,CAAA;AAAA,IACA,SAAS,CAAC,CAAC,KAAK,QAAA,EAAU,IAAA,IAAQ,eAAe,MAAA,GAAS,CAAA;AAAA,IAC1D,eAAA,EAAiB,cAAc,KAAA,GAAQ,UAAA;AAAA,IACvC,SAAA,EAAW;AAAA;AAAA,GACZ,CAAA;AAED,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,IAAA;AAAA,IACP,KAAA;AAAA,IACA,SAAS,SAAA,IAAa;AAAA,GACxB;AACF;;;;"}
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 { kubernetesProxyApiRef } from '@backstage/plugin-kubernetes-react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { V1Container, V1Pod } from '@kubernetes/client-node';\n\nimport { TektonResourcesContextData } 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 } = 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,\n };\n};\n"],"names":[],"mappings":";;;;;;AAoCO,MAAM,0BAA0B,CAAC;AAAA,EACtC,GAAA;AAAA,EACA,UAAA,GAAa;AACf,CAAA,KAAsB;AACpB,EAAA,MAAM,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAA,MAAM,EAAE,QAAA,EAAU,eAAA,EAAgB,GAAI,UAAA;AAAA,IACpC;AAAA,GACF;AACA,EAAA,MAAM,cACH,QAAA,CAAS,MAAA,GAAS,KAAK,QAAA,CAAS,eAAA,IAAmB,CAAC,CAAA,IAAM,EAAA;AAC7D,EAAA,MAAM,cAAA,GAAiB,GAAA,EAAK,IAAA,EAAM,UAAA,IAAc,EAAC;AAEjD,EAAA,MAAM,MA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name": "@backstage-community/plugin-tekton",
3
- "version": "3.41.0",
3
+ "version": "3.41.1",
4
4
  "main": "./dist/index.esm.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "Apache-2.0",