@guillotinaweb/react-gmi 0.20.1 → 0.22.2
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/CHANGELOG.md +17 -0
- package/README.md +18 -10
- package/dist/components/fields/editableField.d.ts +0 -2
- package/dist/components/fields/renderField.d.ts +8 -0
- package/dist/components/login.d.ts +7 -14
- package/dist/components/selected_items_actions.d.ts +5 -2
- package/dist/hooks/useConfig.d.ts +2 -0
- package/dist/hooks/useRegistry.d.ts +2 -0
- package/dist/lib/client.d.ts +5 -4
- package/dist/lib/rest.d.ts +2 -1
- package/dist/react-gmi.esm.js +2179 -2142
- package/dist/react-gmi.esm.js.map +1 -1
- package/dist/react-gmi.js +2178 -2141
- package/dist/react-gmi.js.map +1 -1
- package/dist/react-gmi.modern.js +1721 -1680
- package/dist/react-gmi.modern.js.map +1 -1
- package/dist/react-gmi.umd.js +2178 -2141
- package/dist/react-gmi.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/react-gmi.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { createContext, useState, useCallback, useRef, useEffect, forwardRef, createElement, Fragment, useContext, useReducer } from 'react';
|
|
2
2
|
import usePortal from 'react-useportal';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import jwt_decode from 'jwt-decode';
|
|
@@ -100,124 +100,148 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
100
100
|
return it.next.bind(it);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
var AuthContext = createContext({});
|
|
104
|
+
var ClientContext = createContext({});
|
|
105
|
+
var TraversalContext = createContext({});
|
|
106
|
+
|
|
107
|
+
var Traversal = /*#__PURE__*/function () {
|
|
108
|
+
function Traversal(_ref) {
|
|
109
|
+
var flash = _ref.flash,
|
|
110
|
+
props = _objectWithoutPropertiesLoose(_ref, ["flash"]);
|
|
111
|
+
|
|
112
|
+
Object.assign(this, props);
|
|
113
|
+
if (typeof flash === 'function') this.flash = flash;
|
|
107
114
|
}
|
|
108
115
|
|
|
109
|
-
var _proto =
|
|
116
|
+
var _proto = Traversal.prototype;
|
|
110
117
|
|
|
111
|
-
_proto.
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
_proto.refresh = function refresh(_temp) {
|
|
119
|
+
var _ref2 = _temp === void 0 ? {} : _temp,
|
|
120
|
+
_ref2$transparent = _ref2.transparent,
|
|
121
|
+
transparent = _ref2$transparent === void 0 ? false : _ref2$transparent;
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
123
|
+
this.dispatch({
|
|
124
|
+
type: 'REFRESH',
|
|
125
|
+
payload: {
|
|
126
|
+
transparent: transparent
|
|
127
|
+
}
|
|
128
|
+
});
|
|
121
129
|
};
|
|
122
130
|
|
|
123
|
-
_proto.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Authorization: 'Bearer ' + authToken
|
|
130
|
-
};
|
|
131
|
+
_proto.apply = function apply(data) {
|
|
132
|
+
// apply a optimistic update to context
|
|
133
|
+
this.dispatch({
|
|
134
|
+
type: 'APPLY',
|
|
135
|
+
payload: data
|
|
136
|
+
});
|
|
131
137
|
};
|
|
132
138
|
|
|
133
|
-
_proto.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
_proto.flash = function flash(message, type) {
|
|
140
|
+
this.dispatch({
|
|
141
|
+
type: 'SET_FLASH',
|
|
142
|
+
payload: {
|
|
143
|
+
flash: {
|
|
144
|
+
message: message,
|
|
145
|
+
type: type
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
window.scrollTo({
|
|
150
|
+
top: 0,
|
|
151
|
+
left: 0,
|
|
152
|
+
behavior: 'smooth'
|
|
153
|
+
});
|
|
144
154
|
};
|
|
145
155
|
|
|
146
|
-
_proto.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return Promise.resolve(_this6.request(path, {}));
|
|
151
|
-
} catch (e) {
|
|
152
|
-
return Promise.reject(e);
|
|
153
|
-
}
|
|
156
|
+
_proto.clearFlash = function clearFlash() {
|
|
157
|
+
this.dispatch({
|
|
158
|
+
type: 'CLEAR_FLASH'
|
|
159
|
+
});
|
|
154
160
|
};
|
|
155
161
|
|
|
156
|
-
_proto.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} catch (e) {
|
|
165
|
-
return Promise.reject(e);
|
|
166
|
-
}
|
|
162
|
+
_proto.doAction = function doAction(action, params) {
|
|
163
|
+
this.dispatch({
|
|
164
|
+
type: 'SET_ACTION',
|
|
165
|
+
payload: {
|
|
166
|
+
action: action,
|
|
167
|
+
params: params
|
|
168
|
+
}
|
|
169
|
+
});
|
|
167
170
|
};
|
|
168
171
|
|
|
169
|
-
_proto.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
_proto.cancelAction = function cancelAction() {
|
|
173
|
+
this.dispatch({
|
|
174
|
+
type: 'CLEAR_ACTION'
|
|
175
|
+
});
|
|
176
|
+
};
|
|
172
177
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
body: JSON.stringify(data)
|
|
176
|
-
}));
|
|
177
|
-
} catch (e) {
|
|
178
|
-
return Promise.reject(e);
|
|
179
|
-
}
|
|
178
|
+
_proto.hasPerm = function hasPerm(permission) {
|
|
179
|
+
return this.state.permissions[permission] === true;
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
-
_proto.
|
|
183
|
-
|
|
184
|
-
var _this12 = this;
|
|
182
|
+
_proto.filterTabs = function filterTabs(tabs, tabsPermissions) {
|
|
183
|
+
var _this = this;
|
|
185
184
|
|
|
186
|
-
|
|
185
|
+
var result = {};
|
|
186
|
+
Object.keys(tabs).forEach(function (item) {
|
|
187
|
+
var perm = tabsPermissions[item];
|
|
187
188
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}, headers));
|
|
196
|
-
} catch (e) {
|
|
197
|
-
return Promise.reject(e);
|
|
198
|
-
}
|
|
189
|
+
if (perm && _this.hasPerm(perm)) {
|
|
190
|
+
result[item] = tabs[item];
|
|
191
|
+
} else if (!perm) {
|
|
192
|
+
result[item] = tabs[item];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return result;
|
|
199
196
|
};
|
|
200
197
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
_createClass(Traversal, [{
|
|
199
|
+
key: "path",
|
|
200
|
+
get: function get() {
|
|
201
|
+
return this.state.path;
|
|
204
202
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return Promise.resolve(_this14.request(path, {
|
|
210
|
-
method: 'delete',
|
|
211
|
-
body: JSON.stringify(data)
|
|
212
|
-
}));
|
|
213
|
-
} catch (e) {
|
|
214
|
-
return Promise.reject(e);
|
|
203
|
+
}, {
|
|
204
|
+
key: "pathPrefix",
|
|
205
|
+
get: function get() {
|
|
206
|
+
return this.state.path.slice(1);
|
|
215
207
|
}
|
|
216
|
-
}
|
|
208
|
+
}, {
|
|
209
|
+
key: "context",
|
|
210
|
+
get: function get() {
|
|
211
|
+
return this.state.context;
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "containerPath",
|
|
215
|
+
get: function get() {
|
|
216
|
+
return this.client.getContainerFromPath(this.path);
|
|
217
|
+
}
|
|
218
|
+
}]);
|
|
217
219
|
|
|
218
|
-
return
|
|
220
|
+
return Traversal;
|
|
219
221
|
}();
|
|
220
222
|
|
|
223
|
+
function TraversalProvider(_ref3) {
|
|
224
|
+
var children = _ref3.children,
|
|
225
|
+
props = _objectWithoutPropertiesLoose(_ref3, ["children"]);
|
|
226
|
+
|
|
227
|
+
return /*#__PURE__*/React.createElement(TraversalContext.Provider, {
|
|
228
|
+
value: new Traversal(props)
|
|
229
|
+
}, children);
|
|
230
|
+
}
|
|
231
|
+
function useTraversal() {
|
|
232
|
+
return React.useContext(TraversalContext);
|
|
233
|
+
}
|
|
234
|
+
function ClientProvider(_ref4) {
|
|
235
|
+
var children = _ref4.children,
|
|
236
|
+
client = _ref4.client;
|
|
237
|
+
return /*#__PURE__*/React.createElement(ClientContext.Provider, {
|
|
238
|
+
value: client
|
|
239
|
+
}, children);
|
|
240
|
+
}
|
|
241
|
+
function useGuillotinaClient() {
|
|
242
|
+
return React.useContext(ClientContext);
|
|
243
|
+
}
|
|
244
|
+
|
|
221
245
|
var classnames = function classnames(classNames) {
|
|
222
246
|
return classNames.filter(Boolean).join(' ').trim();
|
|
223
247
|
};
|
|
@@ -269,2067 +293,2071 @@ function sleep(ms) {
|
|
|
269
293
|
});
|
|
270
294
|
}
|
|
271
295
|
|
|
272
|
-
var
|
|
273
|
-
var icon = _ref.icon,
|
|
274
|
-
className = _ref.className,
|
|
275
|
-
align = _ref.align;
|
|
276
|
-
var addClass = className ? className.split(' ') : [className];
|
|
277
|
-
align = align || 'is-right';
|
|
278
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
279
|
-
className: classnames(['icon', align].concat(addClass))
|
|
280
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
281
|
-
className: icon
|
|
282
|
-
}));
|
|
283
|
-
};
|
|
296
|
+
var noop$1 = function noop() {};
|
|
284
297
|
|
|
285
|
-
var
|
|
286
|
-
var
|
|
298
|
+
var Button = function Button(_ref) {
|
|
299
|
+
var _ref2;
|
|
287
300
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
301
|
+
var children = _ref.children,
|
|
302
|
+
_ref$className = _ref.className,
|
|
303
|
+
className = _ref$className === void 0 ? 'is-primary' : _ref$className,
|
|
304
|
+
onClick = _ref.onClick,
|
|
305
|
+
_ref$type = _ref.type,
|
|
306
|
+
type = _ref$type === void 0 ? 'submit' : _ref$type,
|
|
307
|
+
_ref$loading = _ref.loading,
|
|
308
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
309
|
+
_ref$disabled = _ref.disabled,
|
|
310
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
311
|
+
dataTest = _ref.dataTest,
|
|
312
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "onClick", "type", "loading", "disabled", "dataTest"]);
|
|
292
313
|
|
|
293
|
-
var
|
|
294
|
-
var name = _ref.name,
|
|
295
|
-
onRemove = _ref.onRemove,
|
|
296
|
-
_ref$size = _ref.size,
|
|
297
|
-
size = _ref$size === void 0 ? 'is-medium' : _ref$size,
|
|
298
|
-
_ref$color = _ref.color,
|
|
299
|
-
color = _ref$color === void 0 ? 'is-warning' : _ref$color;
|
|
300
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
301
|
-
className: classnames(['tag', color, size])
|
|
302
|
-
}, name, onRemove !== undefined && /*#__PURE__*/React.createElement("button", {
|
|
303
|
-
className: "delete is-small",
|
|
304
|
-
onClick: function onClick() {
|
|
305
|
-
return onRemove();
|
|
306
|
-
}
|
|
307
|
-
}));
|
|
308
|
-
};
|
|
314
|
+
var css = (_ref2 = []).concat.apply(_ref2, ['button'].concat(className.split(' ')));
|
|
309
315
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
type:
|
|
316
|
+
if (loading) css = css.concat('is-loading');
|
|
317
|
+
if (disabled) onClick = noop$1;
|
|
318
|
+
return /*#__PURE__*/React.createElement("p", {
|
|
319
|
+
className: "control"
|
|
320
|
+
}, /*#__PURE__*/React.createElement("button", _extends({
|
|
321
|
+
type: type,
|
|
322
|
+
className: classnames(css),
|
|
316
323
|
onClick: onClick,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function Table(_ref) {
|
|
323
|
-
var headers = _ref.headers,
|
|
324
|
-
children = _ref.children,
|
|
325
|
-
className = _ref.className;
|
|
326
|
-
className = className ? className.split(' ') : ' is-full is-fullwidth is-narrow'.split(' ');
|
|
327
|
-
return /*#__PURE__*/React.createElement("table", {
|
|
328
|
-
className: classnames(['table'].concat(className))
|
|
329
|
-
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, headers && headers.map(function (item, idx) {
|
|
330
|
-
return /*#__PURE__*/React.createElement("th", {
|
|
331
|
-
key: item + idx
|
|
332
|
-
}, item);
|
|
333
|
-
}))), /*#__PURE__*/React.createElement("tbody", null, children));
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function Notification(_ref) {
|
|
337
|
-
var _ref$isColor = _ref.isColor,
|
|
338
|
-
isColor = _ref$isColor === void 0 ? '' : _ref$isColor,
|
|
339
|
-
children = _ref.children;
|
|
340
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
341
|
-
className: 'notification is-' + isColor,
|
|
342
|
-
"data-test": "notificationTest"
|
|
343
|
-
}, children);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// https://github.com/molefrog/wouter
|
|
347
|
-
|
|
348
|
-
var setURLParams = function setURLParams(p) {
|
|
349
|
-
return window.history['pushState'](0, 0, (window.history.pathname || '') + '?' + p.toString().replace(/%2F/g, '/'));
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
var clean = function clean(to) {
|
|
353
|
-
var current = new URLSearchParams();
|
|
354
|
-
Object.keys(to).forEach(function (_key) {
|
|
355
|
-
return current.set(_key, to[_key]);
|
|
356
|
-
});
|
|
357
|
-
setURLParams(current);
|
|
324
|
+
disabled: disabled
|
|
325
|
+
}, rest, {
|
|
326
|
+
"data-test": dataTest
|
|
327
|
+
}), children));
|
|
358
328
|
};
|
|
359
329
|
|
|
360
|
-
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
|
|
330
|
+
function Modal(props) {
|
|
331
|
+
var isActive = props.isActive,
|
|
332
|
+
setActive = props.setActive,
|
|
333
|
+
children = props.children;
|
|
364
334
|
|
|
365
|
-
var
|
|
366
|
-
|
|
367
|
-
patchHistoryEvents(); // this function checks if the location has been changed since the
|
|
368
|
-
// last render and updates the state only when needed.
|
|
369
|
-
// unfortunately, we can't rely on `path` value here, since it can be stale,
|
|
370
|
-
// that's why we store the last pathname in a ref.
|
|
335
|
+
var _usePortal = usePortal(),
|
|
336
|
+
Portal = _usePortal.Portal;
|
|
371
337
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
338
|
+
var css = 'modal ' + (isActive ? 'is-active ' : '') + props.className;
|
|
339
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
|
|
340
|
+
className: css
|
|
341
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
342
|
+
className: "modal-background",
|
|
343
|
+
onClick: function onClick() {
|
|
344
|
+
return setActive(false);
|
|
345
|
+
}
|
|
346
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
347
|
+
className: "modal-content"
|
|
348
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
349
|
+
className: "box"
|
|
350
|
+
}, children)), /*#__PURE__*/React.createElement("button", {
|
|
351
|
+
className: "modal-close is-large",
|
|
352
|
+
"aria-label": "close",
|
|
353
|
+
onClick: function onClick() {
|
|
354
|
+
return setActive(false);
|
|
355
|
+
}
|
|
356
|
+
})));
|
|
357
|
+
}
|
|
358
|
+
function Confirm(_ref) {
|
|
359
|
+
var message = _ref.message,
|
|
360
|
+
onCancel = _ref.onCancel,
|
|
361
|
+
onConfirm = _ref.onConfirm,
|
|
362
|
+
loading = _ref.loading;
|
|
376
363
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}); // it's possible that an update has occurred between render and the effect handler,
|
|
381
|
-
// so we run additional check on mount to catch these updates. Based on:
|
|
382
|
-
// https://gist.github.com/bvaughn/e25397f70e8c65b0ae0d7c90b731b189
|
|
364
|
+
var setActive = function setActive() {
|
|
365
|
+
return onCancel();
|
|
366
|
+
};
|
|
383
367
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
},
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
368
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
369
|
+
isActive: true,
|
|
370
|
+
setActive: setActive,
|
|
371
|
+
className: "confirm"
|
|
372
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h1", {
|
|
373
|
+
className: "title is-size-5"
|
|
374
|
+
}, message || 'Are you Sure?'), /*#__PURE__*/React.createElement("div", {
|
|
375
|
+
className: "level",
|
|
376
|
+
style: {
|
|
377
|
+
marginTop: 50
|
|
378
|
+
}
|
|
379
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
380
|
+
className: "level-left"
|
|
381
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
382
|
+
className: "level-right"
|
|
383
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
384
|
+
className: "button is-danger",
|
|
385
|
+
onClick: function onClick() {
|
|
386
|
+
return onCancel();
|
|
387
|
+
},
|
|
388
|
+
"data-test": "btnCancelModalTest"
|
|
389
|
+
}, "Cancel"), "\xA0\xA0", /*#__PURE__*/React.createElement(Button, {
|
|
390
|
+
loading: loading,
|
|
391
|
+
className: "is-success",
|
|
392
|
+
onClick: function onClick() {
|
|
393
|
+
return onConfirm();
|
|
394
|
+
},
|
|
395
|
+
dataTest: "btnConfirmModalTest"
|
|
396
|
+
}, "Confirm")))));
|
|
397
|
+
} // @todo Improve it... Replacing the inputText to a tree
|
|
395
398
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
399
|
+
function PathTree(_ref2) {
|
|
400
|
+
var title = _ref2.title,
|
|
401
|
+
defaultPath = _ref2.defaultPath,
|
|
402
|
+
children = _ref2.children,
|
|
403
|
+
onConfirm = _ref2.onConfirm,
|
|
404
|
+
onCancel = _ref2.onCancel;
|
|
405
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
406
|
+
isActive: true,
|
|
407
|
+
setActive: onCancel
|
|
408
|
+
}, /*#__PURE__*/React.createElement("h1", null, title), /*#__PURE__*/React.createElement("form", {
|
|
409
|
+
onSubmit: function onSubmit(e) {
|
|
410
|
+
e.preventDefault();
|
|
411
|
+
onConfirm(e.target[0].value, e.target);
|
|
412
|
+
}
|
|
413
|
+
}, /*#__PURE__*/React.createElement("small", {
|
|
414
|
+
style: {
|
|
415
|
+
display: 'block',
|
|
416
|
+
marginTop: 20
|
|
400
417
|
}
|
|
418
|
+
}, "Example: /folder (without /db/container on front)"), /*#__PURE__*/React.createElement("input", {
|
|
419
|
+
className: "input mb-3",
|
|
420
|
+
defaultValue: defaultPath,
|
|
421
|
+
type: "text",
|
|
422
|
+
"data-test": "inputPathTreeTest"
|
|
423
|
+
}), children, /*#__PURE__*/React.createElement("div", {
|
|
424
|
+
className: "level-right mt-3"
|
|
425
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
426
|
+
type: "button",
|
|
427
|
+
className: "button is-danger",
|
|
428
|
+
onClick: onCancel,
|
|
429
|
+
"data-test": "btnCancelModalTest"
|
|
430
|
+
}, "Cancel"), "\xA0\xA0", /*#__PURE__*/React.createElement("button", {
|
|
431
|
+
type: "submit",
|
|
432
|
+
className: "button is-success",
|
|
433
|
+
"data-test": "btnConfirmModalTest"
|
|
434
|
+
}, "Confirm"))));
|
|
435
|
+
}
|
|
401
436
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
437
|
+
function useSetState(initialState) {
|
|
438
|
+
var _useState = useState(initialState),
|
|
439
|
+
state = _useState[0],
|
|
440
|
+
set = _useState[1];
|
|
441
|
+
|
|
442
|
+
var setState = useCallback(function (patch) {
|
|
443
|
+
set(function (prevState) {
|
|
444
|
+
return Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch);
|
|
405
445
|
});
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var current = new URLSearchParams(path.toString());
|
|
410
|
-
current.delete(param);
|
|
411
|
-
setURLParams(current);
|
|
412
|
-
}, [path]);
|
|
413
|
-
return [path, navigate, remove];
|
|
414
|
-
}; // While History API does have `popstate` event, the only
|
|
415
|
-
// proper way to listen to changes via `push/replaceState`
|
|
416
|
-
// is to monkey-patch these methods.
|
|
417
|
-
//
|
|
418
|
-
// See https://stackoverflow.com/a/4585031
|
|
446
|
+
}, [set]);
|
|
447
|
+
return [state, setState];
|
|
448
|
+
}
|
|
419
449
|
|
|
420
|
-
|
|
450
|
+
function _catch(body, recover) {
|
|
451
|
+
try {
|
|
452
|
+
var result = body();
|
|
453
|
+
} catch (e) {
|
|
454
|
+
return recover(e);
|
|
455
|
+
}
|
|
421
456
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
var original = window.history[type];
|
|
457
|
+
if (result && result.then) {
|
|
458
|
+
return result.then(void 0, recover);
|
|
459
|
+
}
|
|
426
460
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
461
|
+
return result;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
var initial = {
|
|
465
|
+
loading: undefined,
|
|
466
|
+
isError: false,
|
|
467
|
+
errorMessage: undefined,
|
|
468
|
+
result: undefined,
|
|
469
|
+
response: undefined
|
|
436
470
|
};
|
|
437
471
|
|
|
438
|
-
var
|
|
439
|
-
if (
|
|
440
|
-
|
|
472
|
+
var getErrorMessage = function getErrorMessage(dataError, defaultValue) {
|
|
473
|
+
if (dataError && dataError.details) {
|
|
474
|
+
return dataError.details;
|
|
475
|
+
} else if (dataError && dataError.reason) {
|
|
476
|
+
return dataError.reason;
|
|
441
477
|
}
|
|
442
478
|
|
|
443
|
-
return
|
|
479
|
+
return defaultValue;
|
|
444
480
|
};
|
|
445
481
|
|
|
446
|
-
function
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
children = _ref.children,
|
|
450
|
-
props = _objectWithoutPropertiesLoose(_ref, ["aRef", "model", "children"]);
|
|
451
|
-
|
|
452
|
-
var _useLocation = useLocation(),
|
|
453
|
-
path = _useLocation[0],
|
|
454
|
-
navigate = _useLocation[1];
|
|
455
|
-
|
|
456
|
-
var aStyle = {
|
|
457
|
-
textDecoration: 'none',
|
|
458
|
-
color: 'currentColor'
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
function onClick(e) {
|
|
462
|
-
e.stopPropagation();
|
|
463
|
-
if (actAsLink(e)) return;
|
|
464
|
-
e.preventDefault();
|
|
465
|
-
navigate({
|
|
466
|
-
path: model.path
|
|
467
|
-
}, true);
|
|
468
|
-
if (props.onClick) props.onClick(e);
|
|
482
|
+
var processResponse = function processResponse(res, ready_body) {
|
|
483
|
+
if (ready_body === void 0) {
|
|
484
|
+
ready_body = true;
|
|
469
485
|
}
|
|
470
486
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
return e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.button !== 0;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function TdLink(_ref) {
|
|
484
|
-
var model = _ref.model,
|
|
485
|
-
children = _ref.children,
|
|
486
|
-
props = _objectWithoutPropertiesLoose(_ref, ["model", "children"]);
|
|
487
|
-
|
|
488
|
-
var link = useRef();
|
|
487
|
+
try {
|
|
488
|
+
var _temp2 = function _temp2(_res$json) {
|
|
489
|
+
return {
|
|
490
|
+
isError: false,
|
|
491
|
+
loading: false,
|
|
492
|
+
result: _res$json,
|
|
493
|
+
response: res
|
|
494
|
+
};
|
|
495
|
+
};
|
|
489
496
|
|
|
490
|
-
|
|
491
|
-
|
|
497
|
+
if (res.status < 400) return Promise.resolve(ready_body ? Promise.resolve(res.json()).then(_temp2) : _temp2(res.status));else return Promise.resolve(res.json()).then(function (_res$json2) {
|
|
498
|
+
return {
|
|
499
|
+
isError: true,
|
|
500
|
+
loading: false,
|
|
501
|
+
errorMessage: getErrorMessage(_res$json2, res.status),
|
|
502
|
+
response: res
|
|
503
|
+
};
|
|
504
|
+
});
|
|
505
|
+
} catch (e) {
|
|
506
|
+
return Promise.reject(e);
|
|
492
507
|
}
|
|
508
|
+
};
|
|
493
509
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}, children));
|
|
500
|
-
}
|
|
510
|
+
var patch = function patch(setState, Ctx) {
|
|
511
|
+
return function (data, endpoint, body) {
|
|
512
|
+
if (body === void 0) {
|
|
513
|
+
body = false;
|
|
514
|
+
}
|
|
501
515
|
|
|
502
|
-
|
|
503
|
-
var
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
defaultField = DEFAULT_FIELD;
|
|
508
|
-
}
|
|
516
|
+
try {
|
|
517
|
+
var _temp5 = function _temp5() {
|
|
518
|
+
setState(newState);
|
|
519
|
+
return newState;
|
|
520
|
+
};
|
|
509
521
|
|
|
510
|
-
|
|
511
|
-
|
|
522
|
+
setState({
|
|
523
|
+
loading: true
|
|
524
|
+
});
|
|
525
|
+
var newState = {};
|
|
512
526
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
527
|
+
var _temp6 = _catch(function () {
|
|
528
|
+
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
529
|
+
return Promise.resolve(Ctx.client.patch(path, data)).then(function (res) {
|
|
530
|
+
return Promise.resolve(processResponse(res, body)).then(function (_processResponse) {
|
|
531
|
+
newState = _processResponse;
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
}, function (e) {
|
|
535
|
+
console.error('Error', e);
|
|
536
|
+
newState = {
|
|
537
|
+
isError: true,
|
|
538
|
+
errorMessage: 'unhandled exception'
|
|
539
|
+
};
|
|
540
|
+
});
|
|
516
541
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
part = part.replace('||', ' ');
|
|
542
|
+
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));
|
|
543
|
+
} catch (e) {
|
|
544
|
+
return Promise.reject(e);
|
|
521
545
|
}
|
|
546
|
+
};
|
|
547
|
+
};
|
|
522
548
|
|
|
523
|
-
|
|
524
|
-
|
|
549
|
+
var del = function del(setState, Ctx) {
|
|
550
|
+
return function (data, endpoint, body) {
|
|
551
|
+
if (body === void 0) {
|
|
552
|
+
body = false;
|
|
525
553
|
}
|
|
526
554
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
555
|
+
try {
|
|
556
|
+
var _temp9 = function _temp9() {
|
|
557
|
+
setState(newState);
|
|
558
|
+
return newState;
|
|
559
|
+
};
|
|
530
560
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
535
|
-
function buildQs(parsedQuery) {
|
|
536
|
-
return parsedQuery.map(function (_ref) {
|
|
537
|
-
var key = _ref[0],
|
|
538
|
-
val = _ref[1];
|
|
539
|
-
return encodeURIComponent(key) + "=" + encodeURIComponent(val);
|
|
540
|
-
}).join('&');
|
|
541
|
-
}
|
|
561
|
+
setState({
|
|
562
|
+
loading: true
|
|
563
|
+
});
|
|
564
|
+
var newState = {};
|
|
542
565
|
|
|
543
|
-
var
|
|
544
|
-
var
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
566
|
+
var _temp10 = _catch(function () {
|
|
567
|
+
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
568
|
+
return Promise.resolve(Ctx.client.delete(path, data)).then(function (res) {
|
|
569
|
+
return Promise.resolve(processResponse(res, body)).then(function (_processResponse2) {
|
|
570
|
+
newState = _processResponse2;
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
}, function (e) {
|
|
574
|
+
console.error('Error', e);
|
|
575
|
+
newState = {
|
|
576
|
+
isError: true,
|
|
577
|
+
errorMessage: 'unhandled exception'
|
|
578
|
+
};
|
|
579
|
+
});
|
|
550
580
|
|
|
551
|
-
|
|
581
|
+
return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10));
|
|
582
|
+
} catch (e) {
|
|
583
|
+
return Promise.reject(e);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
var post = function post(setState, Ctx) {
|
|
589
|
+
return function (data, endpoint, body) {
|
|
590
|
+
if (body === void 0) {
|
|
591
|
+
body = true;
|
|
592
|
+
}
|
|
552
593
|
|
|
553
|
-
_proto.getContext = function getContext(path) {
|
|
554
594
|
try {
|
|
555
|
-
var
|
|
595
|
+
var _temp13 = function _temp13() {
|
|
596
|
+
setState(newState);
|
|
597
|
+
return newState;
|
|
598
|
+
};
|
|
556
599
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
600
|
+
setState({
|
|
601
|
+
loading: true
|
|
602
|
+
});
|
|
603
|
+
var newState = {};
|
|
560
604
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
605
|
+
var _temp14 = _catch(function () {
|
|
606
|
+
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
607
|
+
return Promise.resolve(Ctx.client.post(path, data)).then(function (res) {
|
|
608
|
+
return Promise.resolve(processResponse(res, body)).then(function (_processResponse3) {
|
|
609
|
+
newState = _processResponse3;
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
}, function (e) {
|
|
613
|
+
console.error('Error', e);
|
|
614
|
+
newState = {
|
|
615
|
+
isError: true,
|
|
616
|
+
errorMessage: 'unhandled exception'
|
|
617
|
+
};
|
|
618
|
+
});
|
|
565
619
|
|
|
566
|
-
|
|
567
|
-
}
|
|
620
|
+
return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(_temp13) : _temp13(_temp14));
|
|
568
621
|
} catch (e) {
|
|
569
622
|
return Promise.reject(e);
|
|
570
623
|
}
|
|
571
624
|
};
|
|
625
|
+
};
|
|
572
626
|
|
|
573
|
-
|
|
627
|
+
var get = function get(setState, Ctx) {
|
|
628
|
+
return function (endpoint) {
|
|
574
629
|
try {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
630
|
+
setState({
|
|
631
|
+
loading: true
|
|
632
|
+
});
|
|
633
|
+
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
634
|
+
return Promise.resolve(Ctx.client.get(path)).then(function (req) {
|
|
635
|
+
return Promise.resolve(req.json()).then(function (data) {
|
|
636
|
+
setState({
|
|
637
|
+
loading: false,
|
|
638
|
+
result: data,
|
|
639
|
+
response: req
|
|
640
|
+
});
|
|
641
|
+
return data;
|
|
642
|
+
});
|
|
643
|
+
});
|
|
582
644
|
} catch (e) {
|
|
583
645
|
return Promise.reject(e);
|
|
584
646
|
}
|
|
585
647
|
};
|
|
648
|
+
};
|
|
586
649
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
start = _ref$start === void 0 ? 0 : _ref$start,
|
|
590
|
-
_ref$pageSize = _ref.pageSize,
|
|
591
|
-
pageSize = _ref$pageSize === void 0 ? 10 : _ref$pageSize,
|
|
592
|
-
_ref$withDepth = _ref.withDepth,
|
|
593
|
-
withDepth = _ref$withDepth === void 0 ? true : _ref$withDepth;
|
|
594
|
-
var result = [];
|
|
595
|
-
result = [].concat(parser(start.toString(), 'b_start'), parser(pageSize.toString(), 'b_size'));
|
|
596
|
-
|
|
597
|
-
if (withDepth) {
|
|
598
|
-
var _parser;
|
|
650
|
+
function useCrudContext() {
|
|
651
|
+
var Ctx = useTraversal();
|
|
599
652
|
|
|
600
|
-
|
|
601
|
-
|
|
653
|
+
var _useSetState = useSetState(initial),
|
|
654
|
+
state = _useSetState[0],
|
|
655
|
+
setState = _useSetState[1];
|
|
602
656
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
path = _ref2.path,
|
|
612
|
-
_ref2$withDepth = _ref2.withDepth,
|
|
613
|
-
withDepth = _ref2$withDepth === void 0 ? true : _ref2$withDepth;
|
|
614
|
-
var result = [];
|
|
615
|
-
var containerPath = getContainerFromPath(path);
|
|
657
|
+
return _extends({}, state, {
|
|
658
|
+
Ctx: Ctx,
|
|
659
|
+
patch: patch(setState, Ctx),
|
|
660
|
+
del: del(setState, Ctx),
|
|
661
|
+
post: post(setState, Ctx),
|
|
662
|
+
get: get(setState, Ctx)
|
|
663
|
+
});
|
|
664
|
+
}
|
|
616
665
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
666
|
+
function AddItem(props) {
|
|
667
|
+
var doSubmit = function doSubmit(data) {
|
|
668
|
+
try {
|
|
669
|
+
var form = Object.assign({}, {
|
|
670
|
+
'@type': type
|
|
671
|
+
}, data.formData ? data.formData : data);
|
|
672
|
+
return Promise.resolve(post(form)).then(function (_ref) {
|
|
673
|
+
var isError = _ref.isError,
|
|
674
|
+
errorMessage = _ref.errorMessage;
|
|
620
675
|
|
|
621
|
-
|
|
676
|
+
if (!isError) {
|
|
677
|
+
Ctx.flash('Content created!', 'success');
|
|
678
|
+
} else {
|
|
679
|
+
Ctx.flash("An error has ocurred: " + errorMessage, 'danger');
|
|
680
|
+
}
|
|
622
681
|
|
|
623
|
-
|
|
624
|
-
|
|
682
|
+
Ctx.cancelAction();
|
|
683
|
+
Ctx.refresh();
|
|
684
|
+
});
|
|
685
|
+
} catch (e) {
|
|
686
|
+
return Promise.reject(e);
|
|
625
687
|
}
|
|
688
|
+
};
|
|
626
689
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
if (withDepth) {
|
|
630
|
-
var _parser2;
|
|
690
|
+
var Ctx = useTraversal();
|
|
631
691
|
|
|
632
|
-
|
|
633
|
-
|
|
692
|
+
var _useCrudContext = useCrudContext(),
|
|
693
|
+
post = _useCrudContext.post,
|
|
694
|
+
loading = _useCrudContext.loading;
|
|
634
695
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
696
|
+
var type = props.type;
|
|
697
|
+
var getForm = Ctx.registry.getForm;
|
|
698
|
+
var Form = getForm(type);
|
|
638
699
|
|
|
639
|
-
|
|
700
|
+
var setActive = function setActive() {
|
|
701
|
+
Ctx.cancelAction();
|
|
640
702
|
};
|
|
641
703
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
658
|
-
}, {
|
|
659
|
-
label: 'type',
|
|
660
|
-
child: function child(m) {
|
|
661
|
-
return /*#__PURE__*/React.createElement(TdLink, {
|
|
662
|
-
style: smallcss,
|
|
663
|
-
model: m
|
|
664
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
665
|
-
className: "tag"
|
|
666
|
-
}, m.type));
|
|
667
|
-
}
|
|
668
|
-
}, {
|
|
669
|
-
label: 'id/name',
|
|
670
|
-
child: function child(m, navigate, search) {
|
|
671
|
-
return /*#__PURE__*/React.createElement(TdLink, {
|
|
672
|
-
model: m
|
|
673
|
-
}, m.name, search && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("span", {
|
|
674
|
-
className: "is-size-7 tag is-light"
|
|
675
|
-
}, m.path)));
|
|
676
|
-
}
|
|
677
|
-
}, {
|
|
678
|
-
label: 'created',
|
|
679
|
-
child: function child(m) {
|
|
680
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
681
|
-
style: mediumcss,
|
|
682
|
-
className: "is-size-7 is-vcentered"
|
|
683
|
-
}, m.created);
|
|
684
|
-
}
|
|
685
|
-
}, {
|
|
686
|
-
label: 'modified',
|
|
687
|
-
child: function child(m) {
|
|
688
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
689
|
-
style: mediumcss,
|
|
690
|
-
className: "is-size-7 is-vcentered"
|
|
691
|
-
}, m.updated);
|
|
692
|
-
}
|
|
693
|
-
}];
|
|
694
|
-
} // BBB API changes. Compat G5 and G6
|
|
695
|
-
;
|
|
704
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
705
|
+
isActive: true,
|
|
706
|
+
setActive: setActive
|
|
707
|
+
}, /*#__PURE__*/React.createElement(Form, {
|
|
708
|
+
loading: loading,
|
|
709
|
+
onSubmit: doSubmit,
|
|
710
|
+
onError: function onError(err) {
|
|
711
|
+
return console.log(err);
|
|
712
|
+
},
|
|
713
|
+
actionName: 'Add ' + type,
|
|
714
|
+
title: 'Add ' + type,
|
|
715
|
+
type: type,
|
|
716
|
+
dataTest: "formAdd" + type + "Test"
|
|
717
|
+
}));
|
|
718
|
+
}
|
|
696
719
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
720
|
+
var Permissions = ['guillotina.AddContent', 'guillotina.ModifyContent', 'guillotina.ViewContent', 'guillotina.DeleteContent', 'guillotina.AccessContent', 'guillotina.SeePermissions', 'guillotina.ChangePermissions', 'guillotina.MoveContent', 'guillotina.DuplicateContent', 'guillotina.ReadConfiguration', 'guillotina.RegisterConfigurations', 'guillotina.WriteConfiguration', 'guillotina.ManageAddons', 'guillotina.swagger.View'];
|
|
721
|
+
var Config = {
|
|
722
|
+
DisabledTypes: ['UserManager', 'GroupManager'],
|
|
723
|
+
PageSize: 10,
|
|
724
|
+
DelayActions: 200,
|
|
725
|
+
Permissions: Permissions,
|
|
726
|
+
SearchEngine: 'PostreSQL',
|
|
727
|
+
// Elasticsearch
|
|
728
|
+
fieldHaveDeleteButton: function fieldHaveDeleteButton(schema) {
|
|
729
|
+
return (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
var calculated = Object.assign({}, Config);
|
|
702
733
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
734
|
+
var addConfig = function addConfig(additional, original) {
|
|
735
|
+
var rest = Object.assign({}, original);
|
|
736
|
+
Object.keys(additional).forEach(function (item) {
|
|
737
|
+
if (typeof Config[item] === 'object' && Array.isArray(Config[item])) {
|
|
738
|
+
rest[item] = [].concat(Config[item], additional[item]);
|
|
739
|
+
} else if (typeof Config[item] === 'object') {
|
|
740
|
+
rest[item] = Object.assign({}, Config[item], additional[item]);
|
|
741
|
+
} else {
|
|
742
|
+
rest[item] = additional[item];
|
|
706
743
|
}
|
|
744
|
+
});
|
|
745
|
+
return rest;
|
|
746
|
+
};
|
|
707
747
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
}
|
|
748
|
+
function useConfig(cfg) {
|
|
749
|
+
var ref = React.useRef();
|
|
711
750
|
|
|
712
|
-
|
|
713
|
-
|
|
751
|
+
if (cfg && !ref.current) {
|
|
752
|
+
console.log('cfg', cfg);
|
|
753
|
+
calculated = addConfig(cfg, calculated);
|
|
754
|
+
ref.current = calculated;
|
|
755
|
+
} // if (cfg && !ref.current) {
|
|
756
|
+
// ref.current = addConfig(cfg, ref.current);
|
|
757
|
+
// calculated = ref.current
|
|
758
|
+
// console.log("Current config", cfg)
|
|
759
|
+
// }
|
|
714
760
|
|
|
715
|
-
if (path.startsWith('/')) {
|
|
716
|
-
path = path.slice(1);
|
|
717
|
-
}
|
|
718
761
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
762
|
+
return calculated;
|
|
763
|
+
}
|
|
722
764
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return _this6.applyCompat(data);
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
|
-
} catch (e) {
|
|
731
|
-
return Promise.reject(e);
|
|
732
|
-
}
|
|
733
|
-
};
|
|
765
|
+
var getId = function getId(item) {
|
|
766
|
+
if (item['@id']) {
|
|
767
|
+
return item['@id'];
|
|
768
|
+
}
|
|
734
769
|
|
|
735
|
-
|
|
770
|
+
return item['@absolute_url'];
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
function RemoveItems(props) {
|
|
774
|
+
var removeItems = function removeItems() {
|
|
736
775
|
try {
|
|
737
|
-
var
|
|
776
|
+
var errors = [];
|
|
777
|
+
setLoading(true);
|
|
778
|
+
var actions = items.map(function (item) {
|
|
779
|
+
try {
|
|
780
|
+
console.log(item);
|
|
781
|
+
return Promise.resolve(Ctx.client.delete(getId(item))).then(function (res) {
|
|
782
|
+
var _temp = function () {
|
|
783
|
+
if (!res.ok) {
|
|
784
|
+
return Promise.resolve(res.json()).then(function (err) {
|
|
785
|
+
errors.push(err);
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
}();
|
|
738
789
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
790
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
791
|
+
});
|
|
792
|
+
} catch (e) {
|
|
793
|
+
return Promise.reject(e);
|
|
794
|
+
}
|
|
795
|
+
}); // this sleep is here, to let elasticsearch, wait for
|
|
796
|
+
// index our operations... (will work 99% of use cases)
|
|
742
797
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
798
|
+
actions.push(sleep(cfg.DelayActions));
|
|
799
|
+
return Promise.resolve(Promise.all(actions)).then(function () {
|
|
800
|
+
if (errors.length === 0) {
|
|
801
|
+
Ctx.flash("Items removed!", 'success');
|
|
802
|
+
Ctx.refresh();
|
|
803
|
+
} else {
|
|
804
|
+
var errorstr = errors.map(function (err) {
|
|
805
|
+
return JSON.stringify(err);
|
|
806
|
+
}).join('\n');
|
|
807
|
+
Ctx.flash("Something went wrong!! " + errorstr, 'danger');
|
|
808
|
+
}
|
|
746
809
|
|
|
747
|
-
|
|
748
|
-
|
|
810
|
+
setLoading(false);
|
|
811
|
+
Ctx.cancelAction();
|
|
812
|
+
});
|
|
749
813
|
} catch (e) {
|
|
750
814
|
return Promise.reject(e);
|
|
751
815
|
}
|
|
752
816
|
};
|
|
753
817
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
var _this10 = this;
|
|
757
|
-
|
|
758
|
-
return Promise.resolve(_this10.rest.post(path, data));
|
|
759
|
-
} catch (e) {
|
|
760
|
-
return Promise.reject(e);
|
|
761
|
-
}
|
|
762
|
-
};
|
|
818
|
+
var Ctx = useTraversal();
|
|
819
|
+
var cfg = useConfig();
|
|
763
820
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
};
|
|
821
|
+
var _React$useState = React.useState(false),
|
|
822
|
+
loading = _React$useState[0],
|
|
823
|
+
setLoading = _React$useState[1];
|
|
768
824
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
825
|
+
var _props$items = props.items,
|
|
826
|
+
items = _props$items === void 0 ? [] : _props$items;
|
|
827
|
+
var last = items[items.length - 1]['@name'];
|
|
828
|
+
var itemsNames = items.map(function (item) {
|
|
829
|
+
return item['@name'];
|
|
830
|
+
}).join(', ').replace(", " + last, " and " + last);
|
|
831
|
+
return /*#__PURE__*/React.createElement(Confirm, {
|
|
832
|
+
loading: loading,
|
|
833
|
+
onCancel: function onCancel() {
|
|
834
|
+
return Ctx.cancelAction();
|
|
835
|
+
},
|
|
836
|
+
onConfirm: removeItems,
|
|
837
|
+
message: "Are you sure to remove: " + itemsNames + "?"
|
|
838
|
+
});
|
|
839
|
+
}
|
|
772
840
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
841
|
+
var Checkbox = function Checkbox(_ref) {
|
|
842
|
+
var id = _ref.id,
|
|
843
|
+
className = _ref.className,
|
|
844
|
+
classNameInput = _ref.classNameInput,
|
|
845
|
+
loading = _ref.loading,
|
|
846
|
+
disabled = _ref.disabled,
|
|
847
|
+
_ref$indeterminate = _ref.indeterminate,
|
|
848
|
+
indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
|
|
849
|
+
_ref$value = _ref.value,
|
|
850
|
+
value = _ref$value === void 0 ? false : _ref$value,
|
|
851
|
+
children = _ref.children,
|
|
852
|
+
placeholder = _ref.placeholder,
|
|
853
|
+
onChange = _ref.onChange,
|
|
854
|
+
dataTest = _ref.dataTest,
|
|
855
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["id", "className", "classNameInput", "loading", "disabled", "indeterminate", "value", "color", "backgroundColor", "borderColor", "children", "placeholder", "onChange", "dataTest"]);
|
|
779
856
|
|
|
780
|
-
|
|
781
|
-
try {
|
|
782
|
-
var _this14 = this;
|
|
857
|
+
var inputRef = useRef(null);
|
|
783
858
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
859
|
+
var _React$useState = React.useState(value),
|
|
860
|
+
state = _React$useState[0],
|
|
861
|
+
setState = _React$useState[1];
|
|
787
862
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
863
|
+
useEffect(function () {
|
|
864
|
+
if (inputRef.current) {
|
|
865
|
+
inputRef.current.indeterminate = indeterminate;
|
|
791
866
|
}
|
|
792
|
-
};
|
|
793
|
-
|
|
794
|
-
_proto.post = function post(path, data) {
|
|
795
|
-
try {
|
|
796
|
-
var _this16 = this;
|
|
867
|
+
}, [indeterminate]);
|
|
797
868
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
869
|
+
var updateState = function updateState(ev) {
|
|
870
|
+
setState(ev.target.checked);
|
|
871
|
+
onChange(ev.target.checked);
|
|
802
872
|
};
|
|
803
873
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
874
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
875
|
+
className: "field"
|
|
876
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
877
|
+
htmlFor: id,
|
|
878
|
+
className: classnames(['checkbox', className])
|
|
879
|
+
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
880
|
+
ref: inputRef,
|
|
881
|
+
disabled: disabled || loading,
|
|
882
|
+
id: id,
|
|
883
|
+
type: "checkbox",
|
|
884
|
+
className: classnames(['checkbox', classNameInput]),
|
|
885
|
+
checked: state,
|
|
886
|
+
onChange: updateState,
|
|
887
|
+
"data-test": dataTest
|
|
888
|
+
}, rest)), children || placeholder));
|
|
889
|
+
};
|
|
807
890
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
891
|
+
var ErrorZone = function ErrorZone(_ref) {
|
|
892
|
+
var children = _ref.children,
|
|
893
|
+
id = _ref.id,
|
|
894
|
+
className = _ref.className;
|
|
895
|
+
return /*#__PURE__*/React.createElement("p", {
|
|
896
|
+
className: classnames(['help is-danger', className]),
|
|
897
|
+
id: id
|
|
898
|
+
}, children);
|
|
899
|
+
};
|
|
811
900
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
901
|
+
ErrorZone.propTypes = {
|
|
902
|
+
children: PropTypes.node,
|
|
903
|
+
id: PropTypes.string,
|
|
904
|
+
className: PropTypes.string
|
|
905
|
+
};
|
|
817
906
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
907
|
+
var applyValidators = function applyValidators(value, validators) {
|
|
908
|
+
var validation = Array.isArray(validators) ? validators : [validators];
|
|
909
|
+
var result = true;
|
|
910
|
+
validation.forEach(function (func) {
|
|
911
|
+
if (func(value) === false) {
|
|
912
|
+
result = false;
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
return result;
|
|
916
|
+
};
|
|
821
917
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
918
|
+
var useInput = function useInput(onChange, value, validator) {
|
|
919
|
+
var _React$useState = React.useState({
|
|
920
|
+
hasError: false,
|
|
921
|
+
value: value
|
|
922
|
+
}),
|
|
923
|
+
state = _React$useState[0],
|
|
924
|
+
setState = _React$useState[1];
|
|
825
925
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
926
|
+
var onUpdate = function onUpdate(ev) {
|
|
927
|
+
var value = ev && ev.target ? ev.target.value : ev ? ev : '';
|
|
928
|
+
setState({
|
|
929
|
+
value: value,
|
|
930
|
+
hasError: false
|
|
931
|
+
});
|
|
932
|
+
if (onChange) onChange(value);
|
|
830
933
|
};
|
|
831
934
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
935
|
+
var onBlur = function onBlur() {
|
|
936
|
+
var hasError = applyValidators(state.value, validator) === false;
|
|
937
|
+
if (hasError) setState({
|
|
938
|
+
value: state.value,
|
|
939
|
+
hasError: hasError
|
|
940
|
+
});
|
|
941
|
+
};
|
|
839
942
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
943
|
+
var onFocus = function onFocus() {
|
|
944
|
+
if (state.hasError) {
|
|
945
|
+
setState({
|
|
946
|
+
value: state.value,
|
|
947
|
+
hasError: false
|
|
948
|
+
});
|
|
843
949
|
}
|
|
844
950
|
};
|
|
845
951
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
952
|
+
React.useEffect(function () {
|
|
953
|
+
setState({
|
|
954
|
+
value: value,
|
|
955
|
+
hasError: false
|
|
956
|
+
});
|
|
957
|
+
}, [value]);
|
|
958
|
+
return {
|
|
959
|
+
onChange: onUpdate,
|
|
960
|
+
onFocus: onFocus,
|
|
961
|
+
onBlur: onBlur,
|
|
962
|
+
state: state
|
|
963
|
+
};
|
|
964
|
+
};
|
|
849
965
|
|
|
850
|
-
|
|
851
|
-
return cacheSchemas[name];
|
|
852
|
-
};
|
|
966
|
+
// From github.com/protonmail/proton-shared
|
|
853
967
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
968
|
+
/* eslint-disable no-useless-escape */
|
|
969
|
+
var REGEX_EMAIL = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/i;
|
|
970
|
+
var REGEX_URL = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
|
|
971
|
+
var REGEX_HEX_COLOR = /^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;
|
|
972
|
+
var REGEX_NUMBER = /^\d+$/;
|
|
973
|
+
var isEmpty = function isEmpty(value) {
|
|
974
|
+
if (value === void 0) {
|
|
975
|
+
value = '';
|
|
976
|
+
}
|
|
857
977
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
}();
|
|
978
|
+
return !value.length;
|
|
979
|
+
};
|
|
980
|
+
var maxLength = function maxLength(value, limit) {
|
|
981
|
+
if (value === void 0) {
|
|
982
|
+
value = '';
|
|
983
|
+
}
|
|
865
984
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
}
|
|
870
|
-
};
|
|
985
|
+
if (limit === void 0) {
|
|
986
|
+
limit = 0;
|
|
987
|
+
}
|
|
871
988
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
989
|
+
return value.length <= limit;
|
|
990
|
+
};
|
|
991
|
+
var minLength = function minLength(value, limit) {
|
|
992
|
+
if (value === void 0) {
|
|
993
|
+
value = '';
|
|
994
|
+
}
|
|
875
995
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
}
|
|
880
|
-
};
|
|
996
|
+
if (limit === void 0) {
|
|
997
|
+
limit = 0;
|
|
998
|
+
}
|
|
881
999
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
1000
|
+
return value.length >= limit;
|
|
1001
|
+
};
|
|
1002
|
+
var isEmail = function isEmail(value) {
|
|
1003
|
+
if (value === void 0) {
|
|
1004
|
+
value = '';
|
|
1005
|
+
}
|
|
885
1006
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
};
|
|
1007
|
+
return REGEX_EMAIL.test(value);
|
|
1008
|
+
};
|
|
1009
|
+
var isURL = function isURL(value) {
|
|
1010
|
+
if (value === void 0) {
|
|
1011
|
+
value = '';
|
|
1012
|
+
}
|
|
893
1013
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1014
|
+
return REGEX_URL.test(value);
|
|
1015
|
+
};
|
|
1016
|
+
var isHexColor = function isHexColor(value) {
|
|
1017
|
+
if (value === void 0) {
|
|
1018
|
+
value = '';
|
|
1019
|
+
}
|
|
897
1020
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
_proto.getGroups = function getGroups(path) {
|
|
907
|
-
try {
|
|
908
|
-
var _this32 = this;
|
|
1021
|
+
return REGEX_HEX_COLOR.test(value);
|
|
1022
|
+
};
|
|
1023
|
+
var isNumber = function isNumber(value) {
|
|
1024
|
+
if (value === void 0) {
|
|
1025
|
+
value = '';
|
|
1026
|
+
}
|
|
909
1027
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
};
|
|
1028
|
+
return REGEX_NUMBER.test(value);
|
|
1029
|
+
};
|
|
1030
|
+
var notEmpty = function notEmpty(value) {
|
|
1031
|
+
return !!value.length;
|
|
1032
|
+
};
|
|
916
1033
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1034
|
+
var noop$2 = function noop() {
|
|
1035
|
+
return true;
|
|
1036
|
+
};
|
|
1037
|
+
/** @type any */
|
|
920
1038
|
|
|
921
|
-
var endpoint = getContainerFromPath(path) + "@users";
|
|
922
|
-
return Promise.resolve(_this34.rest.get(endpoint));
|
|
923
|
-
} catch (e) {
|
|
924
|
-
return Promise.reject(e);
|
|
925
|
-
}
|
|
926
|
-
};
|
|
927
1039
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1040
|
+
var Input = React.forwardRef(function (_ref, ref) {
|
|
1041
|
+
var icon = _ref.icon,
|
|
1042
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
1043
|
+
iconPosition = _ref$iconPosition === void 0 ? 'has-icons-right' : _ref$iconPosition,
|
|
1044
|
+
error = _ref.error,
|
|
1045
|
+
errorZoneClassName = _ref.errorZoneClassName,
|
|
1046
|
+
_ref$autoComplete = _ref.autoComplete,
|
|
1047
|
+
autoComplete = _ref$autoComplete === void 0 ? 'off' : _ref$autoComplete,
|
|
1048
|
+
_ref$className = _ref.className,
|
|
1049
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1050
|
+
_ref$widget = _ref.widget,
|
|
1051
|
+
widget = _ref$widget === void 0 ? 'input' : _ref$widget,
|
|
1052
|
+
_ref$type = _ref.type,
|
|
1053
|
+
type = _ref$type === void 0 ? 'text' : _ref$type,
|
|
1054
|
+
_ref$loading = _ref.loading,
|
|
1055
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
1056
|
+
_ref$required = _ref.required,
|
|
1057
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
1058
|
+
id = _ref.id,
|
|
1059
|
+
placeholder = _ref.placeholder,
|
|
1060
|
+
value = _ref.value,
|
|
1061
|
+
_ref$autofocus = _ref.autofocus,
|
|
1062
|
+
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
1063
|
+
onChange = _ref.onChange,
|
|
1064
|
+
_ref$validator = _ref.validator,
|
|
1065
|
+
validator = _ref$validator === void 0 ? noop$2 : _ref$validator,
|
|
1066
|
+
errorMessage = _ref.errorMessage,
|
|
1067
|
+
_ref$dataTest = _ref.dataTest,
|
|
1068
|
+
dataTest = _ref$dataTest === void 0 ? 'testInput' : _ref$dataTest,
|
|
1069
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["icon", "iconPosition", "error", "errorZoneClassName", "autoComplete", "className", "widget", "type", "onPressEnter", "isSubmitted", "loading", "required", "id", "placeholder", "value", "autofocus", "onChange", "validator", "errorMessage", "dataTest"]);
|
|
931
1070
|
|
|
932
|
-
|
|
1071
|
+
if (required) {
|
|
1072
|
+
validator = Array.isArray(validator) ? validator.push(notEmpty) : [validator, notEmpty];
|
|
1073
|
+
}
|
|
933
1074
|
|
|
934
|
-
|
|
1075
|
+
var _useInput = useInput(onChange, value != null ? value : '', validator),
|
|
1076
|
+
state = _useInput.state,
|
|
1077
|
+
handlers = _objectWithoutPropertiesLoose(_useInput, ["state"]);
|
|
935
1078
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
usr = _ref3[1];
|
|
1079
|
+
var _useState = useState(generateUID('input')),
|
|
1080
|
+
uid = _useState[0];
|
|
939
1081
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
groups: _gr$json,
|
|
944
|
-
users: _usr$json
|
|
945
|
-
};
|
|
946
|
-
}
|
|
1082
|
+
var _useState2 = useState(false),
|
|
1083
|
+
mounted = _useState2[0],
|
|
1084
|
+
setMounted = _useState2[1]; // eslint-disable-next-line
|
|
947
1085
|
|
|
948
|
-
var _usr$ok = usr.ok;
|
|
949
|
-
return _usr$ok ? Promise.resolve(usr.json()).then(_temp5) : _temp5([]);
|
|
950
|
-
}
|
|
951
1086
|
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1087
|
+
ref = ref || React.useRef();
|
|
1088
|
+
useEffect(function () {
|
|
1089
|
+
setMounted(true);
|
|
1090
|
+
}, []);
|
|
1091
|
+
useEffect(function () {
|
|
1092
|
+
if (autofocus && !error) {
|
|
1093
|
+
ref.current.focus();
|
|
957
1094
|
}
|
|
1095
|
+
}, [mounted, autofocus, ref, error]);
|
|
1096
|
+
var theError = state.hasError ? errorMessage || 'invalid field' : '';
|
|
1097
|
+
var statusClasses = state.hasError ? 'is-danger' : '';
|
|
1098
|
+
|
|
1099
|
+
var cssControl = function cssControl() {
|
|
1100
|
+
return icon ? ['control', iconPosition] : ['control'];
|
|
958
1101
|
};
|
|
959
1102
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1103
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1104
|
+
className: "field"
|
|
1105
|
+
}, id && placeholder ? /*#__PURE__*/React.createElement("label", {
|
|
1106
|
+
className: "label",
|
|
1107
|
+
htmlFor: id
|
|
1108
|
+
}, placeholder) : null, /*#__PURE__*/React.createElement("div", {
|
|
1109
|
+
className: classnames(cssControl())
|
|
1110
|
+
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
1111
|
+
className: classnames([widget, className, statusClasses]),
|
|
1112
|
+
"aria-invalid": theError,
|
|
1113
|
+
"aria-describedby": uid,
|
|
1114
|
+
id: id,
|
|
1115
|
+
ref: ref,
|
|
1116
|
+
type: type,
|
|
1117
|
+
value: state.value,
|
|
1118
|
+
placeholder: placeholder,
|
|
1119
|
+
autoComplete: autoComplete,
|
|
1120
|
+
disabled: loading || rest.disabled,
|
|
1121
|
+
required: required,
|
|
1122
|
+
"data-test": dataTest
|
|
1123
|
+
}, handlers, rest)), icon && icon), /*#__PURE__*/React.createElement(ErrorZone, {
|
|
1124
|
+
className: errorZoneClassName,
|
|
1125
|
+
id: uid
|
|
1126
|
+
}, state.hasError ? theError : ''));
|
|
1127
|
+
});
|
|
1128
|
+
Input.propTypes = {
|
|
1129
|
+
icon: PropTypes.node,
|
|
1130
|
+
iconPosition: PropTypes.arrayOf(PropTypes.oneOf(['has-icons-left', 'has-icons-right', ''])),
|
|
1131
|
+
error: PropTypes.string,
|
|
1132
|
+
errorZoneClassName: PropTypes.string,
|
|
1133
|
+
autoComplete: PropTypes.string,
|
|
1134
|
+
autoFocus: PropTypes.bool,
|
|
1135
|
+
className: PropTypes.string,
|
|
1136
|
+
disabled: PropTypes.bool,
|
|
1137
|
+
loading: PropTypes.bool,
|
|
1138
|
+
isSubmitted: PropTypes.bool,
|
|
1139
|
+
id: PropTypes.string,
|
|
1140
|
+
name: PropTypes.string,
|
|
1141
|
+
onChange: PropTypes.func,
|
|
1142
|
+
onKeyDown: PropTypes.func,
|
|
1143
|
+
onKeyUp: PropTypes.func,
|
|
1144
|
+
onPressEnter: PropTypes.func,
|
|
1145
|
+
placeholder: PropTypes.string,
|
|
1146
|
+
readOnly: PropTypes.bool,
|
|
1147
|
+
required: PropTypes.bool,
|
|
1148
|
+
type: PropTypes.string,
|
|
1149
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
|
|
1150
|
+
};
|
|
963
1151
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1152
|
+
var Icon = function Icon(_ref) {
|
|
1153
|
+
var icon = _ref.icon,
|
|
1154
|
+
className = _ref.className,
|
|
1155
|
+
align = _ref.align;
|
|
1156
|
+
var addClass = className ? className.split(' ') : [className];
|
|
1157
|
+
align = align || 'is-right';
|
|
1158
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
1159
|
+
className: classnames(['icon', align].concat(addClass))
|
|
1160
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
1161
|
+
className: icon
|
|
1162
|
+
}));
|
|
1163
|
+
};
|
|
970
1164
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1165
|
+
var EmailInput = function EmailInput(_ref) {
|
|
1166
|
+
var _ref$value = _ref.value,
|
|
1167
|
+
value = _ref$value === void 0 ? '' : _ref$value,
|
|
1168
|
+
dataTest = _ref.dataTest,
|
|
1169
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["value", "dataTest"]);
|
|
974
1170
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1171
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
1172
|
+
type: "email",
|
|
1173
|
+
validator: isEmail,
|
|
1174
|
+
errorMessage: "Email address invalid",
|
|
1175
|
+
value: value,
|
|
1176
|
+
"data-test": dataTest,
|
|
1177
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
1178
|
+
icon: "fas fa-envelope"
|
|
1179
|
+
})
|
|
1180
|
+
}, rest));
|
|
1181
|
+
};
|
|
979
1182
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1183
|
+
var Form = function Form(_ref) {
|
|
1184
|
+
var children = _ref.children,
|
|
1185
|
+
_ref$className = _ref.className,
|
|
1186
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1187
|
+
_ref$onSubmit = _ref.onSubmit,
|
|
1188
|
+
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
1189
|
+
_ref$onReset = _ref.onReset,
|
|
1190
|
+
onReset = _ref$onReset === void 0 ? noop : _ref$onReset,
|
|
1191
|
+
_ref$autoComplete = _ref.autoComplete,
|
|
1192
|
+
autoComplete = _ref$autoComplete === void 0 ? 'off' : _ref$autoComplete,
|
|
1193
|
+
title = _ref.title,
|
|
1194
|
+
error = _ref.error,
|
|
1195
|
+
dataTest = _ref.dataTest,
|
|
1196
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "onSubmit", "onReset", "autoComplete", "title", "error", "dataTest"]);
|
|
983
1197
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
return permissions;
|
|
988
|
-
});
|
|
989
|
-
});
|
|
990
|
-
} catch (e) {
|
|
991
|
-
return Promise.reject(e);
|
|
992
|
-
}
|
|
1198
|
+
var handleSubmit = function handleSubmit(event) {
|
|
1199
|
+
event.preventDefault();
|
|
1200
|
+
onSubmit(event);
|
|
993
1201
|
};
|
|
994
1202
|
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1203
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1204
|
+
"data-test": dataTest
|
|
1205
|
+
}, title && /*#__PURE__*/React.createElement("div", {
|
|
1206
|
+
className: "level"
|
|
1207
|
+
}, /*#__PURE__*/React.createElement("h1", {
|
|
1208
|
+
className: "title is-size-4"
|
|
1209
|
+
}, title)), error && /*#__PURE__*/React.createElement("div", {
|
|
1210
|
+
className: "notification is-danger"
|
|
1211
|
+
}, error), /*#__PURE__*/React.createElement("form", _extends({
|
|
1212
|
+
onSubmit: handleSubmit,
|
|
1213
|
+
onReset: onReset,
|
|
1214
|
+
autoComplete: autoComplete,
|
|
1215
|
+
className: classnames(['form', className])
|
|
1216
|
+
}, rest), children));
|
|
1217
|
+
};
|
|
1218
|
+
Form.propTypes = {
|
|
1219
|
+
children: PropTypes.node.isRequired,
|
|
1220
|
+
className: PropTypes.string,
|
|
1221
|
+
onSubmit: PropTypes.func,
|
|
1222
|
+
onReset: PropTypes.func,
|
|
1223
|
+
autoComplete: PropTypes.string
|
|
1224
|
+
};
|
|
1002
1225
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1226
|
+
var PasswordInput = function PasswordInput(_ref) {
|
|
1227
|
+
var _ref$value = _ref.value,
|
|
1228
|
+
value = _ref$value === void 0 ? '' : _ref$value,
|
|
1229
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["value"]);
|
|
1006
1230
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
if (types.status === 401 || types.status === 404) {
|
|
1012
|
-
cacheTypes[path] = [];
|
|
1013
|
-
} else {
|
|
1014
|
-
return Promise.resolve(types.json()).then(function (res) {
|
|
1015
|
-
cacheTypes[path] = res;
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
}();
|
|
1019
|
-
|
|
1020
|
-
if (_temp7 && _temp7.then) return _temp7.then(function () {});
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
}();
|
|
1024
|
-
|
|
1025
|
-
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(_temp10) : _temp10(_temp11));
|
|
1026
|
-
} catch (e) {
|
|
1027
|
-
return Promise.reject(e);
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
|
|
1031
|
-
return GuillotinaClient;
|
|
1032
|
-
}();
|
|
1033
|
-
function getClient(url, auth, isContainer) {
|
|
1034
|
-
if (isContainer === void 0) {
|
|
1035
|
-
isContainer = false;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
return new GuillotinaClient(new RestClient(url, auth), isContainer);
|
|
1039
|
-
}
|
|
1040
|
-
var getContainerFromPath = function getContainerFromPath(path) {
|
|
1041
|
-
if (path.startsWith('/')) {
|
|
1042
|
-
path = path.substring(1);
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
var parts = path.split('/');
|
|
1046
|
-
return parts[0] + "/" + parts[1] + "/";
|
|
1047
|
-
};
|
|
1048
|
-
var lightFileReader = function lightFileReader(file) {
|
|
1049
|
-
try {
|
|
1050
|
-
return Promise.resolve(new Promise(function (resolve) {
|
|
1051
|
-
var reader = new FileReader();
|
|
1052
|
-
reader.readAsArrayBuffer(file);
|
|
1053
|
-
|
|
1054
|
-
reader.onloadend = function (e) {
|
|
1055
|
-
var fileData = e.target.result;
|
|
1056
|
-
resolve({
|
|
1057
|
-
filename: file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''),
|
|
1058
|
-
data: fileData,
|
|
1059
|
-
'content-type': file.type
|
|
1060
|
-
});
|
|
1061
|
-
};
|
|
1062
|
-
}));
|
|
1063
|
-
} catch (e) {
|
|
1064
|
-
return Promise.reject(e);
|
|
1065
|
-
}
|
|
1231
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
1232
|
+
value: value,
|
|
1233
|
+
type: "password"
|
|
1234
|
+
}, rest));
|
|
1066
1235
|
};
|
|
1067
1236
|
|
|
1068
|
-
var
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
} else if (!Array.isArray(data)) {
|
|
1074
|
-
Object.keys(data).map(function (key) {
|
|
1075
|
-
return result = result.concat(extractPermissions(data[key]));
|
|
1076
|
-
});
|
|
1077
|
-
} else if (Array.isArray(data)) {
|
|
1078
|
-
data.map(function (item) {
|
|
1079
|
-
return result = result.concat(extractPermissions(item));
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
return result;
|
|
1237
|
+
var formComponents = {
|
|
1238
|
+
string: Input,
|
|
1239
|
+
password: PasswordInput,
|
|
1240
|
+
boolean: Checkbox,
|
|
1241
|
+
email: EmailInput
|
|
1084
1242
|
};
|
|
1243
|
+
function FormBuilder(_ref) {
|
|
1244
|
+
var schema = _ref.schema,
|
|
1245
|
+
formData = _ref.formData,
|
|
1246
|
+
onSubmit = _ref.onSubmit,
|
|
1247
|
+
actionName = _ref.actionName,
|
|
1248
|
+
children = _ref.children,
|
|
1249
|
+
_ref$exclude = _ref.exclude,
|
|
1250
|
+
exclude = _ref$exclude === void 0 ? [] : _ref$exclude,
|
|
1251
|
+
_ref$remotes = _ref.remotes,
|
|
1252
|
+
remotes = _ref$remotes === void 0 ? [] : _ref$remotes,
|
|
1253
|
+
_ref$submitButton = _ref.submitButton,
|
|
1254
|
+
submitButton = _ref$submitButton === void 0 ? true : _ref$submitButton,
|
|
1255
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["schema", "formData", "title", "onSubmit", "actionName", "children", "exclude", "remotes", "submitButton"]);
|
|
1085
1256
|
|
|
1086
|
-
var
|
|
1087
|
-
var
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
var Traversal = /*#__PURE__*/function () {
|
|
1091
|
-
function Traversal(_ref) {
|
|
1092
|
-
var flash = _ref.flash,
|
|
1093
|
-
props = _objectWithoutPropertiesLoose(_ref, ["flash"]);
|
|
1094
|
-
|
|
1095
|
-
Object.assign(this, props);
|
|
1096
|
-
if (typeof flash === 'function') this.flash = flash;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
var _proto = Traversal.prototype;
|
|
1100
|
-
|
|
1101
|
-
_proto.refresh = function refresh(_temp) {
|
|
1102
|
-
var _ref2 = _temp === void 0 ? {} : _temp,
|
|
1103
|
-
_ref2$transparent = _ref2.transparent,
|
|
1104
|
-
transparent = _ref2$transparent === void 0 ? false : _ref2$transparent;
|
|
1105
|
-
|
|
1106
|
-
this.dispatch({
|
|
1107
|
-
type: 'REFRESH',
|
|
1108
|
-
payload: {
|
|
1109
|
-
transparent: transparent
|
|
1110
|
-
}
|
|
1111
|
-
});
|
|
1112
|
-
};
|
|
1113
|
-
|
|
1114
|
-
_proto.apply = function apply(data) {
|
|
1115
|
-
// apply a optimistic update to context
|
|
1116
|
-
this.dispatch({
|
|
1117
|
-
type: 'APPLY',
|
|
1118
|
-
payload: data
|
|
1119
|
-
});
|
|
1120
|
-
};
|
|
1121
|
-
|
|
1122
|
-
_proto.flash = function flash(message, type) {
|
|
1123
|
-
this.dispatch({
|
|
1124
|
-
type: 'SET_FLASH',
|
|
1125
|
-
payload: {
|
|
1126
|
-
flash: {
|
|
1127
|
-
message: message,
|
|
1128
|
-
type: type
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
window.scrollTo({
|
|
1133
|
-
top: 0,
|
|
1134
|
-
left: 0,
|
|
1135
|
-
behavior: 'smooth'
|
|
1136
|
-
});
|
|
1137
|
-
};
|
|
1138
|
-
|
|
1139
|
-
_proto.clearFlash = function clearFlash() {
|
|
1140
|
-
this.dispatch({
|
|
1141
|
-
type: 'CLEAR_FLASH'
|
|
1142
|
-
});
|
|
1143
|
-
};
|
|
1257
|
+
var ref = React.useRef();
|
|
1258
|
+
var properties = schema.properties,
|
|
1259
|
+
required = schema.required;
|
|
1260
|
+
var values = Object.assign({}, formData || {}); // build initial state
|
|
1144
1261
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
});
|
|
1153
|
-
};
|
|
1262
|
+
var initialState = {};
|
|
1263
|
+
var fields = Object.keys(properties).filter(function (x) {
|
|
1264
|
+
return !exclude.includes(x);
|
|
1265
|
+
});
|
|
1266
|
+
fields.forEach(function (element) {
|
|
1267
|
+
initialState[element] = values[element] || undefined;
|
|
1268
|
+
}); // Register remotes
|
|
1154
1269
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1270
|
+
if (!ref.current) {
|
|
1271
|
+
ref.current = {};
|
|
1272
|
+
Object.keys(remotes).forEach(function (item) {
|
|
1273
|
+
return ref.current[item] = remotes[item];
|
|
1158
1274
|
});
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
_proto.filterTabs = function filterTabs(tabs, tabsPermissions) {
|
|
1166
|
-
var _this = this;
|
|
1167
|
-
|
|
1168
|
-
var result = {};
|
|
1169
|
-
Object.keys(tabs).forEach(function (item) {
|
|
1170
|
-
var perm = tabsPermissions[item];
|
|
1171
|
-
|
|
1172
|
-
if (perm && _this.hasPerm(perm)) {
|
|
1173
|
-
result[item] = tabs[item];
|
|
1174
|
-
} else if (!perm) {
|
|
1175
|
-
result[item] = tabs[item];
|
|
1275
|
+
} else {
|
|
1276
|
+
// apply remote changes
|
|
1277
|
+
Object.keys(remotes).forEach(function (key) {
|
|
1278
|
+
if (JSON.stringify(ref.current[key]) !== JSON.stringify(remotes[key])) {
|
|
1279
|
+
ref.current[key] = remotes[key];
|
|
1176
1280
|
}
|
|
1177
1281
|
});
|
|
1178
|
-
|
|
1179
|
-
};
|
|
1180
|
-
|
|
1181
|
-
_createClass(Traversal, [{
|
|
1182
|
-
key: "path",
|
|
1183
|
-
get: function get() {
|
|
1184
|
-
return this.state.path;
|
|
1185
|
-
}
|
|
1186
|
-
}, {
|
|
1187
|
-
key: "pathPrefix",
|
|
1188
|
-
get: function get() {
|
|
1189
|
-
return this.state.path.slice(1);
|
|
1190
|
-
}
|
|
1191
|
-
}, {
|
|
1192
|
-
key: "context",
|
|
1193
|
-
get: function get() {
|
|
1194
|
-
return this.state.context;
|
|
1195
|
-
}
|
|
1196
|
-
}, {
|
|
1197
|
-
key: "containerPath",
|
|
1198
|
-
get: function get() {
|
|
1199
|
-
return getContainerFromPath(this.path);
|
|
1200
|
-
}
|
|
1201
|
-
}]);
|
|
1202
|
-
|
|
1203
|
-
return Traversal;
|
|
1204
|
-
}();
|
|
1205
|
-
|
|
1206
|
-
function TraversalProvider(_ref3) {
|
|
1207
|
-
var children = _ref3.children,
|
|
1208
|
-
props = _objectWithoutPropertiesLoose(_ref3, ["children"]);
|
|
1209
|
-
|
|
1210
|
-
return /*#__PURE__*/React.createElement(TraversalContext.Provider, {
|
|
1211
|
-
value: new Traversal(props)
|
|
1212
|
-
}, children);
|
|
1213
|
-
}
|
|
1214
|
-
function useTraversal() {
|
|
1215
|
-
return React.useContext(TraversalContext);
|
|
1216
|
-
}
|
|
1217
|
-
function ClientProvider(_ref4) {
|
|
1218
|
-
var children = _ref4.children,
|
|
1219
|
-
client = _ref4.client;
|
|
1220
|
-
return /*#__PURE__*/React.createElement(ClientContext.Provider, {
|
|
1221
|
-
value: client
|
|
1222
|
-
}, children);
|
|
1223
|
-
}
|
|
1224
|
-
function useGuillotinaClient() {
|
|
1225
|
-
return React.useContext(ClientContext);
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
var noop$1 = function noop() {};
|
|
1229
|
-
|
|
1230
|
-
var Button = function Button(_ref) {
|
|
1231
|
-
var _ref2;
|
|
1232
|
-
|
|
1233
|
-
var children = _ref.children,
|
|
1234
|
-
_ref$className = _ref.className,
|
|
1235
|
-
className = _ref$className === void 0 ? 'is-primary' : _ref$className,
|
|
1236
|
-
onClick = _ref.onClick,
|
|
1237
|
-
_ref$type = _ref.type,
|
|
1238
|
-
type = _ref$type === void 0 ? 'submit' : _ref$type,
|
|
1239
|
-
_ref$loading = _ref.loading,
|
|
1240
|
-
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
1241
|
-
_ref$disabled = _ref.disabled,
|
|
1242
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
1243
|
-
dataTest = _ref.dataTest,
|
|
1244
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "onClick", "type", "loading", "disabled", "dataTest"]);
|
|
1245
|
-
|
|
1246
|
-
var css = (_ref2 = []).concat.apply(_ref2, ['button'].concat(className.split(' ')));
|
|
1247
|
-
|
|
1248
|
-
if (loading) css = css.concat('is-loading');
|
|
1249
|
-
if (disabled) onClick = noop$1;
|
|
1250
|
-
return /*#__PURE__*/React.createElement("p", {
|
|
1251
|
-
className: "control"
|
|
1252
|
-
}, /*#__PURE__*/React.createElement("button", _extends({
|
|
1253
|
-
type: type,
|
|
1254
|
-
className: classnames(css),
|
|
1255
|
-
onClick: onClick,
|
|
1256
|
-
disabled: disabled
|
|
1257
|
-
}, rest, {
|
|
1258
|
-
"data-test": dataTest
|
|
1259
|
-
}), children));
|
|
1260
|
-
};
|
|
1261
|
-
|
|
1262
|
-
function Modal(props) {
|
|
1263
|
-
var isActive = props.isActive,
|
|
1264
|
-
setActive = props.setActive,
|
|
1265
|
-
children = props.children;
|
|
1266
|
-
|
|
1267
|
-
var _usePortal = usePortal(),
|
|
1268
|
-
Portal = _usePortal.Portal;
|
|
1282
|
+
}
|
|
1269
1283
|
|
|
1270
|
-
|
|
1271
|
-
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
|
|
1272
|
-
className: css
|
|
1273
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1274
|
-
className: "modal-background",
|
|
1275
|
-
onClick: function onClick() {
|
|
1276
|
-
return setActive(false);
|
|
1277
|
-
}
|
|
1278
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
1279
|
-
className: "modal-content"
|
|
1280
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1281
|
-
className: "box"
|
|
1282
|
-
}, children)), /*#__PURE__*/React.createElement("button", {
|
|
1283
|
-
className: "modal-close is-large",
|
|
1284
|
-
"aria-label": "close",
|
|
1285
|
-
onClick: function onClick() {
|
|
1286
|
-
return setActive(false);
|
|
1287
|
-
}
|
|
1288
|
-
})));
|
|
1289
|
-
}
|
|
1290
|
-
function Confirm(_ref) {
|
|
1291
|
-
var message = _ref.message,
|
|
1292
|
-
onCancel = _ref.onCancel,
|
|
1293
|
-
onConfirm = _ref.onConfirm,
|
|
1294
|
-
loading = _ref.loading;
|
|
1284
|
+
ref.current = ref.current || {};
|
|
1295
1285
|
|
|
1296
|
-
var
|
|
1297
|
-
return
|
|
1286
|
+
var onUpdate = function onUpdate(field) {
|
|
1287
|
+
return function (ev) {
|
|
1288
|
+
ref.current[field] = ev.target ? ev.target.value : ev.value || ev;
|
|
1289
|
+
};
|
|
1298
1290
|
};
|
|
1299
1291
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
}
|
|
1311
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1312
|
-
className: "level-left"
|
|
1313
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
1314
|
-
className: "level-right"
|
|
1315
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
1316
|
-
className: "button is-danger",
|
|
1317
|
-
onClick: function onClick() {
|
|
1318
|
-
return onCancel();
|
|
1319
|
-
}
|
|
1320
|
-
}, "Cancel"), "\xA0\xA0", /*#__PURE__*/React.createElement(Button, {
|
|
1321
|
-
loading: loading,
|
|
1322
|
-
className: "is-success",
|
|
1323
|
-
onClick: function onClick() {
|
|
1324
|
-
return onConfirm();
|
|
1325
|
-
},
|
|
1326
|
-
dataTest: "btnConfirmModalTest"
|
|
1327
|
-
}, "Confirm")))));
|
|
1328
|
-
} // @todo Improve it... Replacing the inputText to a tree
|
|
1292
|
+
var GetTag = function GetTag(_ref2) {
|
|
1293
|
+
var field = _ref2.field;
|
|
1294
|
+
var Tag = formComponents[properties[field].widget || properties[field].type];
|
|
1295
|
+
var props = {
|
|
1296
|
+
label: properties[field].title,
|
|
1297
|
+
value: initialState[field],
|
|
1298
|
+
onChange: onUpdate(field),
|
|
1299
|
+
placeholder: properties[field].title || '',
|
|
1300
|
+
id: generateUID(),
|
|
1301
|
+
dataTest: field + "TestInput"
|
|
1302
|
+
};
|
|
1329
1303
|
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
children = _ref2.children,
|
|
1334
|
-
onConfirm = _ref2.onConfirm,
|
|
1335
|
-
onCancel = _ref2.onCancel;
|
|
1336
|
-
return /*#__PURE__*/React.createElement(Modal, {
|
|
1337
|
-
isActive: true,
|
|
1338
|
-
setActive: onCancel
|
|
1339
|
-
}, /*#__PURE__*/React.createElement("h1", null, title), /*#__PURE__*/React.createElement("form", {
|
|
1340
|
-
onSubmit: function onSubmit(e) {
|
|
1341
|
-
e.preventDefault();
|
|
1342
|
-
onConfirm(e.target[0].value, e.target);
|
|
1304
|
+
if (required.includes(field)) {
|
|
1305
|
+
props.required = true;
|
|
1306
|
+
props.placeholder += ' *';
|
|
1343
1307
|
}
|
|
1344
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
1345
|
-
className: "input",
|
|
1346
|
-
placeholder: "/folder (without /db/container on front)",
|
|
1347
|
-
style: {
|
|
1348
|
-
margin: '20px 0'
|
|
1349
|
-
},
|
|
1350
|
-
defaultValue: defaultPath,
|
|
1351
|
-
type: "text"
|
|
1352
|
-
}), children, /*#__PURE__*/React.createElement("div", {
|
|
1353
|
-
className: "level-right"
|
|
1354
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
1355
|
-
type: "button",
|
|
1356
|
-
className: "button is-danger",
|
|
1357
|
-
onClick: onCancel
|
|
1358
|
-
}, "Cancel"), "\xA0\xA0", /*#__PURE__*/React.createElement("button", {
|
|
1359
|
-
type: "submit",
|
|
1360
|
-
className: "button is-success"
|
|
1361
|
-
}, "Confirm"))));
|
|
1362
|
-
}
|
|
1363
1308
|
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
set = _useState[1];
|
|
1309
|
+
Tag.displayName = field + "Field";
|
|
1310
|
+
return /*#__PURE__*/React.createElement(Tag, props);
|
|
1311
|
+
};
|
|
1368
1312
|
|
|
1369
|
-
var
|
|
1370
|
-
|
|
1371
|
-
|
|
1313
|
+
var children_ = React.Children.map(children, function (child) {
|
|
1314
|
+
return React.cloneElement(child, {
|
|
1315
|
+
onChange: onUpdate
|
|
1372
1316
|
});
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1317
|
+
});
|
|
1318
|
+
|
|
1319
|
+
var changes = function changes() {
|
|
1320
|
+
onSubmit(ref.current, values);
|
|
1321
|
+
};
|
|
1322
|
+
|
|
1323
|
+
return /*#__PURE__*/React.createElement(Form, _extends({
|
|
1324
|
+
onSubmit: changes
|
|
1325
|
+
}, rest), fields.map(function (field) {
|
|
1326
|
+
return /*#__PURE__*/React.createElement(GetTag, {
|
|
1327
|
+
field: field,
|
|
1328
|
+
key: field
|
|
1329
|
+
});
|
|
1330
|
+
}), children_, submitButton && /*#__PURE__*/React.createElement(Button, null, actionName));
|
|
1375
1331
|
}
|
|
1376
1332
|
|
|
1377
|
-
|
|
1378
|
-
try {
|
|
1379
|
-
var result = body();
|
|
1380
|
-
} catch (e) {
|
|
1381
|
-
return recover(e);
|
|
1382
|
-
}
|
|
1333
|
+
/** @type any */
|
|
1383
1334
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1335
|
+
var Select = React.forwardRef(function (_ref, ref) {
|
|
1336
|
+
var options = _ref.options,
|
|
1337
|
+
error = _ref.error,
|
|
1338
|
+
errorZoneClassName = _ref.errorZoneClassName,
|
|
1339
|
+
_ref$size = _ref.size,
|
|
1340
|
+
size = _ref$size === void 0 ? 1 : _ref$size,
|
|
1341
|
+
placeholder = _ref.placeholder,
|
|
1342
|
+
id = _ref.id,
|
|
1343
|
+
_ref$className = _ref.className,
|
|
1344
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1345
|
+
_ref$classWrap = _ref.classWrap,
|
|
1346
|
+
classWrap = _ref$classWrap === void 0 ? '' : _ref$classWrap,
|
|
1347
|
+
_ref$multiple = _ref.multiple,
|
|
1348
|
+
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
1349
|
+
_ref$loading = _ref.loading,
|
|
1350
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
1351
|
+
onChange = _ref.onChange,
|
|
1352
|
+
_ref$appendDefault = _ref.appendDefault,
|
|
1353
|
+
appendDefault = _ref$appendDefault === void 0 ? false : _ref$appendDefault,
|
|
1354
|
+
_ref$style = _ref.style,
|
|
1355
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
1356
|
+
dataTest = _ref.dataTest,
|
|
1357
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["options", "error", "errorZoneClassName", "size", "placeholder", "id", "className", "classWrap", "multiple", "loading", "isSubmitted", "onChange", "appendDefault", "style", "dataTest"]);
|
|
1387
1358
|
|
|
1388
|
-
|
|
1389
|
-
|
|
1359
|
+
var _useState = useState(generateUID('select')),
|
|
1360
|
+
uid = _useState[0];
|
|
1390
1361
|
|
|
1391
|
-
var
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
};
|
|
1362
|
+
var onUpdate = function onUpdate(ev) {
|
|
1363
|
+
if (ev.target.value === '') {
|
|
1364
|
+
onChange({
|
|
1365
|
+
target: {
|
|
1366
|
+
value: undefined
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
} else {
|
|
1370
|
+
onChange(ev);
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1398
1373
|
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1374
|
+
if (appendDefault) {
|
|
1375
|
+
options = [{
|
|
1376
|
+
text: 'Choose..',
|
|
1377
|
+
value: ''
|
|
1378
|
+
}].concat(options);
|
|
1404
1379
|
}
|
|
1405
1380
|
|
|
1406
|
-
|
|
1381
|
+
var statusClasses = error ? 'is-danger' : '';
|
|
1382
|
+
var cssWrap = ['select', statusClasses, multiple ? 'is-multiple' : '', classWrap];
|
|
1383
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1384
|
+
className: "field"
|
|
1385
|
+
}, id && placeholder ? /*#__PURE__*/React.createElement("label", {
|
|
1386
|
+
className: "label",
|
|
1387
|
+
htmlFor: id
|
|
1388
|
+
}, placeholder) : null, /*#__PURE__*/React.createElement("div", {
|
|
1389
|
+
className: classnames(cssWrap)
|
|
1390
|
+
}, /*#__PURE__*/React.createElement("select", _extends({
|
|
1391
|
+
className: classnames(['', className]),
|
|
1392
|
+
size: size,
|
|
1393
|
+
multiple: multiple,
|
|
1394
|
+
disabled: loading || rest.disabled,
|
|
1395
|
+
onChange: onUpdate
|
|
1396
|
+
}, rest, {
|
|
1397
|
+
ref: ref,
|
|
1398
|
+
style: style,
|
|
1399
|
+
"data-test": dataTest
|
|
1400
|
+
}), options.map(function (_ref2, index) {
|
|
1401
|
+
var text = _ref2.text,
|
|
1402
|
+
rest = _objectWithoutPropertiesLoose(_ref2, ["text"]);
|
|
1403
|
+
|
|
1404
|
+
return /*#__PURE__*/React.createElement("option", _extends({
|
|
1405
|
+
key: index.toString()
|
|
1406
|
+
}, rest), text);
|
|
1407
|
+
}))), error && /*#__PURE__*/React.createElement(ErrorZone, {
|
|
1408
|
+
className: errorZoneClassName,
|
|
1409
|
+
id: uid
|
|
1410
|
+
}, error ? error : ''));
|
|
1411
|
+
});
|
|
1412
|
+
Select.propTypes = {
|
|
1413
|
+
error: PropTypes.string,
|
|
1414
|
+
disabled: PropTypes.bool,
|
|
1415
|
+
loading: PropTypes.bool,
|
|
1416
|
+
isSubmitted: PropTypes.bool,
|
|
1417
|
+
size: PropTypes.number,
|
|
1418
|
+
onChange: PropTypes.func,
|
|
1419
|
+
options: PropTypes.arrayOf(PropTypes.object),
|
|
1420
|
+
multiple: PropTypes.bool,
|
|
1421
|
+
className: PropTypes.string
|
|
1407
1422
|
};
|
|
1408
1423
|
|
|
1409
|
-
var
|
|
1410
|
-
|
|
1411
|
-
|
|
1424
|
+
var RestClient = /*#__PURE__*/function () {
|
|
1425
|
+
function RestClient(url, container, auth) {
|
|
1426
|
+
this.auth = auth;
|
|
1427
|
+
this.url = url;
|
|
1428
|
+
this.container = container;
|
|
1412
1429
|
}
|
|
1413
1430
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1431
|
+
var _proto = RestClient.prototype;
|
|
1432
|
+
|
|
1433
|
+
_proto.request = function request(path, data, headers) {
|
|
1434
|
+
try {
|
|
1435
|
+
var _this2 = this;
|
|
1436
|
+
|
|
1437
|
+
if (path.indexOf(_this2.url) !== -1) {
|
|
1438
|
+
path = path.replace(_this2.url, '');
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
if (_this2.container !== '/' && path.indexOf(_this2.container) === -1) {
|
|
1442
|
+
path = "" + _this2.container + path;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
if (!path.startsWith('/')) {
|
|
1446
|
+
path = "/" + path;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
data = data || {};
|
|
1450
|
+
data.headers = headers || _this2.getHeaders();
|
|
1451
|
+
return Promise.resolve(fetch("" + _this2.url + path, data));
|
|
1452
|
+
} catch (e) {
|
|
1453
|
+
return Promise.reject(e);
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
_proto.getHeaders = function getHeaders() {
|
|
1458
|
+
var authToken = this.auth.getToken();
|
|
1459
|
+
if (!authToken) return {};
|
|
1460
|
+
return {
|
|
1461
|
+
Accept: 'application/json',
|
|
1462
|
+
'Content-Type': 'application/json',
|
|
1463
|
+
Authorization: 'Bearer ' + authToken
|
|
1422
1464
|
};
|
|
1465
|
+
};
|
|
1423
1466
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
loading: false,
|
|
1428
|
-
errorMessage: getErrorMessage(_res$json2, res.status),
|
|
1429
|
-
response: res
|
|
1430
|
-
};
|
|
1431
|
-
});
|
|
1432
|
-
} catch (e) {
|
|
1433
|
-
return Promise.reject(e);
|
|
1434
|
-
}
|
|
1435
|
-
};
|
|
1467
|
+
_proto.post = function post(path, data) {
|
|
1468
|
+
try {
|
|
1469
|
+
var _this4 = this;
|
|
1436
1470
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1471
|
+
return Promise.resolve(_this4.request(path, {
|
|
1472
|
+
method: 'post',
|
|
1473
|
+
body: JSON.stringify(data)
|
|
1474
|
+
}));
|
|
1475
|
+
} catch (e) {
|
|
1476
|
+
return Promise.reject(e);
|
|
1441
1477
|
}
|
|
1478
|
+
};
|
|
1442
1479
|
|
|
1480
|
+
_proto.get = function get(path) {
|
|
1443
1481
|
try {
|
|
1444
|
-
var
|
|
1445
|
-
setState(newState);
|
|
1446
|
-
return newState;
|
|
1447
|
-
};
|
|
1482
|
+
var _this6 = this;
|
|
1448
1483
|
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1484
|
+
return Promise.resolve(_this6.request(path, {}));
|
|
1485
|
+
} catch (e) {
|
|
1486
|
+
return Promise.reject(e);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1453
1489
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
return Promise.resolve(processResponse(res, body)).then(function (_processResponse) {
|
|
1458
|
-
newState = _processResponse;
|
|
1459
|
-
});
|
|
1460
|
-
});
|
|
1461
|
-
}, function (e) {
|
|
1462
|
-
console.error('Error', e);
|
|
1463
|
-
newState = {
|
|
1464
|
-
isError: true,
|
|
1465
|
-
errorMessage: 'unhandled exception'
|
|
1466
|
-
};
|
|
1467
|
-
});
|
|
1490
|
+
_proto.put = function put(path, data) {
|
|
1491
|
+
try {
|
|
1492
|
+
var _this8 = this;
|
|
1468
1493
|
|
|
1469
|
-
return Promise.resolve(
|
|
1494
|
+
return Promise.resolve(_this8.request(path, {
|
|
1495
|
+
method: 'put',
|
|
1496
|
+
body: JSON.stringify(data)
|
|
1497
|
+
}));
|
|
1470
1498
|
} catch (e) {
|
|
1471
1499
|
return Promise.reject(e);
|
|
1472
1500
|
}
|
|
1473
1501
|
};
|
|
1474
|
-
};
|
|
1475
1502
|
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1503
|
+
_proto.patch = function patch(path, data) {
|
|
1504
|
+
try {
|
|
1505
|
+
var _this10 = this;
|
|
1506
|
+
|
|
1507
|
+
return Promise.resolve(_this10.request(path, {
|
|
1508
|
+
method: 'PATCH',
|
|
1509
|
+
body: JSON.stringify(data)
|
|
1510
|
+
}));
|
|
1511
|
+
} catch (e) {
|
|
1512
|
+
return Promise.reject(e);
|
|
1480
1513
|
}
|
|
1514
|
+
};
|
|
1481
1515
|
|
|
1516
|
+
_proto.upload = function upload(path, data) {
|
|
1482
1517
|
try {
|
|
1483
|
-
var
|
|
1484
|
-
setState(newState);
|
|
1485
|
-
return newState;
|
|
1486
|
-
};
|
|
1487
|
-
|
|
1488
|
-
setState({
|
|
1489
|
-
loading: true
|
|
1490
|
-
});
|
|
1491
|
-
var newState = {};
|
|
1518
|
+
var _this12 = this;
|
|
1492
1519
|
|
|
1493
|
-
var
|
|
1494
|
-
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
1495
|
-
return Promise.resolve(Ctx.client.delete(path, data)).then(function (res) {
|
|
1496
|
-
return Promise.resolve(processResponse(res, body)).then(function (_processResponse2) {
|
|
1497
|
-
newState = _processResponse2;
|
|
1498
|
-
});
|
|
1499
|
-
});
|
|
1500
|
-
}, function (e) {
|
|
1501
|
-
console.error('Error', e);
|
|
1502
|
-
newState = {
|
|
1503
|
-
isError: true,
|
|
1504
|
-
errorMessage: 'unhandled exception'
|
|
1505
|
-
};
|
|
1506
|
-
});
|
|
1520
|
+
var headers = _this12.getHeaders();
|
|
1507
1521
|
|
|
1508
|
-
|
|
1522
|
+
delete headers['Content-Type'];
|
|
1523
|
+
headers['Content-Type'] = data['content-type'];
|
|
1524
|
+
headers['X-UPLOAD-FILENAME'] = data.filename;
|
|
1525
|
+
headers['Content-Encoding'] = 'base64';
|
|
1526
|
+
return Promise.resolve(_this12.request(path, {
|
|
1527
|
+
method: 'PATCH',
|
|
1528
|
+
body: data.data
|
|
1529
|
+
}, headers));
|
|
1509
1530
|
} catch (e) {
|
|
1510
1531
|
return Promise.reject(e);
|
|
1511
1532
|
}
|
|
1512
1533
|
};
|
|
1513
|
-
};
|
|
1514
1534
|
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
body = true;
|
|
1535
|
+
_proto.delete = function _delete(path, data) {
|
|
1536
|
+
if (data === void 0) {
|
|
1537
|
+
data = undefined;
|
|
1519
1538
|
}
|
|
1520
1539
|
|
|
1521
1540
|
try {
|
|
1522
|
-
var
|
|
1523
|
-
setState(newState);
|
|
1524
|
-
return newState;
|
|
1525
|
-
};
|
|
1526
|
-
|
|
1527
|
-
setState({
|
|
1528
|
-
loading: true
|
|
1529
|
-
});
|
|
1530
|
-
var newState = {};
|
|
1531
|
-
|
|
1532
|
-
var _temp14 = _catch(function () {
|
|
1533
|
-
var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
|
|
1534
|
-
return Promise.resolve(Ctx.client.post(path, data)).then(function (res) {
|
|
1535
|
-
return Promise.resolve(processResponse(res, body)).then(function (_processResponse3) {
|
|
1536
|
-
newState = _processResponse3;
|
|
1537
|
-
});
|
|
1538
|
-
});
|
|
1539
|
-
}, function (e) {
|
|
1540
|
-
console.error('Error', e);
|
|
1541
|
-
newState = {
|
|
1542
|
-
isError: true,
|
|
1543
|
-
errorMessage: 'unhandled exception'
|
|
1544
|
-
};
|
|
1545
|
-
});
|
|
1541
|
+
var _this14 = this;
|
|
1546
1542
|
|
|
1547
|
-
return Promise.resolve(
|
|
1543
|
+
return Promise.resolve(_this14.request(path, {
|
|
1544
|
+
method: 'delete',
|
|
1545
|
+
body: JSON.stringify(data)
|
|
1546
|
+
}));
|
|
1548
1547
|
} catch (e) {
|
|
1549
1548
|
return Promise.reject(e);
|
|
1550
1549
|
}
|
|
1551
1550
|
};
|
|
1551
|
+
|
|
1552
|
+
return RestClient;
|
|
1553
|
+
}();
|
|
1554
|
+
|
|
1555
|
+
var Loading = function Loading(_ref) {
|
|
1556
|
+
var rest = _extends({}, _ref);
|
|
1557
|
+
|
|
1558
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
1559
|
+
className: "progress-line"
|
|
1560
|
+
}, rest));
|
|
1552
1561
|
};
|
|
1553
1562
|
|
|
1554
|
-
var
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1563
|
+
var Tag = function Tag(_ref) {
|
|
1564
|
+
var name = _ref.name,
|
|
1565
|
+
onRemove = _ref.onRemove,
|
|
1566
|
+
_ref$size = _ref.size,
|
|
1567
|
+
size = _ref$size === void 0 ? 'is-medium' : _ref$size,
|
|
1568
|
+
_ref$color = _ref.color,
|
|
1569
|
+
color = _ref$color === void 0 ? 'is-warning' : _ref$color;
|
|
1570
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
1571
|
+
className: classnames(['tag', color, size])
|
|
1572
|
+
}, name, onRemove !== undefined && /*#__PURE__*/React.createElement("button", {
|
|
1573
|
+
className: "delete is-small",
|
|
1574
|
+
onClick: function onClick() {
|
|
1575
|
+
return onRemove();
|
|
1576
|
+
}
|
|
1577
|
+
}));
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
function Delete(_ref) {
|
|
1581
|
+
var onClick = _ref.onClick,
|
|
1582
|
+
className = _ref.className,
|
|
1583
|
+
children = _ref.children;
|
|
1584
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
1585
|
+
type: "button",
|
|
1586
|
+
onClick: onClick,
|
|
1587
|
+
className: "delete " + className,
|
|
1588
|
+
"data-test": "btnDeleteTest"
|
|
1589
|
+
}, children);
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
function Table(_ref) {
|
|
1593
|
+
var headers = _ref.headers,
|
|
1594
|
+
children = _ref.children,
|
|
1595
|
+
className = _ref.className;
|
|
1596
|
+
className = className ? className.split(' ') : ' is-full is-fullwidth is-narrow'.split(' ');
|
|
1597
|
+
return /*#__PURE__*/React.createElement("table", {
|
|
1598
|
+
className: classnames(['table'].concat(className))
|
|
1599
|
+
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, headers && headers.map(function (item, idx) {
|
|
1600
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
1601
|
+
key: item + idx
|
|
1602
|
+
}, item);
|
|
1603
|
+
}))), /*#__PURE__*/React.createElement("tbody", null, children));
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
function Notification(_ref) {
|
|
1607
|
+
var _ref$isColor = _ref.isColor,
|
|
1608
|
+
isColor = _ref$isColor === void 0 ? '' : _ref$isColor,
|
|
1609
|
+
children = _ref.children;
|
|
1610
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1611
|
+
className: 'notification is-' + isColor,
|
|
1612
|
+
"data-test": "notificationTest"
|
|
1613
|
+
}, children);
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
// https://github.com/molefrog/wouter
|
|
1617
|
+
|
|
1618
|
+
var setURLParams = function setURLParams(p) {
|
|
1619
|
+
return window.history['pushState'](0, 0, (window.history.pathname || '') + '?' + p.toString().replace(/%2F/g, '/'));
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
var clean = function clean(to) {
|
|
1623
|
+
var current = new URLSearchParams();
|
|
1624
|
+
Object.keys(to).forEach(function (_key) {
|
|
1625
|
+
return current.set(_key, to[_key]);
|
|
1626
|
+
});
|
|
1627
|
+
setURLParams(current);
|
|
1628
|
+
};
|
|
1629
|
+
|
|
1630
|
+
var useLocation = function useLocation() {
|
|
1631
|
+
var _useState = useState(currentSearchParams()),
|
|
1632
|
+
path = _useState[0],
|
|
1633
|
+
update = _useState[1];
|
|
1634
|
+
|
|
1635
|
+
var prevPath = useRef(path);
|
|
1636
|
+
useEffect(function () {
|
|
1637
|
+
patchHistoryEvents(); // this function checks if the location has been changed since the
|
|
1638
|
+
// last render and updates the state only when needed.
|
|
1639
|
+
// unfortunately, we can't rely on `path` value here, since it can be stale,
|
|
1640
|
+
// that's why we store the last pathname in a ref.
|
|
1641
|
+
|
|
1642
|
+
var checkForUpdates = function checkForUpdates() {
|
|
1643
|
+
var pathname = currentSearchParams();
|
|
1644
|
+
prevPath.current !== pathname && update(prevPath.current = pathname);
|
|
1645
|
+
};
|
|
1646
|
+
|
|
1647
|
+
var events = ['popstate', 'pushState', 'replaceState'];
|
|
1648
|
+
events.map(function (e) {
|
|
1649
|
+
return window.addEventListener(e, checkForUpdates);
|
|
1650
|
+
}); // it's possible that an update has occurred between render and the effect handler,
|
|
1651
|
+
// so we run additional check on mount to catch these updates. Based on:
|
|
1652
|
+
// https://gist.github.com/bvaughn/e25397f70e8c65b0ae0d7c90b731b189
|
|
1653
|
+
|
|
1654
|
+
checkForUpdates();
|
|
1655
|
+
return function () {
|
|
1656
|
+
return events.map(function (e) {
|
|
1657
|
+
return window.removeEventListener(e, checkForUpdates);
|
|
1570
1658
|
});
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1659
|
+
};
|
|
1660
|
+
}, []); // the 2nd argument of the `useLocation` return value is a function
|
|
1661
|
+
// that allows to perform a navigation.
|
|
1662
|
+
//
|
|
1663
|
+
// the function reference should stay the same between re-renders, so that
|
|
1664
|
+
// it can be passed down as an element prop without any performance concerns.
|
|
1665
|
+
|
|
1666
|
+
var navigate = useCallback(function (to, replace) {
|
|
1667
|
+
if (replace) {
|
|
1668
|
+
clean(to);
|
|
1669
|
+
return;
|
|
1573
1670
|
}
|
|
1574
|
-
|
|
1671
|
+
|
|
1672
|
+
var current = new URLSearchParams(path.toString());
|
|
1673
|
+
Object.keys(to).forEach(function (_key) {
|
|
1674
|
+
return current.set(_key, to[_key]);
|
|
1675
|
+
});
|
|
1676
|
+
setURLParams(current);
|
|
1677
|
+
}, [path]);
|
|
1678
|
+
var remove = useCallback(function (param) {
|
|
1679
|
+
var current = new URLSearchParams(path.toString());
|
|
1680
|
+
current.delete(param);
|
|
1681
|
+
setURLParams(current);
|
|
1682
|
+
}, [path]);
|
|
1683
|
+
return [path, navigate, remove];
|
|
1684
|
+
}; // While History API does have `popstate` event, the only
|
|
1685
|
+
// proper way to listen to changes via `push/replaceState`
|
|
1686
|
+
// is to monkey-patch these methods.
|
|
1687
|
+
//
|
|
1688
|
+
// See https://stackoverflow.com/a/4585031
|
|
1689
|
+
|
|
1690
|
+
var patched = 0;
|
|
1691
|
+
|
|
1692
|
+
var patchHistoryEvents = function patchHistoryEvents() {
|
|
1693
|
+
if (patched) return;
|
|
1694
|
+
['pushState', 'replaceState'].map(function (type) {
|
|
1695
|
+
var original = window.history[type];
|
|
1696
|
+
|
|
1697
|
+
window.history[type] = function () {
|
|
1698
|
+
var result = original.apply(this, arguments);
|
|
1699
|
+
var event = new Event(type);
|
|
1700
|
+
event.arguments = arguments;
|
|
1701
|
+
dispatchEvent(event);
|
|
1702
|
+
return result;
|
|
1703
|
+
};
|
|
1704
|
+
});
|
|
1705
|
+
return patched = 1;
|
|
1575
1706
|
};
|
|
1576
1707
|
|
|
1577
|
-
function
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
state = _useSetState[0],
|
|
1582
|
-
setState = _useSetState[1];
|
|
1708
|
+
var currentSearchParams = function currentSearchParams(path) {
|
|
1709
|
+
if (path === void 0) {
|
|
1710
|
+
path = window.location.search;
|
|
1711
|
+
}
|
|
1583
1712
|
|
|
1584
|
-
return
|
|
1585
|
-
|
|
1586
|
-
patch: patch(setState, Ctx),
|
|
1587
|
-
del: del(setState, Ctx),
|
|
1588
|
-
post: post(setState, Ctx),
|
|
1589
|
-
get: get(setState, Ctx)
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1713
|
+
return new URLSearchParams(path);
|
|
1714
|
+
};
|
|
1592
1715
|
|
|
1593
|
-
function
|
|
1594
|
-
var
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
}, data.formData ? data.formData : data);
|
|
1599
|
-
return Promise.resolve(post(form)).then(function (_ref) {
|
|
1600
|
-
var isError = _ref.isError,
|
|
1601
|
-
errorMessage = _ref.errorMessage;
|
|
1716
|
+
function Link(_ref) {
|
|
1717
|
+
var aRef = _ref.aRef,
|
|
1718
|
+
model = _ref.model,
|
|
1719
|
+
children = _ref.children,
|
|
1720
|
+
props = _objectWithoutPropertiesLoose(_ref, ["aRef", "model", "children"]);
|
|
1602
1721
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
Ctx.flash("An error has ocurred: " + errorMessage, 'danger');
|
|
1607
|
-
}
|
|
1722
|
+
var _useLocation = useLocation(),
|
|
1723
|
+
path = _useLocation[0],
|
|
1724
|
+
navigate = _useLocation[1];
|
|
1608
1725
|
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
} catch (e) {
|
|
1613
|
-
return Promise.reject(e);
|
|
1614
|
-
}
|
|
1726
|
+
var aStyle = {
|
|
1727
|
+
textDecoration: 'none',
|
|
1728
|
+
color: 'currentColor'
|
|
1615
1729
|
};
|
|
1616
1730
|
|
|
1617
|
-
|
|
1731
|
+
function onClick(e) {
|
|
1732
|
+
e.stopPropagation();
|
|
1733
|
+
if (actAsLink(e)) return;
|
|
1734
|
+
e.preventDefault();
|
|
1735
|
+
navigate({
|
|
1736
|
+
path: model.path
|
|
1737
|
+
}, true);
|
|
1738
|
+
if (props.onClick) props.onClick(e);
|
|
1739
|
+
}
|
|
1618
1740
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1741
|
+
return /*#__PURE__*/React.createElement("a", _extends({}, props, {
|
|
1742
|
+
ref: aRef,
|
|
1743
|
+
href: "?" + path + model.id + "/",
|
|
1744
|
+
style: aStyle,
|
|
1745
|
+
onClick: onClick
|
|
1746
|
+
}), children);
|
|
1747
|
+
}
|
|
1622
1748
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1749
|
+
function actAsLink(e) {
|
|
1750
|
+
return e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || e.button !== 0;
|
|
1751
|
+
}
|
|
1626
1752
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1753
|
+
function TdLink(_ref) {
|
|
1754
|
+
var model = _ref.model,
|
|
1755
|
+
children = _ref.children,
|
|
1756
|
+
props = _objectWithoutPropertiesLoose(_ref, ["model", "children"]);
|
|
1630
1757
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
dataTest: "formAdd" + type + "Test"
|
|
1644
|
-
}));
|
|
1758
|
+
var link = useRef();
|
|
1759
|
+
|
|
1760
|
+
function onClick() {
|
|
1761
|
+
link.current.click();
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
return /*#__PURE__*/React.createElement("td", _extends({}, props, {
|
|
1765
|
+
onClick: onClick
|
|
1766
|
+
}), /*#__PURE__*/React.createElement(Link, {
|
|
1767
|
+
model: model,
|
|
1768
|
+
aRef: link
|
|
1769
|
+
}, children));
|
|
1645
1770
|
}
|
|
1646
1771
|
|
|
1647
|
-
var
|
|
1648
|
-
var
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1772
|
+
var SEP = '=';
|
|
1773
|
+
var DEFAULT_FIELD = 'title__in';
|
|
1774
|
+
var CLEANER = '||';
|
|
1775
|
+
function parser(qs, defaultField) {
|
|
1776
|
+
if (defaultField === void 0) {
|
|
1777
|
+
defaultField = DEFAULT_FIELD;
|
|
1778
|
+
}
|
|
1654
1779
|
|
|
1655
|
-
|
|
1656
|
-
|
|
1780
|
+
var lastKey = undefined;
|
|
1781
|
+
qs.trim();
|
|
1657
1782
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1783
|
+
if (qs.includes('"')) {
|
|
1784
|
+
qs = qs.replace(/"(\w+) (\w+)"/, "$1" + CLEANER + "$2");
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
qs = qs.split(' ');
|
|
1788
|
+
return qs.map(function (part) {
|
|
1789
|
+
if (part.includes(CLEANER)) {
|
|
1790
|
+
part = part.replace('||', ' ');
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
if (!part.includes(SEP)) {
|
|
1794
|
+
return !lastKey ? [defaultField, part] : [lastKey, part];
|
|
1667
1795
|
}
|
|
1796
|
+
|
|
1797
|
+
var _part$split = part.split(SEP),
|
|
1798
|
+
key = _part$split[0],
|
|
1799
|
+
val = _part$split[1];
|
|
1800
|
+
|
|
1801
|
+
lastKey = key;
|
|
1802
|
+
return [key, val];
|
|
1668
1803
|
});
|
|
1669
|
-
|
|
1670
|
-
|
|
1804
|
+
}
|
|
1805
|
+
function buildQs(parsedQuery) {
|
|
1806
|
+
return parsedQuery.map(function (_ref) {
|
|
1807
|
+
var key = _ref[0],
|
|
1808
|
+
val = _ref[1];
|
|
1809
|
+
return encodeURIComponent(key) + "=" + encodeURIComponent(val);
|
|
1810
|
+
}).join('&');
|
|
1811
|
+
}
|
|
1671
1812
|
|
|
1672
|
-
|
|
1673
|
-
|
|
1813
|
+
var cacheTypes = {};
|
|
1814
|
+
var cacheSchemas = {};
|
|
1815
|
+
var GuillotinaClient = /*#__PURE__*/function () {
|
|
1816
|
+
function GuillotinaClient(rest, pathContainsContainer) {
|
|
1817
|
+
var _this = this;
|
|
1674
1818
|
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
// ref.current = addConfig(cfg, ref.current);
|
|
1681
|
-
// calculated = ref.current
|
|
1682
|
-
// console.log("Current config", cfg)
|
|
1683
|
-
// }
|
|
1819
|
+
this.getContainerFromPath = function (path) {
|
|
1820
|
+
if (_this.pathContainsContainer) {
|
|
1821
|
+
if (path.startsWith('/')) {
|
|
1822
|
+
path = path.substring(1);
|
|
1823
|
+
}
|
|
1684
1824
|
|
|
1825
|
+
var parts = path.split('/');
|
|
1826
|
+
return parts[0] + "/" + parts[1] + "/";
|
|
1827
|
+
}
|
|
1685
1828
|
|
|
1686
|
-
|
|
1687
|
-
}
|
|
1829
|
+
return '';
|
|
1830
|
+
};
|
|
1688
1831
|
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1832
|
+
this.clearContainerFromPath = function (path) {
|
|
1833
|
+
if (_this.pathContainsContainer) {
|
|
1834
|
+
return "/" + _this.cleanPath(path);
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
return path;
|
|
1838
|
+
};
|
|
1839
|
+
|
|
1840
|
+
this.rest = rest;
|
|
1841
|
+
this.pathContainsContainer = pathContainsContainer;
|
|
1692
1842
|
}
|
|
1693
1843
|
|
|
1694
|
-
|
|
1695
|
-
};
|
|
1844
|
+
var _proto = GuillotinaClient.prototype;
|
|
1696
1845
|
|
|
1697
|
-
function
|
|
1698
|
-
var removeItems = function removeItems() {
|
|
1846
|
+
_proto.getContext = function getContext(path) {
|
|
1699
1847
|
try {
|
|
1700
|
-
var
|
|
1701
|
-
setLoading(true);
|
|
1702
|
-
var actions = items.map(function (item) {
|
|
1703
|
-
try {
|
|
1704
|
-
console.log(item);
|
|
1705
|
-
return Promise.resolve(Ctx.client.delete(getId(item))).then(function (res) {
|
|
1706
|
-
var _temp = function () {
|
|
1707
|
-
if (!res.ok) {
|
|
1708
|
-
return Promise.resolve(res.json()).then(function (err) {
|
|
1709
|
-
errors.push(err);
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
}();
|
|
1848
|
+
var _this3 = this;
|
|
1713
1849
|
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
return Promise.reject(e);
|
|
1718
|
-
}
|
|
1719
|
-
}); // this sleep is here, to let elasticsearch, wait for
|
|
1720
|
-
// index our operations... (will work 99% of use cases)
|
|
1850
|
+
switch (path) {
|
|
1851
|
+
case '/':
|
|
1852
|
+
return Promise.resolve(_this3.rest.get(''));
|
|
1721
1853
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
Ctx.refresh();
|
|
1727
|
-
} else {
|
|
1728
|
-
var errorstr = errors.map(function (err) {
|
|
1729
|
-
return JSON.stringify(err);
|
|
1730
|
-
}).join('\n');
|
|
1731
|
-
Ctx.flash("Something went wrong!! " + errorstr, 'danger');
|
|
1732
|
-
}
|
|
1854
|
+
default:
|
|
1855
|
+
if (path.startsWith('/')) {
|
|
1856
|
+
path = path.substring(1);
|
|
1857
|
+
}
|
|
1733
1858
|
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1859
|
+
return Promise.resolve(_this3.rest.get(path));
|
|
1860
|
+
}
|
|
1861
|
+
} catch (e) {
|
|
1862
|
+
return Promise.reject(e);
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1865
|
+
|
|
1866
|
+
_proto.get = function get(path) {
|
|
1867
|
+
try {
|
|
1868
|
+
var _this5 = this;
|
|
1869
|
+
|
|
1870
|
+
if (path.startsWith('/')) {
|
|
1871
|
+
path = path.slice(1);
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
return Promise.resolve(_this5.rest.get(path));
|
|
1737
1875
|
} catch (e) {
|
|
1738
1876
|
return Promise.reject(e);
|
|
1739
1877
|
}
|
|
1740
1878
|
};
|
|
1741
1879
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1880
|
+
_proto.getQueryParamsPostresql = function getQueryParamsPostresql(_ref) {
|
|
1881
|
+
var _ref$start = _ref.start,
|
|
1882
|
+
start = _ref$start === void 0 ? 0 : _ref$start,
|
|
1883
|
+
_ref$pageSize = _ref.pageSize,
|
|
1884
|
+
pageSize = _ref$pageSize === void 0 ? 10 : _ref$pageSize,
|
|
1885
|
+
_ref$withDepth = _ref.withDepth,
|
|
1886
|
+
withDepth = _ref$withDepth === void 0 ? true : _ref$withDepth;
|
|
1887
|
+
var result = [];
|
|
1888
|
+
result = [].concat(parser(start.toString(), 'b_start'), parser(pageSize.toString(), 'b_size'));
|
|
1744
1889
|
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
setLoading = _React$useState[1];
|
|
1890
|
+
if (withDepth) {
|
|
1891
|
+
var _parser;
|
|
1748
1892
|
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
var last = items[items.length - 1]['@name'];
|
|
1752
|
-
var itemsNames = items.map(function (item) {
|
|
1753
|
-
return item['@name'];
|
|
1754
|
-
}).join(', ').replace(", " + last, " and " + last);
|
|
1755
|
-
return /*#__PURE__*/React.createElement(Confirm, {
|
|
1756
|
-
loading: loading,
|
|
1757
|
-
onCancel: function onCancel() {
|
|
1758
|
-
return Ctx.cancelAction();
|
|
1759
|
-
},
|
|
1760
|
-
onConfirm: removeItems,
|
|
1761
|
-
message: "Are you sure to remove: " + itemsNames + "?"
|
|
1762
|
-
});
|
|
1763
|
-
}
|
|
1893
|
+
result = [].concat(result, (_parser = parser('1', 'depth')) != null ? _parser : []);
|
|
1894
|
+
}
|
|
1764
1895
|
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
className = _ref.className,
|
|
1768
|
-
classNameInput = _ref.classNameInput,
|
|
1769
|
-
loading = _ref.loading,
|
|
1770
|
-
disabled = _ref.disabled,
|
|
1771
|
-
_ref$indeterminate = _ref.indeterminate,
|
|
1772
|
-
indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
|
|
1773
|
-
_ref$value = _ref.value,
|
|
1774
|
-
value = _ref$value === void 0 ? false : _ref$value,
|
|
1775
|
-
children = _ref.children,
|
|
1776
|
-
placeholder = _ref.placeholder,
|
|
1777
|
-
onChange = _ref.onChange,
|
|
1778
|
-
dataTest = _ref.dataTest,
|
|
1779
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["id", "className", "classNameInput", "loading", "disabled", "indeterminate", "value", "color", "backgroundColor", "borderColor", "children", "placeholder", "onChange", "dataTest"]);
|
|
1896
|
+
return result;
|
|
1897
|
+
};
|
|
1780
1898
|
|
|
1781
|
-
|
|
1899
|
+
_proto.getQueryParamsElasticsearch = function getQueryParamsElasticsearch(_ref2) {
|
|
1900
|
+
var _ref2$start = _ref2.start,
|
|
1901
|
+
start = _ref2$start === void 0 ? 0 : _ref2$start,
|
|
1902
|
+
_ref2$pageSize = _ref2.pageSize,
|
|
1903
|
+
pageSize = _ref2$pageSize === void 0 ? 10 : _ref2$pageSize,
|
|
1904
|
+
path = _ref2.path,
|
|
1905
|
+
_ref2$withDepth = _ref2.withDepth,
|
|
1906
|
+
withDepth = _ref2$withDepth === void 0 ? true : _ref2$withDepth;
|
|
1907
|
+
var result = [];
|
|
1908
|
+
var containerPath = this.getContainerFromPath(path);
|
|
1782
1909
|
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1910
|
+
if (containerPath.startsWith('/')) {
|
|
1911
|
+
containerPath = containerPath.slice(1);
|
|
1912
|
+
}
|
|
1786
1913
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1914
|
+
var objectPath = path.replace(containerPath, '');
|
|
1915
|
+
|
|
1916
|
+
if (objectPath.endsWith('/')) {
|
|
1917
|
+
objectPath = objectPath.slice(0, -1);
|
|
1790
1918
|
}
|
|
1791
|
-
}, [indeterminate]);
|
|
1792
1919
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1920
|
+
result = [].concat(parser(start.toString(), '_from'), parser(pageSize.toString(), 'size'));
|
|
1921
|
+
|
|
1922
|
+
if (withDepth) {
|
|
1923
|
+
var _parser2;
|
|
1924
|
+
|
|
1925
|
+
result = [].concat(result, (_parser2 = parser('1', 'depth')) != null ? _parser2 : []);
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
if (objectPath !== '') {
|
|
1929
|
+
result = [].concat(result, parser(objectPath, 'path__wildcard'));
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
return result;
|
|
1796
1933
|
};
|
|
1797
1934
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1935
|
+
_proto.getItemsColumn = function getItemsColumn() {
|
|
1936
|
+
var smallcss = {
|
|
1937
|
+
width: 25
|
|
1938
|
+
};
|
|
1939
|
+
var mediumcss = {
|
|
1940
|
+
width: 120
|
|
1941
|
+
};
|
|
1942
|
+
return [{
|
|
1943
|
+
label: '',
|
|
1944
|
+
child: function child(m) {
|
|
1945
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
1946
|
+
style: smallcss
|
|
1947
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
1948
|
+
icon: m.icon
|
|
1949
|
+
}));
|
|
1950
|
+
}
|
|
1951
|
+
}, {
|
|
1952
|
+
label: 'type',
|
|
1953
|
+
child: function child(m) {
|
|
1954
|
+
return /*#__PURE__*/React.createElement(TdLink, {
|
|
1955
|
+
style: smallcss,
|
|
1956
|
+
model: m
|
|
1957
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1958
|
+
className: "tag"
|
|
1959
|
+
}, m.type));
|
|
1960
|
+
}
|
|
1961
|
+
}, {
|
|
1962
|
+
label: 'id/name',
|
|
1963
|
+
child: function child(m, navigate, search) {
|
|
1964
|
+
return /*#__PURE__*/React.createElement(TdLink, {
|
|
1965
|
+
model: m
|
|
1966
|
+
}, m.name, search && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("span", {
|
|
1967
|
+
className: "is-size-7 tag is-light"
|
|
1968
|
+
}, m.path)));
|
|
1969
|
+
}
|
|
1970
|
+
}, {
|
|
1971
|
+
label: 'created',
|
|
1972
|
+
child: function child(m) {
|
|
1973
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
1974
|
+
style: mediumcss,
|
|
1975
|
+
className: "is-size-7 is-vcentered"
|
|
1976
|
+
}, m.created);
|
|
1977
|
+
}
|
|
1978
|
+
}, {
|
|
1979
|
+
label: 'modified',
|
|
1980
|
+
child: function child(m) {
|
|
1981
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
1982
|
+
style: mediumcss,
|
|
1983
|
+
className: "is-size-7 is-vcentered"
|
|
1984
|
+
}, m.updated);
|
|
1985
|
+
}
|
|
1986
|
+
}];
|
|
1987
|
+
} // BBB API changes. Compat G5 and G6
|
|
1988
|
+
;
|
|
1814
1989
|
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
className: classnames(['help is-danger', className]),
|
|
1821
|
-
id: id
|
|
1822
|
-
}, children);
|
|
1823
|
-
};
|
|
1990
|
+
_proto.applyCompat = function applyCompat(data) {
|
|
1991
|
+
data.member = data.items;
|
|
1992
|
+
data.items_count = data.items_total;
|
|
1993
|
+
return data;
|
|
1994
|
+
};
|
|
1824
1995
|
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
};
|
|
1996
|
+
_proto.search = function search(path, params, container, prepare) {
|
|
1997
|
+
if (container === void 0) {
|
|
1998
|
+
container = false;
|
|
1999
|
+
}
|
|
1830
2000
|
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
var result = true;
|
|
1834
|
-
validation.forEach(function (func) {
|
|
1835
|
-
if (func(value) === false) {
|
|
1836
|
-
result = false;
|
|
2001
|
+
if (prepare === void 0) {
|
|
2002
|
+
prepare = true;
|
|
1837
2003
|
}
|
|
1838
|
-
});
|
|
1839
|
-
return result;
|
|
1840
|
-
};
|
|
1841
2004
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
hasError: false,
|
|
1845
|
-
value: value
|
|
1846
|
-
}),
|
|
1847
|
-
state = _React$useState[0],
|
|
1848
|
-
setState = _React$useState[1];
|
|
2005
|
+
try {
|
|
2006
|
+
var _this7 = this;
|
|
1849
2007
|
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
2008
|
+
if (path.startsWith('/')) {
|
|
2009
|
+
path = path.slice(1);
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
if (container) {
|
|
2013
|
+
path = _this7.getContainerFromPath(path);
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
var query = prepare ? toQueryString(params) : params;
|
|
2017
|
+
var url = path + "@search?" + query;
|
|
2018
|
+
return Promise.resolve(_this7.rest.get(url)).then(function (res) {
|
|
2019
|
+
return Promise.resolve(res.json()).then(function (data) {
|
|
2020
|
+
return _this7.applyCompat(data);
|
|
2021
|
+
});
|
|
2022
|
+
});
|
|
2023
|
+
} catch (e) {
|
|
2024
|
+
return Promise.reject(e);
|
|
2025
|
+
}
|
|
1857
2026
|
};
|
|
1858
2027
|
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
2028
|
+
_proto.canido = function canido(path, permissions) {
|
|
2029
|
+
try {
|
|
2030
|
+
var _this9 = this;
|
|
2031
|
+
|
|
2032
|
+
if (path.startsWith('/')) {
|
|
2033
|
+
path = path.slice(1);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
if (Array.isArray(permissions)) {
|
|
2037
|
+
permissions.join(',');
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
var url = path + "@canido?permissions=" + permissions;
|
|
2041
|
+
return Promise.resolve(_this9.rest.get(url));
|
|
2042
|
+
} catch (e) {
|
|
2043
|
+
return Promise.reject(e);
|
|
2044
|
+
}
|
|
1865
2045
|
};
|
|
1866
2046
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2047
|
+
_proto.createObject = function createObject(path, data) {
|
|
2048
|
+
try {
|
|
2049
|
+
var _this11 = this;
|
|
2050
|
+
|
|
2051
|
+
return Promise.resolve(_this11.rest.post(path, data));
|
|
2052
|
+
} catch (e) {
|
|
2053
|
+
return Promise.reject(e);
|
|
1873
2054
|
}
|
|
1874
2055
|
};
|
|
1875
2056
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
hasError: false
|
|
1880
|
-
});
|
|
1881
|
-
}, [value]);
|
|
1882
|
-
return {
|
|
1883
|
-
onChange: onUpdate,
|
|
1884
|
-
onFocus: onFocus,
|
|
1885
|
-
onBlur: onBlur,
|
|
1886
|
-
state: state
|
|
2057
|
+
_proto.cleanPath = function cleanPath(path) {
|
|
2058
|
+
var url = path.split('/').slice(3);
|
|
2059
|
+
return "" + url.join('/');
|
|
1887
2060
|
};
|
|
1888
|
-
};
|
|
1889
2061
|
|
|
1890
|
-
|
|
2062
|
+
_proto.delete = function _delete(path, data) {
|
|
2063
|
+
try {
|
|
2064
|
+
var _this13 = this;
|
|
1891
2065
|
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
var isEmpty = function isEmpty(value) {
|
|
1898
|
-
if (value === void 0) {
|
|
1899
|
-
value = '';
|
|
1900
|
-
}
|
|
2066
|
+
return Promise.resolve(_this13.rest.delete(path, data));
|
|
2067
|
+
} catch (e) {
|
|
2068
|
+
return Promise.reject(e);
|
|
2069
|
+
}
|
|
2070
|
+
};
|
|
1901
2071
|
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
var
|
|
1905
|
-
if (value === void 0) {
|
|
1906
|
-
value = '';
|
|
1907
|
-
}
|
|
2072
|
+
_proto.create = function create(path, data) {
|
|
2073
|
+
try {
|
|
2074
|
+
var _this15 = this;
|
|
1908
2075
|
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
2076
|
+
if (path.startsWith('/')) {
|
|
2077
|
+
path = path.substring(1);
|
|
2078
|
+
}
|
|
1912
2079
|
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
}
|
|
2080
|
+
return Promise.resolve(_this15.rest.post(path, data));
|
|
2081
|
+
} catch (e) {
|
|
2082
|
+
return Promise.reject(e);
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
1919
2085
|
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
2086
|
+
_proto.post = function post(path, data) {
|
|
2087
|
+
try {
|
|
2088
|
+
var _this17 = this;
|
|
1923
2089
|
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
}
|
|
2090
|
+
return Promise.resolve(_this17.create(path, data));
|
|
2091
|
+
} catch (e) {
|
|
2092
|
+
return Promise.reject(e);
|
|
2093
|
+
}
|
|
2094
|
+
};
|
|
1930
2095
|
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
var
|
|
1934
|
-
if (value === void 0) {
|
|
1935
|
-
value = '';
|
|
1936
|
-
}
|
|
2096
|
+
_proto.patch = function patch(path, data) {
|
|
2097
|
+
try {
|
|
2098
|
+
var _this19 = this;
|
|
1937
2099
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
if (value === void 0) {
|
|
1942
|
-
value = '';
|
|
1943
|
-
}
|
|
2100
|
+
if (path.startsWith('/')) {
|
|
2101
|
+
path = path.substring(1);
|
|
2102
|
+
}
|
|
1944
2103
|
|
|
1945
|
-
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
}
|
|
2104
|
+
return Promise.resolve(_this19.rest.patch(path, data));
|
|
2105
|
+
} catch (e) {
|
|
2106
|
+
return Promise.reject(e);
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
1951
2109
|
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
var
|
|
1955
|
-
return !!value.length;
|
|
1956
|
-
};
|
|
2110
|
+
_proto.upload = function upload(path, file) {
|
|
2111
|
+
try {
|
|
2112
|
+
var _this21 = this;
|
|
1957
2113
|
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
}
|
|
1961
|
-
/** @type any */
|
|
2114
|
+
if (path.startsWith('/')) {
|
|
2115
|
+
path = path.substring(1);
|
|
2116
|
+
}
|
|
1962
2117
|
|
|
2118
|
+
return Promise.resolve(_this21.rest.upload(path, file));
|
|
2119
|
+
} catch (e) {
|
|
2120
|
+
return Promise.reject(e);
|
|
2121
|
+
}
|
|
2122
|
+
};
|
|
1963
2123
|
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
iconPosition = _ref$iconPosition === void 0 ? 'has-icons-right' : _ref$iconPosition,
|
|
1968
|
-
error = _ref.error,
|
|
1969
|
-
errorZoneClassName = _ref.errorZoneClassName,
|
|
1970
|
-
_ref$autoComplete = _ref.autoComplete,
|
|
1971
|
-
autoComplete = _ref$autoComplete === void 0 ? 'off' : _ref$autoComplete,
|
|
1972
|
-
_ref$className = _ref.className,
|
|
1973
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1974
|
-
_ref$widget = _ref.widget,
|
|
1975
|
-
widget = _ref$widget === void 0 ? 'input' : _ref$widget,
|
|
1976
|
-
_ref$type = _ref.type,
|
|
1977
|
-
type = _ref$type === void 0 ? 'text' : _ref$type,
|
|
1978
|
-
_ref$loading = _ref.loading,
|
|
1979
|
-
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
1980
|
-
_ref$required = _ref.required,
|
|
1981
|
-
required = _ref$required === void 0 ? false : _ref$required,
|
|
1982
|
-
id = _ref.id,
|
|
1983
|
-
placeholder = _ref.placeholder,
|
|
1984
|
-
value = _ref.value,
|
|
1985
|
-
_ref$autofocus = _ref.autofocus,
|
|
1986
|
-
autofocus = _ref$autofocus === void 0 ? false : _ref$autofocus,
|
|
1987
|
-
onChange = _ref.onChange,
|
|
1988
|
-
_ref$validator = _ref.validator,
|
|
1989
|
-
validator = _ref$validator === void 0 ? noop$2 : _ref$validator,
|
|
1990
|
-
errorMessage = _ref.errorMessage,
|
|
1991
|
-
_ref$dataTest = _ref.dataTest,
|
|
1992
|
-
dataTest = _ref$dataTest === void 0 ? 'testInput' : _ref$dataTest,
|
|
1993
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["icon", "iconPosition", "error", "errorZoneClassName", "autoComplete", "className", "widget", "type", "onPressEnter", "isSubmitted", "loading", "required", "id", "placeholder", "value", "autofocus", "onChange", "validator", "errorMessage", "dataTest"]);
|
|
2124
|
+
_proto.download = function download(path) {
|
|
2125
|
+
try {
|
|
2126
|
+
var _this23 = this;
|
|
1994
2127
|
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2128
|
+
if (path.startsWith('/')) {
|
|
2129
|
+
path = path.substring(1);
|
|
2130
|
+
}
|
|
1998
2131
|
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2132
|
+
return Promise.resolve(_this23.rest.get(path));
|
|
2133
|
+
} catch (e) {
|
|
2134
|
+
return Promise.reject(e);
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2002
2137
|
|
|
2003
|
-
|
|
2004
|
-
|
|
2138
|
+
_proto.getTypeSchema = function getTypeSchema(path, name) {
|
|
2139
|
+
try {
|
|
2140
|
+
var _this25 = this;
|
|
2005
2141
|
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2142
|
+
var _temp3 = function _temp3() {
|
|
2143
|
+
return cacheSchemas[name];
|
|
2144
|
+
};
|
|
2009
2145
|
|
|
2146
|
+
var _temp4 = function () {
|
|
2147
|
+
if (!cacheSchemas[name]) {
|
|
2148
|
+
var url = _this25.getContainerFromPath(path); // todo: handle db case (only addable containers)
|
|
2010
2149
|
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2150
|
+
|
|
2151
|
+
return Promise.resolve(_this25.rest.get(url + "@types/" + name)).then(function (res) {
|
|
2152
|
+
return Promise.resolve(res.json()).then(function (_res$json) {
|
|
2153
|
+
cacheSchemas[name] = _res$json;
|
|
2154
|
+
});
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
}();
|
|
2158
|
+
|
|
2159
|
+
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
|
|
2160
|
+
} catch (e) {
|
|
2161
|
+
return Promise.reject(e);
|
|
2018
2162
|
}
|
|
2019
|
-
}
|
|
2020
|
-
var theError = state.hasError ? errorMessage || 'invalid field' : '';
|
|
2021
|
-
var statusClasses = state.hasError ? 'is-danger' : '';
|
|
2163
|
+
};
|
|
2022
2164
|
|
|
2023
|
-
|
|
2024
|
-
|
|
2165
|
+
_proto.getAddons = function getAddons(path) {
|
|
2166
|
+
try {
|
|
2167
|
+
var _this27 = this;
|
|
2168
|
+
|
|
2169
|
+
return Promise.resolve(_this27.rest.get(path + "@addons"));
|
|
2170
|
+
} catch (e) {
|
|
2171
|
+
return Promise.reject(e);
|
|
2172
|
+
}
|
|
2025
2173
|
};
|
|
2026
2174
|
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
id: id,
|
|
2039
|
-
ref: ref,
|
|
2040
|
-
type: type,
|
|
2041
|
-
value: state.value,
|
|
2042
|
-
placeholder: placeholder,
|
|
2043
|
-
autoComplete: autoComplete,
|
|
2044
|
-
disabled: loading || rest.disabled,
|
|
2045
|
-
required: required,
|
|
2046
|
-
"data-test": dataTest
|
|
2047
|
-
}, handlers, rest)), icon && icon), /*#__PURE__*/React.createElement(ErrorZone, {
|
|
2048
|
-
className: errorZoneClassName,
|
|
2049
|
-
id: uid
|
|
2050
|
-
}, state.hasError ? theError : ''));
|
|
2051
|
-
});
|
|
2052
|
-
Input.propTypes = {
|
|
2053
|
-
icon: PropTypes.node,
|
|
2054
|
-
iconPosition: PropTypes.arrayOf(PropTypes.oneOf(['has-icons-left', 'has-icons-right', ''])),
|
|
2055
|
-
error: PropTypes.string,
|
|
2056
|
-
errorZoneClassName: PropTypes.string,
|
|
2057
|
-
autoComplete: PropTypes.string,
|
|
2058
|
-
autoFocus: PropTypes.bool,
|
|
2059
|
-
className: PropTypes.string,
|
|
2060
|
-
disabled: PropTypes.bool,
|
|
2061
|
-
loading: PropTypes.bool,
|
|
2062
|
-
isSubmitted: PropTypes.bool,
|
|
2063
|
-
id: PropTypes.string,
|
|
2064
|
-
name: PropTypes.string,
|
|
2065
|
-
onChange: PropTypes.func,
|
|
2066
|
-
onKeyDown: PropTypes.func,
|
|
2067
|
-
onKeyUp: PropTypes.func,
|
|
2068
|
-
onPressEnter: PropTypes.func,
|
|
2069
|
-
placeholder: PropTypes.string,
|
|
2070
|
-
readOnly: PropTypes.bool,
|
|
2071
|
-
required: PropTypes.bool,
|
|
2072
|
-
type: PropTypes.string,
|
|
2073
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
|
|
2074
|
-
};
|
|
2175
|
+
_proto.installAddon = function installAddon(path, key) {
|
|
2176
|
+
try {
|
|
2177
|
+
var _this29 = this;
|
|
2178
|
+
|
|
2179
|
+
return Promise.resolve(_this29.rest.post(path + "@addons", {
|
|
2180
|
+
id: key
|
|
2181
|
+
}));
|
|
2182
|
+
} catch (e) {
|
|
2183
|
+
return Promise.reject(e);
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2075
2186
|
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
dataTest = _ref.dataTest,
|
|
2080
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["value", "dataTest"]);
|
|
2187
|
+
_proto.removeAddon = function removeAddon(path, key) {
|
|
2188
|
+
try {
|
|
2189
|
+
var _this31 = this;
|
|
2081
2190
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
icon: "fas fa-envelope"
|
|
2090
|
-
})
|
|
2091
|
-
}, rest));
|
|
2092
|
-
};
|
|
2191
|
+
return Promise.resolve(_this31.rest.delete(path + "@addons", {
|
|
2192
|
+
id: key
|
|
2193
|
+
}));
|
|
2194
|
+
} catch (e) {
|
|
2195
|
+
return Promise.reject(e);
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2093
2198
|
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
2098
|
-
_ref$onSubmit = _ref.onSubmit,
|
|
2099
|
-
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
2100
|
-
_ref$onReset = _ref.onReset,
|
|
2101
|
-
onReset = _ref$onReset === void 0 ? noop : _ref$onReset,
|
|
2102
|
-
_ref$autoComplete = _ref.autoComplete,
|
|
2103
|
-
autoComplete = _ref$autoComplete === void 0 ? 'off' : _ref$autoComplete,
|
|
2104
|
-
title = _ref.title,
|
|
2105
|
-
error = _ref.error,
|
|
2106
|
-
dataTest = _ref.dataTest,
|
|
2107
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "onSubmit", "onReset", "autoComplete", "title", "error", "dataTest"]);
|
|
2199
|
+
_proto.getGroups = function getGroups(path) {
|
|
2200
|
+
try {
|
|
2201
|
+
var _this33 = this;
|
|
2108
2202
|
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2203
|
+
var endpoint = _this33.getContainerFromPath(path) + "@groups";
|
|
2204
|
+
return Promise.resolve(_this33.rest.get(endpoint));
|
|
2205
|
+
} catch (e) {
|
|
2206
|
+
return Promise.reject(e);
|
|
2207
|
+
}
|
|
2112
2208
|
};
|
|
2113
2209
|
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
className: "level"
|
|
2118
|
-
}, /*#__PURE__*/React.createElement("h1", {
|
|
2119
|
-
className: "title is-size-4"
|
|
2120
|
-
}, title)), error && /*#__PURE__*/React.createElement("div", {
|
|
2121
|
-
className: "notification is-danger"
|
|
2122
|
-
}, error), /*#__PURE__*/React.createElement("form", _extends({
|
|
2123
|
-
onSubmit: handleSubmit,
|
|
2124
|
-
onReset: onReset,
|
|
2125
|
-
autoComplete: autoComplete,
|
|
2126
|
-
className: classnames(['form', className])
|
|
2127
|
-
}, rest), children));
|
|
2128
|
-
};
|
|
2129
|
-
Form.propTypes = {
|
|
2130
|
-
children: PropTypes.node.isRequired,
|
|
2131
|
-
className: PropTypes.string,
|
|
2132
|
-
onSubmit: PropTypes.func,
|
|
2133
|
-
onReset: PropTypes.func,
|
|
2134
|
-
autoComplete: PropTypes.string
|
|
2135
|
-
};
|
|
2210
|
+
_proto.getUsers = function getUsers(path) {
|
|
2211
|
+
try {
|
|
2212
|
+
var _this35 = this;
|
|
2136
2213
|
|
|
2137
|
-
var
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2214
|
+
var endpoint = _this35.getContainerFromPath(path) + "@users";
|
|
2215
|
+
return Promise.resolve(_this35.rest.get(endpoint));
|
|
2216
|
+
} catch (e) {
|
|
2217
|
+
return Promise.reject(e);
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2141
2220
|
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
}, rest));
|
|
2146
|
-
};
|
|
2221
|
+
_proto.getPrincipals = function getPrincipals(path) {
|
|
2222
|
+
try {
|
|
2223
|
+
var _this37 = this;
|
|
2147
2224
|
|
|
2148
|
-
var
|
|
2149
|
-
string: Input,
|
|
2150
|
-
password: PasswordInput,
|
|
2151
|
-
boolean: Checkbox,
|
|
2152
|
-
email: EmailInput
|
|
2153
|
-
};
|
|
2154
|
-
function FormBuilder(_ref) {
|
|
2155
|
-
var schema = _ref.schema,
|
|
2156
|
-
formData = _ref.formData,
|
|
2157
|
-
onSubmit = _ref.onSubmit,
|
|
2158
|
-
actionName = _ref.actionName,
|
|
2159
|
-
children = _ref.children,
|
|
2160
|
-
_ref$exclude = _ref.exclude,
|
|
2161
|
-
exclude = _ref$exclude === void 0 ? [] : _ref$exclude,
|
|
2162
|
-
_ref$remotes = _ref.remotes,
|
|
2163
|
-
remotes = _ref$remotes === void 0 ? [] : _ref$remotes,
|
|
2164
|
-
_ref$submitButton = _ref.submitButton,
|
|
2165
|
-
submitButton = _ref$submitButton === void 0 ? true : _ref$submitButton,
|
|
2166
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["schema", "formData", "title", "onSubmit", "actionName", "children", "exclude", "remotes", "submitButton"]);
|
|
2225
|
+
var groups = _this37.getGroups(path);
|
|
2167
2226
|
|
|
2168
|
-
|
|
2169
|
-
var properties = schema.properties,
|
|
2170
|
-
required = schema.required;
|
|
2171
|
-
var values = Object.assign({}, formData || {}); // build initial state
|
|
2227
|
+
var users = _this37.getUsers(path);
|
|
2172
2228
|
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
});
|
|
2177
|
-
fields.forEach(function (element) {
|
|
2178
|
-
initialState[element] = values[element] || undefined;
|
|
2179
|
-
}); // Register remotes
|
|
2229
|
+
return Promise.resolve(Promise.all([groups, users])).then(function (_ref3) {
|
|
2230
|
+
var gr = _ref3[0],
|
|
2231
|
+
usr = _ref3[1];
|
|
2180
2232
|
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
Object.keys(remotes).forEach(function (key) {
|
|
2189
|
-
if (JSON.stringify(ref.current[key]) !== JSON.stringify(remotes[key])) {
|
|
2190
|
-
ref.current[key] = remotes[key];
|
|
2191
|
-
}
|
|
2192
|
-
});
|
|
2193
|
-
}
|
|
2233
|
+
function _temp6(_gr$json) {
|
|
2234
|
+
function _temp5(_usr$json) {
|
|
2235
|
+
return {
|
|
2236
|
+
groups: _gr$json,
|
|
2237
|
+
users: _usr$json
|
|
2238
|
+
};
|
|
2239
|
+
}
|
|
2194
2240
|
|
|
2195
|
-
|
|
2241
|
+
var _usr$ok = usr.ok;
|
|
2242
|
+
return _usr$ok ? Promise.resolve(usr.json()).then(_temp5) : _temp5([]);
|
|
2243
|
+
}
|
|
2196
2244
|
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
}
|
|
2245
|
+
var _gr$ok = gr.ok;
|
|
2246
|
+
return _gr$ok ? Promise.resolve(gr.json()).then(_temp6) : _temp6([]);
|
|
2247
|
+
});
|
|
2248
|
+
} catch (e) {
|
|
2249
|
+
return Promise.reject(e);
|
|
2250
|
+
}
|
|
2201
2251
|
};
|
|
2202
2252
|
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
var props = {
|
|
2207
|
-
label: properties[field].title,
|
|
2208
|
-
value: initialState[field],
|
|
2209
|
-
onChange: onUpdate(field),
|
|
2210
|
-
placeholder: properties[field].title || '',
|
|
2211
|
-
id: generateUID(),
|
|
2212
|
-
dataTest: field + "TestInput"
|
|
2213
|
-
};
|
|
2253
|
+
_proto.getRoles = function getRoles(path) {
|
|
2254
|
+
try {
|
|
2255
|
+
var _this39 = this;
|
|
2214
2256
|
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2257
|
+
var endpoint = _this39.getContainerFromPath(path) + "@available-roles";
|
|
2258
|
+
return Promise.resolve(_this39.rest.get(endpoint));
|
|
2259
|
+
} catch (e) {
|
|
2260
|
+
return Promise.reject(e);
|
|
2218
2261
|
}
|
|
2219
|
-
|
|
2220
|
-
Tag.displayName = field + "Field";
|
|
2221
|
-
return /*#__PURE__*/React.createElement(Tag, props);
|
|
2222
2262
|
};
|
|
2223
2263
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
});
|
|
2228
|
-
});
|
|
2264
|
+
_proto.getAllPermissions = function getAllPermissions(path) {
|
|
2265
|
+
try {
|
|
2266
|
+
var _this41 = this;
|
|
2229
2267
|
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2268
|
+
// paths used to query the API always has to start without a "/"
|
|
2269
|
+
if (path.startsWith('/')) {
|
|
2270
|
+
path = path.slice(1);
|
|
2271
|
+
}
|
|
2233
2272
|
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
})
|
|
2241
|
-
|
|
2242
|
-
}
|
|
2273
|
+
return Promise.resolve(_this41.rest.get(path + '@all_permissions')).then(function (req) {
|
|
2274
|
+
return Promise.resolve(req.json()).then(function (resp) {
|
|
2275
|
+
var permissions = Array.from(new Set(extractPermissions(resp)));
|
|
2276
|
+
return permissions;
|
|
2277
|
+
});
|
|
2278
|
+
});
|
|
2279
|
+
} catch (e) {
|
|
2280
|
+
return Promise.reject(e);
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2243
2283
|
|
|
2244
|
-
|
|
2284
|
+
_proto.getTypes = function getTypes(path) {
|
|
2285
|
+
try {
|
|
2286
|
+
var _this43 = this;
|
|
2245
2287
|
|
|
2246
|
-
var
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
errorZoneClassName = _ref.errorZoneClassName,
|
|
2250
|
-
_ref$size = _ref.size,
|
|
2251
|
-
size = _ref$size === void 0 ? 1 : _ref$size,
|
|
2252
|
-
placeholder = _ref.placeholder,
|
|
2253
|
-
id = _ref.id,
|
|
2254
|
-
_ref$className = _ref.className,
|
|
2255
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
2256
|
-
_ref$classWrap = _ref.classWrap,
|
|
2257
|
-
classWrap = _ref$classWrap === void 0 ? '' : _ref$classWrap,
|
|
2258
|
-
_ref$multiple = _ref.multiple,
|
|
2259
|
-
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
2260
|
-
_ref$loading = _ref.loading,
|
|
2261
|
-
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
2262
|
-
onChange = _ref.onChange,
|
|
2263
|
-
_ref$appendDefault = _ref.appendDefault,
|
|
2264
|
-
appendDefault = _ref$appendDefault === void 0 ? false : _ref$appendDefault,
|
|
2265
|
-
_ref$style = _ref.style,
|
|
2266
|
-
style = _ref$style === void 0 ? {} : _ref$style,
|
|
2267
|
-
dataTest = _ref.dataTest,
|
|
2268
|
-
rest = _objectWithoutPropertiesLoose(_ref, ["options", "error", "errorZoneClassName", "size", "placeholder", "id", "className", "classWrap", "multiple", "loading", "isSubmitted", "onChange", "appendDefault", "style", "dataTest"]);
|
|
2288
|
+
var _temp10 = function _temp10() {
|
|
2289
|
+
return cacheTypes[path];
|
|
2290
|
+
};
|
|
2269
2291
|
|
|
2270
|
-
|
|
2271
|
-
|
|
2292
|
+
if (path.startsWith('/')) {
|
|
2293
|
+
path = path.slice(1);
|
|
2294
|
+
}
|
|
2272
2295
|
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2296
|
+
var _temp11 = function () {
|
|
2297
|
+
if (!cacheTypes[path]) {
|
|
2298
|
+
return Promise.resolve(_this43.rest.get(path + '@addable-types')).then(function (types) {
|
|
2299
|
+
var _temp7 = function () {
|
|
2300
|
+
if (types.status === 401 || types.status === 404) {
|
|
2301
|
+
cacheTypes[path] = [];
|
|
2302
|
+
} else {
|
|
2303
|
+
return Promise.resolve(types.json()).then(function (res) {
|
|
2304
|
+
cacheTypes[path] = res;
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
}();
|
|
2308
|
+
|
|
2309
|
+
if (_temp7 && _temp7.then) return _temp7.then(function () {});
|
|
2310
|
+
});
|
|
2278
2311
|
}
|
|
2279
|
-
});
|
|
2280
|
-
|
|
2281
|
-
|
|
2312
|
+
}();
|
|
2313
|
+
|
|
2314
|
+
return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(_temp10) : _temp10(_temp11));
|
|
2315
|
+
} catch (e) {
|
|
2316
|
+
return Promise.reject(e);
|
|
2282
2317
|
}
|
|
2283
2318
|
};
|
|
2284
2319
|
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2320
|
+
return GuillotinaClient;
|
|
2321
|
+
}();
|
|
2322
|
+
function getClient(url, container, auth) {
|
|
2323
|
+
return new GuillotinaClient(new RestClient(url, container, auth), container === '/');
|
|
2324
|
+
}
|
|
2325
|
+
var lightFileReader = function lightFileReader(file) {
|
|
2326
|
+
try {
|
|
2327
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
2328
|
+
var reader = new FileReader();
|
|
2329
|
+
reader.readAsArrayBuffer(file);
|
|
2330
|
+
|
|
2331
|
+
reader.onloadend = function (e) {
|
|
2332
|
+
var fileData = e.target.result;
|
|
2333
|
+
resolve({
|
|
2334
|
+
filename: file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''),
|
|
2335
|
+
data: fileData,
|
|
2336
|
+
'content-type': file.type
|
|
2337
|
+
});
|
|
2338
|
+
};
|
|
2339
|
+
}));
|
|
2340
|
+
} catch (e) {
|
|
2341
|
+
return Promise.reject(e);
|
|
2290
2342
|
}
|
|
2343
|
+
};
|
|
2291
2344
|
|
|
2292
|
-
|
|
2293
|
-
var
|
|
2294
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2295
|
-
className: "field"
|
|
2296
|
-
}, id && placeholder ? /*#__PURE__*/React.createElement("label", {
|
|
2297
|
-
className: "label",
|
|
2298
|
-
htmlFor: id
|
|
2299
|
-
}, placeholder) : null, /*#__PURE__*/React.createElement("div", {
|
|
2300
|
-
className: classnames(cssWrap)
|
|
2301
|
-
}, /*#__PURE__*/React.createElement("select", _extends({
|
|
2302
|
-
className: classnames(['', className]),
|
|
2303
|
-
size: size,
|
|
2304
|
-
multiple: multiple,
|
|
2305
|
-
disabled: loading || rest.disabled,
|
|
2306
|
-
onChange: onUpdate
|
|
2307
|
-
}, rest, {
|
|
2308
|
-
ref: ref,
|
|
2309
|
-
style: style,
|
|
2310
|
-
"data-test": dataTest
|
|
2311
|
-
}), options.map(function (_ref2, index) {
|
|
2312
|
-
var text = _ref2.text,
|
|
2313
|
-
rest = _objectWithoutPropertiesLoose(_ref2, ["text"]);
|
|
2345
|
+
var extractPermissions = function extractPermissions(data) {
|
|
2346
|
+
var result = [];
|
|
2314
2347
|
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
size: PropTypes.number,
|
|
2329
|
-
onChange: PropTypes.func,
|
|
2330
|
-
options: PropTypes.arrayOf(PropTypes.object),
|
|
2331
|
-
multiple: PropTypes.bool,
|
|
2332
|
-
className: PropTypes.string
|
|
2348
|
+
if (typeof data !== 'object') ; else if (!Array.isArray(data) && data.permission) {
|
|
2349
|
+
result = result.concat([data.permission]);
|
|
2350
|
+
} else if (!Array.isArray(data)) {
|
|
2351
|
+
Object.keys(data).map(function (key) {
|
|
2352
|
+
return result = result.concat(extractPermissions(data[key]));
|
|
2353
|
+
});
|
|
2354
|
+
} else if (Array.isArray(data)) {
|
|
2355
|
+
data.map(function (item) {
|
|
2356
|
+
return result = result.concat(extractPermissions(item));
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
return result;
|
|
2333
2361
|
};
|
|
2334
2362
|
|
|
2335
2363
|
function FileUpload(_ref) {
|
|
@@ -2792,7 +2820,7 @@ function Dropdown(_ref) {
|
|
|
2792
2820
|
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
2793
2821
|
React.createElement("a", {
|
|
2794
2822
|
className: disabled ? 'dropdown-item is-active' : 'dropdown-item',
|
|
2795
|
-
"data-test": "dropdownItemTest-" + option.
|
|
2823
|
+
"data-test": "dropdownItemTest-" + option.value.toLowerCase(),
|
|
2796
2824
|
key: option.text,
|
|
2797
2825
|
onClick: disabled ? undefined : function () {
|
|
2798
2826
|
return onChange(option.value);
|
|
@@ -2808,61 +2836,6 @@ function Dropdown(_ref) {
|
|
|
2808
2836
|
}))));
|
|
2809
2837
|
}
|
|
2810
2838
|
|
|
2811
|
-
var plain = ['string', 'number', 'boolean'];
|
|
2812
|
-
function RenderField(_ref) {
|
|
2813
|
-
var value = _ref.value,
|
|
2814
|
-
Widget = _ref.Widget;
|
|
2815
|
-
if (value === null || value === undefined) return '';
|
|
2816
|
-
|
|
2817
|
-
if (Widget) {
|
|
2818
|
-
return /*#__PURE__*/React.createElement(Widget, {
|
|
2819
|
-
value: value
|
|
2820
|
-
});
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2823
|
-
var type = typeof value;
|
|
2824
|
-
|
|
2825
|
-
if (plain.includes(type)) {
|
|
2826
|
-
return value;
|
|
2827
|
-
}
|
|
2828
|
-
|
|
2829
|
-
if (type === 'object') {
|
|
2830
|
-
if (Array.isArray(value)) {
|
|
2831
|
-
return value.map(function (item) {
|
|
2832
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2833
|
-
key: item
|
|
2834
|
-
}, /*#__PURE__*/React.createElement(RenderField, {
|
|
2835
|
-
value: item
|
|
2836
|
-
}));
|
|
2837
|
-
});
|
|
2838
|
-
}
|
|
2839
|
-
|
|
2840
|
-
return Object.keys(value).map(function (key) {
|
|
2841
|
-
return /*#__PURE__*/React.createElement(FieldValue, {
|
|
2842
|
-
field: key,
|
|
2843
|
-
value: value[key],
|
|
2844
|
-
key: key
|
|
2845
|
-
});
|
|
2846
|
-
});
|
|
2847
|
-
}
|
|
2848
|
-
|
|
2849
|
-
return /*#__PURE__*/React.createElement("p", null, "No render for ", JSON.stringify(value));
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
var FieldValue = function FieldValue(_ref2) {
|
|
2853
|
-
var field = _ref2.field,
|
|
2854
|
-
value = _ref2.value;
|
|
2855
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2856
|
-
className: "field"
|
|
2857
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
2858
|
-
className: "label"
|
|
2859
|
-
}, field), /*#__PURE__*/React.createElement("div", {
|
|
2860
|
-
className: "value"
|
|
2861
|
-
}, /*#__PURE__*/React.createElement(RenderField, {
|
|
2862
|
-
value: value
|
|
2863
|
-
})));
|
|
2864
|
-
};
|
|
2865
|
-
|
|
2866
2839
|
var formatDate = function formatDate(str) {
|
|
2867
2840
|
var d = new Date(str);
|
|
2868
2841
|
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
|
|
@@ -2892,86 +2865,6 @@ function getNewId(id) {
|
|
|
2892
2865
|
});
|
|
2893
2866
|
}
|
|
2894
2867
|
|
|
2895
|
-
var DownloadField = function DownloadField(_ref) {
|
|
2896
|
-
var value = _ref.value;
|
|
2897
|
-
var Ctx = useTraversal();
|
|
2898
|
-
var data = value.data,
|
|
2899
|
-
field = value.field;
|
|
2900
|
-
|
|
2901
|
-
var getField = function getField(downloadFile) {
|
|
2902
|
-
try {
|
|
2903
|
-
var endpoint = Ctx.path + "@download/" + field;
|
|
2904
|
-
return Promise.resolve(Ctx.client.download(endpoint)).then(function (res) {
|
|
2905
|
-
return Promise.resolve(res.blob()).then(function (text) {
|
|
2906
|
-
var blob = new Blob([text], {
|
|
2907
|
-
type: data.content_type
|
|
2908
|
-
});
|
|
2909
|
-
var url = window.URL.createObjectURL(blob); // Create blob link to download
|
|
2910
|
-
|
|
2911
|
-
var link = document.createElement('a');
|
|
2912
|
-
link.href = url;
|
|
2913
|
-
|
|
2914
|
-
if (downloadFile) {
|
|
2915
|
-
link.setAttribute('download', "" + data.filename);
|
|
2916
|
-
} else {
|
|
2917
|
-
link.setAttribute('target', "_blank");
|
|
2918
|
-
}
|
|
2919
|
-
|
|
2920
|
-
document.body.appendChild(link);
|
|
2921
|
-
link.click();
|
|
2922
|
-
setTimeout(function () {
|
|
2923
|
-
var _link$parentNode;
|
|
2924
|
-
|
|
2925
|
-
// For Firefox it is necessary to delay revoking the ObjectURL
|
|
2926
|
-
window.URL.revokeObjectURL(url);
|
|
2927
|
-
(_link$parentNode = link.parentNode) == null ? void 0 : _link$parentNode.removeChild(link);
|
|
2928
|
-
}, 100);
|
|
2929
|
-
});
|
|
2930
|
-
});
|
|
2931
|
-
} catch (e) {
|
|
2932
|
-
return Promise.reject(e);
|
|
2933
|
-
}
|
|
2934
|
-
};
|
|
2935
|
-
|
|
2936
|
-
return /*#__PURE__*/createElement("div", {
|
|
2937
|
-
className: "field"
|
|
2938
|
-
}, /*#__PURE__*/createElement("div", {
|
|
2939
|
-
className: "label"
|
|
2940
|
-
}, data.filename), /*#__PURE__*/createElement("div", {
|
|
2941
|
-
className: "columns"
|
|
2942
|
-
}, /*#__PURE__*/createElement("div", {
|
|
2943
|
-
className: "column"
|
|
2944
|
-
}, /*#__PURE__*/createElement("button", {
|
|
2945
|
-
className: "button is-small is-primary level-left",
|
|
2946
|
-
onClick: function onClick(event) {
|
|
2947
|
-
try {
|
|
2948
|
-
event.preventDefault();
|
|
2949
|
-
event.stopPropagation();
|
|
2950
|
-
getField(false);
|
|
2951
|
-
return Promise.resolve();
|
|
2952
|
-
} catch (e) {
|
|
2953
|
-
return Promise.reject(e);
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
|
-
}, "Open")), /*#__PURE__*/createElement("div", {
|
|
2957
|
-
className: "column"
|
|
2958
|
-
}, /*#__PURE__*/createElement("button", {
|
|
2959
|
-
className: "button is-small is-primary level-right",
|
|
2960
|
-
onClick: function onClick(event) {
|
|
2961
|
-
try {
|
|
2962
|
-
event.preventDefault();
|
|
2963
|
-
event.stopPropagation();
|
|
2964
|
-
getField(true);
|
|
2965
|
-
return Promise.resolve();
|
|
2966
|
-
} catch (e) {
|
|
2967
|
-
return Promise.reject(e);
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
}, "Download"))));
|
|
2971
|
-
};
|
|
2972
|
-
|
|
2973
|
-
var DEFAULT_VALUE_EDITABLE_FIELD = 'Click to edit';
|
|
2974
|
-
var DEFAULT_VALUE_NO_EDITABLE_FIELD = ' -- ';
|
|
2975
2868
|
function EditableField(_ref) {
|
|
2976
2869
|
var field = _ref.field,
|
|
2977
2870
|
value = _ref.value,
|
|
@@ -2995,36 +2888,17 @@ function EditableField(_ref) {
|
|
|
2995
2888
|
loading = _useCrudContext.loading,
|
|
2996
2889
|
Ctx = _useCrudContext.Ctx;
|
|
2997
2890
|
|
|
2891
|
+
var _useConfig = useConfig(),
|
|
2892
|
+
fieldHaveDeleteButton = _useConfig.fieldHaveDeleteButton;
|
|
2893
|
+
|
|
2998
2894
|
var EditComponent = Ctx.registry.get('components', 'EditComponent');
|
|
2895
|
+
var RenderFieldComponent = Ctx.registry.get('components', 'RenderFieldComponent');
|
|
2999
2896
|
useEffect(function () {
|
|
3000
2897
|
if (isEdit && ref.current) {
|
|
3001
2898
|
ref.current.focus();
|
|
3002
2899
|
}
|
|
3003
|
-
});
|
|
3004
|
-
var canModified = modifyContent && !get$1(schema, 'readonly', false);
|
|
3005
|
-
var haveDeleteBtn = (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
|
|
3006
|
-
|
|
3007
|
-
var getRenderProps = function getRenderProps() {
|
|
3008
|
-
var renderProps = {
|
|
3009
|
-
value: val != null ? val : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
3010
|
-
};
|
|
3011
|
-
|
|
3012
|
-
if (val && (schema == null ? void 0 : schema.widget) === 'file') {
|
|
3013
|
-
renderProps['value'] = {
|
|
3014
|
-
data: val,
|
|
3015
|
-
field: field
|
|
3016
|
-
};
|
|
3017
|
-
renderProps['Widget'] = DownloadField;
|
|
3018
|
-
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
3019
|
-
var _val$toString;
|
|
3020
|
-
|
|
3021
|
-
renderProps['value'] = (_val$toString = val == null ? void 0 : val.toString()) != null ? _val$toString : renderProps['value'];
|
|
3022
|
-
} else if (val && (schema == null ? void 0 : schema.type) === 'datetime') {
|
|
3023
|
-
renderProps['value'] = new Date(val).toLocaleString();
|
|
3024
|
-
}
|
|
3025
|
-
|
|
3026
|
-
return renderProps;
|
|
3027
|
-
};
|
|
2900
|
+
});
|
|
2901
|
+
var canModified = modifyContent && !get$1(schema, 'readonly', false);
|
|
3028
2902
|
|
|
3029
2903
|
var saveField = function saveField(ev) {
|
|
3030
2904
|
try {
|
|
@@ -3121,7 +2995,12 @@ function EditableField(_ref) {
|
|
|
3121
2995
|
setEdit(!!canModified);
|
|
3122
2996
|
},
|
|
3123
2997
|
"data-test": "editableFieldTest-" + field
|
|
3124
|
-
}, /*#__PURE__*/React.createElement(
|
|
2998
|
+
}, /*#__PURE__*/React.createElement(RenderFieldComponent, {
|
|
2999
|
+
schema: schema,
|
|
3000
|
+
field: field,
|
|
3001
|
+
val: val,
|
|
3002
|
+
modifyContent: modifyContent
|
|
3003
|
+
}), canModified && /*#__PURE__*/React.createElement(Icon, {
|
|
3125
3004
|
icon: "fas fa-edit"
|
|
3126
3005
|
})), isEdit && /*#__PURE__*/React.createElement("div", {
|
|
3127
3006
|
className: "field",
|
|
@@ -3151,7 +3030,7 @@ function EditableField(_ref) {
|
|
|
3151
3030
|
return setEdit(false);
|
|
3152
3031
|
},
|
|
3153
3032
|
dataTest: "editableFieldBtnCancelTest"
|
|
3154
|
-
}, "Cancel")), !required &&
|
|
3033
|
+
}, "Cancel")), !required && fieldHaveDeleteButton(schema) && /*#__PURE__*/React.createElement("div", {
|
|
3155
3034
|
className: "control"
|
|
3156
3035
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
3157
3036
|
className: "is-small is-danger",
|
|
@@ -3160,6 +3039,172 @@ function EditableField(_ref) {
|
|
|
3160
3039
|
}, "Delete")))));
|
|
3161
3040
|
}
|
|
3162
3041
|
|
|
3042
|
+
var DownloadField = function DownloadField(_ref) {
|
|
3043
|
+
var value = _ref.value;
|
|
3044
|
+
var Ctx = useTraversal();
|
|
3045
|
+
var data = value.data,
|
|
3046
|
+
field = value.field;
|
|
3047
|
+
|
|
3048
|
+
var getField = function getField(downloadFile) {
|
|
3049
|
+
try {
|
|
3050
|
+
var endpoint = Ctx.path + "@download/" + field;
|
|
3051
|
+
return Promise.resolve(Ctx.client.download(endpoint)).then(function (res) {
|
|
3052
|
+
return Promise.resolve(res.blob()).then(function (text) {
|
|
3053
|
+
var blob = new Blob([text], {
|
|
3054
|
+
type: data.content_type
|
|
3055
|
+
});
|
|
3056
|
+
var url = window.URL.createObjectURL(blob); // Create blob link to download
|
|
3057
|
+
|
|
3058
|
+
var link = document.createElement('a');
|
|
3059
|
+
link.href = url;
|
|
3060
|
+
|
|
3061
|
+
if (downloadFile) {
|
|
3062
|
+
link.setAttribute('download', "" + data.filename);
|
|
3063
|
+
} else {
|
|
3064
|
+
link.setAttribute('target', "_blank");
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
document.body.appendChild(link);
|
|
3068
|
+
link.click();
|
|
3069
|
+
setTimeout(function () {
|
|
3070
|
+
var _link$parentNode;
|
|
3071
|
+
|
|
3072
|
+
// For Firefox it is necessary to delay revoking the ObjectURL
|
|
3073
|
+
window.URL.revokeObjectURL(url);
|
|
3074
|
+
(_link$parentNode = link.parentNode) == null ? void 0 : _link$parentNode.removeChild(link);
|
|
3075
|
+
}, 100);
|
|
3076
|
+
});
|
|
3077
|
+
});
|
|
3078
|
+
} catch (e) {
|
|
3079
|
+
return Promise.reject(e);
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
|
|
3083
|
+
return /*#__PURE__*/createElement("div", {
|
|
3084
|
+
className: "field"
|
|
3085
|
+
}, /*#__PURE__*/createElement("div", {
|
|
3086
|
+
className: "label"
|
|
3087
|
+
}, data.filename), /*#__PURE__*/createElement("div", {
|
|
3088
|
+
className: "columns"
|
|
3089
|
+
}, /*#__PURE__*/createElement("div", {
|
|
3090
|
+
className: "column"
|
|
3091
|
+
}, /*#__PURE__*/createElement("button", {
|
|
3092
|
+
className: "button is-small is-primary level-left",
|
|
3093
|
+
onClick: function onClick(event) {
|
|
3094
|
+
try {
|
|
3095
|
+
event.preventDefault();
|
|
3096
|
+
event.stopPropagation();
|
|
3097
|
+
getField(false);
|
|
3098
|
+
return Promise.resolve();
|
|
3099
|
+
} catch (e) {
|
|
3100
|
+
return Promise.reject(e);
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
}, "Open")), /*#__PURE__*/createElement("div", {
|
|
3104
|
+
className: "column"
|
|
3105
|
+
}, /*#__PURE__*/createElement("button", {
|
|
3106
|
+
className: "button is-small is-primary level-right",
|
|
3107
|
+
onClick: function onClick(event) {
|
|
3108
|
+
try {
|
|
3109
|
+
event.preventDefault();
|
|
3110
|
+
event.stopPropagation();
|
|
3111
|
+
getField(true);
|
|
3112
|
+
return Promise.resolve();
|
|
3113
|
+
} catch (e) {
|
|
3114
|
+
return Promise.reject(e);
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
}, "Download"))));
|
|
3118
|
+
};
|
|
3119
|
+
|
|
3120
|
+
var plain = ['string', 'number', 'boolean'];
|
|
3121
|
+
function RenderField(_ref) {
|
|
3122
|
+
var value = _ref.value,
|
|
3123
|
+
Widget = _ref.Widget;
|
|
3124
|
+
if (value === null || value === undefined) return '';
|
|
3125
|
+
|
|
3126
|
+
if (Widget) {
|
|
3127
|
+
return /*#__PURE__*/React.createElement(Widget, {
|
|
3128
|
+
value: value
|
|
3129
|
+
});
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
var type = typeof value;
|
|
3133
|
+
|
|
3134
|
+
if (plain.includes(type)) {
|
|
3135
|
+
return value;
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
if (type === 'object') {
|
|
3139
|
+
if (Array.isArray(value)) {
|
|
3140
|
+
return value.map(function (item) {
|
|
3141
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3142
|
+
key: item
|
|
3143
|
+
}, /*#__PURE__*/React.createElement(RenderField, {
|
|
3144
|
+
value: item
|
|
3145
|
+
}));
|
|
3146
|
+
});
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
return Object.keys(value).map(function (key) {
|
|
3150
|
+
return /*#__PURE__*/React.createElement(FieldValue, {
|
|
3151
|
+
field: key,
|
|
3152
|
+
value: value[key],
|
|
3153
|
+
key: key
|
|
3154
|
+
});
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
return /*#__PURE__*/React.createElement("p", null, "No render for ", JSON.stringify(value));
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
var FieldValue = function FieldValue(_ref2) {
|
|
3162
|
+
var field = _ref2.field,
|
|
3163
|
+
value = _ref2.value;
|
|
3164
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3165
|
+
className: "field"
|
|
3166
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3167
|
+
className: "label"
|
|
3168
|
+
}, field), /*#__PURE__*/React.createElement("div", {
|
|
3169
|
+
className: "value"
|
|
3170
|
+
}, /*#__PURE__*/React.createElement(RenderField, {
|
|
3171
|
+
value: value
|
|
3172
|
+
})));
|
|
3173
|
+
};
|
|
3174
|
+
|
|
3175
|
+
var DEFAULT_VALUE_EDITABLE_FIELD = 'Click to edit';
|
|
3176
|
+
var DEFAULT_VALUE_NO_EDITABLE_FIELD = ' -- ';
|
|
3177
|
+
function RenderFieldComponent(_ref3) {
|
|
3178
|
+
var schema = _ref3.schema,
|
|
3179
|
+
field = _ref3.field,
|
|
3180
|
+
val = _ref3.val,
|
|
3181
|
+
modifyContent = _ref3.modifyContent;
|
|
3182
|
+
|
|
3183
|
+
var getRenderProps = function getRenderProps() {
|
|
3184
|
+
var renderProps = {
|
|
3185
|
+
value: val != null ? val : modifyContent ? DEFAULT_VALUE_EDITABLE_FIELD : DEFAULT_VALUE_NO_EDITABLE_FIELD
|
|
3186
|
+
};
|
|
3187
|
+
|
|
3188
|
+
if (val && (schema == null ? void 0 : schema.widget) === 'file') {
|
|
3189
|
+
renderProps['value'] = {
|
|
3190
|
+
data: val,
|
|
3191
|
+
field: field
|
|
3192
|
+
};
|
|
3193
|
+
renderProps['Widget'] = DownloadField;
|
|
3194
|
+
} else if ((schema == null ? void 0 : schema.type) === 'boolean') {
|
|
3195
|
+
var _val$toString;
|
|
3196
|
+
|
|
3197
|
+
renderProps['value'] = (_val$toString = val == null ? void 0 : val.toString()) != null ? _val$toString : renderProps['value'];
|
|
3198
|
+
} else if (val && (schema == null ? void 0 : schema.type) === 'datetime') {
|
|
3199
|
+
renderProps['value'] = new Date(val).toLocaleString();
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
return renderProps;
|
|
3203
|
+
};
|
|
3204
|
+
|
|
3205
|
+
return /*#__PURE__*/React.createElement(RenderField, getRenderProps());
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3163
3208
|
function IAttachment(_ref) {
|
|
3164
3209
|
var properties = _ref.properties,
|
|
3165
3210
|
values = _ref.values;
|
|
@@ -3723,7 +3768,9 @@ function ItemsActionsProvider(_ref) {
|
|
|
3723
3768
|
* and it select/unselect all items of the page.
|
|
3724
3769
|
*/
|
|
3725
3770
|
|
|
3726
|
-
function AllItemsCheckbox() {
|
|
3771
|
+
function AllItemsCheckbox(_ref2) {
|
|
3772
|
+
var dataTest = _ref2.dataTest;
|
|
3773
|
+
|
|
3727
3774
|
var _useContext = useContext(ItemsActionsCtx),
|
|
3728
3775
|
onSelectAllItems = _useContext.onSelectAllItems,
|
|
3729
3776
|
selected = _useContext.selected;
|
|
@@ -3734,15 +3781,17 @@ function AllItemsCheckbox() {
|
|
|
3734
3781
|
style: {
|
|
3735
3782
|
marginLeft: 2
|
|
3736
3783
|
},
|
|
3737
|
-
value: selected.all
|
|
3784
|
+
value: selected.all,
|
|
3785
|
+
dataTest: dataTest
|
|
3738
3786
|
});
|
|
3739
3787
|
}
|
|
3740
3788
|
/**
|
|
3741
3789
|
* Checkbox component to select ONE item.
|
|
3742
3790
|
*/
|
|
3743
3791
|
|
|
3744
|
-
function ItemCheckbox(
|
|
3745
|
-
var item =
|
|
3792
|
+
function ItemCheckbox(_ref3) {
|
|
3793
|
+
var item = _ref3.item,
|
|
3794
|
+
dataTest = _ref3.dataTest;
|
|
3746
3795
|
|
|
3747
3796
|
var _useContext2 = useContext(ItemsActionsCtx),
|
|
3748
3797
|
selected = _useContext2.selected,
|
|
@@ -3755,7 +3804,8 @@ function ItemCheckbox(_ref2) {
|
|
|
3755
3804
|
onChange: function onChange() {
|
|
3756
3805
|
return onSelectOneItem(item);
|
|
3757
3806
|
},
|
|
3758
|
-
value: value
|
|
3807
|
+
value: value,
|
|
3808
|
+
dataTest: dataTest
|
|
3759
3809
|
});
|
|
3760
3810
|
}
|
|
3761
3811
|
/**
|
|
@@ -3788,7 +3838,9 @@ function ItemsActionsDropdown() {
|
|
|
3788
3838
|
});
|
|
3789
3839
|
},
|
|
3790
3840
|
options: options
|
|
3791
|
-
}, "
|
|
3841
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3842
|
+
"data-test": "btnChooseActionTest"
|
|
3843
|
+
}, "Choose action..."));
|
|
3792
3844
|
}
|
|
3793
3845
|
|
|
3794
3846
|
/* eslint jsx-a11y/anchor-is-valid: "off" */
|
|
@@ -4039,7 +4091,8 @@ function RItem(_ref2) {
|
|
|
4039
4091
|
}, /*#__PURE__*/React.createElement("td", {
|
|
4040
4092
|
style: smallcss
|
|
4041
4093
|
}, /*#__PURE__*/React.createElement(ItemCheckbox, {
|
|
4042
|
-
item: item
|
|
4094
|
+
item: item,
|
|
4095
|
+
dataTest: "itemCheckboxRowTest"
|
|
4043
4096
|
})), columns.map(function (i) {
|
|
4044
4097
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
4045
4098
|
key: i.label
|
|
@@ -5837,7 +5890,7 @@ function CopyItems(props) {
|
|
|
5837
5890
|
items = _props$items === void 0 ? [] : _props$items;
|
|
5838
5891
|
return /*#__PURE__*/React.createElement(PathTree, {
|
|
5839
5892
|
title: "Copy to...",
|
|
5840
|
-
defaultPath:
|
|
5893
|
+
defaultPath: Ctx.client.clearContainerFromPath(Ctx.path),
|
|
5841
5894
|
onConfirm: copyItems,
|
|
5842
5895
|
onCancel: function onCancel() {
|
|
5843
5896
|
return Ctx.cancelAction();
|
|
@@ -5853,12 +5906,15 @@ function CopyItems(props) {
|
|
|
5853
5906
|
}, "New id for \"" + item.id + "\" copy"), /*#__PURE__*/React.createElement("input", {
|
|
5854
5907
|
type: "text",
|
|
5855
5908
|
className: "input",
|
|
5909
|
+
"data-test": "inputCopyIdTest-" + item['@name'],
|
|
5856
5910
|
defaultValue: getNewId(item.id)
|
|
5857
5911
|
}));
|
|
5858
5912
|
}), "\xA0");
|
|
5859
5913
|
}
|
|
5860
5914
|
|
|
5861
5915
|
function CopyItem(props) {
|
|
5916
|
+
var _item$parent$Name;
|
|
5917
|
+
|
|
5862
5918
|
var copyItem = function copyItem(path, form) {
|
|
5863
5919
|
try {
|
|
5864
5920
|
var input = form[1] || {};
|
|
@@ -5891,7 +5947,7 @@ function CopyItem(props) {
|
|
|
5891
5947
|
var item = props.item;
|
|
5892
5948
|
return /*#__PURE__*/React.createElement(PathTree, {
|
|
5893
5949
|
title: "Copy to...",
|
|
5894
|
-
defaultPath: "/" + item['parent']['@name'],
|
|
5950
|
+
defaultPath: "/" + ((_item$parent$Name = item['parent']['@name']) != null ? _item$parent$Name : '/'),
|
|
5895
5951
|
onConfirm: copyItem,
|
|
5896
5952
|
onCancel: function onCancel() {
|
|
5897
5953
|
return Ctx.cancelAction();
|
|
@@ -5904,6 +5960,7 @@ function CopyItem(props) {
|
|
|
5904
5960
|
}, "New id for \"" + item['@name'] + "\" copy"), /*#__PURE__*/React.createElement("input", {
|
|
5905
5961
|
type: "text",
|
|
5906
5962
|
className: "input",
|
|
5963
|
+
"data-test": "inputCopyIdTest-" + item['@name'],
|
|
5907
5964
|
defaultValue: getNewId(item['@name'])
|
|
5908
5965
|
})));
|
|
5909
5966
|
}
|
|
@@ -6399,7 +6456,7 @@ function GroupCtx() {
|
|
|
6399
6456
|
}, /*#__PURE__*/React.createElement("h3", {
|
|
6400
6457
|
className: "title is-size-6"
|
|
6401
6458
|
}, "Users"), /*#__PURE__*/React.createElement("p", null, "Add a User"), /*#__PURE__*/React.createElement(SearchInput, {
|
|
6402
|
-
path:
|
|
6459
|
+
path: Ctx.containerPath,
|
|
6403
6460
|
qs: [].concat(searchParsed, sortParsed),
|
|
6404
6461
|
traversal: Ctx,
|
|
6405
6462
|
onChange: addUser,
|
|
@@ -6532,7 +6589,8 @@ function Path() {
|
|
|
6532
6589
|
key: indx
|
|
6533
6590
|
}, /*#__PURE__*/React.createElement("a", {
|
|
6534
6591
|
href: path,
|
|
6535
|
-
onClick: onClick
|
|
6592
|
+
onClick: onClick,
|
|
6593
|
+
"data-test": "breadcrumbItemTest-home"
|
|
6536
6594
|
}, /*#__PURE__*/React.createElement("span", {
|
|
6537
6595
|
className: "icon"
|
|
6538
6596
|
}, /*#__PURE__*/React.createElement("i", {
|
|
@@ -6703,7 +6761,8 @@ var registry = {
|
|
|
6703
6761
|
properties: {},
|
|
6704
6762
|
components: {
|
|
6705
6763
|
Path: Path,
|
|
6706
|
-
EditComponent: EditComponent
|
|
6764
|
+
EditComponent: EditComponent,
|
|
6765
|
+
RenderFieldComponent: RenderFieldComponent
|
|
6707
6766
|
},
|
|
6708
6767
|
searchEngineQueryParamsFunction: {
|
|
6709
6768
|
PostreSQL: 'getQueryParamsPostresql',
|
|
@@ -7058,148 +7117,126 @@ var ERRORS = {
|
|
|
7058
7117
|
failed_to_fetch: 'Failed to fetch data: Backend not running?',
|
|
7059
7118
|
invalid_credentials: 'Failed! Invalid credentials'
|
|
7060
7119
|
};
|
|
7061
|
-
var
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7120
|
+
var initialState$4 = {
|
|
7121
|
+
username: '',
|
|
7122
|
+
password: '',
|
|
7123
|
+
loading: undefined,
|
|
7124
|
+
errors: undefined
|
|
7125
|
+
};
|
|
7126
|
+
var Login = function Login(_ref) {
|
|
7127
|
+
var currentSchema = _ref.currentSchema,
|
|
7128
|
+
setCurrentSchema = _ref.setCurrentSchema,
|
|
7129
|
+
schemas = _ref.schemas,
|
|
7130
|
+
auth = _ref.auth,
|
|
7131
|
+
onLogin = _ref.onLogin;
|
|
7132
|
+
|
|
7133
|
+
var _useSetState = useSetState(initialState$4),
|
|
7134
|
+
state = _useSetState[0],
|
|
7135
|
+
setState = _useSetState[1];
|
|
7076
7136
|
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7137
|
+
var inputRef = useRef(null);
|
|
7138
|
+
useEffect(function () {
|
|
7139
|
+
if (inputRef) {
|
|
7140
|
+
inputRef.current.focus();
|
|
7141
|
+
}
|
|
7142
|
+
}, [inputRef]);
|
|
7080
7143
|
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7144
|
+
var doLogin = function doLogin(ev) {
|
|
7145
|
+
try {
|
|
7146
|
+
ev.preventDefault();
|
|
7147
|
+
setState({
|
|
7148
|
+
loading: true,
|
|
7149
|
+
errors: undefined
|
|
7150
|
+
});
|
|
7151
|
+
var username = state.username,
|
|
7152
|
+
password = state.password;
|
|
7085
7153
|
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
schema = _this$state.schema;
|
|
7154
|
+
if (currentSchema !== '') {
|
|
7155
|
+
auth.setAccount(currentSchema);
|
|
7156
|
+
}
|
|
7090
7157
|
|
|
7091
|
-
|
|
7092
|
-
|
|
7158
|
+
return Promise.resolve(auth.login(username, password)).then(function (res) {
|
|
7159
|
+
if (!res) {
|
|
7160
|
+
setState({
|
|
7161
|
+
errors: auth.errors,
|
|
7162
|
+
loading: false
|
|
7163
|
+
});
|
|
7164
|
+
return;
|
|
7093
7165
|
}
|
|
7094
7166
|
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
});
|
|
7102
|
-
|
|
7103
|
-
return;
|
|
7104
|
-
}
|
|
7105
|
-
|
|
7106
|
-
if (_this.props.onLogin) {
|
|
7107
|
-
_this.props.onLogin();
|
|
7108
|
-
}
|
|
7109
|
-
});
|
|
7110
|
-
} catch (e) {
|
|
7111
|
-
return Promise.reject(e);
|
|
7112
|
-
}
|
|
7113
|
-
};
|
|
7114
|
-
|
|
7115
|
-
if (props.schemas) {
|
|
7116
|
-
_this.state.schema = props.schemas[0];
|
|
7167
|
+
if (onLogin) {
|
|
7168
|
+
onLogin();
|
|
7169
|
+
}
|
|
7170
|
+
});
|
|
7171
|
+
} catch (e) {
|
|
7172
|
+
return Promise.reject(e);
|
|
7117
7173
|
}
|
|
7118
|
-
|
|
7119
|
-
return _this;
|
|
7120
|
-
}
|
|
7121
|
-
|
|
7122
|
-
var _proto = Login.prototype;
|
|
7123
|
-
|
|
7124
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
7125
|
-
this.ref.current.focus();
|
|
7126
7174
|
};
|
|
7127
7175
|
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
},
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
},
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
type: "submit",
|
|
7193
|
-
"data-test": "btnLoginTest"
|
|
7194
|
-
}, "Login")), /*#__PURE__*/React.createElement("div", {
|
|
7195
|
-
className: "field"
|
|
7196
|
-
}, errors && /*#__PURE__*/React.createElement("p", {
|
|
7197
|
-
className: "has-text-danger"
|
|
7198
|
-
}, ERRORS[errors] || 'Generic error'))));
|
|
7199
|
-
};
|
|
7200
|
-
|
|
7201
|
-
return Login;
|
|
7202
|
-
}(Component);
|
|
7176
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("form", {
|
|
7177
|
+
className: "login__form",
|
|
7178
|
+
action: "",
|
|
7179
|
+
onSubmit: doLogin,
|
|
7180
|
+
"data-test": "formLoginTest"
|
|
7181
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
7182
|
+
className: "field"
|
|
7183
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
7184
|
+
className: "label"
|
|
7185
|
+
}, "Username:"), /*#__PURE__*/React.createElement("input", {
|
|
7186
|
+
type: "text",
|
|
7187
|
+
className: "input",
|
|
7188
|
+
placeholder: "Username",
|
|
7189
|
+
onChange: function onChange(e) {
|
|
7190
|
+
return setState({
|
|
7191
|
+
username: e.target.value
|
|
7192
|
+
});
|
|
7193
|
+
},
|
|
7194
|
+
value: state.username,
|
|
7195
|
+
ref: inputRef,
|
|
7196
|
+
"data-test": "inputUsernameLoginTest"
|
|
7197
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
7198
|
+
className: "field"
|
|
7199
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
7200
|
+
className: "label"
|
|
7201
|
+
}, "Password:"), /*#__PURE__*/React.createElement("input", {
|
|
7202
|
+
type: "password",
|
|
7203
|
+
className: "input",
|
|
7204
|
+
placeholder: "Password",
|
|
7205
|
+
onChange: function onChange(e) {
|
|
7206
|
+
return setState({
|
|
7207
|
+
password: e.target.value
|
|
7208
|
+
});
|
|
7209
|
+
},
|
|
7210
|
+
value: state.password,
|
|
7211
|
+
"data-test": "inputPasswordLoginTest"
|
|
7212
|
+
})), schemas && schemas.length > 1 && /*#__PURE__*/React.createElement("div", {
|
|
7213
|
+
className: "field"
|
|
7214
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
7215
|
+
className: "label"
|
|
7216
|
+
}, "Schema:"), /*#__PURE__*/React.createElement("div", {
|
|
7217
|
+
className: "select"
|
|
7218
|
+
}, /*#__PURE__*/React.createElement("select", {
|
|
7219
|
+
"data-test": "selectSchemaTest",
|
|
7220
|
+
onChange: function onChange(e) {
|
|
7221
|
+
return setCurrentSchema(e.target.value);
|
|
7222
|
+
}
|
|
7223
|
+
}, schemas.map(function (s) {
|
|
7224
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
7225
|
+
value: s,
|
|
7226
|
+
key: s
|
|
7227
|
+
}, s);
|
|
7228
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
7229
|
+
className: "field"
|
|
7230
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
7231
|
+
className: "button is-warning",
|
|
7232
|
+
type: "submit",
|
|
7233
|
+
"data-test": "btnLoginTest"
|
|
7234
|
+
}, "Login")), /*#__PURE__*/React.createElement("div", {
|
|
7235
|
+
className: "field"
|
|
7236
|
+
}, state.errors && /*#__PURE__*/React.createElement("p", {
|
|
7237
|
+
className: "has-text-danger"
|
|
7238
|
+
}, ERRORS[state.errors] || 'Generic error'))));
|
|
7239
|
+
};
|
|
7203
7240
|
|
|
7204
7241
|
function _catch$3(body, recover) {
|
|
7205
7242
|
try {
|
|
@@ -7573,5 +7610,5 @@ var Auth = /*#__PURE__*/function () {
|
|
|
7573
7610
|
return Auth;
|
|
7574
7611
|
}();
|
|
7575
7612
|
|
|
7576
|
-
export { ACTIONS_OBJECT, AddItem, AddPermission, AllItemsCheckbox, ApplicationCtx, Auth, AuthContext, BaseForm, BehaviorNotImplemented, BehaviorsView, Button, Checkbox, ClientContext, ClientProvider, Config, Confirm, ContainerCtx, ContextToolbar, CreateButton, CreateContainer, DEFAULT_VALUE_EDITABLE_FIELD, DEFAULT_VALUE_NO_EDITABLE_FIELD, DatabaseCtx, Delete, DownloadField, EditableField, EmailInput, FileUpload, Flash, FolderCtx, Form, FormBuilder, GroupCtx, GroupToolbar, GroupsCtx, Guillotina, GuillotinaClient, IAttachment, IDublinCore, IMultiAttachment, Icon, Input, InputList, Item, ItemCheckbox, ItemCtx, ItemModel, ItemTitle, ItemsActionsDropdown, ItemsActionsProvider, Layout, Link, Loading, Login, Modal, NotAllowed, Notification, Pagination, PanelActions, PanelAddons, PanelBehaviors, PanelItems, PanelNotImplemented, PanelPermissions, PanelProperties, PasswordInput, Path, PathTree, PermissionPrinperm, PermissionPrinrole, PermissionRoleperm, Permissions, PropertiesButtonView, PropertiesView, REGEX_EMAIL, REGEX_HEX_COLOR, REGEX_NUMBER, REGEX_URL, RItem, RemoveItems, RenderField, RequiredFieldsForm, RestClient, SearchInput, SearchLabels, Select, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, actions, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, get$1 as get, getClient,
|
|
7613
|
+
export { ACTIONS_OBJECT, AddItem, AddPermission, AllItemsCheckbox, ApplicationCtx, Auth, AuthContext, BaseForm, BehaviorNotImplemented, BehaviorsView, Button, Checkbox, ClientContext, ClientProvider, Config, Confirm, ContainerCtx, ContextToolbar, CreateButton, CreateContainer, DEFAULT_VALUE_EDITABLE_FIELD, DEFAULT_VALUE_NO_EDITABLE_FIELD, DatabaseCtx, Delete, DownloadField, EditableField, EmailInput, FileUpload, Flash, FolderCtx, Form, FormBuilder, GroupCtx, GroupToolbar, GroupsCtx, Guillotina, GuillotinaClient, IAttachment, IDublinCore, IMultiAttachment, Icon, Input, InputList, Item, ItemCheckbox, ItemCtx, ItemModel, ItemTitle, ItemsActionsDropdown, ItemsActionsProvider, Layout, Link, Loading, Login, Modal, NotAllowed, Notification, Pagination, PanelActions, PanelAddons, PanelBehaviors, PanelItems, PanelNotImplemented, PanelPermissions, PanelProperties, PasswordInput, Path, PathTree, PermissionPrinperm, PermissionPrinrole, PermissionRoleperm, Permissions, PropertiesButtonView, PropertiesView, REGEX_EMAIL, REGEX_HEX_COLOR, REGEX_NUMBER, REGEX_URL, RItem, RemoveItems, RenderField, RenderFieldComponent, RequiredFieldsForm, RestClient, SearchInput, SearchLabels, Select, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, actions, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, get$1 as get, getClient, getNewId, isEmail, isEmpty, isHexColor, isNumber, isURL, lightFileReader, maxLength, minLength, noop, notEmpty, parser, sleep, stringToSlug, toQueryString, useConfig, useCrudContext, useGuillotinaClient, useLocation, useRegistry, useRemoteField, useTraversal };
|
|
7577
7614
|
//# sourceMappingURL=react-gmi.esm.js.map
|