@blocklet/ui-react 2.9.91 → 2.10.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/build.config.ts +1 -6
- package/lib/@types/index.d.ts +1 -0
- package/lib/@types/index.js +0 -1
- package/lib/BlockletStudio/index.js +50 -50
- package/lib/ComponentInstaller/index.js +122 -202
- package/lib/ComponentInstaller/installer-item.js +116 -138
- package/lib/ComponentInstaller/locales.js +5 -10
- package/lib/ComponentInstaller/use-component-installed.js +37 -41
- package/lib/ComponentManager/components/add-component.js +58 -67
- package/lib/ComponentManager/components/check-component.js +2 -9
- package/lib/ComponentManager/components/publish-component.js +50 -59
- package/lib/ComponentManager/components/resource-dialog.js +42 -39
- package/lib/ComponentManager/index.js +3 -27
- package/lib/ComponentManager/libs/locales.js +2 -8
- package/lib/Dashboard/index.js +74 -99
- package/lib/Footer/brand.js +21 -43
- package/lib/Footer/copyright.js +15 -24
- package/lib/Footer/index.js +47 -71
- package/lib/Footer/internal-footer.js +72 -100
- package/lib/Footer/layout/plain.js +26 -45
- package/lib/Footer/layout/row.js +12 -29
- package/lib/Footer/layout/standard.js +34 -64
- package/lib/Footer/links.js +74 -104
- package/lib/Footer/social-media.js +35 -42
- package/lib/Header/index.js +69 -117
- package/lib/Icon/index.js +18 -53
- package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
- package/lib/UserCenter/components/config-profile.js +67 -0
- package/lib/UserCenter/components/notification.js +203 -186
- package/lib/UserCenter/components/passport.js +70 -79
- package/lib/UserCenter/components/privacy.js +86 -88
- package/lib/UserCenter/components/settings.js +74 -84
- package/lib/UserCenter/components/storage/connect-to.js +56 -75
- package/lib/UserCenter/components/storage/connected.js +16 -37
- package/lib/UserCenter/components/storage/delete.js +42 -51
- package/lib/UserCenter/components/storage/disconnect.js +15 -29
- package/lib/UserCenter/components/storage/index.js +20 -54
- package/lib/UserCenter/components/storage/item.js +94 -122
- package/lib/UserCenter/components/storage/preview-nft.js +77 -85
- package/lib/UserCenter/components/third-party-login/index.js +49 -61
- package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
- package/lib/UserCenter/components/user-center.js +276 -287
- package/lib/UserCenter/components/user-info/index.js +3 -27
- package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
- package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
- package/lib/UserCenter/components/user-info/user-info.js +41 -74
- package/lib/UserCenter/components/webhook-item.js +184 -177
- package/lib/UserCenter/index.js +1 -13
- package/lib/UserCenter/libs/api.js +4 -16
- package/lib/UserCenter/libs/locales.d.ts +10 -0
- package/lib/UserCenter/libs/locales.js +12 -8
- package/lib/UserCenter/libs/utils.js +7 -17
- package/lib/UserSessions/components/user-session-info.js +88 -85
- package/lib/UserSessions/components/user-sessions.js +177 -213
- package/lib/UserSessions/index.js +1 -13
- package/lib/UserSessions/libs/locales.js +2 -8
- package/lib/UserSessions/libs/utils.js +4 -11
- package/lib/blocklets.js +59 -63
- package/lib/common/header-addons.js +44 -60
- package/lib/common/link-blocker.js +9 -18
- package/lib/common/overridable-theme-provider.js +10 -23
- package/lib/common/wallet-hidden-topbar.js +7 -14
- package/lib/contexts/config-user-space.js +38 -46
- package/lib/hooks/use-mobile.js +5 -13
- package/lib/index.js +10 -100
- package/lib/libs/client.js +2 -8
- package/lib/libs/spaces.js +6 -13
- package/lib/types.js +39 -41
- package/lib/utils.js +25 -44
- package/package.json +8 -38
- package/src/@types/index.ts +1 -0
- package/src/Footer/brand.jsx +6 -1
- package/src/UserCenter/components/config-profile.tsx +70 -0
- package/src/UserCenter/components/notification.tsx +63 -47
- package/src/UserCenter/components/settings.tsx +6 -0
- package/src/UserCenter/libs/locales.ts +10 -0
- package/es/@types/index.d.ts +0 -101
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +0 -16
- package/es/BlockletStudio/index.d.ts +0 -28
- package/es/BlockletStudio/index.js +0 -114
- package/es/ComponentInstaller/index.d.ts +0 -37
- package/es/ComponentInstaller/index.js +0 -200
- package/es/ComponentInstaller/installer-item.d.ts +0 -21
- package/es/ComponentInstaller/installer-item.js +0 -139
- package/es/ComponentInstaller/locales.d.ts +0 -28
- package/es/ComponentInstaller/locales.js +0 -22
- package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
- package/es/ComponentInstaller/use-component-installed.js +0 -88
- package/es/ComponentManager/components/add-component.d.ts +0 -16
- package/es/ComponentManager/components/add-component.js +0 -114
- package/es/ComponentManager/components/check-component.d.ts +0 -2
- package/es/ComponentManager/components/check-component.js +0 -2
- package/es/ComponentManager/components/publish-component.d.ts +0 -10
- package/es/ComponentManager/components/publish-component.js +0 -76
- package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
- package/es/ComponentManager/components/resource-dialog.js +0 -74
- package/es/ComponentManager/index.d.ts +0 -3
- package/es/ComponentManager/index.js +0 -3
- package/es/ComponentManager/libs/locales.d.ts +0 -14
- package/es/ComponentManager/libs/locales.js +0 -14
- package/es/Dashboard/index.d.ts +0 -40
- package/es/Dashboard/index.js +0 -118
- package/es/Footer/brand.d.ts +0 -22
- package/es/Footer/brand.js +0 -73
- package/es/Footer/copyright.d.ts +0 -18
- package/es/Footer/copyright.js +0 -25
- package/es/Footer/index.d.ts +0 -6
- package/es/Footer/index.js +0 -82
- package/es/Footer/internal-footer.d.ts +0 -29
- package/es/Footer/internal-footer.js +0 -117
- package/es/Footer/layout/plain.d.ts +0 -15
- package/es/Footer/layout/plain.js +0 -39
- package/es/Footer/layout/row.d.ts +0 -18
- package/es/Footer/layout/row.js +0 -41
- package/es/Footer/layout/standard.d.ts +0 -15
- package/es/Footer/layout/standard.js +0 -53
- package/es/Footer/links.d.ts +0 -22
- package/es/Footer/links.js +0 -207
- package/es/Footer/social-media.d.ts +0 -14
- package/es/Footer/social-media.js +0 -60
- package/es/Header/index.d.ts +0 -10
- package/es/Header/index.js +0 -155
- package/es/Icon/index.d.ts +0 -23
- package/es/Icon/index.js +0 -55
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.js +0 -248
- package/es/UserCenter/components/passport.d.ts +0 -6
- package/es/UserCenter/components/passport.js +0 -88
- package/es/UserCenter/components/privacy.d.ts +0 -11
- package/es/UserCenter/components/privacy.js +0 -99
- package/es/UserCenter/components/settings.d.ts +0 -9
- package/es/UserCenter/components/settings.js +0 -89
- package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
- package/es/UserCenter/components/storage/connect-to.js +0 -108
- package/es/UserCenter/components/storage/connected.d.ts +0 -7
- package/es/UserCenter/components/storage/connected.js +0 -24
- package/es/UserCenter/components/storage/delete.d.ts +0 -7
- package/es/UserCenter/components/storage/delete.js +0 -62
- package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
- package/es/UserCenter/components/storage/disconnect.js +0 -23
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
- package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/es/UserCenter/components/storage/index.d.ts +0 -3
- package/es/UserCenter/components/storage/index.js +0 -27
- package/es/UserCenter/components/storage/item.d.ts +0 -9
- package/es/UserCenter/components/storage/item.js +0 -158
- package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
- package/es/UserCenter/components/storage/preview-nft.js +0 -80
- package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
- package/es/UserCenter/components/third-party-login/index.js +0 -110
- package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
- package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
- package/es/UserCenter/components/user-center.d.ts +0 -15
- package/es/UserCenter/components/user-center.js +0 -414
- package/es/UserCenter/components/user-info/index.d.ts +0 -3
- package/es/UserCenter/components/user-info/index.js +0 -3
- package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
- package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-info-item.js +0 -47
- package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
- package/es/UserCenter/components/user-info/user-info.js +0 -66
- package/es/UserCenter/components/webhook-item.d.ts +0 -3
- package/es/UserCenter/components/webhook-item.js +0 -243
- package/es/UserCenter/index.d.ts +0 -1
- package/es/UserCenter/index.js +0 -1
- package/es/UserCenter/libs/api.d.ts +0 -3
- package/es/UserCenter/libs/api.js +0 -4
- package/es/UserCenter/libs/locales.d.ts +0 -162
- package/es/UserCenter/libs/locales.js +0 -162
- package/es/UserCenter/libs/utils.d.ts +0 -4
- package/es/UserCenter/libs/utils.js +0 -14
- package/es/UserSessions/components/user-session-info.d.ts +0 -6
- package/es/UserSessions/components/user-session-info.js +0 -92
- package/es/UserSessions/components/user-sessions.d.ts +0 -9
- package/es/UserSessions/components/user-sessions.js +0 -265
- package/es/UserSessions/index.d.ts +0 -1
- package/es/UserSessions/index.js +0 -1
- package/es/UserSessions/libs/locales.d.ts +0 -58
- package/es/UserSessions/libs/locales.js +0 -58
- package/es/UserSessions/libs/utils.d.ts +0 -2
- package/es/UserSessions/libs/utils.js +0 -73
- package/es/blocklets.d.ts +0 -16
- package/es/blocklets.js +0 -178
- package/es/common/header-addons.d.ts +0 -21
- package/es/common/header-addons.js +0 -83
- package/es/common/link-blocker.d.ts +0 -7
- package/es/common/link-blocker.js +0 -18
- package/es/common/overridable-theme-provider.d.ts +0 -18
- package/es/common/overridable-theme-provider.js +0 -15
- package/es/common/wallet-hidden-topbar.d.ts +0 -1
- package/es/common/wallet-hidden-topbar.js +0 -14
- package/es/contexts/config-user-space.d.ts +0 -26
- package/es/contexts/config-user-space.js +0 -53
- package/es/hooks/use-mobile.d.ts +0 -4
- package/es/hooks/use-mobile.js +0 -5
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/libs/client.d.ts +0 -2
- package/es/libs/client.js +0 -2
- package/es/libs/spaces.d.ts +0 -2
- package/es/libs/spaces.js +0 -13
- package/es/types.d.ts +0 -2
- package/es/types.js +0 -43
- package/es/utils.d.ts +0 -8
- package/es/utils.js +0 -78
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
9
|
-
var _react = require("@iconify/react");
|
|
10
|
-
var _material = require("@mui/material");
|
|
11
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function InstallerItem({
|
|
14
|
-
optionalComponent,
|
|
15
|
-
index,
|
|
16
|
-
installStatus,
|
|
17
|
-
hasPermission,
|
|
18
|
-
t
|
|
19
|
-
}) {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
3
|
+
import { Icon } from "@iconify/react";
|
|
4
|
+
import { Box, Button } from "@mui/material";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
export default function InstallerItem({ optionalComponent, index, installStatus, hasPermission, t }) {
|
|
20
7
|
const handleInstall = () => {
|
|
21
8
|
window.open(optionalComponent?.installUrl, "_blank");
|
|
22
9
|
};
|
|
@@ -28,134 +15,125 @@ function InstallerItem({
|
|
|
28
15
|
};
|
|
29
16
|
const installStatusDone = installStatus === "stopped" || installStatus === "running";
|
|
30
17
|
const size = 60;
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
backgroundColor: _Colors.temp.gray6
|
|
37
|
-
}
|
|
38
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
39
|
-
sx: {
|
|
40
|
-
padding: "20px 24px",
|
|
41
|
-
paddingTop: 0.5,
|
|
42
|
-
marginTop: 2,
|
|
43
|
-
display: "flex",
|
|
44
|
-
flexDirection: "row",
|
|
45
|
-
justifyContent: "start",
|
|
46
|
-
alignItems: "flex-start"
|
|
47
|
-
},
|
|
48
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)("img", {
|
|
49
|
-
style: {
|
|
50
|
-
width: size,
|
|
51
|
-
height: size,
|
|
52
|
-
minWidth: size,
|
|
53
|
-
minHeight: size
|
|
54
|
-
},
|
|
55
|
-
src: optionalComponent.logoUrl,
|
|
56
|
-
alt: optionalComponent.meta.title
|
|
57
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
18
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
19
|
+
index === 0 ? null : /* @__PURE__ */ jsx(Box, { sx: { width: "100%", height: "1px", backgroundColor: colors.gray6 } }),
|
|
20
|
+
/* @__PURE__ */ jsxs(
|
|
21
|
+
Box,
|
|
22
|
+
{
|
|
58
23
|
sx: {
|
|
24
|
+
padding: "20px 24px",
|
|
25
|
+
paddingTop: 0.5,
|
|
26
|
+
marginTop: 2,
|
|
59
27
|
display: "flex",
|
|
60
|
-
flexDirection: "
|
|
28
|
+
flexDirection: "row",
|
|
61
29
|
justifyContent: "start",
|
|
62
|
-
alignItems: "start"
|
|
63
|
-
marginLeft: 2
|
|
30
|
+
alignItems: "flex-start"
|
|
64
31
|
},
|
|
65
|
-
children: [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
":hover .link-icon": {
|
|
74
|
-
opacity: 1
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
"img",
|
|
35
|
+
{
|
|
36
|
+
style: { width: size, height: size, minWidth: size, minHeight: size },
|
|
37
|
+
src: optionalComponent.logoUrl,
|
|
38
|
+
alt: optionalComponent.meta.title
|
|
75
39
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
paddingLeft: 1,
|
|
81
|
-
fontSize: "13px",
|
|
82
|
-
fontWeight: "400"
|
|
83
|
-
},
|
|
84
|
-
component: "span",
|
|
85
|
-
children: [optionalComponent.meta.version, /* @__PURE__ */(0, _jsxRuntime.jsx)(_react.Icon, {
|
|
86
|
-
className: "link-icon",
|
|
87
|
-
icon: "fluent:open-20-filled",
|
|
88
|
-
style: {
|
|
89
|
-
color: _Colors.temp.primaryBase,
|
|
90
|
-
fontSize: 16,
|
|
91
|
-
transform: "translate(6px, 3px)",
|
|
92
|
-
transition: "all 0.3s"
|
|
93
|
-
}
|
|
94
|
-
})]
|
|
95
|
-
})]
|
|
96
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
97
|
-
sx: {
|
|
98
|
-
marginTop: 0,
|
|
99
|
-
opacity: 0.7
|
|
100
|
-
},
|
|
101
|
-
children: optionalComponent.meta.description
|
|
102
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
103
|
-
sx: {
|
|
104
|
-
display: hasPermission ? "flex" : "none",
|
|
105
|
-
flexDirection: "row",
|
|
106
|
-
gap: 1
|
|
107
|
-
},
|
|
108
|
-
children: installStatus ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
109
|
-
sx: {
|
|
110
|
-
marginTop: 2,
|
|
111
|
-
opacity: 0.7
|
|
112
|
-
},
|
|
113
|
-
children: installStatusDone ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
114
|
-
variant: "contained",
|
|
115
|
-
onClick: handleRefresh,
|
|
116
|
-
children: t("componentInstallerRefresh")
|
|
117
|
-
}, "refresh") : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
118
|
-
disabled: true,
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ jsxs(
|
|
42
|
+
Box,
|
|
43
|
+
{
|
|
119
44
|
sx: {
|
|
120
|
-
|
|
45
|
+
display: "flex",
|
|
46
|
+
flexDirection: "column",
|
|
47
|
+
justifyContent: "start",
|
|
48
|
+
alignItems: "start",
|
|
49
|
+
marginLeft: 2
|
|
121
50
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsxs(
|
|
53
|
+
Box,
|
|
54
|
+
{
|
|
55
|
+
sx: {
|
|
56
|
+
fontSize: "16px",
|
|
57
|
+
fontWeight: "bold",
|
|
58
|
+
cursor: "pointer",
|
|
59
|
+
".link-icon": {
|
|
60
|
+
opacity: 0
|
|
61
|
+
},
|
|
62
|
+
":hover .link-icon": {
|
|
63
|
+
opacity: 1
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
onClick: () => handleOpenStore(optionalComponent.meta?.did),
|
|
67
|
+
children: [
|
|
68
|
+
optionalComponent.meta.title,
|
|
69
|
+
/* @__PURE__ */ jsxs(
|
|
70
|
+
Box,
|
|
71
|
+
{
|
|
72
|
+
sx: {
|
|
73
|
+
paddingLeft: 1,
|
|
74
|
+
fontSize: "13px",
|
|
75
|
+
fontWeight: "400"
|
|
76
|
+
},
|
|
77
|
+
component: "span",
|
|
78
|
+
children: [
|
|
79
|
+
optionalComponent.meta.version,
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
Icon,
|
|
82
|
+
{
|
|
83
|
+
className: "link-icon",
|
|
84
|
+
icon: "fluent:open-20-filled",
|
|
85
|
+
style: {
|
|
86
|
+
color: colors.primaryBase,
|
|
87
|
+
fontSize: 16,
|
|
88
|
+
transform: "translate(6px, 3px)",
|
|
89
|
+
transition: "all 0.3s"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx(Box, { sx: { marginTop: 0, opacity: 0.7 }, children: optionalComponent.meta.description }),
|
|
100
|
+
/* @__PURE__ */ jsx(Box, { sx: { display: hasPermission ? "flex" : "none", flexDirection: "row", gap: 1 }, children: installStatus ? /* @__PURE__ */ jsx(Box, { sx: { marginTop: 2, opacity: 0.7 }, children: installStatusDone ? /* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleRefresh, children: t("componentInstallerRefresh") }, "refresh") : /* @__PURE__ */ jsx(
|
|
101
|
+
Button,
|
|
102
|
+
{
|
|
103
|
+
disabled: true,
|
|
104
|
+
sx: { color: "#333" },
|
|
105
|
+
startIcon: /* @__PURE__ */ jsx(Icon, { icon: "line-md:loading-loop", style: { color: "#333", fontSize: 16 } }),
|
|
106
|
+
variant: "contained",
|
|
107
|
+
children: installStatus
|
|
108
|
+
},
|
|
109
|
+
"status"
|
|
110
|
+
) }) : /* @__PURE__ */ jsx(
|
|
111
|
+
Button,
|
|
112
|
+
{
|
|
113
|
+
sx: { marginTop: 2 },
|
|
114
|
+
variant: "contained",
|
|
115
|
+
className: "button",
|
|
116
|
+
onClick: () => handleInstall(optionalComponent.meta?.did),
|
|
117
|
+
children: t("componentInstallerInstall")
|
|
118
|
+
},
|
|
119
|
+
"install"
|
|
120
|
+
) }),
|
|
121
|
+
installStatusDone ? /* @__PURE__ */ jsx(Box, { sx: { marginTop: 2, opacity: 0.7 }, children: t("componentInstallerSuccessInstalled") }) : null
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] });
|
|
151
129
|
}
|
|
152
130
|
InstallerItem.propTypes = {
|
|
153
|
-
t:
|
|
154
|
-
optionalComponent:
|
|
155
|
-
index:
|
|
156
|
-
installStatus:
|
|
157
|
-
hasPermission:
|
|
131
|
+
t: PropTypes.func.isRequired,
|
|
132
|
+
optionalComponent: PropTypes.object.isRequired,
|
|
133
|
+
index: PropTypes.number.isRequired,
|
|
134
|
+
installStatus: PropTypes.string,
|
|
135
|
+
hasPermission: PropTypes.bool.isRequired
|
|
158
136
|
};
|
|
159
137
|
InstallerItem.defaultProps = {
|
|
160
138
|
installStatus: ""
|
|
161
|
-
};
|
|
139
|
+
};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
1
|
const translations = {
|
|
8
2
|
zh: {
|
|
9
3
|
componentInstallerTitle: '缺少组件',
|
|
@@ -12,7 +6,7 @@ const translations = {
|
|
|
12
6
|
componentInstallerRefresh: '重载页面',
|
|
13
7
|
componentInstallerSuccessInstalled: '安装成功,请重载页面查看变化。',
|
|
14
8
|
componentInstallerSuggestions: '请联系系统管理员安装该组件。',
|
|
15
|
-
componentInstallerNoDefinedInBlockletYML: '组件未在 blocklet.yml 中定义'
|
|
9
|
+
componentInstallerNoDefinedInBlockletYML: '组件未在 blocklet.yml 中定义',
|
|
16
10
|
},
|
|
17
11
|
en: {
|
|
18
12
|
componentInstallerTitle: 'Missing component',
|
|
@@ -21,7 +15,8 @@ const translations = {
|
|
|
21
15
|
componentInstallerRefresh: 'Refresh',
|
|
22
16
|
componentInstallerSuccessInstalled: 'Successfully installed, please refresh the page to see the changes.',
|
|
23
17
|
componentInstallerSuggestions: 'Please contact the system administrator to install the component.',
|
|
24
|
-
componentInstallerNoDefinedInBlockletYML: 'The component is not defined in blocklet.yml'
|
|
25
|
-
}
|
|
18
|
+
componentInstallerNoDefinedInBlockletYML: 'The component is not defined in blocklet.yml',
|
|
19
|
+
},
|
|
26
20
|
};
|
|
27
|
-
|
|
21
|
+
|
|
22
|
+
export default translations;
|
|
@@ -1,72 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/constant';
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { joinURL } from 'ufo';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _constant = require("@arcblock/did-connect/lib/constant");
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _ufo = require("ufo");
|
|
10
|
-
const parseDidToSet = did => {
|
|
5
|
+
const parseDidToSet = (did) => {
|
|
11
6
|
if (typeof did === 'string') {
|
|
12
7
|
return new Set(did.split(';;'));
|
|
13
8
|
}
|
|
14
9
|
return new Set(did);
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
onInstalled,
|
|
19
|
-
onError
|
|
20
|
-
}) {
|
|
11
|
+
|
|
12
|
+
function useComponentInstalled({ did, onInstalled, onError }) {
|
|
21
13
|
const didKeys = Array.isArray(did) ? did.join(';;') : did;
|
|
22
|
-
const [installStatus, setInstallStatus] =
|
|
23
|
-
const onInstalledRef = (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onError
|
|
30
|
-
};
|
|
31
|
-
const {
|
|
32
|
-
optionalComponents,
|
|
33
|
-
componentMountPoints
|
|
34
|
-
} = window.blocklet;
|
|
35
|
-
const optComponents = (0, _react.useMemo)(() => {
|
|
14
|
+
const [installStatus, setInstallStatus] = useState({});
|
|
15
|
+
const onInstalledRef = useRef({ onInstalled, onError });
|
|
16
|
+
onInstalledRef.current = { onInstalled, onError };
|
|
17
|
+
|
|
18
|
+
const { optionalComponents, componentMountPoints } = window.blocklet;
|
|
19
|
+
|
|
20
|
+
const optComponents = useMemo(() => {
|
|
36
21
|
if (!optionalComponents || !optionalComponents.length) {
|
|
37
22
|
return [];
|
|
38
23
|
}
|
|
39
24
|
const didSet = parseDidToSet(didKeys);
|
|
40
|
-
const components = optionalComponents.filter(c => didSet.has(c.meta.did));
|
|
25
|
+
const components = optionalComponents.filter((c) => didSet.has(c.meta.did));
|
|
41
26
|
(components ? onInstalledRef.current.onError : onInstalledRef.current.onInstalled)?.(components);
|
|
42
27
|
return components;
|
|
43
28
|
}, [didKeys, optionalComponents]);
|
|
44
|
-
|
|
29
|
+
|
|
30
|
+
const definedInBlockletYML = useMemo(() => {
|
|
45
31
|
if (optComponents.length) {
|
|
46
32
|
return true;
|
|
47
33
|
}
|
|
48
34
|
const didSet = parseDidToSet(didKeys);
|
|
49
|
-
return (componentMountPoints || []).find(item => didSet.has(item.did));
|
|
35
|
+
return (componentMountPoints || []).find((item) => didSet.has(item.did));
|
|
50
36
|
}, [optComponents, componentMountPoints, didKeys]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
item.
|
|
37
|
+
|
|
38
|
+
optComponents.forEach((item) => {
|
|
39
|
+
item.storeUrl = joinURL(item.meta.homepage, 'blocklets', item.meta.did);
|
|
40
|
+
item.installUrl = joinURL(
|
|
41
|
+
window.blocklet.appUrl,
|
|
42
|
+
AUTH_SERVICE_PREFIX,
|
|
43
|
+
`/admin/components?install-component=${item.meta.did}`
|
|
44
|
+
);
|
|
54
45
|
});
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const handle = (event) => {
|
|
57
49
|
if (event.origin !== window.blocklet.appUrl) {
|
|
58
50
|
return;
|
|
59
51
|
}
|
|
52
|
+
|
|
60
53
|
if (event.data?.kind === 'component-installer' && event.data?.blocklet?.children) {
|
|
61
54
|
let hasChild = false;
|
|
62
55
|
const didSet = parseDidToSet(didKeys);
|
|
63
|
-
event.data?.blocklet?.children.forEach(item => {
|
|
56
|
+
event.data?.blocklet?.children.forEach((item) => {
|
|
64
57
|
if (didSet.has(item.meta?.did)) {
|
|
65
58
|
hasChild = true;
|
|
66
|
-
setInstallStatus(value => {
|
|
59
|
+
setInstallStatus((value) => {
|
|
67
60
|
return {
|
|
68
61
|
...value,
|
|
69
|
-
[item.meta?.did]: item.status || 'waiting'
|
|
62
|
+
[item.meta?.did]: item.status || 'waiting',
|
|
70
63
|
};
|
|
71
64
|
});
|
|
72
65
|
}
|
|
@@ -76,17 +69,20 @@ function useComponentInstalled({
|
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
};
|
|
72
|
+
|
|
79
73
|
window.addEventListener('message', handle);
|
|
80
74
|
return () => {
|
|
81
75
|
window.removeEventListener('message', handle);
|
|
82
76
|
};
|
|
83
77
|
}, [didKeys]);
|
|
78
|
+
|
|
84
79
|
return {
|
|
85
80
|
optComponents,
|
|
86
81
|
installed: !optComponents.length && definedInBlockletYML,
|
|
87
82
|
installStatus,
|
|
88
83
|
setInstallStatus,
|
|
89
|
-
definedInBlockletYML
|
|
84
|
+
definedInBlockletYML,
|
|
90
85
|
};
|
|
91
86
|
}
|
|
92
|
-
|
|
87
|
+
|
|
88
|
+
export default useComponentInstalled;
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _ufo = require("ufo");
|
|
15
|
-
var _Session = require("@arcblock/did-connect/lib/Session");
|
|
16
|
-
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
17
|
-
var _resourceDialog = _interopRequireDefault(require("./resource-dialog"));
|
|
18
|
-
var _locales = require("../libs/locales");
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
function AddComponent({
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useContext } from "react";
|
|
3
|
+
import Button from "@arcblock/ux/lib/Button";
|
|
4
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
5
|
+
import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
+
import { useMemoizedFn, useReactive } from "ahooks";
|
|
7
|
+
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
8
|
+
import { joinURL, withQuery } from "ufo";
|
|
9
|
+
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
10
|
+
import Toast from "@arcblock/ux/lib/Toast";
|
|
11
|
+
import ResourceDialog from "./resource-dialog.js";
|
|
12
|
+
import { translations } from "../libs/locales.js";
|
|
13
|
+
export default function AddComponent({
|
|
21
14
|
componentDid,
|
|
22
15
|
resourceType,
|
|
23
16
|
resourceDid,
|
|
@@ -29,21 +22,17 @@ function AddComponent({
|
|
|
29
22
|
onClose,
|
|
30
23
|
render
|
|
31
24
|
}) {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
locale
|
|
37
|
-
} = (0, _context.useLocaleContext)();
|
|
38
|
-
const t = (0, _ahooks.useMemoizedFn)((key, data = {}) => {
|
|
39
|
-
return (0, _util.translate)(_locales.translations, key, locale, "en", data);
|
|
25
|
+
const { session } = useContext(SessionContext);
|
|
26
|
+
const { locale } = useLocaleContext();
|
|
27
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
28
|
+
return translate(translations, key, locale, "en", data);
|
|
40
29
|
});
|
|
41
|
-
const refIframe =
|
|
42
|
-
const currentState =
|
|
30
|
+
const refIframe = useRef(null);
|
|
31
|
+
const currentState = useReactive({
|
|
43
32
|
loading: false,
|
|
44
33
|
showDialog: false
|
|
45
34
|
});
|
|
46
|
-
const importUrl =
|
|
35
|
+
const importUrl = withQuery(joinURL(WELLKNOWN_SERVICE_PATH_PREFIX, "embed/resources", componentDid, "add"), {
|
|
47
36
|
resourceDid,
|
|
48
37
|
resourceType,
|
|
49
38
|
mode: "dialog",
|
|
@@ -52,72 +41,74 @@ function AddComponent({
|
|
|
52
41
|
enableRunBackground: "false",
|
|
53
42
|
showCategory: "false"
|
|
54
43
|
});
|
|
55
|
-
const handleClose =
|
|
44
|
+
const handleClose = useMemoizedFn(() => {
|
|
56
45
|
currentState.showDialog = false;
|
|
57
46
|
onClose?.();
|
|
58
47
|
});
|
|
59
|
-
const handleComplete =
|
|
48
|
+
const handleComplete = useMemoizedFn(() => {
|
|
60
49
|
currentState.showDialog = false;
|
|
61
50
|
onComplete?.();
|
|
62
51
|
});
|
|
63
|
-
const handleOpen =
|
|
52
|
+
const handleOpen = useMemoizedFn(() => {
|
|
64
53
|
if (!session.user) {
|
|
65
|
-
|
|
54
|
+
Toast.warning(t("needLogin"));
|
|
66
55
|
return;
|
|
67
56
|
}
|
|
68
57
|
if (!grantedRoles.includes(session.user?.role)) {
|
|
69
|
-
|
|
58
|
+
Toast.warning(t("noPermission"));
|
|
70
59
|
return;
|
|
71
60
|
}
|
|
72
61
|
currentState.loading = true;
|
|
73
62
|
currentState.showDialog = true;
|
|
74
63
|
});
|
|
75
|
-
const handleLoad =
|
|
64
|
+
const handleLoad = useMemoizedFn(() => {
|
|
76
65
|
currentState.loading = false;
|
|
77
66
|
if (refIframe.current) {
|
|
78
67
|
refIframe.current?.selectBlocklet(selectedMeta);
|
|
79
68
|
}
|
|
80
69
|
});
|
|
81
|
-
const handleIframeMessage =
|
|
70
|
+
const handleIframeMessage = useMemoizedFn((event) => {
|
|
82
71
|
if (event?.data?.event === "component.installed" && event.data.componentDid === componentDid) {
|
|
83
72
|
if (autoClose || event.data.manual) {
|
|
84
73
|
handleComplete();
|
|
85
74
|
}
|
|
86
75
|
}
|
|
87
76
|
});
|
|
88
|
-
|
|
77
|
+
useEffect(() => {
|
|
89
78
|
if (currentState.showDialog) {
|
|
90
79
|
window.addEventListener("message", handleIframeMessage);
|
|
91
80
|
} else {
|
|
92
81
|
window.removeEventListener("message", handleIframeMessage);
|
|
93
82
|
}
|
|
94
83
|
}, [currentState.showDialog]);
|
|
95
|
-
return /* @__PURE__ */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
mr: 1,
|
|
108
|
-
ml: 1
|
|
84
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
85
|
+
render ? render({ onClick: handleOpen, loading: currentState.loading }) : /* @__PURE__ */ jsx(
|
|
86
|
+
Button,
|
|
87
|
+
{
|
|
88
|
+
variant: "outlined",
|
|
89
|
+
color: "secondary",
|
|
90
|
+
type: "button",
|
|
91
|
+
className: "submit",
|
|
92
|
+
onClick: handleOpen,
|
|
93
|
+
loading: currentState.loading,
|
|
94
|
+
sx: { mr: 1, ml: 1 },
|
|
95
|
+
children: t("importResource")
|
|
109
96
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
97
|
+
"button"
|
|
98
|
+
),
|
|
99
|
+
currentState.showDialog && /* @__PURE__ */ jsx(
|
|
100
|
+
ResourceDialog,
|
|
101
|
+
{
|
|
102
|
+
ref: refIframe,
|
|
103
|
+
src: importUrl,
|
|
104
|
+
storeUrl,
|
|
105
|
+
open: true,
|
|
106
|
+
componentDid,
|
|
107
|
+
loading: currentState.loading,
|
|
108
|
+
onClose: handleClose,
|
|
109
|
+
onComplete: handleComplete,
|
|
110
|
+
onLoad: handleLoad
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] });
|
|
114
|
+
}
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _ComponentInstaller = _interopRequireDefault(require("../../ComponentInstaller"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
module.exports = _ComponentInstaller.default;
|
|
1
|
+
import CheckComponent from "../../ComponentInstaller/index.js";
|
|
2
|
+
export default CheckComponent;
|