@cloudtower/eagle 0.33.16 → 0.33.17

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.
@@ -0,0 +1,20 @@
1
+ import { styled } from '@linaria/react';
2
+
3
+ const KubeConfigModalStyle = "E_kr6am0s";
4
+ const KubeConfigWrapperStyle = "E_k1h3cl5q";
5
+ const KubeConfigTitleStyle = "E_k1a6j97w";
6
+ const KubeConfigTipStyle = "E_k1uim1fg";
7
+ const KubeConfigContentStyle = "E_kobelzt";
8
+ const KubeConfigFooterStyle = "E_kxzv3id";
9
+ const ErrorWrapper = /*#__PURE__*/styled('div')({
10
+ name: "ErrorWrapper",
11
+ class: "E_eld9lt",
12
+ propsAsIs: false
13
+ });
14
+ const ErrorContentWrapper = /*#__PURE__*/styled('div')({
15
+ name: "ErrorContentWrapper",
16
+ class: "E_e1505fqc",
17
+ propsAsIs: false
18
+ });
19
+
20
+ export { ErrorContentWrapper, ErrorWrapper, KubeConfigContentStyle, KubeConfigFooterStyle, KubeConfigModalStyle, KubeConfigTipStyle, KubeConfigTitleStyle, KubeConfigWrapperStyle };
@@ -0,0 +1,96 @@
1
+ import React__default, { useCallback } from 'react';
2
+ import Modal from '../../core/Modal/index.js';
3
+ import { ClipboardCopy16GradientGrayIcon, ClipboardCopy16GradientBlueIcon } from '@cloudtower/icons-react';
4
+ import useParrotTranslation from '../../hooks/useParrotTranslation.js';
5
+ import { cx } from '@linaria/core';
6
+ import { copy, download } from './utils.js';
7
+ import { KubeConfigModalStyle, KubeConfigFooterStyle, KubeConfigWrapperStyle, KubeConfigTitleStyle, KubeConfigTipStyle, KubeConfigContentStyle, ErrorWrapper, ErrorContentWrapper } from './KubeConfigModal.style.js';
8
+ import { usePopModal } from '../../core/KitStoreProvider/index.js';
9
+ import _message from '../../core/message/index.js';
10
+ import Button from '../../core/Button/index.js';
11
+ import Icon from '../../core/Icon/index.js';
12
+ import Loading from '../../core/Loading/index.js';
13
+ import { Typo } from '../../core/Typo/index.js';
14
+
15
+ const ErrorContent = (props) => {
16
+ const { refetch, errorText } = props;
17
+ const { t } = useParrotTranslation();
18
+ return /* @__PURE__ */ React__default.createElement(ErrorWrapper, { className: props.className, style: props.style }, /* @__PURE__ */ React__default.createElement(ErrorContentWrapper, null, /* @__PURE__ */ React__default.createElement("p", { className: cx(Typo.Label.l1_regular_title, "title") }, errorText || t("common.obtain_data_error")), !refetch ? null : /* @__PURE__ */ React__default.createElement(
19
+ Button,
20
+ {
21
+ size: "small",
22
+ type: "ordinary",
23
+ onClick: (e) => {
24
+ e.stopPropagation();
25
+ refetch == null ? void 0 : refetch();
26
+ }
27
+ },
28
+ t("common.retry")
29
+ )));
30
+ };
31
+ const KubeConfigModal = ({
32
+ downloadName,
33
+ customDesc,
34
+ loading,
35
+ data,
36
+ error,
37
+ refetch
38
+ }) => {
39
+ const { t } = useParrotTranslation();
40
+ const popModal = usePopModal();
41
+ const onCopy = useCallback(() => {
42
+ copy(data);
43
+ _message.success(t("common.copy_kubeconfig_success"));
44
+ }, [data, t]);
45
+ const onDownload = useCallback(() => {
46
+ download(`${downloadName}.yaml`, data);
47
+ popModal();
48
+ }, [data, popModal, downloadName]);
49
+ return /* @__PURE__ */ React__default.createElement(
50
+ Modal,
51
+ {
52
+ visible: true,
53
+ fullscreen: true,
54
+ className: KubeConfigModalStyle,
55
+ onCancel: () => {
56
+ popModal();
57
+ },
58
+ footer: /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigFooterStyle }, /* @__PURE__ */ React__default.createElement(
59
+ Button,
60
+ {
61
+ type: "default",
62
+ prefixIcon: /* @__PURE__ */ React__default.createElement(
63
+ Icon,
64
+ {
65
+ src: ClipboardCopy16GradientGrayIcon,
66
+ hoverSrc: ClipboardCopy16GradientBlueIcon
67
+ }
68
+ ),
69
+ onClick: onCopy
70
+ },
71
+ t("common.copy")
72
+ ), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(
73
+ Button,
74
+ {
75
+ type: "text",
76
+ onClick: () => {
77
+ popModal();
78
+ }
79
+ },
80
+ t("common.cancel")
81
+ ), /* @__PURE__ */ React__default.createElement(
82
+ Button,
83
+ {
84
+ type: "primary",
85
+ onClick: onDownload,
86
+ disabled: loading || !!error
87
+ },
88
+ t("common.download")
89
+ )))
90
+ },
91
+ /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigWrapperStyle }, /* @__PURE__ */ React__default.createElement("div", { className: cx(KubeConfigTitleStyle, Typo.Display.d1s_bold_title) }, t("common.download_kubeconfig")), /* @__PURE__ */ React__default.createElement("div", { className: cx(KubeConfigTipStyle, Typo.Label.l1_regular) }, customDesc || t("common.download_kubeconfig_tip")), loading ? /* @__PURE__ */ React__default.createElement(Loading, { fullView: true }) : error ? /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigContentStyle }, /* @__PURE__ */ React__default.createElement(ErrorContent, { refetch, errorText: error })) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigContentStyle }, data)))
92
+ );
93
+ };
94
+ var KubeConfigModal$1 = KubeConfigModal;
95
+
96
+ export { KubeConfigModal$1 as default };
@@ -0,0 +1,22 @@
1
+ function download(filename, content) {
2
+ const element = document.createElement("a");
3
+ element.setAttribute(
4
+ "href",
5
+ "data:text/plain;charset=utf-8," + encodeURIComponent(content)
6
+ );
7
+ element.setAttribute("download", filename);
8
+ element.style.display = "none";
9
+ document.body.appendChild(element);
10
+ element.click();
11
+ document.body.removeChild(element);
12
+ }
13
+ function copy(content) {
14
+ const textarea = document.createElement("textarea");
15
+ textarea.value = content;
16
+ document.body.appendChild(textarea);
17
+ textarea.select();
18
+ document.execCommand("Copy");
19
+ document.body.removeChild(textarea);
20
+ }
21
+
22
+ export { copy, download };
package/dist/esm/index.js CHANGED
@@ -136,6 +136,7 @@ export { default as SummaryTable, SummaryTableRow } from './coreX/SummaryTable/i
136
136
  export { default as SwitchWithText } from './coreX/SwitchWithText/index.js';
137
137
  export { default as TabMenu } from './coreX/TabMenu/index.js';
138
138
  export { default as UnitWithChart, UnitWrapper } from './coreX/UnitWithChart/index.js';
139
+ export { default as KubeConfigModal } from './coreX/KubeConfigModal/index.js';
139
140
  export { CheckPointItem, CheckPointList } from './coreX/CheckPointList/index.js';
140
141
  export { getCalendarTitle } from './coreX/common/getCalendarTitle.js';
141
142
  export { default as AbsoluteDate } from './coreX/DateRangePicker/AbsoluteDate.js';