@abtnode/ux 1.16.16-beta-d8a9fb09 → 1.16.16-beta-740ea329

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.
@@ -20,7 +20,7 @@ export default function CpuMonitor({
20
20
  current: `${Math.floor(currentLoad || 0)}%`,
21
21
  data: history,
22
22
  description: `${t('system.cores')}: ${cpus?.length || 0}`,
23
- dateFn: v => formatTime(v, 'HH:mm', locale),
23
+ dateFn: v => formatTime(v, 'HH:mm:ss', locale),
24
24
  valueFn: formatNumber
25
25
  });
26
26
  }
@@ -52,7 +52,7 @@ export default function MemoryMonitor({
52
52
  },
53
53
  children: [x.title, ": ", x.metric]
54
54
  }, x.title)),
55
- dateFn: v => formatTime(v, 'HH:mm', locale),
55
+ dateFn: v => formatTime(v, 'HH:mm:ss', locale),
56
56
  valueFn: filesize
57
57
  });
58
58
  }
@@ -539,9 +539,9 @@ export default function AddComponent({
539
539
  }
540
540
  return 0;
541
541
  });
542
- const sharedConfigObj = getSharedConfigObj({
542
+ const sharedConfigObj = getSharedConfigObj(ancestors[0], {
543
543
  configs: componentAllConfigs
544
- }, ancestors);
544
+ });
545
545
  const configsValue = {};
546
546
  const configsList = componentAllConfigs.map(item => {
547
547
  const {
@@ -7,7 +7,7 @@ import MaterialTable from '@material-table/core';
7
7
  import TextField from '@mui/material/TextField';
8
8
  import Alert from '@mui/material/Alert';
9
9
  import { BLOCKLET_CONFIGURABLE_KEY, CHAIN_PROP_MAP } from '@blocklet/constant';
10
- import { getComponentMissingConfigs, getSharedConfigObj } from '@blocklet/meta/lib/util';
10
+ import { getComponentMissingConfigs, getSharedConfigObj, isEnvShareable } from '@blocklet/meta/lib/util';
11
11
  import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
12
12
  import Toast from '@arcblock/ux/lib/Toast';
13
13
  import ClickToCopy from '../../click-to-copy';
@@ -23,7 +23,7 @@ const getDescription = (data, t) => {
23
23
  let {
24
24
  description
25
25
  } = data;
26
- if (Object.values(CHAIN_PROP_MAP).includes(data.key)) {
26
+ if (Object.values(CHAIN_PROP_MAP).includes(data.key) || isEnvShareable(data)) {
27
27
  if (description) {
28
28
  description = `${description} (${t('blocklet.config.sharedToAllComponents')})`;
29
29
  } else {
@@ -37,6 +37,19 @@ const getDescription = (data, t) => {
37
37
  children: description
38
38
  });
39
39
  };
40
+ const isCustom = (env, blocklet, ancestors = []) => {
41
+ if (!ancestors?.length &&
42
+ // is container
43
+ !env.custom &&
44
+ // is not manual
45
+ !['CHAIN_ID', 'CHAIN_HOST'].includes(env.key) && !blocklet.meta.environments.find(y => y.name === env.key) &&
46
+ // is not declared in blocklet.yml
47
+ blocklet.children.every(child => !child.meta.environments.find(y => y.name === env.key)) // is not declared in all children
48
+ ) {
49
+ return true;
50
+ }
51
+ return env.custom;
52
+ };
40
53
  export default function ComponentEnvironment({
41
54
  blocklet,
42
55
  ancestors
@@ -50,7 +63,7 @@ export default function ComponentEnvironment({
50
63
  } = useContext(LocaleContext);
51
64
  const dids = [...ancestors.map(x => x.meta.did), blocklet.meta.did];
52
65
  const onConfigChanged = () => Toast.success(t('blocklet.config.changedTip'));
53
- const isConfigEditable = x => x.custom;
66
+ const isConfigEditable = x => isCustom(x, blocklet, ancestors);
54
67
  if (isInstalling(blocklet.status)) {
55
68
  return null;
56
69
  }
@@ -96,7 +109,7 @@ export default function ComponentEnvironment({
96
109
  }
97
110
  const configs = [newData];
98
111
  if (newData.key !== oldData.key) {
99
- if (!newData.custom) {
112
+ if (!isCustom(newData, blocklet, ancestors)) {
100
113
  Toast.error('Only key of custom env can be changed');
101
114
  return;
102
115
  }
@@ -124,7 +137,7 @@ export default function ComponentEnvironment({
124
137
  Toast.error(t('blocklet.config.environment.deleteForbidden'));
125
138
  return;
126
139
  }
127
- if (!data.custom) {
140
+ if (!isCustom(data, blocklet, ancestors)) {
128
141
  Toast.error('Only key of custom env can be changed');
129
142
  return;
130
143
  }
@@ -144,8 +157,8 @@ export default function ComponentEnvironment({
144
157
 
145
158
  // configs
146
159
  const componentConfigs = (blocklet.configs || []).filter(x => !BLOCKLET_CONFIGURABLE_KEY[x.key]);
147
- const sharedConfigObj = getSharedConfigObj(blocklet, ancestors);
148
- const missingRequiredConfigs = getComponentMissingConfigs(blocklet, ancestors);
160
+ const sharedConfigObj = getSharedConfigObj(ancestors[0], blocklet);
161
+ const missingRequiredConfigs = getComponentMissingConfigs(blocklet, ancestors[0]);
149
162
  const configs = componentConfigs.map(x => ({
150
163
  ...x,
151
164
  value: Object.values(CHAIN_PROP_MAP).includes(x.key) && Object.keys(sharedConfigObj).includes(x.key) ? sharedConfigObj[x.key] : sharedConfigObj[x.key] || x.value
@@ -364,7 +364,7 @@ function ComponentItem({
364
364
  color: "error",
365
365
  badgeContent: "",
366
366
  variant: "dot",
367
- invisible: !getComponentMissingConfigs(blocklet, ancestors).length,
367
+ invisible: !getComponentMissingConfigs(blocklet, ancestors[0]).length,
368
368
  children: /*#__PURE__*/_jsx(IconButton, {
369
369
  onClick: open,
370
370
  size: "small",
@@ -28,7 +28,7 @@ function CpuMonitor(_ref) {
28
28
  current: "".concat(Math.floor(currentLoad || 0), "%"),
29
29
  data: history,
30
30
  description: "".concat(t('system.cores'), ": ").concat((cpus === null || cpus === void 0 ? void 0 : cpus.length) || 0),
31
- dateFn: v => (0, _util.formatTime)(v, 'HH:mm', locale),
31
+ dateFn: v => (0, _util.formatTime)(v, 'HH:mm:ss', locale),
32
32
  valueFn: formatNumber
33
33
  });
34
34
  }
@@ -60,7 +60,7 @@ function MemoryMonitor(_ref) {
60
60
  },
61
61
  children: [x.title, ": ", x.metric]
62
62
  }, x.title)),
63
- dateFn: v => (0, _util.formatTime)(v, 'HH:mm', locale),
63
+ dateFn: v => (0, _util.formatTime)(v, 'HH:mm:ss', locale),
64
64
  valueFn: _filesize.default
65
65
  });
66
66
  }
@@ -550,9 +550,9 @@ function AddComponent(_ref2) {
550
550
  }
551
551
  return 0;
552
552
  });
553
- const sharedConfigObj = (0, _util.getSharedConfigObj)({
553
+ const sharedConfigObj = (0, _util.getSharedConfigObj)(ancestors[0], {
554
554
  configs: componentAllConfigs
555
- }, ancestors);
555
+ });
556
556
  const configsValue = {};
557
557
  const configsList = componentAllConfigs.map(item => {
558
558
  const {
@@ -34,7 +34,7 @@ const getDescription = (data, t) => {
34
34
  let {
35
35
  description
36
36
  } = data;
37
- if (Object.values(_constant.CHAIN_PROP_MAP).includes(data.key)) {
37
+ if (Object.values(_constant.CHAIN_PROP_MAP).includes(data.key) || (0, _util.isEnvShareable)(data)) {
38
38
  if (description) {
39
39
  description = "".concat(description, " (").concat(t('blocklet.config.sharedToAllComponents'), ")");
40
40
  } else {
@@ -48,6 +48,20 @@ const getDescription = (data, t) => {
48
48
  children: description
49
49
  });
50
50
  };
51
+ const isCustom = function isCustom(env, blocklet) {
52
+ let ancestors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
53
+ if (!(ancestors !== null && ancestors !== void 0 && ancestors.length) &&
54
+ // is container
55
+ !env.custom &&
56
+ // is not manual
57
+ !['CHAIN_ID', 'CHAIN_HOST'].includes(env.key) && !blocklet.meta.environments.find(y => y.name === env.key) &&
58
+ // is not declared in blocklet.yml
59
+ blocklet.children.every(child => !child.meta.environments.find(y => y.name === env.key)) // is not declared in all children
60
+ ) {
61
+ return true;
62
+ }
63
+ return env.custom;
64
+ };
51
65
  function ComponentEnvironment(_ref) {
52
66
  let {
53
67
  blocklet,
@@ -62,7 +76,7 @@ function ComponentEnvironment(_ref) {
62
76
  } = (0, _react.useContext)(_context.LocaleContext);
63
77
  const dids = [...ancestors.map(x => x.meta.did), blocklet.meta.did];
64
78
  const onConfigChanged = () => _Toast.default.success(t('blocklet.config.changedTip'));
65
- const isConfigEditable = x => x.custom;
79
+ const isConfigEditable = x => isCustom(x, blocklet, ancestors);
66
80
  if ((0, _util2.isInstalling)(blocklet.status)) {
67
81
  return null;
68
82
  }
@@ -108,7 +122,7 @@ function ComponentEnvironment(_ref) {
108
122
  }
109
123
  const configs = [newData];
110
124
  if (newData.key !== oldData.key) {
111
- if (!newData.custom) {
125
+ if (!isCustom(newData, blocklet, ancestors)) {
112
126
  _Toast.default.error('Only key of custom env can be changed');
113
127
  return;
114
128
  }
@@ -136,7 +150,7 @@ function ComponentEnvironment(_ref) {
136
150
  _Toast.default.error(t('blocklet.config.environment.deleteForbidden'));
137
151
  return;
138
152
  }
139
- if (!data.custom) {
153
+ if (!isCustom(data, blocklet, ancestors)) {
140
154
  _Toast.default.error('Only key of custom env can be changed');
141
155
  return;
142
156
  }
@@ -156,8 +170,8 @@ function ComponentEnvironment(_ref) {
156
170
 
157
171
  // configs
158
172
  const componentConfigs = (blocklet.configs || []).filter(x => !_constant.BLOCKLET_CONFIGURABLE_KEY[x.key]);
159
- const sharedConfigObj = (0, _util.getSharedConfigObj)(blocklet, ancestors);
160
- const missingRequiredConfigs = (0, _util.getComponentMissingConfigs)(blocklet, ancestors);
173
+ const sharedConfigObj = (0, _util.getSharedConfigObj)(ancestors[0], blocklet);
174
+ const missingRequiredConfigs = (0, _util.getComponentMissingConfigs)(blocklet, ancestors[0]);
161
175
  const configs = componentConfigs.map(x => _objectSpread(_objectSpread({}, x), {}, {
162
176
  value: Object.values(_constant.CHAIN_PROP_MAP).includes(x.key) && Object.keys(sharedConfigObj).includes(x.key) ? sharedConfigObj[x.key] : sharedConfigObj[x.key] || x.value
163
177
  }));
@@ -389,7 +389,7 @@ function ComponentItem(_ref) {
389
389
  color: "error",
390
390
  badgeContent: "",
391
391
  variant: "dot",
392
- invisible: !(0, _util.getComponentMissingConfigs)(blocklet, ancestors).length,
392
+ invisible: !(0, _util.getComponentMissingConfigs)(blocklet, ancestors[0]).length,
393
393
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
394
394
  onClick: open,
395
395
  size: "small",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.16-beta-d8a9fb09",
3
+ "version": "1.16.16-beta-740ea329",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,23 +27,23 @@
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.16-beta-d8a9fb09",
31
- "@abtnode/constant": "1.16.16-beta-d8a9fb09",
32
- "@abtnode/util": "1.16.16-beta-d8a9fb09",
30
+ "@abtnode/auth": "1.16.16-beta-740ea329",
31
+ "@abtnode/constant": "1.16.16-beta-740ea329",
32
+ "@abtnode/util": "1.16.16-beta-740ea329",
33
33
  "@ahooksjs/use-url-state": "^3.5.1",
34
34
  "@arcblock/did": "^1.18.89",
35
- "@arcblock/did-connect": "^2.7.15",
35
+ "@arcblock/did-connect": "^2.7.16",
36
36
  "@arcblock/did-motif": "^1.1.13",
37
- "@arcblock/icons": "^2.7.15",
38
- "@arcblock/nft-display": "2.7.15",
39
- "@arcblock/react-hooks": "^2.7.15",
40
- "@arcblock/terminal": "^2.7.15",
41
- "@arcblock/ux": "^2.7.15",
42
- "@blocklet/constant": "1.16.16-beta-d8a9fb09",
37
+ "@arcblock/icons": "^2.7.16",
38
+ "@arcblock/nft-display": "2.7.16",
39
+ "@arcblock/react-hooks": "^2.7.16",
40
+ "@arcblock/terminal": "^2.7.16",
41
+ "@arcblock/ux": "^2.7.16",
42
+ "@blocklet/constant": "1.16.16-beta-740ea329",
43
43
  "@blocklet/launcher-layout": "2.2.5",
44
- "@blocklet/list": "^0.12.34",
45
- "@blocklet/meta": "1.16.16-beta-d8a9fb09",
46
- "@blocklet/ui-react": "^2.7.15",
44
+ "@blocklet/list": "^0.12.35",
45
+ "@blocklet/meta": "1.16.16-beta-740ea329",
46
+ "@blocklet/ui-react": "^2.7.16",
47
47
  "@emotion/react": "^11.10.4",
48
48
  "@emotion/styled": "^11.10.4",
49
49
  "@iconify/react": "^4.0.0",
@@ -98,7 +98,7 @@
98
98
  "babel-plugin-inline-react-svg": "^1.1.2",
99
99
  "glob": "^10.3.3"
100
100
  },
101
- "gitHead": "a03d8972fd0fafe810369efa89b03ccd0647dce5",
101
+ "gitHead": "6abb5a7319ad1093f1e2d04d76215d4a127b538d",
102
102
  "exports": {
103
103
  ".": {
104
104
  "import": "./es/index.js",