@cloudtower/eagle 0.33.16 → 0.33.18
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/dist/cjs/core/CTModalFooterError/CTModalFooterError.style.js +5 -0
- package/dist/cjs/core/CTModalFooterError/index.js +46 -0
- package/dist/cjs/core/ConfigProvider/index.js +8 -2
- package/dist/cjs/coreX/KubeConfigModal/KubeConfigModal.style.js +29 -0
- package/dist/cjs/coreX/KubeConfigModal/index.js +102 -0
- package/dist/cjs/coreX/KubeConfigModal/utils.js +25 -0
- package/dist/cjs/hooks/useCTErrorMsg.js +25 -0
- package/dist/cjs/index.js +117 -112
- package/dist/cjs/stats1.html +1 -1
- package/dist/cjs/utils/cterror.js +62 -0
- package/dist/components.css +2973 -2969
- package/dist/esm/core/CTModalFooterError/CTModalFooterError.style.js +3 -0
- package/dist/esm/core/CTModalFooterError/index.js +40 -0
- package/dist/esm/core/ConfigProvider/index.js +9 -4
- package/dist/esm/coreX/KubeConfigModal/KubeConfigModal.style.js +20 -0
- package/dist/esm/coreX/KubeConfigModal/index.js +96 -0
- package/dist/esm/coreX/KubeConfigModal/utils.js +22 -0
- package/dist/esm/hooks/useCTErrorMsg.js +23 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/stats1.html +1 -1
- package/dist/esm/utils/cterror.js +56 -0
- package/dist/linaria.merged.scss +3311 -3306
- package/dist/src/core/CTModalFooterError/CTModalFooterError.style.d.ts +1 -0
- package/dist/src/core/CTModalFooterError/CTModalFooterError.type.d.ts +56 -0
- package/dist/src/core/CTModalFooterError/index.d.ts +3 -0
- package/dist/src/core/ConfigProvider/index.d.ts +6 -1
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/coreX/index.d.ts +1 -0
- package/dist/src/hooks/__tests__/useCTErrorMsg.test.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/useCTErrorMsg.d.ts +7 -0
- package/dist/src/utils/__test__/cterror.test.d.ts +1 -0
- package/dist/src/utils/cterror.d.ts +29 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/type.d.ts +32 -0
- package/dist/stories/docs/core/CTModalFooterError.stories.d.ts +47 -0
- package/dist/style.css +2861 -2857
- package/package.json +5 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React__default, { useMemo } from 'react';
|
|
2
|
+
import { cx } from '@linaria/core';
|
|
3
|
+
import { CTModalFooterErrorStyle } from './CTModalFooterError.style.js';
|
|
4
|
+
import { Typo } from '../Typo/index.js';
|
|
5
|
+
import { useCTErrorMsg } from '../../hooks/useCTErrorMsg.js';
|
|
6
|
+
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
|
|
7
|
+
|
|
8
|
+
const defaultErrorContainerRender = ({
|
|
9
|
+
children,
|
|
10
|
+
className
|
|
11
|
+
}) => {
|
|
12
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
13
|
+
"span",
|
|
14
|
+
{
|
|
15
|
+
className: cx(Typo.Label.l3_regular, CTModalFooterErrorStyle, className)
|
|
16
|
+
},
|
|
17
|
+
children
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
const CTModalFooterError = (props) => {
|
|
21
|
+
const {
|
|
22
|
+
error,
|
|
23
|
+
className,
|
|
24
|
+
ErrorItemRender,
|
|
25
|
+
ErrorContainerRender,
|
|
26
|
+
errorMsgOptions
|
|
27
|
+
} = props;
|
|
28
|
+
const msgs = useCTErrorMsg(error, errorMsgOptions);
|
|
29
|
+
const { t } = useParrotTranslation();
|
|
30
|
+
const ContainerRender = ErrorContainerRender || defaultErrorContainerRender;
|
|
31
|
+
const child = useMemo(() => {
|
|
32
|
+
if (ErrorItemRender) {
|
|
33
|
+
return msgs.map((errorMsg, index) => /* @__PURE__ */ React__default.createElement(ErrorItemRender, { errorMsg, index, key: index }));
|
|
34
|
+
}
|
|
35
|
+
return msgs.join("");
|
|
36
|
+
}, [msgs, ErrorItemRender, t]);
|
|
37
|
+
return /* @__PURE__ */ React__default.createElement(ContainerRender, { className, errorMsgs: msgs, children: child });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { CTModalFooterError };
|
|
@@ -7,7 +7,7 @@ import antd5enUS from 'antd5/lib/locale/en_US';
|
|
|
7
7
|
import antd5zhCN from 'antd5/lib/locale/zh_CN';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
import moment from 'moment';
|
|
10
|
-
import React__default, { useEffect } from 'react';
|
|
10
|
+
import React__default, { createContext, useContext, useEffect } from 'react';
|
|
11
11
|
|
|
12
12
|
var __defProp = Object.defineProperty;
|
|
13
13
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -25,9 +25,14 @@ var __spreadValues = (a, b) => {
|
|
|
25
25
|
}
|
|
26
26
|
return a;
|
|
27
27
|
};
|
|
28
|
+
const ConfigProviderContext = createContext({});
|
|
29
|
+
const useConfig = () => {
|
|
30
|
+
return useContext(ConfigProviderContext);
|
|
31
|
+
};
|
|
28
32
|
const ConfigProvider = ({
|
|
29
33
|
antd5Configs,
|
|
30
34
|
antd4Configs,
|
|
35
|
+
config = {},
|
|
31
36
|
children
|
|
32
37
|
}) => {
|
|
33
38
|
const { i18n } = useParrotTranslation();
|
|
@@ -39,7 +44,7 @@ const ConfigProvider = ({
|
|
|
39
44
|
i18n.on("languageChanged", adjustDateLocale);
|
|
40
45
|
adjustDateLocale(i18n.language);
|
|
41
46
|
}, [i18n]);
|
|
42
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
47
|
+
return /* @__PURE__ */ React__default.createElement(ConfigProviderContext.Provider, { value: config }, /* @__PURE__ */ React__default.createElement(
|
|
43
48
|
ConfigProvider$1,
|
|
44
49
|
__spreadValues({
|
|
45
50
|
autoInsertSpaceInButton: false,
|
|
@@ -53,7 +58,7 @@ const ConfigProvider = ({
|
|
|
53
58
|
}, antd4Configs),
|
|
54
59
|
children
|
|
55
60
|
)
|
|
56
|
-
);
|
|
61
|
+
));
|
|
57
62
|
};
|
|
58
63
|
|
|
59
|
-
export { ConfigProvider };
|
|
64
|
+
export { ConfigProvider, useConfig };
|
|
@@ -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 };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import useParrotTranslation from './useParrotTranslation.js';
|
|
2
|
+
import { parseCTError } from '../utils/cterror.js';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { merge } from 'lodash';
|
|
5
|
+
import { useConfig } from '../core/ConfigProvider/index.js';
|
|
6
|
+
|
|
7
|
+
const useCTErrorMsg = (error, options) => {
|
|
8
|
+
const { t } = useParrotTranslation();
|
|
9
|
+
const globalConfig = useConfig();
|
|
10
|
+
const err = parseCTError(error);
|
|
11
|
+
const ns = (options == null ? void 0 : options.CTErrorI18nNs) || (globalConfig == null ? void 0 : globalConfig.ctErrorI18nNs) || "CTError";
|
|
12
|
+
const errMsg = useMemo(() => {
|
|
13
|
+
return err.map((e) => {
|
|
14
|
+
if ("code" in e) {
|
|
15
|
+
return t(`${ns}.${e.code}`, merge(options == null ? void 0 : options.tOptions, e.params));
|
|
16
|
+
}
|
|
17
|
+
return e.message;
|
|
18
|
+
});
|
|
19
|
+
}, [err, t, ns, options == null ? void 0 : options.tOptions]);
|
|
20
|
+
return errMsg;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { useCTErrorMsg };
|
package/dist/esm/index.js
CHANGED
|
@@ -83,7 +83,8 @@ export { Architecture } from './core/Arch/arch.type.js';
|
|
|
83
83
|
export { CascaderDefaultHeader, CascaderDefaultHeaderContainer, CascaderDefaultHeaderSearch, CascaderDefaultOptionLabel, CascaderDropdown, CascaderInputStyle, CascaderLargeDropdown, CascaderNotData, CascaderSmallDropdown, DoubleRowOptionStyleWrapper, Hide } from './core/Cascader/cascader.style.js';
|
|
84
84
|
export { CascaderDoubleRowOption, CascaderOptionWithCount, NotDataContent, PresetCascaderHeader, PresetCascaderRender, defaultTagRender } from './core/Cascader/cascader.widget.js';
|
|
85
85
|
export { Cascader } from './core/Cascader/index.js';
|
|
86
|
-
export { ConfigProvider } from './core/ConfigProvider/index.js';
|
|
86
|
+
export { ConfigProvider, useConfig } from './core/ConfigProvider/index.js';
|
|
87
|
+
export { CTModalFooterError } from './core/CTModalFooterError/index.js';
|
|
87
88
|
export { default as ExpandableContainer } from './core/ExpandableList/ExpandableContainer.js';
|
|
88
89
|
export { default as ExpandableItem } from './core/ExpandableList/ExpandableItem.js';
|
|
89
90
|
export { default as ExpandIcon } from './core/ExpandableList/ExpandIcon.js';
|
|
@@ -136,6 +137,7 @@ export { default as SummaryTable, SummaryTableRow } from './coreX/SummaryTable/i
|
|
|
136
137
|
export { default as SwitchWithText } from './coreX/SwitchWithText/index.js';
|
|
137
138
|
export { default as TabMenu } from './coreX/TabMenu/index.js';
|
|
138
139
|
export { default as UnitWithChart, UnitWrapper } from './coreX/UnitWithChart/index.js';
|
|
140
|
+
export { default as KubeConfigModal } from './coreX/KubeConfigModal/index.js';
|
|
139
141
|
export { CheckPointItem, CheckPointList } from './coreX/CheckPointList/index.js';
|
|
140
142
|
export { getCalendarTitle } from './coreX/common/getCalendarTitle.js';
|
|
141
143
|
export { default as AbsoluteDate } from './coreX/DateRangePicker/AbsoluteDate.js';
|