@abtnode/ux 1.16.7 → 1.16.8-beta-ca58a421

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,434 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = Storage;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
9
+ var _context = require("@arcblock/ux/lib/Locale/context");
10
+ var _constant = require("@blocklet/constant");
11
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
12
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
13
+ var _material = require("@mui/material");
14
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
15
+ var _Datatable = _interopRequireDefault(require("@arcblock/ux/lib/Datatable"));
16
+ var _ahooks = require("ahooks");
17
+ var _Tag = _interopRequireDefault(require("@arcblock/ux/lib/Tag"));
18
+ var _dayjs = _interopRequireDefault(require("dayjs"));
19
+ var _HelpOutline = _interopRequireDefault(require("@mui/icons-material/HelpOutline"));
20
+ var _lodash = require("lodash");
21
+ var _node = require("../../contexts/node");
22
+ var _blocklet = require("../../../lib/contexts/blocklet");
23
+ var _toast = _interopRequireDefault(require("../../toast"));
24
+ var _switchDidSpaces = _interopRequireDefault(require("./switch-did-spaces"));
25
+ var _spaces = require("../../util/spaces");
26
+ var _jsxRuntime = require("react/jsx-runtime");
27
+ var _templateObject;
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
34
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
35
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
36
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
37
+ const Container = (0, _styled.default)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n"])));
38
+
39
+ /**
40
+ * @description 实时显示备份的进度
41
+ * @param {{appDid: string}} {appDid}
42
+ * @return {{message: string, progress: number, completed: boolean}}
43
+ */
44
+ function useBackupProgress(_ref) {
45
+ let {
46
+ appDid
47
+ } = _ref;
48
+ const [progress, setProgress] = (0, _react.useState)({
49
+ message: '',
50
+ progress: 0,
51
+ completed: false
52
+ });
53
+ const node = (0, _node.useNodeContext)();
54
+ const {
55
+ ws: {
56
+ useSubscription
57
+ }
58
+ } = node;
59
+ useSubscription(_constant.BlockletEvents.backupProgress, data => {
60
+ setProgress(() => _objectSpread({}, data));
61
+ }, [appDid]);
62
+ return progress;
63
+ }
64
+
65
+ /**
66
+ * @description
67
+ * @param {{ blocklet: import('@abtnode/client').BlockletState }} { blocklet }
68
+ * @return {{backups: import('@abtnode/client').Backup[]}}
69
+ */
70
+ function useBackups(_ref2) {
71
+ let {
72
+ blocklet,
73
+ loading
74
+ } = _ref2;
75
+ const [backups, setBackups] = (0, _react.useState)([]);
76
+ const {
77
+ api
78
+ } = (0, _node.useNodeContext)();
79
+ (0, _ahooks.useAsyncEffect)(async () => {
80
+ var _blocklet$meta;
81
+ const {
82
+ backups: data
83
+ } = await api.getBlockletBackups({
84
+ input: {
85
+ did: blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did
86
+ }
87
+ });
88
+ setBackups(data !== null && data !== void 0 ? data : []);
89
+ }, [blocklet, loading]);
90
+ return {
91
+ backups
92
+ };
93
+ }
94
+ function useSpaceGateways(_ref3) {
95
+ let {
96
+ blocklet
97
+ } = _ref3;
98
+ const [spaceGateways, setSpaceGateways] = (0, _react.useState)( /** @type {SpaceGateway[]} */
99
+ []);
100
+ const {
101
+ api
102
+ } = (0, _node.useNodeContext)();
103
+ (0, _ahooks.useAsyncEffect)(async () => {
104
+ const {
105
+ spaceGateways: _spaceGateways
106
+ } = await api.getBlockletSpaceGateways({
107
+ input: {
108
+ did: blocklet.meta.did
109
+ }
110
+ });
111
+ setSpaceGateways([{
112
+ name: 'Prod DID Spaces',
113
+ url: 'https://www.didspaces.com/app',
114
+ protected: true
115
+ }, ...(_spaceGateways !== null && _spaceGateways !== void 0 ? _spaceGateways : [])]);
116
+ }, [blocklet]);
117
+ return {
118
+ spaceGateways
119
+ };
120
+ }
121
+ function Storage() {
122
+ /** @type {{ api: import('@abtnode/client').ABTNodeClient, info: import('@abtnode/client').NodeState }} */
123
+ const {
124
+ api
125
+ } = (0, _node.useNodeContext)();
126
+ const {
127
+ t,
128
+ locale
129
+ } = (0, _react.useContext)(_context.LocaleContext);
130
+ /** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
131
+ const {
132
+ blocklet
133
+ } = (0, _blocklet.useBlockletContext)();
134
+ const endpoint = (0, _react.useMemo)(() => (0, _spaces.getSpaceBackupEndpoint)(blocklet === null || blocklet === void 0 ? void 0 : blocklet.environments), [blocklet]);
135
+ const progress = useBackupProgress({
136
+ appDid: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appDid
137
+ });
138
+ const [loading, setLoading] = (0, _react.useState)(false);
139
+ const {
140
+ backups
141
+ } = useBackups({
142
+ blocklet,
143
+ loading
144
+ });
145
+ const {
146
+ spaceGateways
147
+ } = useSpaceGateways({
148
+ blocklet
149
+ });
150
+ const handleManualBackup = async () => {
151
+ try {
152
+ if (loading) {
153
+ return;
154
+ }
155
+ setLoading(true);
156
+ await api.backupBlocklet({
157
+ input: {
158
+ appDid: blocklet.appDid,
159
+ to: 'spaces'
160
+ }
161
+ });
162
+ } catch (error) {
163
+ _toast.default.error(error.message);
164
+ console.error(error);
165
+ }
166
+ };
167
+ const columns = [{
168
+ label: 'DID Spaces',
169
+ name: 'target',
170
+ options: {
171
+ // eslint-disable-next-line react/no-unstable-nested-components
172
+ customBodyRenderLite: index => {
173
+ var _spaceGateways$find$n, _spaceGateways$find;
174
+ // eslint-disable-next-line no-unused-vars
175
+ const {
176
+ targetUrl
177
+ } = backups[index];
178
+ const spaceName = (_spaceGateways$find$n = (_spaceGateways$find = spaceGateways.find(spaceGateway => targetUrl === null || targetUrl === void 0 ? void 0 : targetUrl.includes(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.url))) === null || _spaceGateways$find === void 0 ? void 0 : _spaceGateways$find.name) !== null && _spaceGateways$find$n !== void 0 ? _spaceGateways$find$n : 'DID Spaces';
179
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Link, {
180
+ fontSize: "16px",
181
+ href: targetUrl,
182
+ target: "_blank",
183
+ children: spaceName
184
+ });
185
+ }
186
+ }
187
+ }, {
188
+ label: t('common.strategy'),
189
+ name: 'strategy',
190
+ options: {
191
+ /**
192
+ * @param {0 | 1} strategy
193
+ * @returns {React.ReactNode}
194
+ */
195
+ // eslint-disable-next-line react/no-unstable-nested-components
196
+ customBodyRender: strategy => {
197
+ const text = strategy === 0 ? t('common.auto') : t('common.manual');
198
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
199
+ children: text
200
+ });
201
+ }
202
+ }
203
+ }, {
204
+ label: t('common.startTime'),
205
+ name: 'createdAt',
206
+ options: {
207
+ /**
208
+ * @param {0 | 1} strategy
209
+ * @returns {React.ReactNode}
210
+ */
211
+ // eslint-disable-next-line react/no-unstable-nested-components
212
+ customBodyRender: createdAt => {
213
+ return (0, _dayjs.default)(createdAt).format('YYYY-MM-DD HH:mm:ss');
214
+ }
215
+ }
216
+ }, {
217
+ label: t('common.endTime'),
218
+ name: 'updatedAt',
219
+ options: {
220
+ /**
221
+ * @param {string} updatedAt
222
+ * @returns {React.ReactNode}
223
+ */
224
+ // eslint-disable-next-line react/no-unstable-nested-components
225
+ customBodyRender: updatedAt => {
226
+ if ((0, _lodash.isEmpty)(updatedAt)) {
227
+ return '';
228
+ }
229
+ return (0, _dayjs.default)(updatedAt).format('YYYY-MM-DD HH:mm:ss');
230
+ }
231
+ }
232
+ }, {
233
+ label: t('common.status'),
234
+ name: 'status',
235
+ options: {
236
+ /**
237
+ * @param {string} status
238
+ * @returns {React.ReactNode}
239
+ */
240
+ // eslint-disable-next-line react/no-unstable-nested-components
241
+ customBodyRenderLite: index => {
242
+ var _backups$index;
243
+ const {
244
+ status,
245
+ message
246
+ } = (_backups$index = backups === null || backups === void 0 ? void 0 : backups[index]) !== null && _backups$index !== void 0 ? _backups$index : {};
247
+ if ((0, _lodash.isNull)(status)) {
248
+ return t('common.progress');
249
+ }
250
+ const node = !status ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
251
+ type: "success",
252
+ children: t('common.success')
253
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
254
+ display: "inline-flex",
255
+ alignItems: "center",
256
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
257
+ type: "error",
258
+ children: t('common.failed')
259
+ }), " \xA0", /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
260
+ style: {
261
+ display: 'flex',
262
+ alignItems: 'center'
263
+ },
264
+ title: message,
265
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Icon, {
266
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_HelpOutline.default, {
267
+ color: "error"
268
+ })
269
+ })
270
+ })]
271
+ });
272
+ return node;
273
+ }
274
+ }
275
+ }];
276
+ (0, _react.useEffect)(() => {
277
+ if (progress !== null && progress !== void 0 && progress.completed) {
278
+ if ((progress === null || progress === void 0 ? void 0 : progress.progress) === 100) {
279
+ _toast.default.success(t('storage.spaces.backupSuccessfully'));
280
+ } else if ((progress === null || progress === void 0 ? void 0 : progress.progress) === -1) {
281
+ _toast.default.error(progress === null || progress === void 0 ? void 0 : progress.message);
282
+ }
283
+ setLoading(false);
284
+ progress.progress = 0;
285
+ } else if (progress.progress) {
286
+ setLoading(true);
287
+ }
288
+ // eslint-disable-next-line react-hooks/exhaustive-deps
289
+ }, [progress]);
290
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
291
+ style: {
292
+ maxWidth: '1280px'
293
+ },
294
+ children: [endpoint && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
295
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
296
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
297
+ sx: {
298
+ display: 'flex',
299
+ alignItems: 'center'
300
+ },
301
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
302
+ fontSize: "1.2rem",
303
+ fontWeight: "bold",
304
+ sx: {
305
+ flexGrow: 1
306
+ },
307
+ children: t('storage.spaces.strategy.title')
308
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
309
+ size: "small",
310
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
311
+ variant: "contained",
312
+ size: "small",
313
+ onClick: handleManualBackup,
314
+ loading: loading && Boolean(progress === null || progress === void 0 ? void 0 : progress.progress),
315
+ children: t('storage.spaces.strategy.backupNow')
316
+ })
317
+ })]
318
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
319
+ marginTop: "16px",
320
+ display: "flex",
321
+ alignItems: "center",
322
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
323
+ flex: 1,
324
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
325
+ children: [t('storage.spaces.strategy.autoBackup'), ": "]
326
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
327
+ title: "coming soon",
328
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Switch, {
329
+ size: "small",
330
+ disabled: true
331
+ })
332
+ })]
333
+ })
334
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
335
+ marginTop: "16px",
336
+ display: "flex",
337
+ alignItems: "center",
338
+ children: (backups === null || backups === void 0 ? void 0 : backups.some(b => !b.status && (b === null || b === void 0 ? void 0 : b.targetUrl.includes((0, _spaces.getSpaceGatewayFromEndpoint)(endpoint))))) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
339
+ variant: "outlined",
340
+ size: "small",
341
+ onClick: () => window.open((0, _spaces.getBackupFilesUrlFromEndpoint)(endpoint)),
342
+ children: t('storage.spaces.strategy.viewBackupFiles')
343
+ })
344
+ })]
345
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
346
+ marginTop: "16px",
347
+ hidden: !(loading && progress !== null && progress !== void 0 && progress.progress),
348
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
349
+ marginTop: "8px",
350
+ marginBottom: "8px",
351
+ fontSize: "1.2rem",
352
+ fontWeight: "bold",
353
+ children: t('storage.spaces.progress.title')
354
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {}), loading && !!(progress !== null && progress !== void 0 && progress.progress) ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
355
+ sx: {
356
+ overflow: 'hidden'
357
+ },
358
+ display: "flex",
359
+ flexDirection: "column",
360
+ justifyContent: "center",
361
+ textAlign: "center",
362
+ marginTop: "24px",
363
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
364
+ color: "primary",
365
+ children: progress === null || progress === void 0 ? void 0 : progress.message
366
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
367
+ sx: {
368
+ display: 'flex',
369
+ alignItems: 'center'
370
+ },
371
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
372
+ sx: {
373
+ width: '100%',
374
+ mr: 1
375
+ },
376
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {
377
+ color: "primary",
378
+ variant: "determinate",
379
+ value: progress === null || progress === void 0 ? void 0 : progress.progress
380
+ })
381
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
382
+ sx: {
383
+ minWidth: 35
384
+ },
385
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
386
+ variant: "body2",
387
+ color: "text.secondary",
388
+ children: [progress === null || progress === void 0 ? void 0 : progress.progress, "%"]
389
+ })
390
+ })]
391
+ })]
392
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
393
+ marginTop: "16px",
394
+ display: "flex",
395
+ justifyContent: "center",
396
+ alignContent: "center",
397
+ height: "44px",
398
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
399
+ children: t('storage.spaces.notYet')
400
+ })
401
+ })]
402
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
403
+ marginTop: "24px",
404
+ hidden: !(backups !== null && backups !== void 0 && backups.length),
405
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
406
+ marginTop: "8px",
407
+ marginBottom: "8px",
408
+ fontSize: "1.2rem",
409
+ fontWeight: "bold",
410
+ children: t('storage.spaces.record.title')
411
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Datatable.default, {
412
+ data: backups,
413
+ columns: columns,
414
+ emptyNode: t('storage.spaces.record.emptyData', locale),
415
+ options: {
416
+ download: false,
417
+ filter: false,
418
+ print: false
419
+ }
420
+ })]
421
+ })]
422
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
423
+ marginTop: endpoint ? '24px' : '0px',
424
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
425
+ marginBottom: "8px",
426
+ fontSize: "1.2rem",
427
+ fontWeight: "bold",
428
+ children: t('storage.spaces.gateway.connect.title')
429
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_switchDidSpaces.default, {
430
+ mode: endpoint ? 'switch' : 'add'
431
+ })]
432
+ })]
433
+ });
434
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = SpaceItem;
7
+ var _styles = require("@mui/styles");
8
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
9
+ var _ListItemSecondaryAction = _interopRequireDefault(require("@mui/material/ListItemSecondaryAction"));
10
+ var _Launch = _interopRequireDefault(require("@mui/icons-material/Launch"));
11
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+ var _Tag = _interopRequireDefault(require("@arcblock/ux/lib/Tag"));
14
+ var _context = require("@arcblock/ux/lib/Locale/context");
15
+ var _delete = _interopRequireDefault(require("./delete"));
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ const _excluded = ["spaceGateway", "connected", "onDelete"];
18
+ /* eslint-disable react/jsx-one-expression-per-line */
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
24
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
25
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
26
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
27
+ const useStyles = (0, _styles.makeStyles)(() => ({
28
+ buttonText: {
29
+ textTransform: 'none !important'
30
+ },
31
+ iconRoot: {
32
+ minWidth: 24
33
+ },
34
+ menuName: {
35
+ display: 'flex',
36
+ flexDirection: 'column',
37
+ marginRight: '100px',
38
+ '& span': {
39
+ overflow: 'hidden',
40
+ textOverflow: 'ellipsis',
41
+ whiteSpace: 'nowrap'
42
+ }
43
+ }
44
+ }));
45
+
46
+ /**
47
+ * @typedef {{
48
+ * name: string,
49
+ * url: string,
50
+ * protected?: boolean,
51
+ * connected?: boolean,
52
+ * }} SpaceGateway
53
+ */
54
+
55
+ /**
56
+ *
57
+ *
58
+ * @export
59
+ * @param {{
60
+ * spaceGateway: SpaceGateway,
61
+ * onDelete: (spaceGateway: SpaceGateway) => Promise<void> | void
62
+ * }} { spaceGateway, onDelete }
63
+ * @return {*}
64
+ */
65
+ function SpaceItem(_ref) {
66
+ let {
67
+ spaceGateway,
68
+ connected,
69
+ onDelete
70
+ } = _ref,
71
+ rest = _objectWithoutProperties(_ref, _excluded);
72
+ const classes = useStyles();
73
+ const {
74
+ t
75
+ } = (0, _context.useLocaleContext)();
76
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({
77
+ className: classes.menuName
78
+ }, rest), {}, {
79
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
80
+ component: "span",
81
+ variant: "subtitle1",
82
+ style: {
83
+ fontWeight: '400'
84
+ },
85
+ children: [spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.name, " ", connected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
86
+ color: "primary",
87
+ children: t('storage.spaces.gateway.connect.connected')
88
+ })]
89
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
90
+ className: "url",
91
+ component: "span",
92
+ variant: "inherit",
93
+ children: "".concat(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.url)
94
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ListItemSecondaryAction.default, {
95
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
96
+ onClick: e => {
97
+ e.stopPropagation();
98
+ window.open(spaceGateway.url);
99
+ },
100
+ size: "small",
101
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Launch.default, {})
102
+ }), (spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.protected) !== true && /*#__PURE__*/(0, _jsxRuntime.jsx)(_delete.default, {
103
+ spaceGateway: spaceGateway,
104
+ onDelete: onDelete
105
+ })]
106
+ })]
107
+ }));
108
+ }
109
+ SpaceItem.propTypes = {
110
+ teamDid: _propTypes.default.string.isRequired,
111
+ spaceGateway: _propTypes.default.shape({
112
+ name: _propTypes.default.string.isRequired,
113
+ url: _propTypes.default.string.isRequired,
114
+ protected: _propTypes.default.bool
115
+ }).isRequired,
116
+ connected: _propTypes.default.bool,
117
+ onDelete: _propTypes.default.func
118
+ };
119
+ SpaceItem.defaultProps = {
120
+ onDelete: () => {},
121
+ connected: false
122
+ };