@backstage/plugin-kubernetes-react 0.3.0-next.0 → 0.3.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @backstage/plugin-kubernetes-react
2
2
 
3
+ ## 0.3.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3c184af: Extracted common dialog component.
8
+ - Updated dependencies
9
+ - @backstage/core-components@0.14.0-next.0
10
+ - @backstage/catalog-model@1.4.4-next.0
11
+ - @backstage/core-plugin-api@1.8.3-next.0
12
+ - @backstage/errors@1.2.3
13
+ - @backstage/types@1.1.1
14
+ - @backstage/plugin-kubernetes-common@0.7.4-next.1
15
+
3
16
  ## 0.3.0-next.0
4
17
 
5
18
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -860,6 +860,6 @@ declare const PodExecTerminal: (props: PodExecTerminalProps) => React__default.J
860
860
  *
861
861
  * @public
862
862
  */
863
- declare const PodExecTerminalDialog: (props: PodExecTerminalProps) => React__default.JSX.Element;
863
+ declare const PodExecTerminalDialog: (props: PodExecTerminalProps) => false | React__default.JSX.Element | undefined;
864
864
 
865
865
  export { AksClusterLinksFormatter, AksKubernetesAuthProvider, Cluster, ClusterContext, ClusterLinksFormatter, ClusterLinksFormatterOptions, ClusterProps, ContainerCard, ContainerCardProps, ContainerScope, CronJobsAccordions, CronJobsAccordionsProps, CustomResources, CustomResourcesProps, DEFAULT_FORMATTER_NAME, DetectedErrorsContext, EksClusterLinksFormatter, ErrorList, ErrorListProps, ErrorMatcher, ErrorPanel, ErrorPanelProps, ErrorReporting, ErrorReportingProps, Events, EventsContent, EventsContentProps, EventsOptions, EventsProps, FixDialog, FixDialogProps, FormatClusterLinkOptions, GkeClusterLinksFormatter, GoogleKubernetesAuthProvider, GroupedResponsesContext, HorizontalPodAutoscalerDrawer, IngressesAccordions, IngressesAccordionsProps, JobsAccordions, JobsAccordionsProps, KubernetesApi, KubernetesAuthProvider, KubernetesAuthProviders, KubernetesAuthProvidersApi, KubernetesBackendClient, KubernetesClusterLinkFormatter, KubernetesClusterLinkFormatterApi, KubernetesDrawer, KubernetesDrawerProps, KubernetesDrawerable, KubernetesObject, KubernetesObjects, KubernetesProxyApi, KubernetesProxyClient, KubernetesStructuredMetadataTableDrawer, KubernetesStructuredMetadataTableDrawerProps, LinkErrorPanel, LinkErrorPanelProps, ManifestYaml, ManifestYamlProps, OidcKubernetesAuthProvider, OpenshiftClusterLinksFormatter, PendingPodContent, PendingPodContentProps, PodAndErrors, PodColumns, PodDrawer, PodDrawerProps, PodExecTerminal, PodExecTerminalDialog, PodExecTerminalProps, PodLogs, PodLogsDialog, PodLogsDialogProps, PodLogsOptions, PodLogsProps, PodMetricsContext, PodMetricsMatcher, PodNamesWithErrorsContext, PodNamesWithMetricsContext, PodScope, PodsTable, PodsTablesProps, READY_COLUMNS, RESOURCE_COLUMNS, RancherClusterLinksFormatter, ResourceUtilization, ResourceUtilizationProps, ServerSideKubernetesAuthProvider, ServicesAccordions, ServicesAccordionsProps, StandardClusterLinksFormatter, getDefaultFormatters, kubernetesApiRef, kubernetesAuthProvidersApiRef, kubernetesClusterLinkFormatterApiRef, kubernetesProxyApiRef, useCustomResources, useEvents, useKubernetesObjects, useMatchingErrors, usePodLogs, usePodMetrics };
package/dist/index.esm.js CHANGED
@@ -11,8 +11,8 @@ import { groupResponses } from '@backstage/plugin-kubernetes-common';
11
11
  import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
12
12
  import { LinearGauge, DismissableBanner, EmptyState, LogViewer, StructuredMetadataTable, CodeSnippet, WarningPanel, LinkButton, StatusError, StatusOK, StatusWarning, ItemCardGrid, SubvalueCell, StatusAborted, Table, StatusPending } from '@backstage/core-components';
13
13
  import { DateTime } from 'luxon';
14
- import CloseIcon from '@material-ui/icons/Close';
15
14
  import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
15
+ import CloseIcon from '@material-ui/icons/Close';
16
16
  import 'xterm/css/xterm.css';
17
17
  import { Terminal } from 'xterm';
18
18
  import { FitAddon } from 'xterm-addon-fit';
@@ -853,6 +853,67 @@ const formatMillicores = (value) => {
853
853
  return `${(parseFloat(value.toString()) * 1e3).toFixed(0)}m`;
854
854
  };
855
855
 
856
+ const useStyles$3 = makeStyles(
857
+ (theme) => createStyles({
858
+ dialogPaper: { minHeight: "calc(100% - 64px)" },
859
+ dialogContent: { flexBasis: 0 },
860
+ closeButton: {
861
+ position: "absolute",
862
+ right: theme.spacing(1),
863
+ top: theme.spacing(1),
864
+ color: theme.palette.grey[500]
865
+ }
866
+ })
867
+ );
868
+ const KubernetesDialog = ({
869
+ buttonAriaLabel,
870
+ buttonIcon,
871
+ buttonText,
872
+ children,
873
+ disabled,
874
+ title
875
+ }) => {
876
+ const classes = useStyles$3();
877
+ const [open, setOpen] = useState(false);
878
+ const openDialog = () => {
879
+ setOpen(true);
880
+ };
881
+ const closeDialog = () => {
882
+ setOpen(false);
883
+ };
884
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
885
+ Dialog,
886
+ {
887
+ maxWidth: "xl",
888
+ fullWidth: true,
889
+ open,
890
+ onClose: closeDialog,
891
+ PaperProps: { className: classes.dialogPaper }
892
+ },
893
+ /* @__PURE__ */ React__default.createElement(DialogTitle, { id: "dialog-title" }, title, /* @__PURE__ */ React__default.createElement(
894
+ IconButton,
895
+ {
896
+ "aria-label": "close",
897
+ className: classes.closeButton,
898
+ onClick: closeDialog
899
+ },
900
+ /* @__PURE__ */ React__default.createElement(CloseIcon, null)
901
+ )),
902
+ /* @__PURE__ */ React__default.createElement(DialogContent, { className: classes.dialogContent }, children)
903
+ ), /* @__PURE__ */ React__default.createElement(
904
+ Button,
905
+ {
906
+ variant: "outlined",
907
+ "aria-label": buttonAriaLabel,
908
+ component: "label",
909
+ disabled,
910
+ onClick: openDialog,
911
+ startIcon: buttonIcon
912
+ },
913
+ buttonText
914
+ ));
915
+ };
916
+
856
917
  var __accessCheck = (obj, member, msg) => {
857
918
  if (!member.has(obj))
858
919
  throw TypeError("Cannot " + msg);
@@ -890,7 +951,7 @@ class PodExecTerminalAttachAddon extends AttachAddon {
890
951
  _textEncoder = new WeakMap();
891
952
 
892
953
  const hasSocketProtocol = (url) => /wss?:\/\//.test(url.toString());
893
- const useStyles$4 = makeStyles(
954
+ const useStyles$2 = makeStyles(
894
955
  (theme) => createStyles({
895
956
  podExecTerminal: {
896
957
  width: "100%",
@@ -900,7 +961,7 @@ const useStyles$4 = makeStyles(
900
961
  })
901
962
  );
902
963
  const PodExecTerminal = (props) => {
903
- const classes = useStyles$4();
964
+ const classes = useStyles$2();
904
965
  const { containerName, podNamespace, podName } = props;
905
966
  const [baseUrl, setBaseUrl] = useState(window.location.host);
906
967
  const terminalRef = React__default.useRef(null);
@@ -967,60 +1028,20 @@ const PodExecTerminal = (props) => {
967
1028
  );
968
1029
  };
969
1030
 
970
- const useStyles$3 = makeStyles(
971
- (theme) => createStyles({
972
- dialogPaper: { minHeight: "calc(100% - 64px)" },
973
- dialogContent: { flexBasis: 0 },
974
- closeButton: {
975
- position: "absolute",
976
- right: theme.spacing(1),
977
- top: theme.spacing(1),
978
- color: theme.palette.grey[500]
979
- }
980
- })
981
- );
982
1031
  const PodExecTerminalDialog = (props) => {
983
- const classes = useStyles$3();
984
1032
  const { clusterName, containerName, podName } = props;
985
- const [open, setOpen] = useState(false);
986
1033
  const isPodExecTerminalSupported = useIsPodExecTerminalSupported();
987
- const openDialog = () => {
988
- setOpen(true);
989
- };
990
- const closeDialog = () => {
991
- setOpen(false);
992
- };
993
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, !isPodExecTerminalSupported.loading && isPodExecTerminalSupported.value && /* @__PURE__ */ React__default.createElement(
994
- Dialog,
995
- {
996
- maxWidth: false,
997
- fullWidth: true,
998
- open,
999
- onClose: closeDialog,
1000
- PaperProps: { className: classes.dialogPaper }
1001
- },
1002
- /* @__PURE__ */ React__default.createElement(DialogTitle, { id: "dialog-title" }, podName, " - ", containerName, " terminal shell on cluster", " ", clusterName, /* @__PURE__ */ React__default.createElement(
1003
- IconButton,
1004
- {
1005
- "aria-label": "close",
1006
- className: classes.closeButton,
1007
- onClick: closeDialog
1008
- },
1009
- /* @__PURE__ */ React__default.createElement(CloseIcon, null)
1010
- )),
1011
- /* @__PURE__ */ React__default.createElement(DialogContent, { className: classes.dialogContent }, /* @__PURE__ */ React__default.createElement(PodExecTerminal, { ...props }))
1012
- ), /* @__PURE__ */ React__default.createElement(
1013
- Button,
1034
+ return !isPodExecTerminalSupported.loading && isPodExecTerminalSupported.value && /* @__PURE__ */ React__default.createElement(
1035
+ KubernetesDialog,
1014
1036
  {
1015
- variant: "outlined",
1016
- "aria-label": "open terminal",
1017
- component: "label",
1037
+ buttonAriaLabel: "open terminal",
1038
+ buttonIcon: /* @__PURE__ */ React__default.createElement(OpenInBrowserIcon, null),
1039
+ buttonText: "Terminal",
1018
1040
  disabled: isPodExecTerminalSupported.loading || !isPodExecTerminalSupported.value,
1019
- onClick: openDialog,
1020
- startIcon: /* @__PURE__ */ React__default.createElement(OpenInBrowserIcon, null)
1041
+ title: `${podName} - ${containerName} terminal shell on cluster ${clusterName}`
1021
1042
  },
1022
- "Terminal"
1023
- ));
1043
+ /* @__PURE__ */ React__default.createElement(PodExecTerminal, { ...props })
1044
+ );
1024
1045
  };
1025
1046
 
1026
1047
  const getProgressColor = ({
@@ -1114,44 +1135,18 @@ const PodLogs = ({
1114
1135
  ));
1115
1136
  };
1116
1137
 
1117
- const useStyles$2 = makeStyles(
1118
- (theme) => createStyles({
1119
- closeButton: {
1120
- position: "absolute",
1121
- right: theme.spacing(1),
1122
- top: theme.spacing(1),
1123
- color: theme.palette.grey[500]
1124
- }
1125
- })
1126
- );
1127
1138
  const PodLogsDialog = ({ containerScope }) => {
1128
- const classes = useStyles$2();
1129
- const [open, setOpen] = useState(false);
1130
- const openDialog = () => {
1131
- setOpen(true);
1132
- };
1133
- const closeDialog = () => {
1134
- setOpen(false);
1135
- };
1136
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Dialog, { maxWidth: "xl", fullWidth: true, open, onClose: closeDialog }, /* @__PURE__ */ React__default.createElement(DialogTitle, { id: "dialog-title" }, containerScope.podName, " - ", containerScope.containerName, " logs on cluster ", containerScope.clusterName, /* @__PURE__ */ React__default.createElement(
1137
- IconButton,
1138
- {
1139
- "aria-label": "close",
1140
- className: classes.closeButton,
1141
- onClick: closeDialog
1142
- },
1143
- /* @__PURE__ */ React__default.createElement(CloseIcon, null)
1144
- )), /* @__PURE__ */ React__default.createElement(DialogContent, null, /* @__PURE__ */ React__default.createElement(PodLogs, { containerScope }))), /* @__PURE__ */ React__default.createElement(
1145
- Button,
1139
+ return /* @__PURE__ */ React__default.createElement(
1140
+ KubernetesDialog,
1146
1141
  {
1147
- variant: "outlined",
1148
- "aria-label": "get logs",
1149
- component: "label",
1150
- onClick: openDialog,
1151
- startIcon: /* @__PURE__ */ React__default.createElement(SubjectIcon, null)
1142
+ buttonAriaLabel: "get logs",
1143
+ buttonIcon: /* @__PURE__ */ React__default.createElement(SubjectIcon, null),
1144
+ buttonText: "Logs",
1145
+ disabled: false,
1146
+ title: `${containerScope.podName} - ${containerScope.containerName} logs on cluster ${containerScope.clusterName}`
1152
1147
  },
1153
- "Logs"
1154
- ));
1148
+ /* @__PURE__ */ React__default.createElement(PodLogs, { containerScope })
1149
+ );
1155
1150
  };
1156
1151
 
1157
1152
  const getContainerHealthChecks = (containerSpec, containerStatus) => {