@backstage/plugin-kubernetes-react 0.4.5-next.0 → 0.5.0-next.2

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 (95) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/config.d.ts +15 -0
  3. package/dist/alpha.d.ts +8 -0
  4. package/dist/alpha.esm.js +2 -0
  5. package/dist/alpha.esm.js.map +1 -0
  6. package/dist/api/KubernetesBackendClient.esm.js.map +1 -1
  7. package/dist/api/KubernetesClusterLinkFormatter.esm.js.map +1 -1
  8. package/dist/api/KubernetesProxyClient.esm.js +13 -0
  9. package/dist/api/KubernetesProxyClient.esm.js.map +1 -1
  10. package/dist/api/formatters/AksClusterLinksFormatter.esm.js.map +1 -1
  11. package/dist/api/formatters/EksClusterLinksFormatter.esm.js.map +1 -1
  12. package/dist/api/formatters/GkeClusterLinksFormatter.esm.js.map +1 -1
  13. package/dist/api/formatters/OpenshiftClusterLinksFormatter.esm.js.map +1 -1
  14. package/dist/api/formatters/RancherClusterLinksFormatter.esm.js.map +1 -1
  15. package/dist/api/formatters/StandardClusterLinksFormatter.esm.js.map +1 -1
  16. package/dist/api/formatters/index.esm.js.map +1 -1
  17. package/dist/api/types.esm.js.map +1 -1
  18. package/dist/components/Cluster/Cluster.esm.js.map +1 -1
  19. package/dist/components/CronJobsAccordions/CronJobsAccordions.esm.js.map +1 -1
  20. package/dist/components/CronJobsAccordions/CronJobsDrawer.esm.js.map +1 -1
  21. package/dist/components/CustomResources/ArgoRollouts/Rollout.esm.js.map +1 -1
  22. package/dist/components/CustomResources/ArgoRollouts/RolloutDrawer.esm.js.map +1 -1
  23. package/dist/components/CustomResources/ArgoRollouts/StepsProgress.esm.js.map +1 -1
  24. package/dist/components/CustomResources/CustomResources.esm.js.map +1 -1
  25. package/dist/components/CustomResources/DefaultCustomResource.esm.js.map +1 -1
  26. package/dist/components/CustomResources/DefaultCustomResourceDrawer.esm.js.map +1 -1
  27. package/dist/components/DaemonSetsAccordions/DaemonSetsAccordions.esm.js.map +1 -1
  28. package/dist/components/DaemonSetsAccordions/DaemonSetsDrawer.esm.js.map +1 -1
  29. package/dist/components/DeploymentsAccordions/DeploymentDrawer.esm.js.map +1 -1
  30. package/dist/components/DeploymentsAccordions/DeploymentsAccordions.esm.js.map +1 -1
  31. package/dist/components/ErrorPanel/ErrorPanel.esm.js.map +1 -1
  32. package/dist/components/ErrorReporting/ErrorReporting.esm.js.map +1 -1
  33. package/dist/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.esm.js.map +1 -1
  34. package/dist/components/IngressesAccordions/IngressDrawer.esm.js.map +1 -1
  35. package/dist/components/IngressesAccordions/IngressesAccordions.esm.js.map +1 -1
  36. package/dist/components/JobsAccordions/JobsAccordions.esm.js.map +1 -1
  37. package/dist/components/JobsAccordions/JobsDrawer.esm.js.map +1 -1
  38. package/dist/components/KubernetesDialog/KubernetesDialog.esm.js.map +1 -1
  39. package/dist/components/KubernetesDrawer/KubernetesDrawer.esm.js.map +1 -1
  40. package/dist/components/KubernetesDrawer/KubernetesStructuredMetadataTableDrawer.esm.js.map +1 -1
  41. package/dist/components/KubernetesDrawer/ManifestYaml.esm.js.map +1 -1
  42. package/dist/components/PodExecTerminal/PodExecTerminal.esm.js.map +1 -1
  43. package/dist/components/PodExecTerminal/PodExecTerminalAttachAddon.esm.js.map +1 -1
  44. package/dist/components/PodExecTerminal/PodExecTerminalDialog.esm.js.map +1 -1
  45. package/dist/components/Pods/ErrorList/ErrorList.esm.js.map +1 -1
  46. package/dist/components/Pods/Events/Events.esm.js +2 -2
  47. package/dist/components/Pods/Events/Events.esm.js.map +1 -1
  48. package/dist/components/Pods/Events/useEvents.esm.js.map +1 -1
  49. package/dist/components/Pods/FixDialog/FixDialog.esm.js.map +1 -1
  50. package/dist/components/Pods/PodDelete/PodDeleteButton.esm.js +50 -0
  51. package/dist/components/Pods/PodDelete/PodDeleteButton.esm.js.map +1 -0
  52. package/dist/components/Pods/PodDelete/usePodDelete.esm.js +21 -0
  53. package/dist/components/Pods/PodDelete/usePodDelete.esm.js.map +1 -0
  54. package/dist/components/Pods/PodDrawer/ContainerCard.esm.js +1 -1
  55. package/dist/components/Pods/PodDrawer/ContainerCard.esm.js.map +1 -1
  56. package/dist/components/Pods/PodDrawer/PendingPodContent.esm.js.map +1 -1
  57. package/dist/components/Pods/PodDrawer/PodDrawer.esm.js +24 -1
  58. package/dist/components/Pods/PodDrawer/PodDrawer.esm.js.map +1 -1
  59. package/dist/components/Pods/PodLogs/PodLogs.esm.js.map +1 -1
  60. package/dist/components/Pods/PodLogs/PodLogsDialog.esm.js.map +1 -1
  61. package/dist/components/Pods/PodLogs/usePodLogs.esm.js.map +1 -1
  62. package/dist/components/Pods/PodsTable.esm.js.map +1 -1
  63. package/dist/components/ResourceUtilization/ResourceUtilization.esm.js.map +1 -1
  64. package/dist/components/ServicesAccordions/ServiceDrawer.esm.js.map +1 -1
  65. package/dist/components/ServicesAccordions/ServicesAccordions.esm.js.map +1 -1
  66. package/dist/components/StatefulSetsAccordions/StatefulSetDrawer.esm.js.map +1 -1
  67. package/dist/components/StatefulSetsAccordions/StatefulSetsAccordions.esm.js.map +1 -1
  68. package/dist/hooks/Cluster.esm.js.map +1 -1
  69. package/dist/hooks/GroupedResponses.esm.js.map +1 -1
  70. package/dist/hooks/PodNamesWithErrors.esm.js.map +1 -1
  71. package/dist/hooks/auth.esm.js.map +1 -1
  72. package/dist/hooks/useCustomResources.esm.js.map +1 -1
  73. package/dist/hooks/useIsPodDeleteEnabled.esm.js +9 -0
  74. package/dist/hooks/useIsPodDeleteEnabled.esm.js.map +1 -0
  75. package/dist/hooks/useIsPodExecTerminalEnabled.esm.js.map +1 -1
  76. package/dist/hooks/useIsPodExecTerminalSupported.esm.js.map +1 -1
  77. package/dist/hooks/useKubernetesObjects.esm.js.map +1 -1
  78. package/dist/hooks/useMatchingErrors.esm.js.map +1 -1
  79. package/dist/hooks/usePodMetrics.esm.js.map +1 -1
  80. package/dist/index.d.ts +14 -0
  81. package/dist/index.esm.js +1 -0
  82. package/dist/index.esm.js.map +1 -1
  83. package/dist/kubernetes-auth-provider/AksKubernetesAuthProvider.esm.js.map +1 -1
  84. package/dist/kubernetes-auth-provider/GoogleKubernetesAuthProvider.esm.js.map +1 -1
  85. package/dist/kubernetes-auth-provider/KubernetesAuthProviders.esm.js.map +1 -1
  86. package/dist/kubernetes-auth-provider/OidcKubernetesAuthProvider.esm.js.map +1 -1
  87. package/dist/kubernetes-auth-provider/ServerSideAuthProvider.esm.js.map +1 -1
  88. package/dist/kubernetes-auth-provider/types.esm.js.map +1 -1
  89. package/dist/translation.esm.js +15 -0
  90. package/dist/translation.esm.js.map +1 -0
  91. package/dist/utils/crons.esm.js.map +1 -1
  92. package/dist/utils/owner.esm.js.map +1 -1
  93. package/dist/utils/pod.esm.js.map +1 -1
  94. package/dist/utils/resources.esm.js.map +1 -1
  95. package/package.json +32 -11
@@ -1 +1 @@
1
- {"version":3,"file":"ManifestYaml.esm.js","sources":["../../../src/components/KubernetesDrawer/ManifestYaml.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { CodeSnippet } from '@backstage/core-components';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport Switch from '@material-ui/core/Switch';\nimport jsyaml from 'js-yaml';\nimport React, { useState } from 'react';\n\n/**\n * Props of ManifestYaml\n *\n * @public\n */\nexport interface ManifestYamlProps {\n object: object;\n}\n\n/**\n * Renders a Kubernetes object as a YAML code snippet\n *\n * @public\n */\nexport const ManifestYaml = ({ object }: ManifestYamlProps) => {\n // Toggle whether the Kubernetes resource managed fields should be shown in\n // the YAML display. This toggle is only available when the YAML is being\n // shown because managed fields are never visible in the structured display.\n const [managedFields, setManagedFields] = useState<boolean>(false);\n return (\n <>\n <FormControlLabel\n control={\n <Switch\n checked={managedFields}\n onChange={event => {\n setManagedFields(event.target.checked);\n }}\n name=\"Managed Fields\"\n />\n }\n label=\"Managed Fields\"\n />\n <CodeSnippet\n language=\"yaml\"\n text={jsyaml.dump(object, {\n // NOTE: this will remove any field called `managedFields`\n // not just the metadata one\n // TODO: @mclarke make this only remove the `metadata.managedFields`\n replacer: (key: string, value: string): any => {\n if (!managedFields) {\n return key === 'managedFields' ? undefined : value;\n }\n return value;\n },\n })}\n />\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;AAmCO,MAAM,YAAe,GAAA,CAAC,EAAE,MAAA,EAAgC,KAAA;AAI7D,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GAAI,SAAkB,KAAK,CAAA,CAAA;AACjE,EAAA,uBAEIA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,OACE,kBAAAA,cAAA,CAAA,aAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,OAAS,EAAA,aAAA;AAAA,UACT,UAAU,CAAS,KAAA,KAAA;AACjB,YAAiB,gBAAA,CAAA,KAAA,CAAM,OAAO,OAAO,CAAA,CAAA;AAAA,WACvC;AAAA,UACA,IAAK,EAAA,gBAAA;AAAA,SAAA;AAAA,OACP;AAAA,MAEF,KAAM,EAAA,gBAAA;AAAA,KAAA;AAAA,GAER,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,QAAS,EAAA,MAAA;AAAA,MACT,IAAA,EAAM,MAAO,CAAA,IAAA,CAAK,MAAQ,EAAA;AAAA;AAAA;AAAA;AAAA,QAIxB,QAAA,EAAU,CAAC,GAAA,EAAa,KAAuB,KAAA;AAC7C,UAAA,IAAI,CAAC,aAAe,EAAA;AAClB,YAAO,OAAA,GAAA,KAAQ,kBAAkB,KAAY,CAAA,GAAA,KAAA,CAAA;AAAA,WAC/C;AACA,UAAO,OAAA,KAAA,CAAA;AAAA,SACT;AAAA,OACD,CAAA;AAAA,KAAA;AAAA,GAEL,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ManifestYaml.esm.js","sources":["../../../src/components/KubernetesDrawer/ManifestYaml.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { CodeSnippet } from '@backstage/core-components';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport Switch from '@material-ui/core/Switch';\nimport jsyaml from 'js-yaml';\nimport React, { useState } from 'react';\n\n/**\n * Props of ManifestYaml\n *\n * @public\n */\nexport interface ManifestYamlProps {\n object: object;\n}\n\n/**\n * Renders a Kubernetes object as a YAML code snippet\n *\n * @public\n */\nexport const ManifestYaml = ({ object }: ManifestYamlProps) => {\n // Toggle whether the Kubernetes resource managed fields should be shown in\n // the YAML display. This toggle is only available when the YAML is being\n // shown because managed fields are never visible in the structured display.\n const [managedFields, setManagedFields] = useState<boolean>(false);\n return (\n <>\n <FormControlLabel\n control={\n <Switch\n checked={managedFields}\n onChange={event => {\n setManagedFields(event.target.checked);\n }}\n name=\"Managed Fields\"\n />\n }\n label=\"Managed Fields\"\n />\n <CodeSnippet\n language=\"yaml\"\n text={jsyaml.dump(object, {\n // NOTE: this will remove any field called `managedFields`\n // not just the metadata one\n // TODO: @mclarke make this only remove the `metadata.managedFields`\n replacer: (key: string, value: string): any => {\n if (!managedFields) {\n return key === 'managedFields' ? undefined : value;\n }\n return value;\n },\n })}\n />\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;AAmCO,MAAM,YAAe,GAAA,CAAC,EAAE,MAAA,EAAgC,KAAA;AAI7D,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GAAI,SAAkB,KAAK,CAAA;AACjE,EAAA,uBAEIA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,OACE,kBAAAA,cAAA,CAAA,aAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,OAAS,EAAA,aAAA;AAAA,UACT,UAAU,CAAS,KAAA,KAAA;AACjB,YAAiB,gBAAA,CAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA,WACvC;AAAA,UACA,IAAK,EAAA;AAAA;AAAA,OACP;AAAA,MAEF,KAAM,EAAA;AAAA;AAAA,GAER,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,QAAS,EAAA,MAAA;AAAA,MACT,IAAA,EAAM,MAAO,CAAA,IAAA,CAAK,MAAQ,EAAA;AAAA;AAAA;AAAA;AAAA,QAIxB,QAAA,EAAU,CAAC,GAAA,EAAa,KAAuB,KAAA;AAC7C,UAAA,IAAI,CAAC,aAAe,EAAA;AAClB,YAAO,OAAA,GAAA,KAAQ,kBAAkB,KAAY,CAAA,GAAA,KAAA;AAAA;AAE/C,UAAO,OAAA,KAAA;AAAA;AACT,OACD;AAAA;AAAA,GAEL,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PodExecTerminal.esm.js","sources":["../../../src/components/PodExecTerminal/PodExecTerminal.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 'xterm/css/xterm.css';\n\nimport { discoveryApiRef, useApi } from '@backstage/core-plugin-api';\nimport { ClusterAttributes } from '@backstage/plugin-kubernetes-common';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { Terminal } from 'xterm';\nimport { FitAddon } from 'xterm-addon-fit';\n\nimport { PodExecTerminalAttachAddon } from './PodExecTerminalAttachAddon';\n\n/**\n * Props drilled down to the PodExecTerminal component\n *\n * @public\n */\nexport interface PodExecTerminalProps {\n cluster: ClusterAttributes;\n containerName: string;\n podName: string;\n podNamespace: string;\n}\n\nconst hasSocketProtocol = (url: string | URL) =>\n /wss?:\\/\\//.test(url.toString());\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n podExecTerminal: {\n width: '100%',\n height: '100%',\n '& .xterm-screen': { padding: theme.spacing(1) },\n },\n }),\n);\n\n/**\n * Executes a `/bin/sh` process in the given pod's container and opens a terminal connected to it\n *\n * @public\n */\nexport const PodExecTerminal = (props: PodExecTerminalProps) => {\n const classes = useStyles();\n const { containerName, podNamespace, podName } = props;\n\n const [baseUrl, setBaseUrl] = useState(window.location.host);\n\n const terminalRef = React.useRef(null);\n const discoveryApi = useApi(discoveryApiRef);\n const namespace = podNamespace ?? 'default';\n\n useEffect(() => {\n discoveryApi\n .getBaseUrl('kubernetes')\n .then(url => url ?? window.location.host)\n .then(url => url.replace(/^http(s?):\\/\\//, 'ws$1://'))\n .then(url => setBaseUrl(url));\n }, [discoveryApi]);\n\n const urlParams = useMemo(() => {\n const params = new URLSearchParams({\n container: containerName,\n stdin: 'true',\n stdout: 'true',\n stderr: 'true',\n tty: 'true',\n command: '/bin/sh',\n });\n return params;\n }, [containerName]);\n\n const socketUrl = useMemo(() => {\n if (!hasSocketProtocol(baseUrl)) {\n return '';\n }\n\n return new URL(\n `${baseUrl}/proxy/api/v1/namespaces/${namespace}/pods/${podName}/exec?${urlParams}`,\n );\n }, [baseUrl, namespace, podName, urlParams]);\n\n useEffect(() => {\n if (!hasSocketProtocol(socketUrl)) {\n return () => {};\n }\n\n const terminal = new Terminal();\n const fitAddon = new FitAddon();\n terminal.loadAddon(fitAddon);\n\n if (terminalRef.current) {\n terminal.open(terminalRef.current);\n fitAddon.fit();\n }\n\n terminal.writeln('Starting terminal, please wait...');\n\n const socket = new WebSocket(socketUrl, ['channel.k8s.io']);\n\n socket.onopen = () => {\n terminal.clear();\n const attachAddon = new PodExecTerminalAttachAddon(socket, {\n bidirectional: true,\n });\n\n terminal.loadAddon(attachAddon);\n };\n\n socket.onclose = () => {\n terminal.writeln('Socket connection closed');\n };\n\n return () => {\n terminal?.clear();\n socket?.close();\n };\n }, [baseUrl, socketUrl]);\n\n return (\n <div\n data-testid=\"terminal\"\n ref={terminalRef}\n className={classes.podExecTerminal}\n />\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;AAsCA,MAAM,oBAAoB,CAAC,GAAA,KACzB,YAAY,IAAK,CAAA,GAAA,CAAI,UAAU,CAAA,CAAA;AAEjC,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,UAC5B,YAAa,CAAA;AAAA,IACX,eAAiB,EAAA;AAAA,MACf,KAAO,EAAA,MAAA;AAAA,MACP,MAAQ,EAAA,MAAA;AAAA,MACR,mBAAmB,EAAE,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAE,EAAA;AAAA,KACjD;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAOa,MAAA,eA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AEA,IAAA,OAAO,MAAM;AACX,MAAA,QAAA,EAAU,KAAM,EAAA,CAAA;AAChB,MAAA,MAAA,EAAQ,KAAM,EAAA,CAAA;AAAA,KAChB,CAAA;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,SAAS,CAAC,CAAA,CAAA;AAEvB,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,aAAY,EAAA,UAAA;AAAA,MACZ,GAAK,EAAA,WAAA;AAAA,MACL,WAAW,OAAQ,CAAA,eAAA;AAAA,KAAA;AAAA,GACrB,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"PodExecTerminal.esm.js","sources":["../../../src/components/PodExecTerminal/PodExecTerminal.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 'xterm/css/xterm.css';\n\nimport { discoveryApiRef, useApi } from '@backstage/core-plugin-api';\nimport { ClusterAttributes } from '@backstage/plugin-kubernetes-common';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { Terminal } from 'xterm';\nimport { FitAddon } from 'xterm-addon-fit';\n\nimport { PodExecTerminalAttachAddon } from './PodExecTerminalAttachAddon';\n\n/**\n * Props drilled down to the PodExecTerminal component\n *\n * @public\n */\nexport interface PodExecTerminalProps {\n cluster: ClusterAttributes;\n containerName: string;\n podName: string;\n podNamespace: string;\n}\n\nconst hasSocketProtocol = (url: string | URL) =>\n /wss?:\\/\\//.test(url.toString());\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n podExecTerminal: {\n width: '100%',\n height: '100%',\n '& .xterm-screen': { padding: theme.spacing(1) },\n },\n }),\n);\n\n/**\n * Executes a `/bin/sh` process in the given pod's container and opens a terminal connected to it\n *\n * @public\n */\nexport const PodExecTerminal = (props: PodExecTerminalProps) => {\n const classes = useStyles();\n const { containerName, podNamespace, podName } = props;\n\n const [baseUrl, setBaseUrl] = useState(window.location.host);\n\n const terminalRef = React.useRef(null);\n const discoveryApi = useApi(discoveryApiRef);\n const namespace = podNamespace ?? 'default';\n\n useEffect(() => {\n discoveryApi\n .getBaseUrl('kubernetes')\n .then(url => url ?? window.location.host)\n .then(url => url.replace(/^http(s?):\\/\\//, 'ws$1://'))\n .then(url => setBaseUrl(url));\n }, [discoveryApi]);\n\n const urlParams = useMemo(() => {\n const params = new URLSearchParams({\n container: containerName,\n stdin: 'true',\n stdout: 'true',\n stderr: 'true',\n tty: 'true',\n command: '/bin/sh',\n });\n return params;\n }, [containerName]);\n\n const socketUrl = useMemo(() => {\n if (!hasSocketProtocol(baseUrl)) {\n return '';\n }\n\n return new URL(\n `${baseUrl}/proxy/api/v1/namespaces/${namespace}/pods/${podName}/exec?${urlParams}`,\n );\n }, [baseUrl, namespace, podName, urlParams]);\n\n useEffect(() => {\n if (!hasSocketProtocol(socketUrl)) {\n return () => {};\n }\n\n const terminal = new Terminal();\n const fitAddon = new FitAddon();\n terminal.loadAddon(fitAddon);\n\n if (terminalRef.current) {\n terminal.open(terminalRef.current);\n fitAddon.fit();\n }\n\n terminal.writeln('Starting terminal, please wait...');\n\n const socket = new WebSocket(socketUrl, ['channel.k8s.io']);\n\n socket.onopen = () => {\n terminal.clear();\n const attachAddon = new PodExecTerminalAttachAddon(socket, {\n bidirectional: true,\n });\n\n terminal.loadAddon(attachAddon);\n };\n\n socket.onclose = () => {\n terminal.writeln('Socket connection closed');\n };\n\n return () => {\n terminal?.clear();\n socket?.close();\n };\n }, [baseUrl, socketUrl]);\n\n return (\n <div\n data-testid=\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c,IAAI,0BAAA,CAA2B,MAAQ,EAAA;AAAA,QACzD,aAAe,EAAA;AAAA,OAChB,CAAA;AAED,MAAA,QAAA,CAAS,UAAU,WAAW,CAAA;AAAA,KAChC;AAEA,IAAA,MAAA,CAAO,UAAU,MAAM;AACrB,MAAA,QAAA,CAAS,QAAQ,0BAA0B,CAAA;AAAA,KAC7C;AAEA,IAAA,OAAO,MAAM;AACX,MAAA,QAAA,EAAU,KAAM,EAAA;AAChB,MAAA,MAAA,EAAQ,KAAM,EAAA;AAAA,KAChB;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,SAAS,CAAC,CAAA;AAEvB,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,aAAY,EAAA,UAAA;AAAA,MACZ,GAAK,EAAA,WAAA;AAAA,MACL,WAAW,OAAQ,CAAA;AAAA;AAAA,GACrB;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PodExecTerminalAttachAddon.esm.js","sources":["../../../src/components/PodExecTerminal/PodExecTerminalAttachAddon.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { AttachAddon, IAttachOptions } from 'xterm-addon-attach';\n\nexport class PodExecTerminalAttachAddon extends AttachAddon {\n #textEncoder = new TextEncoder();\n\n constructor(socket: WebSocket, options?: IAttachOptions) {\n super(socket, options);\n\n const thisAddon = this as any;\n\n // These methods are private in the original AttachAddon,\n // thus have to override at runtime like this\n thisAddon._sendBinary = (data: string) => {\n if (!thisAddon._checkOpenSocket()) {\n return;\n }\n\n const buffer = Uint8Array.from([0, ...this.#textEncoder.encode(data)]);\n\n thisAddon._socket.send(buffer);\n };\n\n thisAddon._sendData = (data: string) => {\n if (!thisAddon._checkOpenSocket()) {\n return;\n }\n\n thisAddon._sendBinary(data);\n };\n }\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,mCAAmC,WAAY,CAAA;AAAA,EAC1D,YAAA,GAAe,IAAI,WAAY,EAAA,CAAA;AAAA,EAE/B,WAAA,CAAY,QAAmB,OAA0B,EAAA;AACvD,IAAA,KAAA,CAAM,QAAQ,OAAO,CAAA,CAAA;AAErB,IAAA,MAAM,SAAY,GAAA,IAAA,CAAA;AAIlB,IAAU,SAAA,CAAA,WAAA,GAAc,CAAC,IAAiB,KAAA;AACxC,MAAI,IAAA,CAAC,SAAU,CAAA,gBAAA,EAAoB,EAAA;AACjC,QAAA,OAAA;AAAA,OACF;AAEA,MAAM,MAAA,MAAA,GAAS,UAAW,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,GAAG,IAAA,CAAK,YAAa,CAAA,MAAA,CAAO,IAAI,CAAC,CAAC,CAAA,CAAA;AAErE,MAAU,SAAA,CAAA,OAAA,CAAQ,KAAK,MAAM,CAAA,CAAA;AAAA,KAC/B,CAAA;AAEA,IAAU,SAAA,CAAA,SAAA,GAAY,CAAC,IAAiB,KAAA;AACtC,MAAI,IAAA,CAAC,SAAU,CAAA,gBAAA,EAAoB,EAAA;AACjC,QAAA,OAAA;AAAA,OACF;AAEA,MAAA,SAAA,CAAU,YAAY,IAAI,CAAA,CAAA;AAAA,KAC5B,CAAA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"PodExecTerminalAttachAddon.esm.js","sources":["../../../src/components/PodExecTerminal/PodExecTerminalAttachAddon.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { AttachAddon, IAttachOptions } from 'xterm-addon-attach';\n\nexport class PodExecTerminalAttachAddon extends AttachAddon {\n #textEncoder = new TextEncoder();\n\n constructor(socket: WebSocket, options?: IAttachOptions) {\n super(socket, options);\n\n const thisAddon = this as any;\n\n // These methods are private in the original AttachAddon,\n // thus have to override at runtime like this\n thisAddon._sendBinary = (data: string) => {\n if (!thisAddon._checkOpenSocket()) {\n return;\n }\n\n const buffer = Uint8Array.from([0, ...this.#textEncoder.encode(data)]);\n\n thisAddon._socket.send(buffer);\n };\n\n thisAddon._sendData = (data: string) => {\n if (!thisAddon._checkOpenSocket()) {\n return;\n }\n\n thisAddon._sendBinary(data);\n };\n }\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,mCAAmC,WAAY,CAAA;AAAA,EAC1D,YAAA,GAAe,IAAI,WAAY,EAAA;AAAA,EAE/B,WAAA,CAAY,QAAmB,OAA0B,EAAA;AACvD,IAAA,KAAA,CAAM,QAAQ,OAAO,CAAA;AAErB,IAAA,MAAM,SAAY,GAAA,IAAA;AAIlB,IAAU,SAAA,CAAA,WAAA,GAAc,CAAC,IAAiB,KAAA;AACxC,MAAI,IAAA,CAAC,SAAU,CAAA,gBAAA,EAAoB,EAAA;AACjC,QAAA;AAAA;AAGF,MAAM,MAAA,MAAA,GAAS,UAAW,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,GAAG,IAAA,CAAK,YAAa,CAAA,MAAA,CAAO,IAAI,CAAC,CAAC,CAAA;AAErE,MAAU,SAAA,CAAA,OAAA,CAAQ,KAAK,MAAM,CAAA;AAAA,KAC/B;AAEA,IAAU,SAAA,CAAA,SAAA,GAAY,CAAC,IAAiB,KAAA;AACtC,MAAI,IAAA,CAAC,SAAU,CAAA,gBAAA,EAAoB,EAAA;AACjC,QAAA;AAAA;AAGF,MAAA,SAAA,CAAU,YAAY,IAAI,CAAA;AAAA,KAC5B;AAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PodExecTerminalDialog.esm.js","sources":["../../../src/components/PodExecTerminal/PodExecTerminalDialog.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';\nimport React from 'react';\n\nimport { KubernetesDialog } from '../KubernetesDialog';\nimport { useIsPodExecTerminalSupported } from '../../hooks';\nimport { PodExecTerminal, PodExecTerminalProps } from './PodExecTerminal';\n\n/**\n * Opens a terminal connected to the given pod's container in a dialog\n *\n * @public\n */\nexport const PodExecTerminalDialog = (props: PodExecTerminalProps) => {\n const { cluster, containerName, podName } = props;\n\n const isPodExecTerminalSupported = useIsPodExecTerminalSupported();\n\n return (\n !isPodExecTerminalSupported.loading &&\n isPodExecTerminalSupported.value && (\n <KubernetesDialog\n buttonAriaLabel=\"open terminal\"\n buttonIcon={<OpenInBrowserIcon />}\n buttonText=\"Terminal\"\n disabled={\n isPodExecTerminalSupported.loading ||\n !isPodExecTerminalSupported.value\n }\n title={`${podName} - ${containerName} terminal shell on cluster ${\n cluster.title || cluster.name\n }`}\n >\n <PodExecTerminal {...props} />\n </KubernetesDialog>\n )\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;AA4Ba,MAAA,qBAAA,GAAwB,CAAC,KAAgC,KAAA;AACpE,EAAA,MAAM,EAAE,OAAA,EAAS,aAAe,EAAA,OAAA,EAAY,GAAA,KAAA,CAAA;AAE5C,EAAA,MAAM,6BAA6B,6BAA8B,EAAA,CAAA;AAEjE,EAAA,OACE,CAAC,0BAAA,CAA2B,OAC5B,IAAA,0BAAA,CAA2B,KACzB,oBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,eAAgB,EAAA,eAAA;AAAA,MAChB,UAAA,+CAAa,iBAAkB,EAAA,IAAA,CAAA;AAAA,MAC/B,UAAW,EAAA,UAAA;AAAA,MACX,QACE,EAAA,0BAAA,CAA2B,OAC3B,IAAA,CAAC,0BAA2B,CAAA,KAAA;AAAA,MAE9B,KAAA,EAAO,GAAG,OAAO,CAAA,GAAA,EAAM,aAAa,CAClC,2BAAA,EAAA,OAAA,CAAQ,KAAS,IAAA,OAAA,CAAQ,IAC3B,CAAA,CAAA;AAAA,KAAA;AAAA,oBAEAA,cAAA,CAAA,aAAA,CAAC,eAAiB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AAAA,GAC9B,CAAA;AAGN;;;;"}
1
+ {"version":3,"file":"PodExecTerminalDialog.esm.js","sources":["../../../src/components/PodExecTerminal/PodExecTerminalDialog.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';\nimport React from 'react';\n\nimport { KubernetesDialog } from '../KubernetesDialog';\nimport { useIsPodExecTerminalSupported } from '../../hooks';\nimport { PodExecTerminal, PodExecTerminalProps } from './PodExecTerminal';\n\n/**\n * Opens a terminal connected to the given pod's container in a dialog\n *\n * @public\n */\nexport const PodExecTerminalDialog = (props: PodExecTerminalProps) => {\n const { cluster, containerName, podName } = props;\n\n const isPodExecTerminalSupported = useIsPodExecTerminalSupported();\n\n return (\n !isPodExecTerminalSupported.loading &&\n isPodExecTerminalSupported.value && (\n <KubernetesDialog\n buttonAriaLabel=\"open terminal\"\n buttonIcon={<OpenInBrowserIcon />}\n buttonText=\"Terminal\"\n disabled={\n isPodExecTerminalSupported.loading ||\n !isPodExecTerminalSupported.value\n }\n title={`${podName} - ${containerName} terminal shell on cluster ${\n cluster.title || cluster.name\n }`}\n >\n <PodExecTerminal {...props} />\n </KubernetesDialog>\n )\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;AA4Ba,MAAA,qBAAA,GAAwB,CAAC,KAAgC,KAAA;AACpE,EAAA,MAAM,EAAE,OAAA,EAAS,aAAe,EAAA,OAAA,EAAY,GAAA,KAAA;AAE5C,EAAA,MAAM,6BAA6B,6BAA8B,EAAA;AAEjE,EAAA,OACE,CAAC,0BAAA,CAA2B,OAC5B,IAAA,0BAAA,CAA2B,KACzB,oBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,eAAgB,EAAA,eAAA;AAAA,MAChB,UAAA,+CAAa,iBAAkB,EAAA,IAAA,CAAA;AAAA,MAC/B,UAAW,EAAA,UAAA;AAAA,MACX,QACE,EAAA,0BAAA,CAA2B,OAC3B,IAAA,CAAC,0BAA2B,CAAA,KAAA;AAAA,MAE9B,KAAA,EAAO,GAAG,OAAO,CAAA,GAAA,EAAM,aAAa,CAClC,2BAAA,EAAA,OAAA,CAAQ,KAAS,IAAA,OAAA,CAAQ,IAC3B,CAAA;AAAA,KAAA;AAAA,oBAEAA,cAAA,CAAA,aAAA,CAAC,eAAiB,EAAA,EAAA,GAAG,KAAO,EAAA;AAAA,GAC9B;AAGN;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorList.esm.js","sources":["../../../../src/components/Pods/ErrorList/ErrorList.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Divider from '@material-ui/core/Divider';\nimport Paper from '@material-ui/core/Paper';\nimport Grid from '@material-ui/core/Grid';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport { PodAndErrors } from '../types';\nimport { FixDialog } from '../FixDialog/FixDialog';\n\nconst useStyles = makeStyles((_theme: Theme) =>\n createStyles({\n root: {\n overflow: 'auto',\n },\n list: {\n width: '100%',\n },\n }),\n);\n\n/**\n * Props for ErrorList\n *\n * @public\n */\nexport interface ErrorListProps {\n podAndErrors: PodAndErrors[];\n}\n\n/**\n * Shows a list of errors found on a Pod\n *\n * @public\n */\nexport const ErrorList = ({ podAndErrors }: ErrorListProps) => {\n const classes = useStyles();\n return (\n <Paper className={classes.root}>\n <List className={classes.list}>\n {podAndErrors\n .filter(pae => pae.errors.length > 0)\n .flatMap(onlyPodWithErrors => {\n return onlyPodWithErrors.errors.map((error, i) => {\n return (\n <React.Fragment\n key={`${\n onlyPodWithErrors.pod.metadata?.name ?? 'unknown'\n }-eli-${i}`}\n >\n {i > 0 && <Divider key={`error-divider${i}`} />}\n <ListItem>\n <Grid container>\n <Grid item xs={9}>\n <ListItemText\n primary={error.message}\n secondary={onlyPodWithErrors.pod.metadata?.name}\n />\n </Grid>\n <Grid item xs={3}>\n <FixDialog\n pod={onlyPodWithErrors.pod}\n error={error}\n clusterName={onlyPodWithErrors.cluster.name}\n />\n </Grid>\n </Grid>\n </ListItem>\n </React.Fragment>\n );\n });\n })}\n </List>\n </Paper>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;AA2BA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,WAC5B,YAAa,CAAA;AAAA,IACX,IAAM,EAAA;AAAA,MACJ,QAAU,EAAA,MAAA;AAAA,KACZ;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,KAAO,EAAA,MAAA;AAAA,KACT;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAgBO,MAAM,SAAY,GAAA,CAAC,EAAE,YAAA,EAAmC,KAAA;AAC7D,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,oDACG,KAAM,EAAA,EAAA,SAAA,EAAW,QAAQ,IACxB,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,QAAK,SAAW,EAAA,OAAA,CAAQ,QACtB,YACE,CAAA,MAAA,CAAO,SAAO,GAAI,CAAA,MAAA,CAAO,SAAS,CAAC,CAAA,CACnC,QAAQ,CAAqB,iBAAA,KAAA;AAC5B,IAAA,OAAO,iBAAkB,CAAA,MAAA,CAAO,GAAI,CAAA,CAAC,OAAO,CAAM,KAAA;AAChD,MACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,QAACA,cAAM,CAAA,QAAA;AAAA,QAAN;AAAA,UACC,GAAA,EAAK,GACH,iBAAkB,CAAA,GAAA,CAAI,UAAU,IAAQ,IAAA,SAC1C,QAAQ,CAAC,CAAA,CAAA;AAAA,SAAA;AAAA,QAER,IAAI,CAAK,oBAAAA,cAAA,CAAA,aAAA,CAAC,WAAQ,GAAK,EAAA,CAAA,aAAA,EAAgB,CAAC,CAAI,CAAA,EAAA,CAAA;AAAA,wBAC7CA,cAAA,CAAA,aAAA,CAAC,QACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,SAAA,EAAS,IACb,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,EAAA,EAAI,CACb,EAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,SAAS,KAAM,CAAA,OAAA;AAAA,YACf,SAAA,EAAW,iBAAkB,CAAA,GAAA,CAAI,QAAU,EAAA,IAAA;AAAA,WAAA;AAAA,SAE/C,CACA,kBAAAA,cAAA,CAAA,aAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,IAAI,CACb,EAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,UAAC,SAAA;AAAA,UAAA;AAAA,YACC,KAAK,iBAAkB,CAAA,GAAA;AAAA,YACvB,KAAA;AAAA,YACA,WAAA,EAAa,kBAAkB,OAAQ,CAAA,IAAA;AAAA,WAAA;AAAA,SAE3C,CACF,CACF,CAAA;AAAA,OACF,CAAA;AAAA,KAEH,CAAA,CAAA;AAAA,GACF,CACL,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ErrorList.esm.js","sources":["../../../../src/components/Pods/ErrorList/ErrorList.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Divider from '@material-ui/core/Divider';\nimport Paper from '@material-ui/core/Paper';\nimport Grid from '@material-ui/core/Grid';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport { PodAndErrors } from '../types';\nimport { FixDialog } from '../FixDialog/FixDialog';\n\nconst useStyles = makeStyles((_theme: Theme) =>\n createStyles({\n root: {\n overflow: 'auto',\n },\n list: {\n width: '100%',\n },\n }),\n);\n\n/**\n * Props for ErrorList\n *\n * @public\n */\nexport interface ErrorListProps {\n podAndErrors: PodAndErrors[];\n}\n\n/**\n * Shows a list of errors found on a Pod\n *\n * @public\n */\nexport const ErrorList = ({ podAndErrors }: ErrorListProps) => {\n const classes = useStyles();\n return (\n <Paper className={classes.root}>\n <List className={classes.list}>\n {podAndErrors\n .filter(pae => pae.errors.length > 0)\n .flatMap(onlyPodWithErrors => {\n return onlyPodWithErrors.errors.map((error, i) => {\n return (\n <React.Fragment\n key={`${\n onlyPodWithErrors.pod.metadata?.name ?? 'unknown'\n }-eli-${i}`}\n >\n {i > 0 && <Divider key={`error-divider${i}`} />}\n <ListItem>\n <Grid container>\n <Grid item xs={9}>\n <ListItemText\n primary={error.message}\n secondary={onlyPodWithErrors.pod.metadata?.name}\n />\n </Grid>\n <Grid item xs={3}>\n <FixDialog\n pod={onlyPodWithErrors.pod}\n error={error}\n clusterName={onlyPodWithErrors.cluster.name}\n />\n </Grid>\n </Grid>\n </ListItem>\n </React.Fragment>\n );\n });\n })}\n </List>\n </Paper>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;AA2BA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,WAC5B,YAAa,CAAA;AAAA,IACX,IAAM,EAAA;AAAA,MACJ,QAAU,EAAA;AAAA,KACZ;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,KAAO,EAAA;AAAA;AACT,GACD;AACH,CAAA;AAgBO,MAAM,SAAY,GAAA,CAAC,EAAE,YAAA,EAAmC,KAAA;AAC7D,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,oDACG,KAAM,EAAA,EAAA,SAAA,EAAW,QAAQ,IACxB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AE3C,CACF,CACF;AAAA,OACF;AAAA,KAEH,CAAA;AAAA,GACF,CACL,CACF,CAAA;AAEJ;;;;"}
@@ -30,13 +30,13 @@ const EventsContent = ({
30
30
  return event.type === "Warning";
31
31
  }
32
32
  return true;
33
- }).map((event) => {
33
+ }).map((event, index) => {
34
34
  const timeAgo = event.metadata.creationTimestamp ? DateTime.fromISO(event.metadata.creationTimestamp).toRelative(
35
35
  {
36
36
  locale: "en"
37
37
  }
38
38
  ) : "unknown";
39
- return /* @__PURE__ */ React__default.createElement(ListItem, { key: event.metadata.name }, /* @__PURE__ */ React__default.createElement(Tooltip, { title: `${event.type ?? ""} event` }, getAvatarByType(event.type)), /* @__PURE__ */ React__default.createElement(
39
+ return /* @__PURE__ */ React__default.createElement(ListItem, { key: `${event.metadata.name}-${index}` }, /* @__PURE__ */ React__default.createElement(Tooltip, { title: `${event.type ?? ""} event` }, getAvatarByType(event.type)), /* @__PURE__ */ React__default.createElement(
40
40
  ListItemText,
41
41
  {
42
42
  primary: `First event ${timeAgo} (count: ${event.count})`,
@@ -1 +1 @@
1
- {"version":3,"file":"Events.esm.js","sources":["../../../../src/components/Pods/Events/Events.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 Avatar from '@material-ui/core/Avatar';\nimport Container from '@material-ui/core/Container';\nimport Grid from '@material-ui/core/Grid';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemAvatar from '@material-ui/core/ListItemAvatar';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\n\nimport InfoIcon from '@material-ui/icons/Info';\nimport WarningIcon from '@material-ui/icons/Warning';\nimport { DateTime } from 'luxon';\n\nimport { useEvents } from './useEvents';\nimport Skeleton from '@material-ui/lab/Skeleton';\nimport { DismissableBanner } from '@backstage/core-components';\nimport { Event } from 'kubernetes-models/v1';\n\n/**\n * Props for Events\n *\n * @public\n */\nexport interface EventsContentProps {\n warningEventsOnly?: boolean;\n events: Event[];\n}\n\nconst getAvatarByType = (type?: string) => {\n return (\n <ListItemAvatar>\n <Avatar>{type === 'Warning' ? <WarningIcon /> : <InfoIcon />}</Avatar>\n </ListItemAvatar>\n );\n};\n\n/**\n * Shows given Kubernetes events\n *\n * @public\n */\nexport const EventsContent = ({\n events,\n warningEventsOnly,\n}: EventsContentProps) => {\n if (events.length === 0) {\n return <Typography>No events found</Typography>;\n }\n\n return (\n <Container>\n <Grid>\n <List>\n {events\n .filter(event => {\n if (warningEventsOnly) {\n return event.type === 'Warning';\n }\n return true;\n })\n .map(event => {\n const timeAgo = event.metadata.creationTimestamp\n ? DateTime.fromISO(event.metadata.creationTimestamp).toRelative(\n {\n locale: 'en',\n },\n )\n : 'unknown';\n return (\n <ListItem key={event.metadata.name}>\n <Tooltip title={`${event.type ?? ''} event`}>\n {getAvatarByType(event.type)}\n </Tooltip>\n <ListItemText\n primary={`First event ${timeAgo} (count: ${event.count})`}\n secondary={`${event.reason}: ${event.message}`}\n />\n </ListItem>\n );\n })}\n </List>\n </Grid>\n </Container>\n );\n};\n\n/**\n * Props for Events\n *\n * @public\n */\nexport interface EventsProps {\n involvedObjectName: string;\n namespace: string;\n clusterName: string;\n warningEventsOnly?: boolean;\n}\n\n/**\n * Retrieves and shows Kubernetes events for the given object\n *\n * @public\n */\nexport const Events = ({\n involvedObjectName,\n namespace,\n clusterName,\n warningEventsOnly,\n}: EventsProps) => {\n const { value, error, loading } = useEvents({\n involvedObjectName,\n namespace,\n clusterName,\n });\n\n return (\n <>\n {error && (\n <DismissableBanner\n {...{\n message: error.message,\n variant: 'error',\n fixed: false,\n }}\n id=\"events\"\n />\n )}\n {loading && <Skeleton variant=\"rect\" width=\"100%\" height=\"100%\" />}\n {!loading && value !== undefined && (\n <EventsContent warningEventsOnly={warningEventsOnly} events={value} />\n )}\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;AA8CA,MAAM,eAAA,GAAkB,CAAC,IAAkB,KAAA;AACzC,EAAA,uBACGA,cAAA,CAAA,aAAA,CAAA,cAAA,EAAA,IAAA,kBACEA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAQ,IAAS,KAAA,SAAA,mBAAaA,cAAA,CAAA,aAAA,CAAA,WAAA,EAAA,IAAY,CAAK,mBAAAA,cAAA,CAAA,aAAA,CAAC,QAAS,EAAA,IAAA,CAAG,CAC/D,CAAA,CAAA;AAEJ,CAAA,CAAA;AAOO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,MAAA;AAAA,EACA,iBAAA;AACF,CAA0B,KAAA;AACxB,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAO,uBAAAA,cAAA,CAAA,aAAA,CAAC,kBAAW,iBAAe,CAAA,CAAA;AAAA,GACpC;AAEA,EACE,uBAAAA,cAAA,CAAA,aAAA,CAAC,iCACEA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,+CACE,IACE,EAAA,IAAA,EAAA,MAAA,CACE,OAAO,CAAS,KAAA,KAAA;AACf,IAAA,IAAI,iBAAmB,EAAA;AACrB,MAAA,OAAO,MAAM,IAAS,KAAA,SAAA,CAAA;AAAA,KACxB;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACR,CACA,CAAA,GAAA,CAAI,CAAS,KAAA,KAAA;AACZ,IAAM,MAAA,OAAA,GAAU,MAAM,QAAS,CAAA,iBAAA,GAC3B,SAAS,OAAQ,CAAA,KAAA,CAAM,QAAS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AAA,EAAS,SAAQ,MAAO,EAAA,KAAA,EAAM,QAAO,MAAO,EAAA,MAAA,EAAO,GAC/D,CAAC,OAAA,IAAW,UAAU,KACrB,CAAA,oBAAAA,cAAA,CAAA,aAAA,CAAC,iBAAc,iBAAsC,EAAA,MAAA,EAAQ,OAAO,CAExE,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"Events.esm.js","sources":["../../../../src/components/Pods/Events/Events.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 Avatar from '@material-ui/core/Avatar';\nimport Container from '@material-ui/core/Container';\nimport Grid from '@material-ui/core/Grid';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemAvatar from '@material-ui/core/ListItemAvatar';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\n\nimport InfoIcon from '@material-ui/icons/Info';\nimport WarningIcon from '@material-ui/icons/Warning';\nimport { DateTime } from 'luxon';\n\nimport { useEvents } from './useEvents';\nimport Skeleton from '@material-ui/lab/Skeleton';\nimport { DismissableBanner } from '@backstage/core-components';\nimport { Event } from 'kubernetes-models/v1';\n\n/**\n * Props for Events\n *\n * @public\n */\nexport interface EventsContentProps {\n warningEventsOnly?: boolean;\n events: Event[];\n}\n\nconst getAvatarByType = (type?: string) => {\n return (\n <ListItemAvatar>\n <Avatar>{type === 'Warning' ? <WarningIcon /> : <InfoIcon />}</Avatar>\n </ListItemAvatar>\n );\n};\n\n/**\n * Shows given Kubernetes events\n *\n * @public\n */\nexport const EventsContent = ({\n events,\n warningEventsOnly,\n}: EventsContentProps) => {\n if (events.length === 0) {\n return <Typography>No events found</Typography>;\n }\n\n return (\n <Container>\n <Grid>\n <List>\n {events\n .filter(event => {\n if (warningEventsOnly) {\n return event.type === 'Warning';\n }\n return true;\n })\n .map((event, index) => {\n const timeAgo = event.metadata.creationTimestamp\n ? DateTime.fromISO(event.metadata.creationTimestamp).toRelative(\n {\n locale: 'en',\n },\n )\n : 'unknown';\n return (\n <ListItem key={`${event.metadata.name}-${index}`}>\n <Tooltip title={`${event.type ?? ''} event`}>\n {getAvatarByType(event.type)}\n </Tooltip>\n <ListItemText\n primary={`First event ${timeAgo} (count: ${event.count})`}\n secondary={`${event.reason}: ${event.message}`}\n />\n </ListItem>\n );\n })}\n </List>\n </Grid>\n </Container>\n );\n};\n\n/**\n * Props for Events\n *\n * @public\n */\nexport interface EventsProps {\n involvedObjectName: string;\n namespace: string;\n clusterName: string;\n warningEventsOnly?: boolean;\n}\n\n/**\n * Retrieves and shows Kubernetes events for the given object\n *\n * @public\n */\nexport const Events = ({\n involvedObjectName,\n namespace,\n clusterName,\n warningEventsOnly,\n}: EventsProps) => {\n const { value, error, loading } = useEvents({\n involvedObjectName,\n namespace,\n clusterName,\n });\n\n return (\n <>\n {error && (\n <DismissableBanner\n {...{\n message: error.message,\n variant: 'error',\n fixed: false,\n }}\n id=\"events\"\n />\n )}\n {loading && <Skeleton variant=\"rect\" width=\"100%\" height=\"100%\" />}\n {!loading && value !== undefined && (\n <EventsContent warningEventsOnly={warningEventsOnly} events={value} />\n )}\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;AA8CA,MAAM,eAAA,GAAkB,CAAC,IAAkB,KAAA;AACzC,EAAA,uBACGA,cAAA,CAAA,aAAA,CAAA,cAAA,EAAA,IAAA,kBACEA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAQ,IAAS,KAAA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,OAAO,CAAA,SAAA,EAAY,MAAM,KAAK,CAAA,CAAA,CAAA;AAAA,QACtD,WAAW,CAAG,EAAA,KAAA,CAAM,MAAM,CAAA,EAAA,EAAK,MAAM,OAAO,CAAA;AAAA;AAAA,KAEhD,CAAA;AAAA,GAEH,CACL,CACF,CACF,CAAA;AAEJ;AAmBO,MAAM,SAAS,CAAC;AAAA,EACrB,kBAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAmB,KAAA;AACjB,EAAA,MAAM,EAAE,KAAA,EAAO,KAAO,EAAA,OAAA,KAAY,SAAU,CAAA;AAAA,IAC1C,kBAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,mFAEK,KACC,oBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,QACF,SAAS,KAAM,CAAA,OAAA;AAAA,QACf,OAAS,EAAA,OAAA;AAAA,QACT,KAAO,EAAA;AAAA,OACT;AAAA,MACA,EAAG,EAAA;AAAA;AAAA,GACL,EAED,2BAAYA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAS,SAAQ,MAAO,EAAA,KAAA,EAAM,QAAO,MAAO,EAAA,MAAA,EAAO,GAC/D,CAAC,OAAA,IAAW,UAAU,KACrB,CAAA,oBAAAA,cAAA,CAAA,aAAA,CAAC,iBAAc,iBAAsC,EAAA,MAAA,EAAQ,OAAO,CAExE,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEvents.esm.js","sources":["../../../../src/components/Pods/Events/useEvents.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { useApi } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport { kubernetesProxyApiRef } from '../../../api/types';\n\n/**\n * Arguments for useEvents\n *\n * @public\n */\nexport interface EventsOptions {\n involvedObjectName: string;\n namespace: string;\n clusterName: string;\n}\n\n/**\n * Retrieves the events for the given object\n *\n * @public\n */\nexport const useEvents = ({\n involvedObjectName,\n namespace,\n clusterName,\n}: EventsOptions) => {\n const kubernetesProxyApi = useApi(kubernetesProxyApiRef);\n return useAsync(async () => {\n return await kubernetesProxyApi.getEventsByInvolvedObjectName({\n involvedObjectName,\n namespace,\n clusterName,\n });\n }, [involvedObjectName, namespace, clusterName]);\n};\n"],"names":[],"mappings":";;;;AAmCO,MAAM,YAAY,CAAC;AAAA,EACxB,kBAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AACF,CAAqB,KAAA;AACnB,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA,CAAA;AACvD,EAAA,OAAO,SAAS,YAAY;AAC1B,IAAO,OAAA,MAAM,mBAAmB,6BAA8B,CAAA;AAAA,MAC5D,kBAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACA,EAAA,CAAC,kBAAoB,EAAA,SAAA,EAAW,WAAW,CAAC,CAAA,CAAA;AACjD;;;;"}
1
+ {"version":3,"file":"useEvents.esm.js","sources":["../../../../src/components/Pods/Events/useEvents.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { useApi } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport { kubernetesProxyApiRef } from '../../../api/types';\n\n/**\n * Arguments for useEvents\n *\n * @public\n */\nexport interface EventsOptions {\n involvedObjectName: string;\n namespace: string;\n clusterName: string;\n}\n\n/**\n * Retrieves the events for the given object\n *\n * @public\n */\nexport const useEvents = ({\n involvedObjectName,\n namespace,\n clusterName,\n}: EventsOptions) => {\n const kubernetesProxyApi = useApi(kubernetesProxyApiRef);\n return useAsync(async () => {\n return await kubernetesProxyApi.getEventsByInvolvedObjectName({\n involvedObjectName,\n namespace,\n clusterName,\n });\n }, [involvedObjectName, namespace, clusterName]);\n};\n"],"names":[],"mappings":";;;;AAmCO,MAAM,YAAY,CAAC;AAAA,EACxB,kBAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAqB,KAAA;AACnB,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAA,OAAO,SAAS,YAAY;AAC1B,IAAO,OAAA,MAAM,mBAAmB,6BAA8B,CAAA;AAAA,MAC5D,kBAAA;AAAA,MACA,SAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,GACA,EAAA,CAAC,kBAAoB,EAAA,SAAA,EAAW,WAAW,CAAC,CAAA;AACjD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"FixDialog.esm.js","sources":["../../../../src/components/Pods/FixDialog/FixDialog.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, { useState } from 'react';\n\nimport Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport IconButton from '@material-ui/core/IconButton';\nimport { makeStyles, createStyles, Theme } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport CloseIcon from '@material-ui/icons/Close';\nimport HelpIcon from '@material-ui/icons/Help';\nimport OpenInNewIcon from '@material-ui/icons/OpenInNew';\n\nimport { Pod } from 'kubernetes-models/v1/Pod';\nimport { DetectedError } from '@backstage/plugin-kubernetes-common';\nimport { PodLogs } from '../PodLogs';\nimport { Events } from '../Events';\nimport { LinkButton } from '@backstage/core-components';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n closeButton: {\n position: 'absolute',\n right: theme.spacing(1),\n top: theme.spacing(1),\n color: theme.palette.grey[500],\n },\n }),\n);\n\n/**\n * Props for FixDialog\n *\n * @public\n */\nexport interface FixDialogProps {\n open?: boolean;\n clusterName: string;\n pod: Pod;\n error: DetectedError;\n}\n\n/**\n * A dialog for fixing detected Kubernetes errors\n *\n * @public\n */\nexport const FixDialog: React.FC<FixDialogProps> = ({\n open,\n pod,\n error,\n clusterName,\n}: FixDialogProps) => {\n const [isOpen, setOpen] = useState(!!open);\n const classes = useStyles();\n\n const openDialog = () => {\n setOpen(true);\n };\n\n const closeDialog = () => {\n setOpen(false);\n };\n\n const pf = error.proposedFix;\n\n const dialogContent = () => {\n return (\n <Grid container>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Detected error:</Typography>\n <Typography>{error.message}</Typography>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Cause explanation:</Typography>\n <Typography>\n {error.proposedFix?.rootCauseExplanation ?? 'unknown'}\n </Typography>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Fix:</Typography>\n <List>\n {(error.proposedFix?.actions ?? []).map((fix, i) => {\n return (\n <ListItem key={`${pod.metadata?.name ?? 'unknown'}-pf-${i}`}>\n {fix}\n </ListItem>\n );\n })}\n </List>\n </Grid>\n\n {pf && pf.type === 'logs' && (\n <>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Crash logs:</Typography>\n </Grid>\n <Grid item xs={9}>\n <PodLogs\n previous\n containerScope={{\n podName: pod.metadata?.name ?? 'unknown',\n podNamespace: pod.metadata?.namespace ?? 'unknown',\n cluster: { name: clusterName },\n containerName: pf.container,\n }}\n />\n </Grid>\n </>\n )}\n {pf && pf.type === 'events' && (\n <>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Events:</Typography>\n </Grid>\n <Grid item xs={9}>\n <Events\n warningEventsOnly\n involvedObjectName={pod.metadata?.name ?? ''}\n namespace={pod.metadata?.namespace ?? ''}\n clusterName={clusterName}\n />\n </Grid>\n </>\n )}\n </Grid>\n );\n };\n\n return (\n <>\n <Button\n variant=\"outlined\"\n aria-label=\"fix issue\"\n component=\"label\"\n onClick={openDialog}\n startIcon={<HelpIcon />}\n >\n Help\n </Button>\n <Dialog maxWidth=\"xl\" fullWidth open={isOpen} onClose={closeDialog}>\n <DialogTitle id=\"dialog-title\">\n {pod.metadata?.name} - {error.type}\n <IconButton\n aria-label=\"close\"\n className={classes.closeButton}\n onClick={closeDialog}\n >\n <CloseIcon />\n </IconButton>\n </DialogTitle>\n <DialogContent>{dialogContent()}</DialogContent>\n <DialogActions>\n {pf && pf.type === 'docs' && (\n <LinkButton\n to={pf.docsLink}\n variant=\"outlined\"\n startIcon={<OpenInNewIcon />}\n target=\"_blank\"\n rel=\"noopener\"\n >\n Open docs\n </LinkButton>\n )}\n </DialogActions>\n </Dialog>\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,SAAY,GAA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,EAAA,UAAA;AAAA,MACR,YAAW,EAAA,WAAA;AAAA,MACX,SAAU,EAAA,OAAA;AAAA,MACV,OAAS,EAAA,UAAA;AAAA,MACT,SAAA,+CAAY,QAAS,EAAA,IAAA,CAAA;AAAA,KAAA;AAAA,IACtB,MAAA;AAAA,GAED,+CACC,MAAO,EAAA,EAAA,QAAA,EAAS,MAAK,SAAS,EAAA,IAAA,EAAC,MAAM,MAAQ,EAAA,OAAA,EAAS,+BACpDA,cAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAY,IAAG,cACb,EAAA,EAAA,GAAA,CAAI,UAAU,IAAK,EAAA,KAAA,EAAI,MAAM,IAC9B,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,YAAW,EAAA,OAAA;AAAA,MACX,WAAW,OAAQ,CAAA,WAAA;AAAA,MACnB,OAAS,EAAA,WAAA;AAAA,KAAA;AAAA,iDAER,SAAU,EAAA,IAAA,CAAA;AAAA,GAEf,CAAA,kBACCA,cAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAA,EAAe,aAAc,EAAE,CAChC,kBAAAA,cAAA,CAAA,aAAA,CAAC,aACE,EAAA,IAAA,EAAA,EAAA,IAAM,EAAG,CAAA,IAAA,KAAS,MACjB,oBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,IAAI,EAAG,CAAA,QAAA;AAAA,MACP,OAAQ,EAAA,UAAA;AAAA,MACR,SAAA,+CAAY,aAAc,EAAA,IAAA,CAAA;AAAA,MAC1B,MAAO,EAAA,QAAA;AAAA,MACP,GAAI,EAAA,UAAA;AAAA,KAAA;AAAA,IACL,WAAA;AAAA,GAIL,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"FixDialog.esm.js","sources":["../../../../src/components/Pods/FixDialog/FixDialog.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, { useState } from 'react';\n\nimport Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport IconButton from '@material-ui/core/IconButton';\nimport { makeStyles, createStyles, Theme } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport CloseIcon from '@material-ui/icons/Close';\nimport HelpIcon from '@material-ui/icons/Help';\nimport OpenInNewIcon from '@material-ui/icons/OpenInNew';\n\nimport { Pod } from 'kubernetes-models/v1/Pod';\nimport { DetectedError } from '@backstage/plugin-kubernetes-common';\nimport { PodLogs } from '../PodLogs';\nimport { Events } from '../Events';\nimport { LinkButton } from '@backstage/core-components';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n closeButton: {\n position: 'absolute',\n right: theme.spacing(1),\n top: theme.spacing(1),\n color: theme.palette.grey[500],\n },\n }),\n);\n\n/**\n * Props for FixDialog\n *\n * @public\n */\nexport interface FixDialogProps {\n open?: boolean;\n clusterName: string;\n pod: Pod;\n error: DetectedError;\n}\n\n/**\n * A dialog for fixing detected Kubernetes errors\n *\n * @public\n */\nexport const FixDialog: React.FC<FixDialogProps> = ({\n open,\n pod,\n error,\n clusterName,\n}: FixDialogProps) => {\n const [isOpen, setOpen] = useState(!!open);\n const classes = useStyles();\n\n const openDialog = () => {\n setOpen(true);\n };\n\n const closeDialog = () => {\n setOpen(false);\n };\n\n const pf = error.proposedFix;\n\n const dialogContent = () => {\n return (\n <Grid container>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Detected error:</Typography>\n <Typography>{error.message}</Typography>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Cause explanation:</Typography>\n <Typography>\n {error.proposedFix?.rootCauseExplanation ?? 'unknown'}\n </Typography>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Fix:</Typography>\n <List>\n {(error.proposedFix?.actions ?? []).map((fix, i) => {\n return (\n <ListItem key={`${pod.metadata?.name ?? 'unknown'}-pf-${i}`}>\n {fix}\n </ListItem>\n );\n })}\n </List>\n </Grid>\n\n {pf && pf.type === 'logs' && (\n <>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Crash logs:</Typography>\n </Grid>\n <Grid item xs={9}>\n <PodLogs\n previous\n containerScope={{\n podName: pod.metadata?.name ?? 'unknown',\n podNamespace: pod.metadata?.namespace ?? 'unknown',\n cluster: { name: clusterName },\n containerName: pf.container,\n }}\n />\n </Grid>\n </>\n )}\n {pf && pf.type === 'events' && (\n <>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Events:</Typography>\n </Grid>\n <Grid item xs={9}>\n <Events\n warningEventsOnly\n involvedObjectName={pod.metadata?.name ?? ''}\n namespace={pod.metadata?.namespace ?? ''}\n clusterName={clusterName}\n />\n </Grid>\n </>\n )}\n </Grid>\n );\n };\n\n return (\n <>\n <Button\n variant=\"outlined\"\n aria-label=\"fix issue\"\n component=\"label\"\n onClick={openDialog}\n startIcon={<HelpIcon />}\n >\n Help\n </Button>\n <Dialog maxWidth=\"xl\" fullWidth open={isOpen} onClose={closeDialog}>\n <DialogTitle id=\"dialog-title\">\n {pod.metadata?.name} - {error.type}\n <IconButton\n aria-label=\"close\"\n className={classes.closeButton}\n onClick={closeDialog}\n >\n <CloseIcon />\n </IconButton>\n </DialogTitle>\n <DialogContent>{dialogContent()}</DialogContent>\n <DialogActions>\n {pf && pf.type === 'docs' && (\n <LinkButton\n to={pf.docsLink}\n variant=\"outlined\"\n startIcon={<OpenInNewIcon />}\n target=\"_blank\"\n rel=\"noopener\"\n >\n Open docs\n </LinkButton>\n )}\n </DialogActions>\n </Dialog>\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,UAC5B,YAAa,CAAA;AAAA,IACX,WAAa,EAAA;AAAA,MACX,QAAU,EAAA,UAAA;AAAA,MACV,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MACtB,GAAA,EAAK,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MACpB,KAAO,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,CAAK,GAAG;AAAA;AAC/B,GACD;AACH,CAAA;AAmBO,MAAM,YAAsC,CAAC;AAAA,EAClD,IAAA;AAAA,EACA,GAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAsB,KAAA;AACpB,EAAA,MAAM,CAAC,MAAQ,EAAA,OAAO,IAAI,QAAS,CAAA,CAAC,CAAC,IAAI,CAAA;AACzC,EAAA,MAAM,UAAU,SAAU,EAAA;AAE1B,EAAA,MAAM,aAAa,MAAM;AACvB,IAAA,OAAA,CAAQ,IAAI,CAAA;AAAA,GACd;AAEA,EAAA,MAAM,cAAc,MAAM;AACxB,IAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,GACf;AAEA,EAAA,MAAM,KAAK,KAAM,CAAA,WAAA;AAEjB,EAAA,MAAM,gBAAgB,MAAM;AAC1B,IAAA,uBACGA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,SAAS,EAAA,IAAA,EAAA,kBACZA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,EAAI,EAAA,EAAA,EAAA,kBACZA,cAAA,CAAA,aAAA,CAAA,UA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 import Grid from '@material-ui/core/Grid';
3
+ import Typography from '@material-ui/core/Typography';
4
+ import CardActions from '@material-ui/core/CardActions';
5
+ import Button from '@material-ui/core/Button';
6
+ import CloseIcon from '@material-ui/icons/Close';
7
+ import CircularProgress from '@material-ui/core/CircularProgress';
8
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
9
+ import { kubernetesReactTranslationRef } from '../../../translation.esm.js';
10
+ import { usePodDelete } from './usePodDelete.esm.js';
11
+
12
+ const PodDeleteButton = ({ podScope }) => {
13
+ const [isLoading, setIsLoading] = useState(false);
14
+ const [hasError, setHasError] = useState(false);
15
+ const deletePod = usePodDelete();
16
+ const { t } = useTranslationRef(kubernetesReactTranslationRef);
17
+ const buttonText = t("podDrawer.buttons.delete");
18
+ const handleDeleteClick = async () => {
19
+ setIsLoading(true);
20
+ try {
21
+ await deletePod(podScope);
22
+ } catch (error) {
23
+ setHasError(true);
24
+ console.error(error);
25
+ }
26
+ };
27
+ return /* @__PURE__ */ React__default.createElement(Grid, { container: true, item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(CardActions, null, /* @__PURE__ */ React__default.createElement(
28
+ Button,
29
+ {
30
+ variant: "outlined",
31
+ "aria-label": buttonText,
32
+ component: "label",
33
+ onClick: handleDeleteClick,
34
+ startIcon: isLoading ? /* @__PURE__ */ React__default.createElement(CircularProgress, { size: 18 }) : /* @__PURE__ */ React__default.createElement(CloseIcon, null),
35
+ disabled: isLoading
36
+ },
37
+ buttonText
38
+ )), hasError && /* @__PURE__ */ React__default.createElement(
39
+ Typography,
40
+ {
41
+ variant: "body1",
42
+ color: "error",
43
+ style: { textAlign: "right" }
44
+ },
45
+ "Could not delete the pod. Please check the console for the full report."
46
+ )));
47
+ };
48
+
49
+ export { PodDeleteButton };
50
+ //# sourceMappingURL=PodDeleteButton.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PodDeleteButton.esm.js","sources":["../../../../src/components/Pods/PodDelete/PodDeleteButton.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, { useState } from 'react';\n\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport CardActions from '@material-ui/core/CardActions';\nimport Button from '@material-ui/core/Button';\nimport DeleteIcon from '@material-ui/icons/Close';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { kubernetesReactTranslationRef } from '../../../translation';\n\nimport { usePodDelete } from './usePodDelete';\nimport { PodScope } from './types';\n\n/**\n * Props for PodDeleteButton\n *\n * @public\n */\nexport interface PodDeleteButtonProps {\n podScope: PodScope;\n}\n\n/**\n * a Delete button to delete a given pod\n *\n * @public\n */\nexport const PodDeleteButton = ({ podScope }: PodDeleteButtonProps) => {\n const [isLoading, setIsLoading] = useState(false);\n const [hasError, setHasError] = useState(false);\n const deletePod = usePodDelete();\n\n const { t } = useTranslationRef(kubernetesReactTranslationRef);\n const buttonText = t('podDrawer.buttons.delete');\n\n const handleDeleteClick = async () => {\n setIsLoading(true);\n try {\n await deletePod(podScope);\n } catch (error) {\n setHasError(true);\n // eslint-disable-next-line no-console\n console.error(error);\n }\n };\n\n return (\n <Grid container item xs={12}>\n <Grid item xs={12}>\n <CardActions>\n <Button\n variant=\"outlined\"\n aria-label={buttonText}\n component=\"label\"\n onClick={handleDeleteClick}\n startIcon={\n isLoading ? <CircularProgress size={18} /> : <DeleteIcon />\n }\n disabled={isLoading}\n >\n {buttonText}\n </Button>\n </CardActions>\n {hasError && (\n <Typography\n variant=\"body1\"\n color=\"error\"\n style={{ textAlign: 'right' }}\n >\n Could not delete the pod. Please check the console for the full\n report.\n </Typography>\n )}\n </Grid>\n </Grid>\n );\n};\n"],"names":["React","DeleteIcon"],"mappings":";;;;;;;;;;;AA2CO,MAAM,eAAkB,GAAA,CAAC,EAAE,QAAA,EAAqC,KAAA;AACrE,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,KAAK,CAAA;AAC9C,EAAA,MAAM,YAAY,YAAa,EAAA;AAE/B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,6BAA6B,CAAA;AAC7D,EAAM,MAAA,UAAA,GAAa,EAAE,0BAA0B,CAAA;AAE/C,EAAA,MAAM,oBAAoB,YAAY;AACpC,IAAA,YAAA,CAAa,IAAI,CAAA;AACjB,IAAI,IAAA;AACF,MAAA,MAAM,UAAU,QAAQ,CAAA;AAAA,aACjB,KAAO,EAAA;AACd,MAAA,WAAA,CAAY,IAAI,CAAA;AAEhB,MAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAAA;AACrB,GACF;AAEA,EAAA,uBACGA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,SAAS,EAAA,IAAA,EAAC,MAAI,IAAC,EAAA,EAAA,EAAI,EACvB,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,EAAI,EAAA,EAAA,EAAA,+CACZ,WACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,UAAA;AAAA,MACR,YAAY,EAAA,UAAA;AAAA,MACZ,SAAU,EAAA,OAAA;AAAA,MACV,OAAS,EAAA,iBAAA;AAAA,MACT,SAAA,EACE,4BAAaA,cAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAiB,MAAM,EAAI,EAAA,CAAA,gDAAMC,SAAW,EAAA,IAAA,CAAA;AAAA,MAE3D,QAAU,EAAA;AAAA,KAAA;AAAA,IAET;AAAA,GAEL,GACC,QACC,oBAAAD,cAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,OAAA;AAAA,MACR,KAAM,EAAA,OAAA;AAAA,MACN,KAAA,EAAO,EAAE,SAAA,EAAW,OAAQ;AAAA,KAAA;AAAA,IAC7B;AAAA,GAKL,CACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,21 @@
1
+ import { useCallback } from 'react';
2
+ import { useApi } from '@backstage/core-plugin-api';
3
+ import { kubernetesProxyApiRef } from '../../../api/types.esm.js';
4
+
5
+ const usePodDelete = () => {
6
+ const kubernetesProxyApi = useApi(kubernetesProxyApiRef);
7
+ const deletePod = useCallback(
8
+ async (podScope) => {
9
+ return await kubernetesProxyApi.deletePod({
10
+ podName: podScope.podName,
11
+ namespace: podScope.podNamespace,
12
+ clusterName: podScope.cluster.name
13
+ });
14
+ },
15
+ [kubernetesProxyApi]
16
+ );
17
+ return deletePod;
18
+ };
19
+
20
+ export { usePodDelete };
21
+ //# sourceMappingURL=usePodDelete.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePodDelete.esm.js","sources":["../../../../src/components/Pods/PodDelete/usePodDelete.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 { useCallback } from 'react';\n\nimport { PodScope } from './types';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { kubernetesProxyApiRef } from '../../../api/types';\n\n/**\n * Arguments for usePodDelete\n *\n * @public\n */\nexport interface PodDeleteOptions {\n podScope: PodScope;\n}\n\n/**\n * Delete a given pod\n *\n * @public\n */\nexport const usePodDelete = () => {\n const kubernetesProxyApi = useApi(kubernetesProxyApiRef);\n\n const deletePod = useCallback(\n async (podScope: PodScope) => {\n return await kubernetesProxyApi.deletePod({\n podName: podScope.podName,\n namespace: podScope.podNamespace,\n clusterName: podScope.cluster.name,\n });\n },\n [kubernetesProxyApi],\n );\n\n return deletePod;\n};\n"],"names":[],"mappings":";;;;AAmCO,MAAM,eAAe,MAAM;AAChC,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AAEvD,EAAA,MAAM,SAAY,GAAA,WAAA;AAAA,IAChB,OAAO,QAAuB,KAAA;AAC5B,MAAO,OAAA,MAAM,mBAAmB,SAAU,CAAA;AAAA,QACxC,SAAS,QAAS,CAAA,OAAA;AAAA,QAClB,WAAW,QAAS,CAAA,YAAA;AAAA,QACpB,WAAA,EAAa,SAAS,OAAQ,CAAA;AAAA,OAC/B,CAAA;AAAA,KACH;AAAA,IACA,CAAC,kBAAkB;AAAA,GACrB;AAEA,EAAO,OAAA,SAAA;AACT;;;;"}
@@ -7,8 +7,8 @@ import Grid from '@material-ui/core/Grid';
7
7
  import Typography from '@material-ui/core/Typography';
8
8
  import { DateTime } from 'luxon';
9
9
  import React__default from 'react';
10
- import { useIsPodExecTerminalEnabled } from '../../../hooks/useIsPodExecTerminalEnabled.esm.js';
11
10
  import '@backstage/core-plugin-api';
11
+ import { useIsPodExecTerminalEnabled } from '../../../hooks/useIsPodExecTerminalEnabled.esm.js';
12
12
  import 'react-use/esm/useAsync';
13
13
  import '../../../api/types.esm.js';
14
14
  import 'react-use/esm/useInterval';
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerCard.esm.js","sources":["../../../../src/components/Pods/PodDrawer/ContainerCard.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { StructuredMetadataTable } from '@backstage/core-components';\nimport { ClientContainerStatus } from '@backstage/plugin-kubernetes-common';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { IContainer, IContainerStatus } from 'kubernetes-models/v1';\nimport { DateTime } from 'luxon';\nimport React from 'react';\n\nimport { useIsPodExecTerminalEnabled } from '../../../hooks';\nimport { bytesToMiB, formatMillicores } from '../../../utils/resources';\nimport { PodExecTerminalDialog } from '../../PodExecTerminal/PodExecTerminalDialog';\nimport { ResourceUtilization } from '../../ResourceUtilization';\nimport { PodLogsDialog, PodScope } from '../PodLogs';\n\nconst getContainerHealthChecks = (\n containerSpec: IContainer,\n containerStatus: IContainerStatus,\n): { [key: string]: boolean } => {\n const healthCheck = {\n 'not waiting to start': containerStatus.state?.waiting === undefined,\n 'no restarts': containerStatus.restartCount === 0,\n };\n if (containerStatus.state?.terminated?.reason === 'Completed') {\n return healthCheck;\n }\n Object.assign(\n healthCheck,\n { started: !!containerStatus.started },\n { ready: containerStatus.ready },\n { 'readiness probe set': containerSpec?.readinessProbe !== undefined },\n );\n if (containerSpec && containerSpec?.livenessProbe !== undefined) {\n Object.assign(healthCheck, {\n 'liveness probe set': containerSpec.livenessProbe,\n });\n }\n return healthCheck;\n};\n\nconst getCurrentState = (containerStatus: IContainerStatus): string => {\n return (\n containerStatus.state?.waiting?.reason ||\n containerStatus.state?.terminated?.reason ||\n (containerStatus.state?.running !== undefined ? 'Running' : 'Unknown')\n );\n};\n\nconst getStartedAtTime = (\n containerStatus: IContainerStatus,\n): string | undefined => {\n return (\n containerStatus.state?.running?.startedAt ||\n containerStatus.state?.terminated?.startedAt\n );\n};\n\ninterface ContainerDatetimeProps {\n prefix: string;\n dateTime: string;\n}\n\nconst ContainerDatetime = ({ prefix, dateTime }: ContainerDatetimeProps) => {\n return (\n <Typography variant=\"subtitle2\">\n {prefix}:{' '}\n {DateTime.fromISO(dateTime).toRelative({\n locale: 'en',\n })}\n </Typography>\n );\n};\n\n/**\n * Props for ContainerCard\n *\n * @public\n */\nexport interface ContainerCardProps {\n podScope: PodScope;\n containerSpec?: IContainer;\n containerStatus: IContainerStatus;\n containerMetrics?: ClientContainerStatus;\n}\n\n/**\n * Shows details about a container within a pod\n *\n * @public\n */\nexport const ContainerCard: React.FC<ContainerCardProps> = ({\n podScope,\n containerSpec,\n containerStatus,\n containerMetrics,\n}: ContainerCardProps) => {\n const isPodExecTerminalEnabled = useIsPodExecTerminalEnabled();\n\n // This should never be undefined\n if (containerSpec === undefined) {\n return <Typography>error reading pod from cluster</Typography>;\n }\n const containerStartedTime = getStartedAtTime(containerStatus);\n const containerFinishedTime = containerStatus.state?.terminated?.finishedAt;\n\n return (\n <Card>\n <CardHeader\n title={containerStatus.name}\n subheader={containerStatus.image}\n />\n <CardContent>\n <Grid container>\n <Grid item xs={12}>\n {containerStartedTime && (\n <ContainerDatetime\n prefix=\"Started\"\n dateTime={containerStartedTime}\n />\n )}\n {containerFinishedTime && (\n <ContainerDatetime\n prefix=\"Completed\"\n dateTime={containerFinishedTime}\n />\n )}\n {containerStartedTime && containerFinishedTime && (\n <Typography variant=\"subtitle2\">\n Execution time:{' '}\n {DateTime.fromISO(containerFinishedTime)\n .diff(DateTime.fromISO(containerStartedTime), [\n 'hours',\n 'minutes',\n 'seconds',\n ])\n .toHuman()}\n </Typography>\n )}\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">\n Status: {getCurrentState(containerStatus)}\n </Typography>\n </Grid>\n {containerStatus.restartCount > 0 && (\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">\n Restarts: {containerStatus.restartCount}\n </Typography>\n </Grid>\n )}\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">Container health</Typography>\n </Grid>\n <Grid item xs={12}>\n <StructuredMetadataTable\n metadata={getContainerHealthChecks(\n containerSpec,\n containerStatus,\n )}\n />\n </Grid>\n {containerMetrics && (\n <Grid container item xs={12} spacing={0}>\n <Grid item xs={12}>\n <Typography variant=\"subtitle1\">\n Resource utilization\n </Typography>\n </Grid>\n <Grid item xs={12} style={{ minHeight: '5rem' }}>\n <ResourceUtilization\n compressed\n title=\"CPU requests\"\n usage={containerMetrics.cpuUsage.currentUsage}\n total={containerMetrics.cpuUsage.requestTotal}\n totalFormatted={formatMillicores(\n containerMetrics.cpuUsage.requestTotal,\n )}\n />\n <ResourceUtilization\n compressed\n title=\"CPU limits\"\n usage={containerMetrics.cpuUsage.currentUsage}\n total={containerMetrics.cpuUsage.limitTotal}\n totalFormatted={formatMillicores(\n containerMetrics.cpuUsage.limitTotal,\n )}\n />\n <ResourceUtilization\n compressed\n title=\"Memory requests\"\n usage={containerMetrics.memoryUsage.currentUsage}\n total={containerMetrics.memoryUsage.requestTotal}\n totalFormatted={bytesToMiB(\n containerMetrics.memoryUsage.requestTotal,\n )}\n />\n <ResourceUtilization\n compressed\n title=\"Memory limits\"\n usage={containerMetrics.memoryUsage.currentUsage}\n total={containerMetrics.memoryUsage.limitTotal}\n totalFormatted={bytesToMiB(\n containerMetrics.memoryUsage.limitTotal,\n )}\n />\n </Grid>\n </Grid>\n )}\n </Grid>\n </CardContent>\n <CardActions>\n <PodLogsDialog\n containerScope={{\n containerName: containerStatus.name,\n ...podScope,\n }}\n />\n {isPodExecTerminalEnabled && (\n <PodExecTerminalDialog\n cluster={podScope.cluster}\n containerName={containerStatus.name}\n podName={podScope.podName}\n podNamespace={podScope.podNamespace}\n />\n )}\n </CardActions>\n </Card>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,wBAAA,GAA2B,CAC/B,aAAA,EACA,eAC+B,KAAA;AAC/B,EAAA,MAAM,WAAc,GAAA;AAAA,IAClB,sBAAA,EAAwB,eAAgB,CAAA,KAAA,EAAO,OAAY,KAAA,KAAA,CAAA;AAAA,IAC3D,aAAA,EAAe,gBAAgB,YAAiB,KAAA,CAAA;AAAA,GAClD,CAAA;AACA,EAAA,IAAI,eAAgB,CAAA,KAAA,EAAO,UAAY,EAAA,MAAA,KAAW,WAAa,EAAA;AAC7D,IAAO,OAAA,WAAA,CAAA;AAAA,GACT;AACA,EAAO,MAAA,CAAA,MAAA;AAAA,IACL,WAAA;AAAA,IACA,EAAE,OAAA,EAAS,CAAC,CAAC,gBAAgB,OAAQ,EAAA;AAAA,IACrC,EAAE,KAAO,EAAA,eAAA,CAAgB,KAAM,EAAA;AAAA,IAC/B,EAAE,qBAAA,EAAuB,aAAe,EAAA,cAAA,KAAmB,KAAU,CAAA,EAAA;AAAA,GACvE,CAAA;AACA,EAAI,IAAA,aAAA,IAAiB,aAAe,EAAA,aAAA,KAAkB,KAAW,CAAA,EAAA;AAC/D,IAAA,MAAA,CAAO,OAAO,WAAa,EAAA;AAAA,MACzB,sBAAsB,aAAc,CAAA,aAAA;AAAA,KACrC,CAAA,CAAA;AAAA,GACH;AACA,EAAO,OAAA,WAAA,CAAA;AACT,CAAA,CAAA;AAEA,MAAM,eAAA,GAAkB,CAAC,eAA8C,KAAA;AACrE,EAAA,OACE,eAAgB,CAAA,KAAA,EAAO,OAAS,EAAA,MAAA,IAChC,eAAgB,CAAA,KAAA,EAAO,UAAY,EAAA,MAAA,KAClC,eAAgB,CAAA,KAAA,EAAO,OAAY,KAAA,KAAA,CAAA,GAAY,SAA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AAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,SAAS,QAAS,CAAA,OAAA;AAAA,MAClB,eAAe,eAAgB,CAAA,IAAA;AAAA,MAC/B,SAAS,QAAS,CAAA,OAAA;AAAA,MAClB,cAAc,QAAS,CAAA,YAAA;AAAA,KAAA;AAAA,GAG7B,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ContainerCard.esm.js","sources":["../../../../src/components/Pods/PodDrawer/ContainerCard.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { StructuredMetadataTable } from '@backstage/core-components';\nimport { ClientContainerStatus } from '@backstage/plugin-kubernetes-common';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { IContainer, IContainerStatus } from 'kubernetes-models/v1';\nimport { DateTime } from 'luxon';\nimport React from 'react';\n\nimport { useIsPodExecTerminalEnabled } from '../../../hooks';\nimport { bytesToMiB, formatMillicores } from '../../../utils/resources';\nimport { PodExecTerminalDialog } from '../../PodExecTerminal/PodExecTerminalDialog';\nimport { ResourceUtilization } from '../../ResourceUtilization';\nimport { PodLogsDialog, PodScope } from '../PodLogs';\n\nconst getContainerHealthChecks = (\n containerSpec: IContainer,\n containerStatus: IContainerStatus,\n): { [key: string]: boolean } => {\n const healthCheck = {\n 'not waiting to start': containerStatus.state?.waiting === undefined,\n 'no restarts': containerStatus.restartCount === 0,\n };\n if (containerStatus.state?.terminated?.reason === 'Completed') {\n return healthCheck;\n }\n Object.assign(\n healthCheck,\n { started: !!containerStatus.started },\n { ready: containerStatus.ready },\n { 'readiness probe set': containerSpec?.readinessProbe !== undefined },\n );\n if (containerSpec && containerSpec?.livenessProbe !== undefined) {\n Object.assign(healthCheck, {\n 'liveness probe set': containerSpec.livenessProbe,\n });\n }\n return healthCheck;\n};\n\nconst getCurrentState = (containerStatus: IContainerStatus): string => {\n return (\n containerStatus.state?.waiting?.reason ||\n containerStatus.state?.terminated?.reason ||\n (containerStatus.state?.running !== undefined ? 'Running' : 'Unknown')\n );\n};\n\nconst getStartedAtTime = (\n containerStatus: IContainerStatus,\n): string | undefined => {\n return (\n containerStatus.state?.running?.startedAt ||\n containerStatus.state?.terminated?.startedAt\n );\n};\n\ninterface ContainerDatetimeProps {\n prefix: string;\n dateTime: string;\n}\n\nconst ContainerDatetime = ({ prefix, dateTime }: ContainerDatetimeProps) => {\n return (\n <Typography variant=\"subtitle2\">\n {prefix}:{' '}\n {DateTime.fromISO(dateTime).toRelative({\n locale: 'en',\n })}\n </Typography>\n );\n};\n\n/**\n * Props for ContainerCard\n *\n * @public\n */\nexport interface ContainerCardProps {\n podScope: PodScope;\n containerSpec?: IContainer;\n containerStatus: IContainerStatus;\n containerMetrics?: ClientContainerStatus;\n}\n\n/**\n * Shows details about a container within a pod\n *\n * @public\n */\nexport const ContainerCard: React.FC<ContainerCardProps> = ({\n podScope,\n containerSpec,\n containerStatus,\n containerMetrics,\n}: ContainerCardProps) => {\n const isPodExecTerminalEnabled = useIsPodExecTerminalEnabled();\n\n // This should never be undefined\n if (containerSpec === undefined) {\n return <Typography>error reading pod from cluster</Typography>;\n }\n const containerStartedTime = getStartedAtTime(containerStatus);\n const containerFinishedTime = containerStatus.state?.terminated?.finishedAt;\n\n return (\n <Card>\n <CardHeader\n title={containerStatus.name}\n subheader={containerStatus.image}\n />\n <CardContent>\n <Grid container>\n <Grid item xs={12}>\n {containerStartedTime && (\n <ContainerDatetime\n prefix=\"Started\"\n dateTime={containerStartedTime}\n />\n )}\n {containerFinishedTime && (\n <ContainerDatetime\n prefix=\"Completed\"\n dateTime={containerFinishedTime}\n />\n )}\n {containerStartedTime && containerFinishedTime && (\n <Typography variant=\"subtitle2\">\n Execution time:{' '}\n {DateTime.fromISO(containerFinishedTime)\n .diff(DateTime.fromISO(containerStartedTime), [\n 'hours',\n 'minutes',\n 'seconds',\n ])\n .toHuman()}\n </Typography>\n )}\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">\n Status: {getCurrentState(containerStatus)}\n </Typography>\n </Grid>\n {containerStatus.restartCount > 0 && (\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">\n Restarts: {containerStatus.restartCount}\n </Typography>\n </Grid>\n )}\n <Grid item xs={12}>\n <Typography variant=\"subtitle2\">Container health</Typography>\n </Grid>\n <Grid item xs={12}>\n <StructuredMetadataTable\n metadata={getContainerHealthChecks(\n containerSpec,\n containerStatus,\n )}\n />\n </Grid>\n {containerMetrics && (\n <Grid container item xs={12} spacing={0}>\n <Grid item xs={12}>\n <Typography variant=\"subtitle1\">\n Resource utilization\n </Typography>\n </Grid>\n <Grid item xs={12} style={{ minHeight: '5rem' }}>\n <ResourceUtilization\n compressed\n title=\"CPU requests\"\n usage={containerMetrics.cpuUsage.currentUsage}\n total={containerMetrics.cpuUsage.requestTotal}\n totalFormatted={formatMillicores(\n containerMetrics.cpuUsage.requestTotal,\n )}\n />\n <ResourceUtilization\n compressed\n title=\"CPU limits\"\n usage={containerMetrics.cpuUsage.currentUsage}\n total={containerMetrics.cpuUsage.limitTotal}\n totalFormatted={formatMillicores(\n containerMetrics.cpuUsage.limitTotal,\n )}\n />\n <ResourceUtilization\n compressed\n title=\"Memory requests\"\n usage={containerMetrics.memoryUsage.currentUsage}\n total={containerMetrics.memoryUsage.requestTotal}\n totalFormatted={bytesToMiB(\n containerMetrics.memoryUsage.requestTotal,\n )}\n />\n <ResourceUtilization\n compressed\n title=\"Memory limits\"\n usage={containerMetrics.memoryUsage.currentUsage}\n total={containerMetrics.memoryUsage.limitTotal}\n totalFormatted={bytesToMiB(\n containerMetrics.memoryUsage.limitTotal,\n )}\n />\n </Grid>\n </Grid>\n )}\n </Grid>\n </CardContent>\n <CardActions>\n <PodLogsDialog\n containerScope={{\n containerName: containerStatus.name,\n ...podScope,\n }}\n />\n {isPodExecTerminalEnabled && (\n <PodExecTerminalDialog\n cluster={podScope.cluster}\n containerName={containerStatus.name}\n podName={podScope.podName}\n podNamespace={podScope.podNamespace}\n />\n )}\n </CardActions>\n </Card>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,wBAAA,GAA2B,CAC/B,aAAA,EACA,eAC+B,KAAA;AAC/B,EAAA,MAAM,WAAc,GAAA;AAAA,IAClB,sBAAA,EAAwB,eAAgB,CAAA,KAAA,EAAO,OAAY,KAAA,KAAA,CAAA;AAAA,IAC3D,aAAA,EAAe,gBAAgB,YAAiB,KAAA;AAAA,GAClD;AACA,EAAA,IAAI,eAAgB,CAAA,KAAA,EAAO,UAAY,EAAA,MAAA,KAAW,WAAa,EAAA;AAC7D,IAAO,OAAA,WAAA;AAAA;AAET,EAAO,MAAA,CAAA,MAAA;AAAA,IACL,WAAA;AAAA,IACA,EAAE,OAAA,EAAS,CAAC,CAAC,gBAAgB,OAAQ,EAAA;AAAA,IACrC,EAAE,KAAO,EAAA,eAAA,CAAgB,KAAM,EAAA;AAAA,IAC/B,EAAE,qBAAA,EAAuB,aAAe,EAAA,cAAA,KAAmB,KAAU,CAAA;AAAA,GACvE;AACA,EAAI,IAAA,aAAA,IAAiB,aAAe,EAAA,aAAA,KAAkB,KAAW,CAAA,EAAA;AAC/D,IAAA,MAAA,CAAO,OAAO,WAAa,EAAA;AAAA,MACzB,sBAAsB,aAAc,CAAA;AAAA,KACrC,CAAA;AAAA;AAEH,EAAO,OAAA,WAAA;A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AA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,SAAS,QAAS,CAAA,OAAA;AAAA,MAClB,eAAe,eAAgB,CAAA,IAAA;AAAA,MAC/B,SAAS,QAAS,CAAA,OAAA;AAAA,MAClB,cAAc,QAAS,CAAA;AAAA;AAAA,GAG7B,CACF,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PendingPodContent.esm.js","sources":["../../../../src/components/Pods/PodDrawer/PendingPodContent.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 Grid from '@material-ui/core/Grid';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport Typography from '@material-ui/core/Typography';\nimport { IPodCondition, Pod } from 'kubernetes-models/v1';\nimport {\n StatusError,\n StatusOK,\n StatusWarning,\n} from '@backstage/core-components';\nimport { DateTime } from 'luxon';\n\ninterface PodConditionProps {\n condition: IPodCondition;\n}\n\nconst PodCondition = ({ condition }: PodConditionProps) => {\n return (\n <>\n {condition.status === 'False' && (\n <StatusError>\n {condition.type} - ({condition.reason}{' '}\n {condition.lastTransitionTime &&\n DateTime.fromISO(condition.lastTransitionTime).toRelative({\n locale: 'en',\n })}\n ) - {condition.message}{' '}\n </StatusError>\n )}\n {condition.status === 'True' && (\n <StatusOK>\n {condition.type} - (\n {condition.lastTransitionTime &&\n DateTime.fromISO(condition.lastTransitionTime).toRelative({\n locale: 'en',\n })}\n )\n </StatusOK>\n )}\n {condition.status === 'Unknown' && (\n <StatusWarning>\n {condition.type} - (\n {condition.lastTransitionTime &&\n DateTime.fromISO(condition.lastTransitionTime).toRelative({\n locale: 'en',\n })}\n ) {condition.message}\n </StatusWarning>\n )}\n </>\n );\n};\n\n/**\n * Props for PendingPodContent\n *\n * @public\n */\nexport interface PendingPodContentProps {\n pod: Pod;\n}\n\n/**\n * Shows details about pod's conditions as it starts\n *\n * @public\n */\nexport const PendingPodContent = ({ pod }: PendingPodContentProps) => {\n // TODO add PodHasNetwork when it's out of alpha\n // https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions\n const startupConditions = [\n pod.status?.conditions?.find(c => c.type === 'PodScheduled'),\n pod.status?.conditions?.find(c => c.type === 'Initialized'),\n pod.status?.conditions?.find(c => c.type === 'ContainersReady'),\n pod.status?.conditions?.find(c => c.type === 'Ready'),\n ].filter((c): c is IPodCondition => !!c); // filter out undefined\n return (\n <Grid container spacing={2}>\n <Grid item xs={12}>\n <Typography variant=\"h5\">Pod is Pending. Conditions:</Typography>\n <List>\n {startupConditions.map(c => (\n <ListItem key={c.type}>\n <PodCondition condition={c} />\n </ListItem>\n ))}\n </List>\n </Grid>\n </Grid>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;AAgCA,MAAM,YAAe,GAAA,CAAC,EAAE,SAAA,EAAmC,KAAA;AACzD,EAAA,mFAEK,SAAU,CAAA,MAAA,KAAW,2BACnBA,cAAA,CAAA,aAAA,CAAA,WAAA,EAAA,IAAA,EACE,UAAU,IAAK,EAAA,MAAA,EAAK,UAAU,MAAQ,EAAA,GAAA,EACtC,UAAU,kBACT,IAAA,QAAA,CAAS,QAAQ,SAAU,CAAA,kBAAkB,EAAE,UAAW,CAAA;AAAA,IACxD,MAAQ,EAAA,IAAA;AAAA,GACT,GAAE,MACA,EAAA,SAAA,CAAU,SAAS,GAC1B,CAAA,EAED,SAAU,CAAA,MAAA,KAAW,MACpB,oBAAAA,cAAA,CAAA,aAAA,CAAC,gBACE,SAAU,CAAA,IAAA,EAAK,QACf,SAAU,CAAA,kBAA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AK,6BAA2B,CAAA,kBACnDA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EACE,kBAAkB,GAAI,CAAA,CAAA,CAAA,qBACpBA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAS,KAAK,CAAE,CAAA,IAAA,EAAA,kBACdA,cAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,WAAW,CAAG,EAAA,CAC9B,CACD,CACH,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"PendingPodContent.esm.js","sources":["../../../../src/components/Pods/PodDrawer/PendingPodContent.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 Grid from '@material-ui/core/Grid';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport Typography from '@material-ui/core/Typography';\nimport { IPodCondition, Pod } from 'kubernetes-models/v1';\nimport {\n StatusError,\n StatusOK,\n StatusWarning,\n} from '@backstage/core-components';\nimport { DateTime } from 'luxon';\n\ninterface PodConditionProps {\n condition: IPodCondition;\n}\n\nconst PodCondition = ({ condition }: PodConditionProps) => {\n return (\n <>\n {condition.status === 'False' && (\n <StatusError>\n {condition.type} - ({condition.reason}{' '}\n {condition.lastTransitionTime &&\n DateTime.fromISO(condition.lastTransitionTime).toRelative({\n locale: 'en',\n })}\n ) - {condition.message}{' '}\n </StatusError>\n )}\n {condition.status === 'True' && (\n <StatusOK>\n {condition.type} - (\n {condition.lastTransitionTime &&\n DateTime.fromISO(condition.lastTransitionTime).toRelative({\n locale: 'en',\n })}\n )\n </StatusOK>\n )}\n {condition.status === 'Unknown' && (\n <StatusWarning>\n {condition.type} - (\n {condition.lastTransitionTime &&\n DateTime.fromISO(condition.lastTransitionTime).toRelative({\n locale: 'en',\n })}\n ) {condition.message}\n </StatusWarning>\n )}\n </>\n );\n};\n\n/**\n * Props for PendingPodContent\n *\n * @public\n */\nexport interface PendingPodContentProps {\n pod: Pod;\n}\n\n/**\n * Shows details about pod's conditions as it starts\n *\n * @public\n */\nexport const PendingPodContent = ({ pod }: PendingPodContentProps) => {\n // TODO add PodHasNetwork when it's out of alpha\n // https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions\n const startupConditions = [\n pod.status?.conditions?.find(c => c.type === 'PodScheduled'),\n pod.status?.conditions?.find(c => c.type === 'Initialized'),\n pod.status?.conditions?.find(c => c.type === 'ContainersReady'),\n pod.status?.conditions?.find(c => c.type === 'Ready'),\n ].filter((c): c is IPodCondition => !!c); // filter out undefined\n return (\n <Grid container spacing={2}>\n <Grid item xs={12}>\n <Typography variant=\"h5\">Pod is Pending. Conditions:</Typography>\n <List>\n {startupConditions.map(c => (\n <ListItem key={c.type}>\n <PodCondition condition={c} />\n </ListItem>\n ))}\n </List>\n </Grid>\n </Grid>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;AAgCA,MAAM,YAAe,GAAA,CAAC,EAAE,SAAA,EAAmC,KAAA;AACzD,EAAA,mFAEK,SAAU,CAAA,MAAA,KAAW,2BACnBA,cAAA,CAAA,aAAA,CAAA,WAAA,EAAA,IAAA,EACE,UAAU,IAAK,EAAA,MAAA,EAAK,UAAU,MAAQ,EAAA,GAAA,EACtC,UAAU,kBACT,IAAA,QAAA,CAAS,QAAQ,SAAU,CAAA,kBAAkB,EAAE,UAAW,CAAA;AAAA,IACxD,MAAQ,EAAA;AAAA,GACT,GAAE,MACA,EAAA,SAAA,CAAU,SAAS,GAC1B,CAAA,EAED,SAAU,CAAA,MAAA,KAAW,MACpB,oBAAAA,c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AAC,UAAW,EAAA,EAAA,OAAA,EAAQ,QAAK,6BAA2B,CAAA,kBACnDA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EACE,kBAAkB,GAAI,CAAA,CAAA,CAAA,qBACpBA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAS,KAAK,CAAE,CAAA,IAAA,EAAA,kBACdA,cAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,WAAW,CAAG,EAAA,CAC9B,CACD,CACH,CACF,CACF,CAAA;AAEJ;;;;"}
@@ -9,11 +9,24 @@ import { KubernetesDrawer } from '../../KubernetesDrawer/KubernetesDrawer.esm.js
9
9
  import '@material-ui/core/FormControlLabel';
10
10
  import '@material-ui/core/Switch';
11
11
  import 'js-yaml';
12
+ import { PodDeleteButton } from '../PodDelete/PodDeleteButton.esm.js';
12
13
  import { PendingPodContent } from './PendingPodContent.esm.js';
13
14
  import { ErrorList } from '../ErrorList/ErrorList.esm.js';
14
15
  import { usePodMetrics } from '../../../hooks/usePodMetrics.esm.js';
15
16
  import { ResourceUtilization } from '../../ResourceUtilization/ResourceUtilization.esm.js';
16
17
  import { formatMillicores, bytesToMiB } from '../../../utils/resources.esm.js';
18
+ import { useIsPodDeleteEnabled } from '../../../hooks/useIsPodDeleteEnabled.esm.js';
19
+ import '@backstage/core-plugin-api';
20
+ import 'react-use/esm/useAsync';
21
+ import '../../../api/types.esm.js';
22
+ import 'react-use/esm/useInterval';
23
+ import 'react-use/esm/useAsyncRetry';
24
+ import '../../../kubernetes-auth-provider/types.esm.js';
25
+ import '../../../hooks/PodNamesWithErrors.esm.js';
26
+ import '../../../hooks/PodNamesWithMetrics.esm.js';
27
+ import '../../../hooks/GroupedResponses.esm.js';
28
+ import '../../../hooks/Cluster.esm.js';
29
+ import '../../../hooks/useMatchingErrors.esm.js';
17
30
 
18
31
  const useDrawerContentStyles = makeStyles(
19
32
  (_theme) => createStyles({
@@ -41,6 +54,7 @@ function getContainerSpecByName(pod, containerName) {
41
54
  const PodDrawer = ({ podAndErrors, open }) => {
42
55
  const classes = useDrawerContentStyles();
43
56
  const podMetrics = usePodMetrics(podAndErrors.cluster.name, podAndErrors.pod);
57
+ const isPodDeleteEnabled = useIsPodDeleteEnabled();
44
58
  return /* @__PURE__ */ React__default.createElement(
45
59
  KubernetesDrawer,
46
60
  {
@@ -49,7 +63,16 @@ const PodDrawer = ({ podAndErrors, open }) => {
49
63
  kubernetesObject: podAndErrors.pod,
50
64
  label: /* @__PURE__ */ React__default.createElement(Typography, { variant: "subtitle1" }, podAndErrors.pod.metadata?.name ?? "unknown")
51
65
  },
52
- /* @__PURE__ */ React__default.createElement("div", { className: classes.content }, podMetrics && /* @__PURE__ */ React__default.createElement(Grid, { container: true, item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(Typography, { variant: "h5" }, "Resource utilization")), /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 6 }, /* @__PURE__ */ React__default.createElement(
66
+ /* @__PURE__ */ React__default.createElement("div", { className: classes.content }, isPodDeleteEnabled && /* @__PURE__ */ React__default.createElement(
67
+ PodDeleteButton,
68
+ {
69
+ podScope: {
70
+ podName: podAndErrors.pod.metadata?.name ?? "unknown",
71
+ podNamespace: podAndErrors.pod.metadata?.namespace ?? "default",
72
+ cluster: podAndErrors.cluster
73
+ }
74
+ }
75
+ ), podMetrics && /* @__PURE__ */ React__default.createElement(Grid, { container: true, item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React__default.createElement(Typography, { variant: "h5" }, "Resource utilization")), /* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 6 }, /* @__PURE__ */ React__default.createElement(
53
76
  ResourceUtilization,
54
77
  {
55
78
  title: "CPU requests",
@@ -1 +1 @@
1
- {"version":3,"file":"PodDrawer.esm.js","sources":["../../../../src/components/Pods/PodDrawer/PodDrawer.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nimport { ItemCardGrid } from '@backstage/core-components';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\n\nimport { Pod } from 'kubernetes-models/v1';\n\nimport { ContainerCard } from './ContainerCard';\n\nimport { PodAndErrors } from '../types';\nimport { KubernetesDrawer } from '../../KubernetesDrawer';\nimport { PendingPodContent } from './PendingPodContent';\nimport { ErrorList } from '../ErrorList';\nimport { usePodMetrics } from '../../../hooks/usePodMetrics';\nimport { ResourceUtilization } from '../../ResourceUtilization';\nimport { bytesToMiB, formatMillicores } from '../../../utils/resources';\n\nconst useDrawerContentStyles = makeStyles((_theme: Theme) =>\n createStyles({\n header: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n content: {\n height: '80%',\n },\n icon: {\n fontSize: 20,\n },\n podoklist: {\n width: '100%',\n maxWidth: 360,\n maxHeight: 360,\n },\n }),\n);\n\nfunction getContainerSpecByName(pod: Pod, containerName: string) {\n return pod.spec?.containers.find(c => c.name === containerName);\n}\n\n/**\n * Props for PodDrawer\n *\n * @public\n */\nexport interface PodDrawerProps {\n open?: boolean;\n podAndErrors: PodAndErrors;\n}\n\n/**\n * A Drawer for Kubernetes Pods\n *\n * @public\n */\nexport const PodDrawer = ({ podAndErrors, open }: PodDrawerProps) => {\n const classes = useDrawerContentStyles();\n const podMetrics = usePodMetrics(podAndErrors.cluster.name, podAndErrors.pod);\n\n return (\n <KubernetesDrawer\n open={open}\n drawerContentsHeader={\n <Typography variant=\"subtitle1\">\n Pod{' '}\n {podAndErrors.pod.status?.podIP &&\n `(${podAndErrors.pod.status?.podIP})`}\n </Typography>\n }\n kubernetesObject={podAndErrors.pod}\n label={\n <Typography variant=\"subtitle1\">\n {podAndErrors.pod.metadata?.name ?? 'unknown'}\n </Typography>\n }\n >\n <div className={classes.content}>\n {podMetrics && (\n <Grid container item xs={12}>\n <Grid item xs={12}>\n <Typography variant=\"h5\">Resource utilization</Typography>\n </Grid>\n <Grid item xs={6}>\n <ResourceUtilization\n title=\"CPU requests\"\n usage={podMetrics.cpu.currentUsage}\n total={podMetrics.cpu.requestTotal}\n totalFormatted={formatMillicores(podMetrics.cpu.requestTotal)}\n />\n <ResourceUtilization\n title=\"CPU limits\"\n usage={podMetrics.cpu.currentUsage}\n total={podMetrics.cpu.limitTotal}\n totalFormatted={formatMillicores(podMetrics.cpu.limitTotal)}\n />\n </Grid>\n <Grid item xs={6}>\n <ResourceUtilization\n title=\"Memory requests\"\n usage={podMetrics.memory.currentUsage}\n total={podMetrics.memory.requestTotal}\n totalFormatted={bytesToMiB(podMetrics.memory.requestTotal)}\n />\n <ResourceUtilization\n title=\"Memory limits\"\n usage={podMetrics.memory.currentUsage}\n total={podMetrics.memory.limitTotal}\n totalFormatted={bytesToMiB(podMetrics.memory.limitTotal)}\n />\n </Grid>\n </Grid>\n )}\n {podAndErrors.pod.status?.phase === 'Pending' && (\n <PendingPodContent pod={podAndErrors.pod} />\n )}\n {podAndErrors.pod.status?.containerStatuses?.length && (\n <Grid container spacing={2}>\n <Grid item xs={12}>\n <Typography variant=\"h5\">Containers</Typography>\n </Grid>\n <Grid item xs={12}>\n <ItemCardGrid>\n {podAndErrors.pod.status?.containerStatuses?.map(\n (containerStatus, i) => {\n const containerSpec = getContainerSpecByName(\n podAndErrors.pod,\n containerStatus.name,\n );\n const containerMetrics = (\n podMetrics?.containers ?? []\n ).find(c => c.container === containerStatus.name);\n return (\n <ContainerCard\n key={`container-card-${podAndErrors.pod.metadata?.name}-${i}`}\n containerMetrics={containerMetrics}\n podScope={{\n podName: podAndErrors.pod.metadata?.name ?? 'unknown',\n podNamespace:\n podAndErrors.pod.metadata?.namespace ?? 'unknown',\n cluster: podAndErrors.cluster,\n }}\n containerSpec={containerSpec}\n containerStatus={containerStatus}\n />\n );\n },\n )}\n </ItemCardGrid>\n </Grid>\n {podAndErrors.errors.length > 0 && (\n <Grid item xs={12}>\n <Typography variant=\"h5\">Errors</Typography>\n </Grid>\n )}\n {podAndErrors.errors.length > 0 && (\n <Grid item xs={12}>\n <ErrorList podAndErrors={[podAndErrors]} />\n </Grid>\n )}\n </Grid>\n )}\n </div>\n </KubernetesDrawer>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAM,sBAAyB,GAAA,UAAA;AAAA,EAAW,CAAC,WACzC,YAAa,CAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,cAAgB,EAAA,eAAA;AAAA,KAClB;AAAA,IACA,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA,KAAA;AAAA,KACV;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,QAAU,EAAA,EAAA;AAAA,KACZ;AAAA,IACA,SAAW,EAAA;AAAA,MACT,KAAO,EAAA,MAAA;AAAA,MACP,QAAU,EAAA,GAAA;AAAA,MACV,SAAW,EAAA,GAAA;AAAA,KACb;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAEA,SAAS,sBAAA,CAAuB,KAAU,aAAuB,EAAA;AAC/D,EAAA,OAAO,IAAI,IAAM,EAAA,UAAA,CAAW,KAAK,CAAK,CAAA,KAAA,CAAA,CAAE,SAAS,aAAa,CAAA,CAAA;AAChE,CAAA;AAiBO,MAAM,SAAY,GAAA,CAAC,EAAE,YAAA,EAAc,MAA2B,KAAA;AACnE,EAAA,MAAM,UAAU,sBAAuB,E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AA;AAAA,YACA,eAAA;AAAA,WAAA;AAAA,SACF,CAAA;AAAA,OAEJ;AAAA,KAEJ,CACF,CAAA,EACC,YAAa,CAAA,MAAA,CAAO,SAAS,CAC5B,oBAAAA,cAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,MAAC,EAAI,EAAA,EAAA,EAAA,+CACZ,UAAW,EAAA,EAAA,OAAA,EAAQ,QAAK,QAAM,CACjC,CAED,EAAA,YAAA,CAAa,OAAO,MAAS,GAAA,CAAA,oBAC3BA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,MAAI,IAAC,EAAA,EAAA,EAAI,EACb,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,aAAU,YAAc,EAAA,CAAC,YAAY,CAAG,EAAA,CAC3C,CAEJ,CAEJ,CAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"PodDrawer.esm.js","sources":["../../../../src/components/Pods/PodDrawer/PodDrawer.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nimport { ItemCardGrid } from '@backstage/core-components';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\n\nimport { Pod } from 'kubernetes-models/v1';\n\nimport { ContainerCard } from './ContainerCard';\n\nimport { PodAndErrors } from '../types';\nimport { KubernetesDrawer } from '../../KubernetesDrawer';\nimport { PodDeleteButton } from '../PodDelete/PodDeleteButton';\nimport { PendingPodContent } from './PendingPodContent';\nimport { ErrorList } from '../ErrorList';\nimport { usePodMetrics } from '../../../hooks/usePodMetrics';\nimport { ResourceUtilization } from '../../ResourceUtilization';\nimport { bytesToMiB, formatMillicores } from '../../../utils/resources';\nimport { useIsPodDeleteEnabled } from '../../../hooks';\n\nconst useDrawerContentStyles = makeStyles((_theme: Theme) =>\n createStyles({\n header: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n content: {\n height: '80%',\n },\n icon: {\n fontSize: 20,\n },\n podoklist: {\n width: '100%',\n maxWidth: 360,\n maxHeight: 360,\n },\n }),\n);\n\nfunction getContainerSpecByName(pod: Pod, containerName: string) {\n return pod.spec?.containers.find(c => c.name === containerName);\n}\n\n/**\n * Props for PodDrawer\n *\n * @public\n */\nexport interface PodDrawerProps {\n open?: boolean;\n podAndErrors: PodAndErrors;\n}\n\n/**\n * A Drawer for Kubernetes Pods\n *\n * @public\n */\nexport const PodDrawer = ({ podAndErrors, open }: PodDrawerProps) => {\n const classes = useDrawerContentStyles();\n const podMetrics = usePodMetrics(podAndErrors.cluster.name, podAndErrors.pod);\n const isPodDeleteEnabled = useIsPodDeleteEnabled();\n\n return (\n <KubernetesDrawer\n open={open}\n drawerContentsHeader={\n <Typography variant=\"subtitle1\">\n Pod{' '}\n {podAndErrors.pod.status?.podIP &&\n `(${podAndErrors.pod.status?.podIP})`}\n </Typography>\n }\n kubernetesObject={podAndErrors.pod}\n label={\n <Typography variant=\"subtitle1\">\n {podAndErrors.pod.metadata?.name ?? 'unknown'}\n </Typography>\n }\n >\n <div className={classes.content}>\n {isPodDeleteEnabled && (\n <PodDeleteButton\n podScope={{\n podName: podAndErrors.pod.metadata?.name ?? 'unknown',\n podNamespace: podAndErrors.pod.metadata?.namespace ?? 'default',\n cluster: podAndErrors.cluster,\n }}\n />\n )}\n {podMetrics && (\n <Grid container item xs={12}>\n <Grid item xs={12}>\n <Typography variant=\"h5\">Resource utilization</Typography>\n </Grid>\n <Grid item xs={6}>\n <ResourceUtilization\n title=\"CPU requests\"\n usage={podMetrics.cpu.currentUsage}\n total={podMetrics.cpu.requestTotal}\n totalFormatted={formatMillicores(podMetrics.cpu.requestTotal)}\n />\n <ResourceUtilization\n title=\"CPU limits\"\n usage={podMetrics.cpu.currentUsage}\n total={podMetrics.cpu.limitTotal}\n totalFormatted={formatMillicores(podMetrics.cpu.limitTotal)}\n />\n </Grid>\n <Grid item xs={6}>\n <ResourceUtilization\n title=\"Memory requests\"\n usage={podMetrics.memory.currentUsage}\n total={podMetrics.memory.requestTotal}\n totalFormatted={bytesToMiB(podMetrics.memory.requestTotal)}\n />\n <ResourceUtilization\n title=\"Memory limits\"\n usage={podMetrics.memory.currentUsage}\n total={podMetrics.memory.limitTotal}\n totalFormatted={bytesToMiB(podMetrics.memory.limitTotal)}\n />\n </Grid>\n </Grid>\n )}\n {podAndErrors.pod.status?.phase === 'Pending' && (\n <PendingPodContent pod={podAndErrors.pod} />\n )}\n {podAndErrors.pod.status?.containerStatuses?.length && (\n <Grid container spacing={2}>\n <Grid item xs={12}>\n <Typography variant=\"h5\">Containers</Typography>\n </Grid>\n <Grid item xs={12}>\n <ItemCardGrid>\n {podAndErrors.pod.status?.containerStatuses?.map(\n (containerStatus, i) => {\n const containerSpec = getContainerSpecByName(\n podAndErrors.pod,\n containerStatus.name,\n );\n const containerMetrics = (\n podMetrics?.containers ?? []\n ).find(c => c.container === containerStatus.name);\n return (\n <ContainerCard\n key={`container-card-${podAndErrors.pod.metadata?.name}-${i}`}\n containerMetrics={containerMetrics}\n podScope={{\n podName: podAndErrors.pod.metadata?.name ?? 'unknown',\n podNamespace:\n podAndErrors.pod.metadata?.namespace ?? 'unknown',\n cluster: podAndErrors.cluster,\n }}\n containerSpec={containerSpec}\n containerStatus={containerStatus}\n />\n );\n },\n )}\n </ItemCardGrid>\n </Grid>\n {podAndErrors.errors.length > 0 && (\n <Grid item xs={12}>\n <Typography variant=\"h5\">Errors</Typography>\n </Grid>\n )}\n {podAndErrors.errors.length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,oBAAAA,cAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,MAAC,EAAI,EAAA,EAAA,EAAA,+CACZ,UAAW,EAAA,EAAA,OAAA,EAAQ,QAAK,QAAM,CACjC,CAED,EAAA,YAAA,CAAa,OAAO,MAAS,GAAA,CAAA,oBAC3BA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,MAAI,IAAC,EAAA,EAAA,EAAI,EACb,EAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,aAAU,YAAc,EAAA,CAAC,YAAY,CAAG,EAAA,CAC3C,CAEJ,CAEJ;AAAA,GACF;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PodLogs.esm.js","sources":["../../../../src/components/Pods/PodLogs/PodLogs.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 DismissableBanner,\n EmptyState,\n LogViewer,\n} from '@backstage/core-components';\nimport Paper from '@material-ui/core/Paper';\nimport Skeleton from '@material-ui/lab/Skeleton';\n\nimport { ContainerScope } from './types';\nimport { usePodLogs } from './usePodLogs';\n\n/**\n * Props for PodLogs\n *\n * @public\n */\nexport interface PodLogsProps {\n containerScope: ContainerScope;\n previous?: boolean;\n}\n\n/**\n * Shows the logs for the given pod\n *\n * @public\n */\nexport const PodLogs: React.FC<PodLogsProps> = ({\n containerScope,\n previous,\n}: PodLogsProps) => {\n const { value, error, loading } = usePodLogs({\n containerScope,\n previous,\n });\n\n return (\n <>\n {error && (\n <DismissableBanner\n {...{\n message: error.message,\n variant: 'error',\n fixed: false,\n }}\n id=\"pod-logs\"\n />\n )}\n <Paper\n elevation={1}\n style={{ height: '100%', width: '100%', minHeight: '55rem' }}\n >\n {loading && <Skeleton variant=\"rect\" width=\"100%\" height=\"100%\" />}\n {!loading &&\n value !== undefined &&\n (value.text === '' ? (\n <EmptyState\n missing=\"data\"\n title=\"No logs emitted\"\n description=\"No logs were emitted by the container\"\n />\n ) : (\n <LogViewer text={value.text} />\n ))}\n </Paper>\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;AA2CO,MAAM,UAAkC,CAAC;AAAA,EAC9C,cAAA;AAAA,EACA,QAAA;AACF,CAAoB,KAAA;AAClB,EAAA,MAAM,EAAE,KAAA,EAAO,KAAO,EAAA,OAAA,KAAY,UAAW,CAAA;AAAA,IAC3C,cAAA;AAAA,IACA,QAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAA,mFAEK,KACC,oBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,QACF,SAAS,KAAM,CAAA,OAAA;AAAA,QACf,OAAS,EAAA,OAAA;AAAA,QACT,KAAO,EAAA,KAAA;AAAA,OACT;AAAA,MACA,EAAG,EAAA,UAAA;AAAA,KAAA;AAAA,GAGP,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,CAAA;AAAA,MACX,OAAO,EAAE,MAAA,EAAQ,QAAQ,KAAO,EAAA,MAAA,EAAQ,WAAW,OAAQ,EAAA;AAAA,KAAA;AAAA,IAE1D,OAAA,iDAAY,QAAS,EAAA,EAAA,OAAA,EAAQ,QAAO,KAAM,EAAA,MAAA,EAAO,QAAO,MAAO,EAAA,CAAA;AAAA,IAC/D,CAAC,OACA,IAAA,KAAA,KAAU,KACT,CAAA,KAAA,KAAA,CAAM,SAAS,EACd,mBAAAA,cAAA,CAAA,aAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,MAAA;AAAA,QACR,KAAM,EAAA,iBAAA;AAAA,QACN,WAAY,EAAA,uCAAA;AAAA,OAAA;AAAA,KAGd,mBAAAA,cAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,IAAA,EAAM,MAAM,IAAM,EAAA,CAAA,CAAA;AAAA,GAGrC,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"PodLogs.esm.js","sources":["../../../../src/components/Pods/PodLogs/PodLogs.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 DismissableBanner,\n EmptyState,\n LogViewer,\n} from '@backstage/core-components';\nimport Paper from '@material-ui/core/Paper';\nimport Skeleton from '@material-ui/lab/Skeleton';\n\nimport { ContainerScope } from './types';\nimport { usePodLogs } from './usePodLogs';\n\n/**\n * Props for PodLogs\n *\n * @public\n */\nexport interface PodLogsProps {\n containerScope: ContainerScope;\n previous?: boolean;\n}\n\n/**\n * Shows the logs for the given pod\n *\n * @public\n */\nexport const PodLogs: React.FC<PodLogsProps> = ({\n containerScope,\n previous,\n}: PodLogsProps) => {\n const { value, error, loading } = usePodLogs({\n containerScope,\n previous,\n });\n\n return (\n <>\n {error && (\n <DismissableBanner\n {...{\n message: error.message,\n variant: 'error',\n fixed: false,\n }}\n id=\"pod-logs\"\n />\n )}\n <Paper\n elevation={1}\n style={{ height: '100%', width: '100%', minHeight: '55rem' }}\n >\n {loading && <Skeleton variant=\"rect\" width=\"100%\" height=\"100%\" />}\n {!loading &&\n value !== undefined &&\n (value.text === '' ? (\n <EmptyState\n missing=\"data\"\n title=\"No logs emitted\"\n description=\"No logs were emitted by the container\"\n />\n ) : (\n <LogViewer text={value.text} />\n ))}\n </Paper>\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;AA2CO,MAAM,UAAkC,CAAC;AAAA,EAC9C,cAAA;AAAA,EACA;AACF,CAAoB,KAAA;AAClB,EAAA,MAAM,EAAE,KAAA,EAAO,KAAO,EAAA,OAAA,KAAY,UAAW,CAAA;AAAA,IAC3C,cAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,mFAEK,KACC,oBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,QACF,SAAS,KAAM,CAAA,OAAA;AAAA,QACf,OAAS,EAAA,OAAA;AAAA,QACT,KAAO,EAAA;AAAA,OACT;AAAA,MACA,EAAG,EAAA;AAAA;AAAA,GAGP,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,CAAA;AAAA,MACX,OAAO,EAAE,MAAA,EAAQ,QAAQ,KAAO,EAAA,MAAA,EAAQ,WAAW,OAAQ;AAAA,KAAA;AAAA,IAE1D,OAAA,iDAAY,QAAS,EAAA,EAAA,OAAA,EAAQ,QAAO,KAAM,EAAA,MAAA,EAAO,QAAO,MAAO,EAAA,CAAA;AAAA,IAC/D,CAAC,OACA,IAAA,KAAA,KAAU,KACT,CAAA,KAAA,KAAA,CAAM,SAAS,EACd,mBAAAA,cAAA,CAAA,aAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,MAAA;AAAA,QACR,KAAM,EAAA,iBAAA;AAAA,QACN,WAAY,EAAA;AAAA;AAAA,KAGd,mBAAAA,cAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,IAAA,EAAM,MAAM,IAAM,EAAA,CAAA;AAAA,GAGrC,CAAA;AAEJ;;;;"}