@backstage/plugin-kubernetes-react 0.5.0-next.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +30 -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 +1 -1
  22. package/dist/components/CustomResources/ArgoRollouts/Rollout.esm.js.map +1 -1
  23. package/dist/components/CustomResources/ArgoRollouts/RolloutDrawer.esm.js.map +1 -1
  24. package/dist/components/CustomResources/ArgoRollouts/StepsProgress.esm.js.map +1 -1
  25. package/dist/components/CustomResources/CustomResources.esm.js.map +1 -1
  26. package/dist/components/CustomResources/DefaultCustomResource.esm.js.map +1 -1
  27. package/dist/components/CustomResources/DefaultCustomResourceDrawer.esm.js.map +1 -1
  28. package/dist/components/DaemonSetsAccordions/DaemonSetsAccordions.esm.js.map +1 -1
  29. package/dist/components/DaemonSetsAccordions/DaemonSetsDrawer.esm.js.map +1 -1
  30. package/dist/components/DeploymentsAccordions/DeploymentDrawer.esm.js.map +1 -1
  31. package/dist/components/DeploymentsAccordions/DeploymentsAccordions.esm.js +1 -1
  32. package/dist/components/DeploymentsAccordions/DeploymentsAccordions.esm.js.map +1 -1
  33. package/dist/components/ErrorPanel/ErrorPanel.esm.js.map +1 -1
  34. package/dist/components/ErrorReporting/ErrorReporting.esm.js.map +1 -1
  35. package/dist/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.esm.js.map +1 -1
  36. package/dist/components/IngressesAccordions/IngressDrawer.esm.js.map +1 -1
  37. package/dist/components/IngressesAccordions/IngressesAccordions.esm.js.map +1 -1
  38. package/dist/components/JobsAccordions/JobsAccordions.esm.js.map +1 -1
  39. package/dist/components/JobsAccordions/JobsDrawer.esm.js.map +1 -1
  40. package/dist/components/KubernetesDialog/KubernetesDialog.esm.js.map +1 -1
  41. package/dist/components/KubernetesDrawer/KubernetesDrawer.esm.js.map +1 -1
  42. package/dist/components/KubernetesDrawer/KubernetesStructuredMetadataTableDrawer.esm.js.map +1 -1
  43. package/dist/components/KubernetesDrawer/ManifestYaml.esm.js.map +1 -1
  44. package/dist/components/PodExecTerminal/PodExecTerminal.esm.js.map +1 -1
  45. package/dist/components/PodExecTerminal/PodExecTerminalAttachAddon.esm.js.map +1 -1
  46. package/dist/components/PodExecTerminal/PodExecTerminalDialog.esm.js.map +1 -1
  47. package/dist/components/Pods/ErrorList/ErrorList.esm.js.map +1 -1
  48. package/dist/components/Pods/Events/Events.esm.js +2 -2
  49. package/dist/components/Pods/Events/Events.esm.js.map +1 -1
  50. package/dist/components/Pods/Events/useEvents.esm.js.map +1 -1
  51. package/dist/components/Pods/FixDialog/FixDialog.esm.js.map +1 -1
  52. package/dist/components/Pods/PodDelete/PodDeleteButton.esm.js +50 -0
  53. package/dist/components/Pods/PodDelete/PodDeleteButton.esm.js.map +1 -0
  54. package/dist/components/Pods/PodDelete/usePodDelete.esm.js +21 -0
  55. package/dist/components/Pods/PodDelete/usePodDelete.esm.js.map +1 -0
  56. package/dist/components/Pods/PodDrawer/ContainerCard.esm.js +1 -1
  57. package/dist/components/Pods/PodDrawer/ContainerCard.esm.js.map +1 -1
  58. package/dist/components/Pods/PodDrawer/PendingPodContent.esm.js.map +1 -1
  59. package/dist/components/Pods/PodDrawer/PodDrawer.esm.js +24 -1
  60. package/dist/components/Pods/PodDrawer/PodDrawer.esm.js.map +1 -1
  61. package/dist/components/Pods/PodLogs/PodLogs.esm.js.map +1 -1
  62. package/dist/components/Pods/PodLogs/PodLogsDialog.esm.js.map +1 -1
  63. package/dist/components/Pods/PodLogs/usePodLogs.esm.js.map +1 -1
  64. package/dist/components/Pods/PodsTable.esm.js +1 -1
  65. package/dist/components/Pods/PodsTable.esm.js.map +1 -1
  66. package/dist/components/ResourceUtilization/ResourceUtilization.esm.js.map +1 -1
  67. package/dist/components/ServicesAccordions/ServiceDrawer.esm.js.map +1 -1
  68. package/dist/components/ServicesAccordions/ServicesAccordions.esm.js.map +1 -1
  69. package/dist/components/StatefulSetsAccordions/StatefulSetDrawer.esm.js.map +1 -1
  70. package/dist/components/StatefulSetsAccordions/StatefulSetsAccordions.esm.js +1 -1
  71. package/dist/components/StatefulSetsAccordions/StatefulSetsAccordions.esm.js.map +1 -1
  72. package/dist/hooks/Cluster.esm.js.map +1 -1
  73. package/dist/hooks/GroupedResponses.esm.js.map +1 -1
  74. package/dist/hooks/PodNamesWithErrors.esm.js.map +1 -1
  75. package/dist/hooks/auth.esm.js.map +1 -1
  76. package/dist/hooks/useCustomResources.esm.js.map +1 -1
  77. package/dist/hooks/useIsPodDeleteEnabled.esm.js +9 -0
  78. package/dist/hooks/useIsPodDeleteEnabled.esm.js.map +1 -0
  79. package/dist/hooks/useIsPodExecTerminalEnabled.esm.js.map +1 -1
  80. package/dist/hooks/useIsPodExecTerminalSupported.esm.js.map +1 -1
  81. package/dist/hooks/useKubernetesObjects.esm.js.map +1 -1
  82. package/dist/hooks/useMatchingErrors.esm.js.map +1 -1
  83. package/dist/hooks/usePodMetrics.esm.js.map +1 -1
  84. package/dist/index.d.ts +14 -0
  85. package/dist/index.esm.js +1 -0
  86. package/dist/index.esm.js.map +1 -1
  87. package/dist/kubernetes-auth-provider/AksKubernetesAuthProvider.esm.js.map +1 -1
  88. package/dist/kubernetes-auth-provider/GoogleKubernetesAuthProvider.esm.js.map +1 -1
  89. package/dist/kubernetes-auth-provider/KubernetesAuthProviders.esm.js.map +1 -1
  90. package/dist/kubernetes-auth-provider/OidcKubernetesAuthProvider.esm.js.map +1 -1
  91. package/dist/kubernetes-auth-provider/ServerSideAuthProvider.esm.js.map +1 -1
  92. package/dist/kubernetes-auth-provider/types.esm.js.map +1 -1
  93. package/dist/translation.esm.js +15 -0
  94. package/dist/translation.esm.js.map +1 -0
  95. package/dist/utils/crons.esm.js.map +1 -1
  96. package/dist/utils/owner.esm.js.map +1 -1
  97. package/dist/utils/pod.esm.js +1 -1
  98. package/dist/utils/pod.esm.js.map +1 -1
  99. package/dist/utils/resources.esm.js.map +1 -1
  100. package/package.json +36 -15
@@ -1 +1 @@
1
- {"version":3,"file":"KubernetesStructuredMetadataTableDrawer.esm.js","sources":["../../../src/components/KubernetesDrawer/KubernetesStructuredMetadataTableDrawer.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, { ChangeEvent, useContext, useState } from 'react';\nimport Button from '@material-ui/core/Button';\nimport Typography from '@material-ui/core/Typography';\nimport IconButton from '@material-ui/core/IconButton';\nimport Drawer from '@material-ui/core/Drawer';\nimport Switch from '@material-ui/core/Switch';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles, createStyles, Theme } from '@material-ui/core/styles';\nimport Close from '@material-ui/icons/Close';\nimport OpenInNewIcon from '@material-ui/icons/OpenInNew';\nimport { V1ObjectMeta } from '@kubernetes/client-node';\nimport { withStyles } from '@material-ui/core/styles';\nimport {\n LinkButton as BackstageButton,\n StructuredMetadataTable,\n WarningPanel,\n} from '@backstage/core-components';\nimport { ClusterContext } from '../../hooks';\nimport { ClusterAttributes } from '@backstage/plugin-kubernetes-common';\nimport { ManifestYaml } from './ManifestYaml';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { kubernetesClusterLinkFormatterApiRef } from '../../api';\nimport useAsync from 'react-use/esm/useAsync';\n\nconst useDrawerStyles = makeStyles((theme: Theme) =>\n createStyles({\n paper: {\n width: '50%',\n justifyContent: 'space-between',\n padding: theme.spacing(2.5),\n },\n }),\n);\n\nconst useDrawerContentStyles = makeStyles((_: Theme) =>\n createStyles({\n header: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n errorMessage: {\n marginTop: '1em',\n marginBottom: '1em',\n },\n options: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n icon: {\n fontSize: 20,\n },\n content: {\n height: '80%',\n },\n }),\n);\n\nconst PodDrawerButton = withStyles({\n root: {\n padding: '6px 5px',\n },\n label: {\n textTransform: 'none',\n },\n})(Button);\n\n/**\n *\n *\n * @public\n */\nexport type LinkErrorPanelProps = {\n cluster: ClusterAttributes;\n errorMessage?: string;\n children?: React.ReactNode;\n};\n\n/**\n *\n *\n * @public\n */\nexport const LinkErrorPanel = ({\n cluster,\n errorMessage,\n}: LinkErrorPanelProps) => (\n <WarningPanel\n title=\"There was a problem formatting the link to the Kubernetes dashboard\"\n message={`Could not format the link to the dashboard of your cluster named '${\n cluster.name\n }'. Its dashboardApp property has been set to '${\n cluster.dashboardApp || 'standard'\n }.'`}\n >\n {errorMessage && (\n <Typography variant=\"body2\">Errors: {errorMessage}</Typography>\n )}\n </WarningPanel>\n);\n\n/**\n *\n *\n * @public\n */\nexport interface KubernetesDrawerable {\n metadata?: V1ObjectMeta;\n}\n\ninterface KubernetesStructuredMetadataTableDrawerContentProps<\n T extends KubernetesDrawerable,\n> {\n toggleDrawer: (e: ChangeEvent<{}>, isOpen: boolean) => void;\n object: T;\n renderObject: (obj: T) => object;\n kind: string;\n}\n\nfunction replaceNullsWithUndefined(someObj: any) {\n const replacer = (_: any, value: any) =>\n String(value) === 'null' || String(value) === 'undefined'\n ? undefined\n : value;\n\n return JSON.parse(JSON.stringify(someObj, replacer));\n}\n\nconst KubernetesStructuredMetadataTableDrawerContent = <\n T extends KubernetesDrawerable,\n>({\n toggleDrawer,\n object,\n renderObject,\n kind,\n}: KubernetesStructuredMetadataTableDrawerContentProps<T>) => {\n const [isYaml, setIsYaml] = useState<boolean>(false);\n\n const formatter = useApi(kubernetesClusterLinkFormatterApiRef);\n const classes = useDrawerContentStyles();\n const cluster = useContext(ClusterContext);\n const { value: clusterLink, error } = useAsync(\n async () =>\n formatter.formatClusterLink({\n dashboardUrl: cluster.dashboardUrl,\n dashboardApp: cluster.dashboardApp,\n dashboardParameters: cluster.dashboardParameters,\n object,\n kind,\n }),\n [cluster, object, kind, formatter],\n );\n\n return (\n <>\n <div className={classes.header}>\n <Grid container justifyContent=\"flex-start\" alignItems=\"flex-start\">\n <Grid item xs={11}>\n <Typography variant=\"h5\">\n {object.metadata?.name ?? 'unknown name'}\n </Typography>\n </Grid>\n <Grid item xs={1}>\n <IconButton\n key=\"dismiss\"\n title=\"Close the drawer\"\n onClick={e => toggleDrawer(e, false)}\n color=\"inherit\"\n >\n <Close className={classes.icon} />\n </IconButton>\n </Grid>\n <Grid item xs={11}>\n <Typography color=\"textSecondary\" variant=\"body1\">\n {kind}\n </Typography>\n </Grid>\n <Grid item xs={11}>\n <FormControlLabel\n control={\n <Switch\n checked={isYaml}\n onChange={event => {\n setIsYaml(event.target.checked);\n }}\n name=\"YAML\"\n />\n }\n label=\"YAML\"\n />\n </Grid>\n </Grid>\n </div>\n {error && (\n <div className={classes.errorMessage}>\n <LinkErrorPanel\n cluster={cluster}\n errorMessage={error.message || error.toString()}\n />\n </div>\n )}\n <div className={classes.options}>\n <div>\n {clusterLink && (\n <BackstageButton\n variant=\"outlined\"\n color=\"primary\"\n size=\"small\"\n to={clusterLink}\n endIcon={<OpenInNewIcon />}\n >\n Open Kubernetes Dashboard\n </BackstageButton>\n )}\n </div>\n </div>\n <div className={classes.content}>\n {isYaml && <ManifestYaml object={object} />}\n {!isYaml && (\n <StructuredMetadataTable\n metadata={renderObject(replaceNullsWithUndefined(object))}\n />\n )}\n </div>\n </>\n );\n};\n\n/**\n *\n * @public\n */\nexport interface KubernetesStructuredMetadataTableDrawerProps<\n T extends KubernetesDrawerable,\n> {\n object: T;\n renderObject: (obj: T) => object;\n buttonVariant?: 'h5' | 'subtitle2';\n kind: string;\n expanded?: boolean;\n children?: React.ReactNode;\n}\n\n/**\n *\n * @public\n */\nexport const KubernetesStructuredMetadataTableDrawer = <\n T extends KubernetesDrawerable,\n>({\n object,\n renderObject,\n kind,\n buttonVariant = 'subtitle2',\n expanded = false,\n children,\n}: KubernetesStructuredMetadataTableDrawerProps<T>) => {\n const [isOpen, setIsOpen] = useState(expanded);\n const classes = useDrawerStyles();\n\n const toggleDrawer = (e: ChangeEvent<{}>, newValue: boolean) => {\n e.stopPropagation();\n setIsOpen(newValue);\n };\n\n return (\n <>\n <PodDrawerButton\n onClick={e => toggleDrawer(e, true)}\n onFocus={event => event.stopPropagation()}\n >\n {children === undefined ? (\n <Typography variant={buttonVariant}>\n {object.metadata?.name ?? 'unknown object'}\n </Typography>\n ) : (\n children\n )}\n </PodDrawerButton>\n <Drawer\n classes={{\n paper: classes.paper,\n }}\n anchor=\"right\"\n open={isOpen}\n onClose={(e: any) => toggleDrawer(e, false)}\n onClick={event => event.stopPropagation()}\n >\n <KubernetesStructuredMetadataTableDrawerContent\n kind={kind}\n toggleDrawer={toggleDrawer}\n object={object}\n renderObject={renderObject}\n />\n </Drawer>\n </>\n );\n};\n"],"names":["React","Close","BackstageButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,eAAkB,GAAA,UAAA;AAAA,EAAW,CAAC,UAClC,YAAa,CAAA;AAAA,IACX,KAAO,EAAA;AAAA,MACL,KAAO,EAAA,KAAA;AAAA,MACP,cAAgB,EAAA,eAAA;AAAA,MAChB,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,KAC5B;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAEA,MAAM,sBAAyB,GAAA,UAAA;AAAA,EAAW,CAAC,MACzC,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,YAAc,EAAA;AAAA,MACZ,SAAW,EAAA,KAAA;AAAA,MACX,YAAc,EAAA,KAAA;AAAA,KAChB;AAAA,IACA,OAAS,EAAA;AAAA,MACP,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,cAAgB,EAAA,eAAA;AAAA,KAClB;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,QAAU,EAAA,EAAA;AAAA,KACZ;AAAA,IACA,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA,KAAA;AAAA,KACV;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAEA,MAAM,kBAAkB,UAAW,CAAA;AAAA,EACjC,IAAM,EAAA;AAAA,IACJ,OAAS,EAAA,SAAA;AAAA,GACX;A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AAa,KACZ,CAAA,mBAAAA,cAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAS,iBAClB,MAAO,CAAA,QAAA,EAAU,IAAQ,IAAA,gBAC5B,CAEA,GAAA,QAAA;AAAA,GAGJ,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA;AAAA,QACP,OAAO,OAAQ,CAAA,KAAA;AAAA,OACjB;AAAA,MACA,MAAO,EAAA,OAAA;AAAA,MACP,IAAM,EAAA,MAAA;AAAA,MACN,OAAS,EAAA,CAAC,CAAW,KAAA,YAAA,CAAa,GAAG,KAAK,CAAA;AAAA,MAC1C,OAAA,EAAS,CAAS,KAAA,KAAA,KAAA,CAAM,eAAgB,EAAA;AAAA,KAAA;AAAA,oBAExCA,cAAA,CAAA,aAAA;AAAA,MAAC,8CAAA;AAAA,MAAA;AAAA,QACC,IAAA;AAAA,QACA,YAAA;AAAA,QACA,MAAA;AAAA,QACA,YAAA;AAAA,OAAA;AAAA,KACF;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"KubernetesStructuredMetadataTableDrawer.esm.js","sources":["../../../src/components/KubernetesDrawer/KubernetesStructuredMetadataTableDrawer.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, { ChangeEvent, useContext, useState } from 'react';\nimport Button from '@material-ui/core/Button';\nimport Typography from '@material-ui/core/Typography';\nimport IconButton from '@material-ui/core/IconButton';\nimport Drawer from '@material-ui/core/Drawer';\nimport Switch from '@material-ui/core/Switch';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles, createStyles, Theme } from '@material-ui/core/styles';\nimport Close from '@material-ui/icons/Close';\nimport OpenInNewIcon from '@material-ui/icons/OpenInNew';\nimport { V1ObjectMeta } from '@kubernetes/client-node';\nimport { withStyles } from '@material-ui/core/styles';\nimport {\n LinkButton as BackstageButton,\n StructuredMetadataTable,\n WarningPanel,\n} from '@backstage/core-components';\nimport { ClusterContext } from '../../hooks';\nimport { ClusterAttributes } from '@backstage/plugin-kubernetes-common';\nimport { ManifestYaml } from './ManifestYaml';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { kubernetesClusterLinkFormatterApiRef } from '../../api';\nimport useAsync from 'react-use/esm/useAsync';\n\nconst useDrawerStyles = makeStyles((theme: Theme) =>\n createStyles({\n paper: {\n width: '50%',\n justifyContent: 'space-between',\n padding: theme.spacing(2.5),\n },\n }),\n);\n\nconst useDrawerContentStyles = makeStyles((_: Theme) =>\n createStyles({\n header: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n errorMessage: {\n marginTop: '1em',\n marginBottom: '1em',\n },\n options: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'space-between',\n },\n icon: {\n fontSize: 20,\n },\n content: {\n height: '80%',\n },\n }),\n);\n\nconst PodDrawerButton = withStyles({\n root: {\n padding: '6px 5px',\n },\n label: {\n textTransform: 'none',\n },\n})(Button);\n\n/**\n *\n *\n * @public\n */\nexport type LinkErrorPanelProps = {\n cluster: ClusterAttributes;\n errorMessage?: string;\n children?: React.ReactNode;\n};\n\n/**\n *\n *\n * @public\n */\nexport const LinkErrorPanel = ({\n cluster,\n errorMessage,\n}: LinkErrorPanelProps) => (\n <WarningPanel\n title=\"There was a problem formatting the link to the Kubernetes dashboard\"\n message={`Could not format the link to the dashboard of your cluster named '${\n cluster.name\n }'. Its dashboardApp property has been set to '${\n cluster.dashboardApp || 'standard'\n }.'`}\n >\n {errorMessage && (\n <Typography variant=\"body2\">Errors: {errorMessage}</Typography>\n )}\n </WarningPanel>\n);\n\n/**\n *\n *\n * @public\n */\nexport interface KubernetesDrawerable {\n metadata?: V1ObjectMeta;\n}\n\ninterface KubernetesStructuredMetadataTableDrawerContentProps<\n T extends KubernetesDrawerable,\n> {\n toggleDrawer: (e: ChangeEvent<{}>, isOpen: boolean) => void;\n object: T;\n renderObject: (obj: T) => object;\n kind: string;\n}\n\nfunction replaceNullsWithUndefined(someObj: any) {\n const replacer = (_: any, value: any) =>\n String(value) === 'null' || String(value) === 'undefined'\n ? undefined\n : value;\n\n return JSON.parse(JSON.stringify(someObj, replacer));\n}\n\nconst KubernetesStructuredMetadataTableDrawerContent = <\n T extends KubernetesDrawerable,\n>({\n toggleDrawer,\n object,\n renderObject,\n kind,\n}: KubernetesStructuredMetadataTableDrawerContentProps<T>) => {\n const [isYaml, setIsYaml] = useState<boolean>(false);\n\n const formatter = useApi(kubernetesClusterLinkFormatterApiRef);\n const classes = useDrawerContentStyles();\n const cluster = useContext(ClusterContext);\n const { value: clusterLink, error } = useAsync(\n async () =>\n formatter.formatClusterLink({\n dashboardUrl: cluster.dashboardUrl,\n dashboardApp: cluster.dashboardApp,\n dashboardParameters: cluster.dashboardParameters,\n object,\n kind,\n }),\n [cluster, object, kind, formatter],\n );\n\n return (\n <>\n <div className={classes.header}>\n <Grid container justifyContent=\"flex-start\" alignItems=\"flex-start\">\n <Grid item xs={11}>\n <Typography variant=\"h5\">\n {object.metadata?.name ?? 'unknown name'}\n </Typography>\n </Grid>\n <Grid item xs={1}>\n <IconButton\n key=\"dismiss\"\n title=\"Close the drawer\"\n onClick={e => toggleDrawer(e, false)}\n color=\"inherit\"\n >\n <Close className={classes.icon} />\n </IconButton>\n </Grid>\n <Grid item xs={11}>\n <Typography color=\"textSecondary\" variant=\"body1\">\n {kind}\n </Typography>\n </Grid>\n <Grid item xs={11}>\n <FormControlLabel\n control={\n <Switch\n checked={isYaml}\n onChange={event => {\n setIsYaml(event.target.checked);\n }}\n name=\"YAML\"\n />\n }\n label=\"YAML\"\n />\n </Grid>\n </Grid>\n </div>\n {error && (\n <div className={classes.errorMessage}>\n <LinkErrorPanel\n cluster={cluster}\n errorMessage={error.message || error.toString()}\n />\n </div>\n )}\n <div className={classes.options}>\n <div>\n {clusterLink && (\n <BackstageButton\n variant=\"outlined\"\n color=\"primary\"\n size=\"small\"\n to={clusterLink}\n endIcon={<OpenInNewIcon />}\n >\n Open Kubernetes Dashboard\n </BackstageButton>\n )}\n </div>\n </div>\n <div className={classes.content}>\n {isYaml && <ManifestYaml object={object} />}\n {!isYaml && (\n <StructuredMetadataTable\n metadata={renderObject(replaceNullsWithUndefined(object))}\n />\n )}\n </div>\n </>\n );\n};\n\n/**\n *\n * @public\n */\nexport interface KubernetesStructuredMetadataTableDrawerProps<\n T extends KubernetesDrawerable,\n> {\n object: T;\n renderObject: (obj: T) => object;\n buttonVariant?: 'h5' | 'subtitle2';\n kind: string;\n expanded?: boolean;\n children?: React.ReactNode;\n}\n\n/**\n *\n * @public\n */\nexport const KubernetesStructuredMetadataTableDrawer = <\n T extends KubernetesDrawerable,\n>({\n object,\n renderObject,\n kind,\n buttonVariant = 'subtitle2',\n expanded = false,\n children,\n}: KubernetesStructuredMetadataTableDrawerProps<T>) => {\n const [isOpen, setIsOpen] = useState(expanded);\n const classes = useDrawerStyles();\n\n const toggleDrawer = (e: ChangeEvent<{}>, newValue: boolean) => {\n e.stopPropagation();\n setIsOpen(newValue);\n };\n\n return (\n <>\n <PodDrawerButton\n onClick={e => toggleDrawer(e, true)}\n onFocus={event => event.stopPropagation()}\n >\n {children === undefined ? (\n <Typography variant={buttonVariant}>\n {object.metadata?.name ?? 'unknown object'}\n </Typography>\n ) : (\n children\n )}\n </PodDrawerButton>\n <Drawer\n classes={{\n paper: classes.paper,\n }}\n anchor=\"right\"\n open={isOpen}\n onClose={(e: any) => toggleDrawer(e, false)}\n onClick={event => event.stopPropagation()}\n >\n <KubernetesStructuredMetadataTableDrawerContent\n kind={kind}\n toggleDrawer={toggleDrawer}\n object={object}\n renderObject={renderObject}\n />\n </Drawer>\n </>\n );\n};\n"],"names":["React","Close","BackstageButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,eAAkB,GAAA,UAAA;AAAA,EAAW,CAAC,UAClC,YAAa,CAAA;AAAA,IACX,KAAO,EAAA;AAAA,MACL,KAAO,EAAA,KAAA;AAAA,MACP,cAAgB,EAAA,eAAA;AAAA,MAChB,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,GAAG;AAAA;AAC5B,GACD;AACH,CAAA;AAEA,MAAM,sBAAyB,GAAA,UAAA;AAAA,EAAW,CAAC,MACzC,YAAa,CAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,cAAgB,EAAA;AAAA,KAClB;AAAA,IACA,YAAc,EAAA;AAAA,MACZ,SAAW,EAAA,KAAA;AAAA,MACX,YAAc,EAAA;AAAA,KAChB;AAAA,IACA,OAAS,EAAA;AAAA,MACP,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,cAAgB,EAAA;AAAA,KAClB;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,QAAU,EAAA;AAAA,KACZ;AAAA,IACA,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA;AAAA;AACV,GACD;AACH,CAAA;AAEA,MAAM,kBAAkB,UAAW,CAAA;AAAA,EACjC,IAAM,EAAA;AAAA,IACJ,OAAS,EAAA;AAAA,GACX;AAAA,EACA,KAAO,EAAA;AAAA,IACL,aAAe,EAAA;AAAA;AAEnB,CAAC,EAAE,MAAM,CAAA;AAkBF,MAAM,iBAAiB,CAAC;AAAA,EAC7B,OAAA;AAAA,EACA;AACF,CACE,qBAAAA,cAAA,CAAA,aAAA;AAAA,EAAC,YAAA;AAA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S,KAAA,KAAA,KAAA,CAAM,eAAgB;AAAA,KAAA;AAAA,oBAExCA,cAAA,CAAA,aAAA;AAAA,MAAC,8CAAA;AAAA,MAAA;AAAA,QACC,IAAA;AAAA,QACA,YAAA;AAAA,QACA,MAAA;AAAA,QACA;AAAA;AAAA;AACF,GAEJ,CAAA;AAEJ;;;;"}
@@ -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,eAAA,GAAkB,CAAC,KAAgC,KAAA;AAC9D,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,EAAE,aAAA,EAAe,YAAc,EAAA,OAAA,EAAY,GAAA,KAAA,CAAA;AAEjD,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,IAAI,QAAS,CAAA,MAAA,CAAO,SAAS,IAAI,CAAA,CAAA;AAE3D,EAAM,MAAA,WAAA,GAAcA,cAAM,CAAA,MAAA,CAAO,IAAI,CAAA,CAAA;AACrC,EAAM,MAAA,YAAA,GAAe,OAAO,eAAe,CAAA,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AAA;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=\"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;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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S,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,C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A,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,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;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;AAAA;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;AAAA;AAAA,SAE3C,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,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MAAC,YAAA;AAAA,MAAA;AAAA,QACC,OAAS,EAAA,CAAA,YAAA,EAAe,OAAO,CAAA,SAAA,EAAY,MAAM,KAAK,CAAA,CAAA,CAAA;AAAA,QACtD,WAAW,CAAG,EAAA,KAAA,CAAM,MAAM,CAAA,EAAA,EAAK,MAAM,OAAO,CAAA,CAAA;AAAA,OAAA;AAAA,KAEhD,CAAA,CAAA;AAAA,GAEH,CACL,CACF,CACF,CAAA,CAAA;AAEJ,EAAA;AAmBO,MAAM,SAAS,CAAC;AAAA,EACrB,kBAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,iBAAA;AACF,CAAmB,KAAA;AACjB,EAAA,MAAM,EAAE,KAAA,EAAO,KAAO,EAAA,OAAA,KAAY,SAAU,CAAA;AAAA,IAC1C,kBAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;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,QAAA;AAAA,KAAA;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,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,SAAA,mBAAaA,cAAA,CAAA,aAAA,CAAA,WAAA,EAAA,IAAY,CAAK,mBAAAA,cAAA,CAAA,aAAA,CAAC,QAAS,EAAA,IAAA,CAAG,CAC/D,CAAA;AAEJ,CAAA;AAOO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,MAAA;AAAA,EACA;AACF,CAA0B,KAAA;AACxB,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAO,uBAAAA,cAAA,CAAA,aAAA,CAAC,kBAAW,iBAAe,CAAA;AAAA;AAGpC,EACE,uBAAAA,cAAA,CAAA,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AAU,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,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,CAAA;AAAA,KAC/B;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAmBO,MAAM,YAAsC,CAAC;AAAA,E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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,OAA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,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;AAAA,KAAA;AAAA,iDAER,SAAU,EAAA,IAAA;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;AAAA,KAAA;AAAA,IACL;AAAA,GAIL,CACF,CACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,50 @@
1
+ import React__default, { useState } from 'react';
2
+ 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,KA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ACF,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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AAA;AAAA,IAAA;AAAA,MACC,UAAU,EAAA,IAAA;AAAA,MACV,KAAM,EAAA,iBAAA;AAAA,MACN,KAAA,EAAO,iBAAiB,WAAY,CAAA,YAAA;AAAA,MACpC,KAAA,EAAO,iBAAiB,WAAY,CAAA,YAAA;AAAA,MACpC,cAAgB,EAAA,UAAA;AAAA,QACd,iBAAiB,WAAY,CAAA,YAAA;AAAA,OAC/B;AAAA,KAAA;AAAA,GAEF,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACC,UAAU,EAAA,IAAA;AAAA,MACV,KAAM,EAAA,eAAA;AAAA,MACN,KAAA,EAAO,iBAAiB,WAAY,CAAA,YAAA;AAAA,MACpC,KAAA,EAAO,iBAAiB,WAAY,CAAA,UAAA;AAAA,MACpC,cAAgB,EAAA,UAAA;AAAA,QACd,iBAAiB,WAAY,CAAA,UAAA;AAAA,OAC/B;AAAA,KAAA;AAAA,GAEJ,CACF,CAEJ,CACF,CAAA,+CACC,WACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,cAAgB,EAAA;AAAA,QACd,eAAe,eAAgB,CAAA,IAAA;AAAA,QAC/B,GAAG,QAAA;AAAA,OACL;AAAA,KAAA;AAAA,KAED,wBACC,oBAAAA,cAAA,CAAA,aAAA;AAAA,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 )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AAAA,GAEF,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACC,UAAU,EAAA,IAAA;AAAA,MACV,KAAM,EAAA,iBAAA;AAAA,MACN,KAAA,EAAO,iBAAiB,WAAY,CAAA,YAAA;AAAA,MACpC,KAAA,EAAO,iBAAiB,WAAY,CAAA,YAAA;AAAA,MACpC,cAAgB,EAAA,UAAA;AAAA,QACd,iBAAiB,WAAY,CAAA;AAAA;AAC/B;AAAA,GAEF,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACC,UAAU,EAAA,IAAA;AAAA,MACV,KAAM,EAAA,eAAA;AAAA,MACN,KAAA,EAAO,iBAAiB,WAAY,CAAA,YAAA;AAAA,MACpC,KAAA,EAAO,iBAAiB,WAAY,CAAA,UAAA;AAAA,MACpC,cAAgB,EAAA,UAAA;AAAA,QACd,iBAAiB,WAAY,CAAA;AAAA;AAC/B;AAAA,GAEJ,CACF,CAEJ,CACF,CAAA,+CACC,WACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,cAAgB,EAAA;AAAA,QACd,eAAe,eAAgB,CAAA,IAAA;AAAA,QAC/B,GAAG;AAAA;AACL;AAAA,KAED,wBACC,oBAAAA,cAAA,CAAA,aAAA;AAAA,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,kBAAA,IACT,SAAS,OAAQ,CAAA,SAAA,CAAU,kBAAkB,CAAA,CAAE,UAAW,CAAA;AAAA,IACxD,MAAQ,EAAA,IAAA;AAAA,GACT,CAAE,EAAA,GAEP,GAED,SAAU,CAAA,MAAA,KAAW,6BACnBA,cAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAA,EACE,UAAU,IAAK,EAAA,MAAA,EACf,UAAU,kBACT,IAAA,QAAA,CAAS,QAAQ,SAAU,CAAA,kBAAkB,EAAE,UAAW,CAAA;AAAA,IACxD,MAAQ,EAAA,IAAA;AAAA,GACT,CAAA,EAAE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Content.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,cAAA,CAAA,aAAA,CAAC,gBACE,SAAU,CAAA,IAAA,EAAK,QACf,SAAU,CAAA,kBAAA,IACT,SAAS,OAAQ,CAAA,SAAA,CAAU,kBAAkB,CAAA,CAAE,UAAW,CAAA;AAAA,IACxD,MAAQ,EAAA;AAAA,GACT,CAAE,EAAA,GAEP,GAED,SAAU,CAAA,MAAA,KAAW,6BACnBA,cAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAA,EACE,UAAU,IAAK,EAAA,MAAA,EACf,UAAU,kBACT,IAAA,QAAA,CAAS,QAAQ,SAAU,CAAA,kBAAkB,EA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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",