@abtnode/ux 1.16.22 → 1.16.23-beta-f85576a6

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.
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import IconButton from '@mui/material/IconButton';
5
5
  import Box from '@mui/material/Box';
6
6
  import EditIcon from '@mui/icons-material/Edit';
7
- import { getDisplayName } from '@blocklet/meta/lib/util';
7
+ import { getDisplayName, hasStartEngine } from '@blocklet/meta/lib/util';
8
8
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
9
  import Dialog from '@arcblock/ux/lib/Dialog';
10
10
  import Tabs from '@arcblock/ux/lib/Tabs';
@@ -23,7 +23,7 @@ export default function ComponentConfiguration({
23
23
  t
24
24
  } = useLocaleContext();
25
25
  const isComponent = !!ancestors.length;
26
- const [tab, setTab] = useState('settings');
26
+ const [tab, setTab] = useState(hasStartEngine(blocklet?.meta) ? 'settings' : 'environments');
27
27
  const name = isComponent ? getDisplayName(blocklet, true) : t('blocklet.component.container');
28
28
  if (isInstalling(blocklet.status)) {
29
29
  return null;
@@ -40,7 +40,7 @@ export default function ComponentConfiguration({
40
40
  setShowDialog(true);
41
41
  };
42
42
  const tabConfigs = {
43
- settings: {
43
+ settings: hasStartEngine(blocklet.meta) && {
44
44
  label: t('blocklet.component.setting'),
45
45
  value: 'settings',
46
46
  component: /*#__PURE__*/_jsx(ComponentSetting, {
@@ -57,7 +57,8 @@ export default function ComponentConfiguration({
57
57
  })
58
58
  }
59
59
  };
60
- const tabs = Object.values(tabConfigs).map(({
60
+ const tabConfigsArr = Object.values(tabConfigs).filter(Boolean);
61
+ const tabs = tabConfigsArr.map(({
61
62
  label,
62
63
  value
63
64
  }) => ({
@@ -67,7 +68,7 @@ export default function ComponentConfiguration({
67
68
  const onTabChange = newTab => {
68
69
  setTab(newTab);
69
70
  };
70
- const tabConfig = tabConfigs[tab] || tabConfigs.settings;
71
+ const tabConfig = tabConfigs[tab] || tabConfigsArr[0];
71
72
  return [typeof children === 'function' ? children({
72
73
  open: onOpen
73
74
  }) : /*#__PURE__*/_jsx(IconButton, {
@@ -365,7 +365,7 @@ function ComponentItem({
365
365
  children: /*#__PURE__*/_jsx(LaunchIcon, {})
366
366
  })
367
367
  })
368
- }), hasStartEngine(blocklet.meta) && /*#__PURE__*/_jsx(ComponentConfiguration, {
368
+ }), /*#__PURE__*/_jsx(ComponentConfiguration, {
369
369
  blocklet: blocklet,
370
370
  ancestors: ancestors,
371
371
  children: ({
@@ -28,8 +28,7 @@ const Types = [{
28
28
  en: 'Application',
29
29
  zh: '应用'
30
30
  },
31
- value: 'pack',
32
- disabled: true
31
+ value: 'pack'
33
32
  }];
34
33
  export default function CreateProject({
35
34
  ...rest
@@ -19,6 +19,7 @@ import Button from '@arcblock/ux/lib/Button';
19
19
  import Toast from '@arcblock/ux/lib/Toast';
20
20
  import Empty from '@arcblock/ux/lib/Empty';
21
21
  import Tabs from '@arcblock/ux/lib/Tabs';
22
+ import Alert from '@arcblock/ux/lib/Alert';
22
23
  import { PROJECT } from '@blocklet/constant';
23
24
  import { WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
24
25
  import BlockletBundleAvatar from '../bundle-avatar';
@@ -128,6 +129,7 @@ export default function CreateRelease({
128
129
  } = useNodeContext();
129
130
  const uploaderLogoRef = useRef(null);
130
131
  const uploaderScreenshotRef = useRef(null);
132
+ const [projectType, setProjectType] = useState();
131
133
  const releaseId = inputReleaseId === 'create' ? '' : inputReleaseId;
132
134
  const mode = inputReleaseId === 'create' ? 'create' : 'edit';
133
135
  const tabs = [];
@@ -143,7 +145,9 @@ export default function CreateRelease({
143
145
  const [tab, setTab] = useState(tabs[0]?.value);
144
146
  const isPublished = release?.status === 'published';
145
147
  const readOnly = isPublished;
146
- const getProject = () => {
148
+ const getProject = ({
149
+ typeOnly
150
+ } = {}) => {
147
151
  api.getProject({
148
152
  input: {
149
153
  did: blocklet.meta.did,
@@ -152,12 +156,17 @@ export default function CreateRelease({
152
156
  }).then(res => {
153
157
  setLoading(false);
154
158
  const data = res.project || {};
159
+ if (typeOnly) {
160
+ setProjectType(data.type);
161
+ return;
162
+ }
155
163
  if (!data.blockletVersion) {
156
164
  data.blockletVersion = '1.0.0';
157
165
  } else if (semver.valid(data.blockletVersion)) {
158
166
  data.blockletVersion = semver.inc(data.blockletVersion, 'patch');
159
167
  }
160
168
  setParams(pickParams(data));
169
+ setProjectType(data.type);
161
170
  }).catch(err => {
162
171
  setLoading(false);
163
172
  Toast.error(formatError(err));
@@ -186,6 +195,9 @@ export default function CreateRelease({
186
195
  return;
187
196
  }
188
197
  getRelease();
198
+ getProject({
199
+ typeOnly: true
200
+ });
189
201
  }
190
202
  if (mode === 'create') {
191
203
  getProject();
@@ -351,8 +363,15 @@ export default function CreateRelease({
351
363
  })]
352
364
  })]
353
365
  }), /*#__PURE__*/_jsxs(Box, {
354
- pt: 3,
355
- children: [/*#__PURE__*/_jsxs(Box, {
366
+ children: [projectType === 'pack' && /*#__PURE__*/_jsx(Alert, {
367
+ type: "info",
368
+ style: {
369
+ width: '100%'
370
+ },
371
+ children: t('blocklet.publish.packTip')
372
+ }), /*#__PURE__*/_jsx(Box, {
373
+ pt: 3
374
+ }), /*#__PURE__*/_jsxs(Box, {
356
375
  display: "flex",
357
376
  className: "section",
358
377
  children: [/*#__PURE__*/_jsx(Typography, {
@@ -1,4 +1,4 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useState, useEffect, useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from '@emotion/styled';
4
4
  import joinUrl from 'url-join';
@@ -24,6 +24,12 @@ const fillParent = (nodes, parentId) => {
24
24
  });
25
25
  return nodes;
26
26
  };
27
+ function arraysAreEqual(arr1, arr2) {
28
+ if (arr1.length !== arr2.length) {
29
+ return false;
30
+ }
31
+ return arr1.every((value, index) => value === arr2[index]);
32
+ }
27
33
  export default function Resource({
28
34
  app,
29
35
  component,
@@ -41,7 +47,14 @@ export default function Resource({
41
47
  } = useNodeContext();
42
48
  const [resources, setResources] = useState([]);
43
49
  const [selectedResourceIds, setSelectedResourceIds] = useState([]);
50
+ const [initialResourceIds, setInitialResourceIds] = useState([]);
44
51
  const [loading, setLoading] = useState(false);
52
+ const warning = useMemo(() => {
53
+ if (arraysAreEqual(selectedResourceIds, initialResourceIds)) {
54
+ return null;
55
+ }
56
+ return t('blocklet.publish.resourceChangedWarning');
57
+ }, [selectedResourceIds, initialResourceIds, t]);
45
58
  const releaseId = release.id;
46
59
  const readonly = release.status === 'published';
47
60
  const {
@@ -80,6 +93,7 @@ export default function Resource({
80
93
  Toast.success(t('common.saveSuccess'));
81
94
  setLoading(false);
82
95
  saveSelected(selectedResourceIds);
96
+ setInitialResourceIds(selectedResourceIds);
83
97
  onSave(selectedResourceIds);
84
98
  } catch (err) {
85
99
  setLoading(false);
@@ -103,6 +117,7 @@ export default function Resource({
103
117
  }).then(res => {
104
118
  const list = res?.resources || [];
105
119
  setSelectedResourceIds(list);
120
+ setInitialResourceIds(list);
106
121
  }).catch(err => {
107
122
  Toast.error(err.message);
108
123
  });
@@ -138,6 +153,11 @@ export default function Resource({
138
153
  })
139
154
  })]
140
155
  })
156
+ }), !!warning && /*#__PURE__*/_jsx(Box, {
157
+ color: "warning.main",
158
+ mt: 1,
159
+ fontSize: 14,
160
+ children: warning
141
161
  }), !!error && /*#__PURE__*/_jsx(Box, {
142
162
  color: "error.main",
143
163
  mt: 1,
package/es/locales/en.js CHANGED
@@ -643,6 +643,8 @@ export default {
643
643
  createBlockletDid: 'Create from DID Wallet',
644
644
  createReleaseSuccess: 'Release created successfully',
645
645
  saveDraftSuccess: 'Draft saved successfully',
646
+ packTip: 'Components and application configuration will be automatically included in the blocklet',
647
+ resourceChangedWarning: 'You have modified the resource, please save it in time',
646
648
  connect: {
647
649
  title: 'Create Blocklet DID',
648
650
  scan: 'Scan the QR code below to generate Blocklet DID',
package/es/locales/zh.js CHANGED
@@ -652,6 +652,8 @@ export default {
652
652
  createBlockletDid: '通过 DID 钱包创建',
653
653
  createReleaseSuccess: '发布成功',
654
654
  saveDraftSuccess: '保存成功',
655
+ packTip: 'Blocklet 中将自动包含组件和应用配置',
656
+ resourceChangedWarning: '您修改了资源,请及时保存',
655
657
  connect: {
656
658
  title: '创建 Blocklet DID',
657
659
  scan: '扫描下面的二维码来生成 Blocklet DID',
@@ -32,7 +32,7 @@ function ComponentConfiguration(_ref) {
32
32
  t
33
33
  } = (0, _context.useLocaleContext)();
34
34
  const isComponent = !!ancestors.length;
35
- const [tab, setTab] = (0, _react.useState)('settings');
35
+ const [tab, setTab] = (0, _react.useState)((0, _util.hasStartEngine)(blocklet === null || blocklet === void 0 ? void 0 : blocklet.meta) ? 'settings' : 'environments');
36
36
  const name = isComponent ? (0, _util.getDisplayName)(blocklet, true) : t('blocklet.component.container');
37
37
  if ((0, _util2.isInstalling)(blocklet.status)) {
38
38
  return null;
@@ -49,7 +49,7 @@ function ComponentConfiguration(_ref) {
49
49
  setShowDialog(true);
50
50
  };
51
51
  const tabConfigs = {
52
- settings: {
52
+ settings: (0, _util.hasStartEngine)(blocklet.meta) && {
53
53
  label: t('blocklet.component.setting'),
54
54
  value: 'settings',
55
55
  component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_setting.default, {
@@ -66,7 +66,8 @@ function ComponentConfiguration(_ref) {
66
66
  })
67
67
  }
68
68
  };
69
- const tabs = Object.values(tabConfigs).map(_ref2 => {
69
+ const tabConfigsArr = Object.values(tabConfigs).filter(Boolean);
70
+ const tabs = tabConfigsArr.map(_ref2 => {
70
71
  let {
71
72
  label,
72
73
  value
@@ -79,7 +80,7 @@ function ComponentConfiguration(_ref) {
79
80
  const onTabChange = newTab => {
80
81
  setTab(newTab);
81
82
  };
82
- const tabConfig = tabConfigs[tab] || tabConfigs.settings;
83
+ const tabConfig = tabConfigs[tab] || tabConfigsArr[0];
83
84
  return [typeof children === 'function' ? children({
84
85
  open: onOpen
85
86
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
@@ -391,7 +391,7 @@ function ComponentItem(_ref) {
391
391
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Launch.default, {})
392
392
  })
393
393
  })
394
- }), (0, _util.hasStartEngine)(blocklet.meta) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_configuration.default, {
394
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_configuration.default, {
395
395
  blocklet: blocklet,
396
396
  ancestors: ancestors,
397
397
  children: _ref3 => {
@@ -42,8 +42,7 @@ const Types = [{
42
42
  en: 'Application',
43
43
  zh: '应用'
44
44
  },
45
- value: 'pack',
46
- disabled: true
45
+ value: 'pack'
47
46
  }];
48
47
  function CreateProject(_ref) {
49
48
  let rest = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
@@ -25,6 +25,7 @@ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
25
25
  var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
26
26
  var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
27
27
  var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
28
+ var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
28
29
  var _constant = require("@blocklet/constant");
29
30
  var _constant2 = require("@abtnode/constant");
30
31
  var _bundleAvatar = _interopRequireDefault(require("../bundle-avatar"));
@@ -144,6 +145,7 @@ function CreateRelease(_ref2) {
144
145
  } = (0, _node.useNodeContext)();
145
146
  const uploaderLogoRef = (0, _react.useRef)(null);
146
147
  const uploaderScreenshotRef = (0, _react.useRef)(null);
148
+ const [projectType, setProjectType] = (0, _react.useState)();
147
149
  const releaseId = inputReleaseId === 'create' ? '' : inputReleaseId;
148
150
  const mode = inputReleaseId === 'create' ? 'create' : 'edit';
149
151
  const tabs = [];
@@ -162,7 +164,10 @@ function CreateRelease(_ref2) {
162
164
  const [tab, setTab] = (0, _react.useState)((_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.value);
163
165
  const isPublished = (release === null || release === void 0 ? void 0 : release.status) === 'published';
164
166
  const readOnly = isPublished;
165
- const getProject = () => {
167
+ const getProject = function getProject() {
168
+ let {
169
+ typeOnly
170
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
166
171
  api.getProject({
167
172
  input: {
168
173
  did: blocklet.meta.did,
@@ -171,12 +176,17 @@ function CreateRelease(_ref2) {
171
176
  }).then(res => {
172
177
  setLoading(false);
173
178
  const data = res.project || {};
179
+ if (typeOnly) {
180
+ setProjectType(data.type);
181
+ return;
182
+ }
174
183
  if (!data.blockletVersion) {
175
184
  data.blockletVersion = '1.0.0';
176
185
  } else if (_semver.default.valid(data.blockletVersion)) {
177
186
  data.blockletVersion = _semver.default.inc(data.blockletVersion, 'patch');
178
187
  }
179
188
  setParams(pickParams(data));
189
+ setProjectType(data.type);
180
190
  }).catch(err => {
181
191
  setLoading(false);
182
192
  _Toast.default.error((0, _util.formatError)(err));
@@ -205,6 +215,9 @@ function CreateRelease(_ref2) {
205
215
  return;
206
216
  }
207
217
  getRelease();
218
+ getProject({
219
+ typeOnly: true
220
+ });
208
221
  }
209
222
  if (mode === 'create') {
210
223
  getProject();
@@ -365,8 +378,15 @@ function CreateRelease(_ref2) {
365
378
  })]
366
379
  })]
367
380
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
368
- pt: 3,
369
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
381
+ children: [projectType === 'pack' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
382
+ type: "info",
383
+ style: {
384
+ width: '100%'
385
+ },
386
+ children: t('blocklet.publish.packTip')
387
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
388
+ pt: 3
389
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
370
390
  display: "flex",
371
391
  className: "section",
372
392
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
@@ -32,6 +32,12 @@ const fillParent = (nodes, parentId) => {
32
32
  });
33
33
  return nodes;
34
34
  };
35
+ function arraysAreEqual(arr1, arr2) {
36
+ if (arr1.length !== arr2.length) {
37
+ return false;
38
+ }
39
+ return arr1.every((value, index) => value === arr2[index]);
40
+ }
35
41
  function Resource(_ref) {
36
42
  let {
37
43
  app,
@@ -50,7 +56,14 @@ function Resource(_ref) {
50
56
  } = (0, _node.useNodeContext)();
51
57
  const [resources, setResources] = (0, _react.useState)([]);
52
58
  const [selectedResourceIds, setSelectedResourceIds] = (0, _react.useState)([]);
59
+ const [initialResourceIds, setInitialResourceIds] = (0, _react.useState)([]);
53
60
  const [loading, setLoading] = (0, _react.useState)(false);
61
+ const warning = (0, _react.useMemo)(() => {
62
+ if (arraysAreEqual(selectedResourceIds, initialResourceIds)) {
63
+ return null;
64
+ }
65
+ return t('blocklet.publish.resourceChangedWarning');
66
+ }, [selectedResourceIds, initialResourceIds, t]);
54
67
  const releaseId = release.id;
55
68
  const readonly = release.status === 'published';
56
69
  const {
@@ -89,6 +102,7 @@ function Resource(_ref) {
89
102
  _Toast.default.success(t('common.saveSuccess'));
90
103
  setLoading(false);
91
104
  saveSelected(selectedResourceIds);
105
+ setInitialResourceIds(selectedResourceIds);
92
106
  onSave(selectedResourceIds);
93
107
  } catch (err) {
94
108
  setLoading(false);
@@ -113,6 +127,7 @@ function Resource(_ref) {
113
127
  }).then(res => {
114
128
  const list = (res === null || res === void 0 ? void 0 : res.resources) || [];
115
129
  setSelectedResourceIds(list);
130
+ setInitialResourceIds(list);
116
131
  }).catch(err => {
117
132
  _Toast.default.error(err.message);
118
133
  });
@@ -148,6 +163,11 @@ function Resource(_ref) {
148
163
  })
149
164
  })]
150
165
  })
166
+ }), !!warning && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
167
+ color: "warning.main",
168
+ mt: 1,
169
+ fontSize: 14,
170
+ children: warning
151
171
  }), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
152
172
  color: "error.main",
153
173
  mt: 1,
package/lib/locales/en.js CHANGED
@@ -649,6 +649,8 @@ var _default = exports.default = {
649
649
  createBlockletDid: 'Create from DID Wallet',
650
650
  createReleaseSuccess: 'Release created successfully',
651
651
  saveDraftSuccess: 'Draft saved successfully',
652
+ packTip: 'Components and application configuration will be automatically included in the blocklet',
653
+ resourceChangedWarning: 'You have modified the resource, please save it in time',
652
654
  connect: {
653
655
  title: 'Create Blocklet DID',
654
656
  scan: 'Scan the QR code below to generate Blocklet DID',
package/lib/locales/zh.js CHANGED
@@ -658,6 +658,8 @@ var _default = exports.default = {
658
658
  createBlockletDid: '通过 DID 钱包创建',
659
659
  createReleaseSuccess: '发布成功',
660
660
  saveDraftSuccess: '保存成功',
661
+ packTip: 'Blocklet 中将自动包含组件和应用配置',
662
+ resourceChangedWarning: '您修改了资源,请及时保存',
661
663
  connect: {
662
664
  title: '创建 Blocklet DID',
663
665
  scan: '扫描下面的二维码来生成 Blocklet DID',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.22",
3
+ "version": "1.16.23-beta-f85576a6",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,9 +27,9 @@
27
27
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
28
28
  "license": "Apache-2.0",
29
29
  "dependencies": {
30
- "@abtnode/auth": "1.16.22",
31
- "@abtnode/constant": "1.16.22",
32
- "@abtnode/util": "1.16.22",
30
+ "@abtnode/auth": "1.16.23-beta-f85576a6",
31
+ "@abtnode/constant": "1.16.23-beta-f85576a6",
32
+ "@abtnode/util": "1.16.23-beta-f85576a6",
33
33
  "@ahooksjs/use-url-state": "^3.5.1",
34
34
  "@arcblock/did": "^1.18.108",
35
35
  "@arcblock/did-connect": "^2.9.13",
@@ -39,10 +39,10 @@
39
39
  "@arcblock/react-hooks": "^2.9.13",
40
40
  "@arcblock/terminal": "^2.9.13",
41
41
  "@arcblock/ux": "^2.9.13",
42
- "@blocklet/constant": "1.16.22",
42
+ "@blocklet/constant": "1.16.23-beta-f85576a6",
43
43
  "@blocklet/launcher-layout": "2.2.51",
44
44
  "@blocklet/list": "^0.12.65",
45
- "@blocklet/meta": "1.16.22",
45
+ "@blocklet/meta": "1.16.23-beta-f85576a6",
46
46
  "@blocklet/ui-react": "^2.9.13",
47
47
  "@blocklet/uploader": "^0.0.64",
48
48
  "@emotion/react": "^11.10.4",
@@ -102,7 +102,7 @@
102
102
  "babel-plugin-inline-react-svg": "^1.1.2",
103
103
  "glob": "^10.3.3"
104
104
  },
105
- "gitHead": "eba523c2d8f62f2a1c742b23e3280774bf9bc4cf",
105
+ "gitHead": "bac83a74944b4cef3ccb386277023caf0e1d5cd4",
106
106
  "exports": {
107
107
  ".": {
108
108
  "import": "./es/index.js",