@kineticdata/react 6.1.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +110 -110
  2. package/assets/task/icons/defer.svg +12 -12
  3. package/assets/task/icons/drag-handle.svg +3 -3
  4. package/assets/task/icons/filter.svg +11 -11
  5. package/assets/task/icons/loop.svg +10 -10
  6. package/assets/task/icons/plus_small.svg +5 -5
  7. package/assets/task/icons/routine.svg +9 -9
  8. package/assets/task/icons/scale-minus.svg +11 -11
  9. package/assets/task/icons/scale-plus.svg +13 -13
  10. package/assets/task/icons/start.svg +11 -11
  11. package/assets/task/icons/stop.svg +8 -8
  12. package/lib/apis/core/activity.js +4 -4
  13. package/lib/apis/core/attributeDefinitions.js +55 -0
  14. package/lib/apis/core/attributeDefinitions.test.js +7 -4
  15. package/lib/apis/core/authentication.js +12 -1
  16. package/lib/apis/core/bridgeModels.test.js +46 -23
  17. package/lib/apis/core/bridgedresources.js +41 -41
  18. package/lib/apis/core/fileResources.js +2 -6
  19. package/lib/apis/core/forms.js +51 -2
  20. package/lib/apis/core/forms.test.js +32 -19
  21. package/lib/apis/core/kapps.js +49 -0
  22. package/lib/apis/core/kapps.test.js +16 -10
  23. package/lib/apis/core/notices.js +7 -0
  24. package/lib/apis/core/securityPolicyDefinitions.test.js +7 -4
  25. package/lib/apis/core/space.js +18 -0
  26. package/lib/apis/core/space.test.js +16 -10
  27. package/lib/apis/core/submissionActivities.js +38 -0
  28. package/lib/apis/core/submissions.js +62 -0
  29. package/lib/apis/core/translations.test.js +126 -55
  30. package/lib/apis/core/userPreferences.js +59 -0
  31. package/lib/apis/core/webApis.js +32 -2
  32. package/lib/apis/core/webhooks.test.js +7 -4
  33. package/lib/apis/http.js +22 -11
  34. package/lib/apis/index.js +24 -0
  35. package/lib/apis/integrator/index.js +95 -20
  36. package/lib/components/common/AttributeSelect.js +1 -0
  37. package/lib/components/common/BridgeSelect.js +1 -0
  38. package/lib/components/common/ConnectionSelect.js +2 -1
  39. package/lib/components/common/FormSelect.js +1 -0
  40. package/lib/components/common/NodeSelect.js +1 -0
  41. package/lib/components/common/StaticSelect.js +1 -0
  42. package/lib/components/common/TeamSelect.js +1 -0
  43. package/lib/components/common/ToastContainer.js +3 -3
  44. package/lib/components/common/Typeahead.js +3 -0
  45. package/lib/components/common/UserSelect.js +1 -0
  46. package/lib/components/common/authentication/AuthenticationContainer.js +121 -55
  47. package/lib/components/common/preferences/PreferencesProvider.js +461 -0
  48. package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +7 -7
  49. package/lib/components/core/field_definition/FieldDefinitionForm.js +3 -3
  50. package/lib/components/core/form/FormTable.js +0 -1
  51. package/lib/components/core/integration/IntegrationTable.js +3 -0
  52. package/lib/components/core/space/SpaceForm.js +14 -14
  53. package/lib/components/core/submission/SubmissionActivityForm.js +79 -0
  54. package/lib/components/core/submission/SubmissionForm.js +12 -2
  55. package/lib/components/core/translation/EntryTable.js +8 -7
  56. package/lib/components/core/user/UserForm.js +2 -0
  57. package/lib/components/core/user/UserTable.js +4 -4
  58. package/lib/components/form/Form.js +14 -3
  59. package/lib/components/form/FormState.js +1 -1
  60. package/lib/components/form/SimpleForm.js +2 -2
  61. package/lib/components/index.js +68 -0
  62. package/lib/components/integrator/connection/ConnectionForm.js +62 -18
  63. package/lib/components/integrator/connection/ConnectionTable.js +5 -3
  64. package/lib/components/integrator/connection/config_fields/http.js +19 -19
  65. package/lib/components/integrator/connection/config_fields/sql.js +123 -0
  66. package/lib/components/integrator/integrationTypes.js +27 -5
  67. package/lib/components/integrator/operation/OperationForm.js +24 -4
  68. package/lib/components/integrator/operation/OperationTable.js +3 -5
  69. package/lib/components/integrator/operation/config_fields/http.js +3 -2
  70. package/lib/components/integrator/operation/config_fields/sql.js +81 -0
  71. package/lib/components/system/SystemUserForm.js +2 -0
  72. package/lib/components/table/Table.js +75 -15
  73. package/lib/components/table/Table.redux.js +296 -72
  74. package/lib/components/table/defaults/FilterControl.js +24 -0
  75. package/lib/components/table/defaults/index.js +2 -0
  76. package/lib/components/table/tests/Table.test.js +22 -22
  77. package/lib/components/table/tests/components.js +9 -2
  78. package/lib/components/task/builder/Connector.js +51 -41
  79. package/lib/components/task/builder/Node.js +25 -38
  80. package/lib/components/task/builder/SvgCanvas.js +3 -17
  81. package/lib/components/task/builder/TreeBuilder.js +1 -2
  82. package/lib/components/task/builder/builder.redux.js +52 -32
  83. package/lib/components/task/builder/helpers.js +35 -5
  84. package/lib/components/task/common/UsageTable.js +8 -1
  85. package/lib/components/task/handlers/HandlerTable.js +9 -18
  86. package/lib/components/task/runs/RunTable.js +6 -10
  87. package/lib/components/task/workflows/LinkedWorkflowTable.js +14 -9
  88. package/lib/components/task/workflows/WorkflowTable.js +25 -24
  89. package/lib/helpers/index.js +18 -2
  90. package/lib/index.js +2 -1
  91. package/lib/saga.js +4 -4
  92. package/lib/store.js +2 -1
  93. package/package.json +5 -6
  94. package/proxyhelper.js +201 -201
  95. package/CHANGELOG.md +0 -116
@@ -0,0 +1,461 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.usePreferences = exports.setPreferenceJSON = exports.setPreferenceBool = exports.setPreference = exports.PreferencesProvider = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createClass"));
12
+ var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classPrivateFieldLooseBase"));
13
+ var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classPrivateFieldLooseKey"));
14
+ var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
15
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
16
+ var _reducer = require("../../../reducer");
17
+ var _saga = require("../../../saga");
18
+ var _effects = require("redux-saga/effects");
19
+ var _store = require("../../../store");
20
+ var _react = require("react");
21
+ var _immutable = require("immutable");
22
+ var _reactRedux = require("react-redux");
23
+ var _apis = require("../../../apis");
24
+ /**
25
+ * Preferences are stored as key-value pairs, where both the key and value are
26
+ * strings. These can be stored either in a browser session, or persisted in
27
+ * the database. We can also set temporary preferences which are only stored in
28
+ * redux, and thus will reset when the app is reloaded.
29
+ *
30
+ * This implementation expects that the key persisted in session or the db will
31
+ * consist of a prefix and key(suffix) value, where both contain lowercase
32
+ * alphanumeric characters and dashes. This implementation then combines the
33
+ * two parts with 4 consecutive dashes (----) to create the full key. The
34
+ * reason for having the two parts is to allow us to group preferences together
35
+ * by using the same prefix, which will make it easier to retrieve groups of
36
+ * preferences.
37
+ *
38
+ * The value must be saved as a string. In order to use other datatypes, you
39
+ * will need to convert the data when retrieving and updating preferences.
40
+ *
41
+ * Persisted preference examples:
42
+ * 'kapp-forms-table----filter-toggle': 'true'
43
+ * 'kapp-forms-table----initial-filters': '{"name": "A", "type": "Service"}'
44
+ * 'workflow-table----columns': '["name", "event", "updatedAt"]'
45
+ *
46
+ * Retrieved preference structure (as stored in redux):
47
+ * {
48
+ * kapp-forms-table: {
49
+ * 'filter-toggle': 'true',
50
+ * 'initial-filters': '{"name": "A", "type": "Service"}'
51
+ * },
52
+ * workflow-table: {
53
+ * 'columns': '["name", "event", "updatedAt"]'
54
+ * }
55
+ * }
56
+ */
57
+
58
+ (0, _reducer.regHandlers)({
59
+ INIT_PREFERENCES: function INIT_PREFERENCES(state) {
60
+ return state.set('preferences', (0, _immutable.Map)());
61
+ },
62
+ LOAD_PREFERENCES: function LOAD_PREFERENCES(state, _ref) {
63
+ var payload = _ref.payload;
64
+ return state.set('preferences', payload);
65
+ },
66
+ SET_PREFERENCE_PERSISTENT: function SET_PREFERENCE_PERSISTENT(state, _ref2) {
67
+ var _ref2$payload = _ref2.payload,
68
+ prefix = _ref2$payload.prefix,
69
+ key = _ref2$payload.key,
70
+ value = _ref2$payload.value;
71
+ return typeof value === 'function' ? state.updateIn(['preferences', prefix, key], value) : state.setIn(['preferences', prefix, key], value);
72
+ },
73
+ SET_PREFERENCE_SESSION: function SET_PREFERENCE_SESSION(state, _ref3) {
74
+ var _ref3$payload = _ref3.payload,
75
+ prefix = _ref3$payload.prefix,
76
+ key = _ref3$payload.key,
77
+ value = _ref3$payload.value;
78
+ return typeof value === 'function' ? state.updateIn(['preferences', prefix, key], value) : state.setIn(['preferences', prefix, key], value);
79
+ },
80
+ SET_PREFERENCE_TEMP: function SET_PREFERENCE_TEMP(state, _ref4) {
81
+ var _ref4$payload = _ref4.payload,
82
+ prefix = _ref4$payload.prefix,
83
+ key = _ref4$payload.key,
84
+ value = _ref4$payload.value;
85
+ return typeof value === 'function' ? state.updateIn(['preferences', prefix, key], value) : state.setIn(['preferences', prefix, key], value);
86
+ }
87
+ });
88
+ (0, _saga.regSaga)((0, _effects.takeLatest)('INIT_PREFERENCES', function (_ref5) {
89
+ var loggedIn = _ref5.payload;
90
+ return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
91
+ var preferences, persisted;
92
+ return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
93
+ while (1) switch (_context.prev = _context.next) {
94
+ case 0:
95
+ // Create preferences map
96
+ preferences = (0, _immutable.Map)();
97
+ if (!loggedIn) {
98
+ _context.next = 6;
99
+ break;
100
+ }
101
+ _context.next = 4;
102
+ return (0, _effects.call)(_apis.fetchUserPreferences);
103
+ case 4:
104
+ persisted = _context.sent;
105
+ if (persisted.userPreferences) {
106
+ // Combine both preference lists
107
+ preferences = preferences.merge(Object.fromEntries(persisted.userPreferences.map(function (_ref6) {
108
+ var key = _ref6.key,
109
+ value = _ref6.value;
110
+ return [key, value];
111
+ })));
112
+ }
113
+ case 6:
114
+ // Get preferences from session storage
115
+ preferences = preferences.merge((0, _objectSpread3["default"])({}, sessionStorage));
116
+ _context.next = 9;
117
+ return (0, _effects.put)((0, _store.action)('LOAD_PREFERENCES', preferences
118
+ // Split each key into a prefix and key(suffix), using an empty
119
+ // string if a prefix is missing
120
+ .mapKeys(function (key) {
121
+ var keyArray = key.split(/(.*)----/);
122
+ if (keyArray.length > 1) return keyArray.slice(1, 3);else if (keyArray.length === 1) return ['', keyArray[0]];else return ['', ''];
123
+ })
124
+ // Group the preferences by the prefix
125
+ .groupBy(function (val, key) {
126
+ return key[0];
127
+ })
128
+ // Update each group to change theirs keys to remove the prefix
129
+ .map(function (val) {
130
+ return val.mapKeys(function (key) {
131
+ return key[1];
132
+ });
133
+ })));
134
+ case 9:
135
+ case "end":
136
+ return _context.stop();
137
+ }
138
+ }, _callee);
139
+ })();
140
+ }));
141
+ (0, _saga.regSaga)((0, _effects.takeEvery)('SET_PREFERENCE_PERSISTENT', function (_ref7) {
142
+ var _ref7$payload = _ref7.payload,
143
+ prefix = _ref7$payload.prefix,
144
+ key = _ref7$payload.key;
145
+ return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2() {
146
+ var updatedValue;
147
+ return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
148
+ while (1) switch (_context2.prev = _context2.next) {
149
+ case 0:
150
+ _context2.next = 2;
151
+ return (0, _effects.select)(function (state) {
152
+ return state.getIn(['preferences', prefix, key]);
153
+ });
154
+ case 2:
155
+ updatedValue = _context2.sent;
156
+ if (!(typeof updatedValue === 'string')) {
157
+ _context2.next = 8;
158
+ break;
159
+ }
160
+ _context2.next = 6;
161
+ return (0, _effects.call)(_apis.upsertUserPreference, {
162
+ userPreference: {
163
+ key: "".concat(prefix, "----").concat(key),
164
+ value: updatedValue
165
+ }
166
+ });
167
+ case 6:
168
+ _context2.next = 9;
169
+ break;
170
+ case 8:
171
+ console.error("User preference values must be strings. The value for key '".concat(key, "' was of type '").concat(typeof updatedValue, "'."));
172
+ case 9:
173
+ case "end":
174
+ return _context2.stop();
175
+ }
176
+ }, _callee2);
177
+ })();
178
+ }));
179
+ (0, _saga.regSaga)((0, _effects.takeEvery)('SET_PREFERENCE_SESSION', function (_ref8) {
180
+ var _ref8$payload = _ref8.payload,
181
+ prefix = _ref8$payload.prefix,
182
+ key = _ref8$payload.key;
183
+ return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee3() {
184
+ var updatedValue;
185
+ return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
186
+ while (1) switch (_context3.prev = _context3.next) {
187
+ case 0:
188
+ _context3.next = 2;
189
+ return (0, _effects.select)(function (state) {
190
+ return state.getIn(['preferences', prefix, key]);
191
+ });
192
+ case 2:
193
+ updatedValue = _context3.sent;
194
+ if (!(typeof updatedValue === 'string')) {
195
+ _context3.next = 8;
196
+ break;
197
+ }
198
+ _context3.next = 6;
199
+ return (0, _effects.call)([sessionStorage, sessionStorage.setItem], "".concat(prefix, "----").concat(key), updatedValue);
200
+ case 6:
201
+ _context3.next = 9;
202
+ break;
203
+ case 8:
204
+ console.error("User preference values must be strings. The value for key '".concat(key, "' was of type '").concat(typeof updatedValue, "'."));
205
+ case 9:
206
+ case "end":
207
+ return _context3.stop();
208
+ }
209
+ }, _callee3);
210
+ })();
211
+ }));
212
+
213
+ /**
214
+ * Sets a preference value for a given prefix and key
215
+ * @param {String} prefix The prefix part of the preference key.
216
+ * @param {String} key The key(suffix) part of the preference key.
217
+ * @param {String|Function} value The value to store for the preference key, or
218
+ * an updater function that receives the previous value as a parameter.
219
+ * @param {('persist'|'session'|'temp')} duration How long to store the
220
+ * preference for. Defaults to `session`.
221
+ * - `persist` will store it forever.
222
+ * - `session` will store it for the current browser session.
223
+ * - `temp` will store it for the current instance of the webpage.
224
+ */
225
+ var setPreference = exports.setPreference = function setPreference(prefix, key, value, duration) {
226
+ return (0, _store.dispatch)(duration === 'persist' ? 'SET_PREFERENCE_PERSISTENT' : duration === 'temp' ? 'SET_PREFERENCE_TEMP' : 'SET_PREFERENCE_SESSION', {
227
+ prefix: prefix,
228
+ key: key,
229
+ value: value
230
+ });
231
+ };
232
+ var setPreferenceBool = exports.setPreferenceBool = function setPreferenceBool(prefix, key, value, duration) {
233
+ return setPreference(prefix, key, typeof value === 'function' ? function (stateValue) {
234
+ return toBooleanString(value(fromBooleanString(stateValue)));
235
+ } : toBooleanString(value), duration);
236
+ };
237
+ var setPreferenceJSON = exports.setPreferenceJSON = function setPreferenceJSON(prefix, key, value, duration) {
238
+ return setPreference(prefix, key, typeof value === 'function' ? function (stateValue) {
239
+ return toJSONString(value(fromJSONString(stateValue)));
240
+ } : toJSONString(value), duration);
241
+ };
242
+
243
+ /**
244
+ * A class for defining a Preference record with getters and setters for
245
+ * different data types.
246
+ * @class
247
+ * @property {string} prefix The prefix of the preference
248
+ * @property {string} key The key of the preference
249
+ * @property {string} value The value of the preference
250
+ */
251
+ var _prefix = /*#__PURE__*/(0, _classPrivateFieldLooseKey2["default"])("prefix");
252
+ var _key = /*#__PURE__*/(0, _classPrivateFieldLooseKey2["default"])("key");
253
+ var _value = /*#__PURE__*/(0, _classPrivateFieldLooseKey2["default"])("value");
254
+ var Preference = /*#__PURE__*/function () {
255
+ function Preference(prefix, key, value) {
256
+ (0, _classCallCheck2["default"])(this, Preference);
257
+ Object.defineProperty(this, _prefix, {
258
+ writable: true,
259
+ value: void 0
260
+ });
261
+ Object.defineProperty(this, _key, {
262
+ writable: true,
263
+ value: void 0
264
+ });
265
+ Object.defineProperty(this, _value, {
266
+ writable: true,
267
+ value: void 0
268
+ });
269
+ (0, _classPrivateFieldLooseBase2["default"])(this, _prefix)[_prefix] = prefix;
270
+ (0, _classPrivateFieldLooseBase2["default"])(this, _key)[_key] = key;
271
+ (0, _classPrivateFieldLooseBase2["default"])(this, _value)[_value] = value;
272
+ this.asBool = this.asBool.bind(this);
273
+ this.asJSON = this.asJSON.bind(this);
274
+ this.set = this.set.bind(this);
275
+ this.setBool = this.setBool.bind(this);
276
+ this.setJSON = this.setJSON.bind(this);
277
+ }
278
+
279
+ /**
280
+ * Get the preference prefix
281
+ * @returns {String}
282
+ */
283
+ (0, _createClass2["default"])(Preference, [{
284
+ key: "prefix",
285
+ get: function get() {
286
+ return (0, _classPrivateFieldLooseBase2["default"])(this, _prefix)[_prefix];
287
+ }
288
+ /**
289
+ * Get the preference key
290
+ * @returns {String}
291
+ */
292
+ }, {
293
+ key: "key",
294
+ get: function get() {
295
+ return (0, _classPrivateFieldLooseBase2["default"])(this, _key)[_key];
296
+ }
297
+ /**
298
+ * Get the preference value as a string
299
+ * @returns {String}
300
+ */
301
+ }, {
302
+ key: "value",
303
+ get: function get() {
304
+ return (0, _classPrivateFieldLooseBase2["default"])(this, _value)[_value];
305
+ }
306
+
307
+ /**
308
+ * Get the preference value as a boolean, defaulting to the provided
309
+ * `defaultValue` if there is no preference set.
310
+ * @param {boolean} [defaultValue]
311
+ * @returns {boolean}
312
+ */
313
+ }, {
314
+ key: "asBool",
315
+ value: function asBool(defaultValue) {
316
+ return fromBooleanString((0, _classPrivateFieldLooseBase2["default"])(this, _value)[_value], defaultValue);
317
+ }
318
+
319
+ /**
320
+ * Get the preference values as a JSON object, defaulting to the provided
321
+ * `defaultValue` if there is no preference set, or the set preference is
322
+ * not a valid JSON string
323
+ * @param {Object} [defaultValue]
324
+ * @returns {Object}
325
+ */
326
+ }, {
327
+ key: "asJSON",
328
+ value: function asJSON(defaultValue) {
329
+ return fromJSONString((0, _classPrivateFieldLooseBase2["default"])(this, _value)[_value], defaultValue);
330
+ }
331
+
332
+ /**
333
+ * Saves the provided value for this preference for the given duration
334
+ * @param {string} value The value to save
335
+ * @param {('persist'|'session'|'temp')} [duration] How long to save the
336
+ * preference for. Defaults to `session`.
337
+ * - `persist` will store it forever.
338
+ * - `session` will store it for the current browser session.
339
+ * - `temp` will store it for the current instance of the webpage.
340
+ */
341
+ }, {
342
+ key: "set",
343
+ value: function set(value, duration) {
344
+ setPreference((0, _classPrivateFieldLooseBase2["default"])(this, _prefix)[_prefix], (0, _classPrivateFieldLooseBase2["default"])(this, _key)[_key], value, duration);
345
+ }
346
+
347
+ /**
348
+ * Saves the provided boolean value for this preference for the given duration
349
+ * @param {boolean} value The boolean value to save
350
+ * @param {('persist'|'session'|'temp')} [duration] How long to save the
351
+ * preference for. Defaults to `session`.
352
+ * - `persist` will store it forever.
353
+ * - `session` will store it for the current browser session.
354
+ * - `temp` will store it for the current instance of the webpage.
355
+ */
356
+ }, {
357
+ key: "setBool",
358
+ value: function setBool(value, duration) {
359
+ setPreference((0, _classPrivateFieldLooseBase2["default"])(this, _prefix)[_prefix], (0, _classPrivateFieldLooseBase2["default"])(this, _key)[_key], toBooleanString(value), duration);
360
+ }
361
+
362
+ /**
363
+ * Saves the provided JSON value for this preference for the given duration
364
+ * @param {Object} value The JSON value to save
365
+ * @param {('persist'|'session'|'temp')} [duration] How long to save the
366
+ * preference for. Defaults to `session`.
367
+ * - `persist` will store it forever.
368
+ * - `session` will store it for the current browser session.
369
+ * - `temp` will store it for the current instance of the webpage.
370
+ */
371
+ }, {
372
+ key: "setJSON",
373
+ value: function setJSON(value, duration) {
374
+ setPreference((0, _classPrivateFieldLooseBase2["default"])(this, _prefix)[_prefix], (0, _classPrivateFieldLooseBase2["default"])(this, _key)[_key], toJSONString(value), duration);
375
+ }
376
+ }]);
377
+ return Preference;
378
+ }();
379
+ /**
380
+ * Hook for retrieving user preferences for a given prefix.
381
+ *
382
+ * @param {String} prefix A prefix that defines a group of preferences to allow
383
+ * for fetching multiple related preferences at once. Prefixes should be
384
+ * lowercase, alphanumeric and dashes only, and should not contain multiple
385
+ * consecutive dashes.
386
+ * @param {String[]} [keys] List of preference keys for the given prefix to
387
+ * return. Keys should be lowercase, alphanumeric and dashes only, and should
388
+ * not contain multiple consecutive dashes.
389
+ * @returns {Object.<string,Preference>} Returns a map of preferences for the
390
+ * provided `keys`. Each preference is a class with getters and setters for
391
+ * various data types.
392
+ */
393
+ var usePreferences = exports.usePreferences = function usePreferences() {
394
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
395
+ var keys = arguments.length > 1 ? arguments[1] : undefined;
396
+ var preferences = (0, _store.useSelector)(function (state) {
397
+ var prefixPrefs = state.getIn(['preferences', prefix], (0, _immutable.Map)());
398
+ return Array.isArray(keys) ? keys.reduce(function (prefs, key) {
399
+ return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, prefs), {}, (0, _defineProperty2["default"])({}, key, prefixPrefs.get(key, '')));
400
+ }, {}) : prefixPrefs.toJS();
401
+ }, _reactRedux.shallowEqual);
402
+ return (0, _react.useMemo)(function () {
403
+ return Object.fromEntries(Object.entries(preferences).map(function (_ref9) {
404
+ var _ref10 = (0, _slicedToArray2["default"])(_ref9, 2),
405
+ key = _ref10[0],
406
+ value = _ref10[1];
407
+ return [key, new Preference(prefix, key, value)];
408
+ }));
409
+ }, [preferences, prefix]);
410
+ };
411
+ var PreferencesProvider = exports.PreferencesProvider = function PreferencesProvider(_ref11) {
412
+ var loggedIn = _ref11.loggedIn,
413
+ children = _ref11.children;
414
+ (0, _react.useEffect)(function () {
415
+ (0, _store.dispatch)('INIT_PREFERENCES', loggedIn);
416
+ }, [loggedIn]);
417
+ return children;
418
+ };
419
+
420
+ /**
421
+ * @param {String} value JSON string to parse into a JS object.
422
+ * @param {Object} [defaultValue] Value to return if the `value` param isn't
423
+ * valid JSON.
424
+ * @returns {Object}
425
+ */
426
+ function fromJSONString(value, defaultValue) {
427
+ try {
428
+ return value && typeof value === 'string' ? JSON.parse(value) : defaultValue || null;
429
+ } catch (e) {
430
+ return defaultValue || null;
431
+ }
432
+ }
433
+
434
+ /**
435
+ * @param {Object} value JS object to convert into a JSON string.
436
+ * @returns {String}
437
+ */
438
+ function toJSONString(value) {
439
+ try {
440
+ return value && typeof value === 'object' ? JSON.stringify(value) : '';
441
+ } catch (e) {
442
+ return '';
443
+ }
444
+ }
445
+
446
+ /**
447
+ * @param {String} value Boolean string to parse into a boolean variable.
448
+ * @param {boolean} [defaultValue] Value to return if the `value` param is empty.
449
+ * @returns {boolean}
450
+ */
451
+ function fromBooleanString(value, defaultValue) {
452
+ return value && typeof value === 'string' ? (value === null || value === void 0 ? void 0 : value.toLowerCase()) === 'true' : typeof defaultValue === 'boolean' ? defaultValue : null;
453
+ }
454
+
455
+ /**
456
+ * @param {boolean} value Boolean variable to convert to a string.
457
+ * @returns {string}
458
+ */
459
+ function toBooleanString(value) {
460
+ return typeof value === 'boolean' ? value ? 'true' : 'false' : '';
461
+ }
@@ -78,9 +78,9 @@ var fields = function fields(_ref4) {
78
78
  };
79
79
  };
80
80
 
81
- /**
82
- * @component
83
- * A form for creating and updating Attribute Definitions within the Kinetic Platform
81
+ /**
82
+ * @component
83
+ * A form for creating and updating Attribute Definitions within the Kinetic Platform
84
84
  */
85
85
  var AttributeDefinitionForm = exports.AttributeDefinitionForm = (0, _Form.generateForm)({
86
86
  formOptions: ['kappSlug', 'attributeType', 'attributeName'],
@@ -100,10 +100,10 @@ AttributeDefinitionForm.propTypes = {
100
100
  attributeType: _propTypes["default"].oneOf(['spaceAttributeDefinitions', 'teamAttributeDefinitions', 'userAttributeDefinitions', 'userProfileAttributeDefinitions', 'categoryAttributeDefinitions', 'kappAttributeDefinitions', 'formAttributeDefinitions']).isRequired,
101
101
  /** The name of the attribute (assumes new if not null). */
102
102
  attributeName: _propTypes["default"].string,
103
- /**
104
- * If the attribute definition is for a Kapp
105
- * (Kapp Attributes, Form Attributes, Category Attributes, ...etc)
106
- * a Kapp Slug is required.
103
+ /**
104
+ * If the attribute definition is for a Kapp
105
+ * (Kapp Attributes, Form Attributes, Category Attributes, ...etc)
106
+ * a Kapp Slug is required.
107
107
  */
108
108
  kappSlug: _propTypes["default"].string
109
109
  };
@@ -112,9 +112,9 @@ var fields = function fields(_ref6) {
112
112
  };
113
113
  };
114
114
 
115
- /**
116
- * @component
117
- * A form for creating and updating Field Definitions within the Kinetic Platform
115
+ /**
116
+ * @component
117
+ * A form for creating and updating Field Definitions within the Kinetic Platform
118
118
  */
119
119
  var FieldDefinitionForm = exports.FieldDefinitionForm = (0, _Form.generateForm)({
120
120
  formOptions: ['kappSlug', 'name'],
@@ -114,7 +114,6 @@ var columns = [{
114
114
  value: 'type',
115
115
  title: 'Type',
116
116
  sortable: true,
117
- filter: 'startsWith',
118
117
  type: 'text',
119
118
  toggleable: true
120
119
  }, {
@@ -11,7 +11,9 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
11
11
  var _Table = require("../../table/Table");
12
12
  var _apis = require("../../../apis");
13
13
  var _http = require("../../../apis/http");
14
+ var _helpers = require("../../../helpers");
14
15
  var _excluded = ["integrations"];
16
+ var clientSide = (0, _helpers.defineFilter)(true).startsWith('name', 'name').end();
15
17
  var fetchIntegrationsWithSupportingData = function fetchIntegrationsWithSupportingData(options) {
16
18
  return (0, _apis.fetchIntegrations)(options).then(function (_ref) {
17
19
  var integrations = _ref.integrations,
@@ -57,6 +59,7 @@ var dataSource = function dataSource(_ref4) {
57
59
  var kappSlug = _ref4.kappSlug;
58
60
  return {
59
61
  fn: fetchIntegrationsWithSupportingData,
62
+ clientSide: clientSide,
60
63
  params: function params(paramData) {
61
64
  return [(0, _objectSpread2["default"])((0, _objectSpread2["default"])({
62
65
  include: 'details',
@@ -473,24 +473,24 @@ var SpaceForm = exports.SpaceForm = (0, _Form.generateForm)({
473
473
  });
474
474
  SpaceForm.displayName = 'SpaceForm';
475
475
  SpaceForm.propTypes = {
476
- /**
477
- * A unique identifier for this form.
478
- * If none is provided, one will be automatically generated and
479
- * the form will be automatically mounted.
480
- *
481
- * If a formKey is provided, the form won't render until the
482
- * `mountForm` action is dispatched.
476
+ /**
477
+ * A unique identifier for this form.
478
+ * If none is provided, one will be automatically generated and
479
+ * the form will be automatically mounted.
480
+ *
481
+ * If a formKey is provided, the form won't render until the
482
+ * `mountForm` action is dispatched.
483
483
  */
484
484
  formKey: _propTypes["default"].string,
485
- /**
486
- * A set of fields that should be added to the form
485
+ /**
486
+ * A set of fields that should be added to the form
487
487
  */
488
488
  addFields: _propTypes["default"].oneOfType([_propTypes["default"].array, _propTypes["default"].func]),
489
- /**
490
- * The layout of the form.
491
- * - @param {Node} form The react `Node` of the rendered form
492
- * - @param {Object} bindings all bindings fetched when the form was loaded
493
- * - @param {Boolean} initialized If the form has been initialized
489
+ /**
490
+ * The layout of the form.
491
+ * - @param {Node} form The react `Node` of the rendered form
492
+ * - @param {Object} bindings all bindings fetched when the form was loaded
493
+ * - @param {Boolean} initialized If the form has been initialized
494
494
  */
495
495
  children: _propTypes["default"].func
496
496
  };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SubmissionActivityForm = void 0;
7
+ var _apis = require("../../../apis");
8
+ var _Form = require("../../form/Form");
9
+ var _immutable = require("immutable");
10
+ var dataSources = function dataSources(_ref) {
11
+ var submissionId = _ref.submissionId,
12
+ activityId = _ref.activityId;
13
+ return {
14
+ activity: {
15
+ fn: _apis.fetchSubmissionActivity,
16
+ params: submissionId && activityId && [{
17
+ submissionId: submissionId,
18
+ activityId: activityId,
19
+ include: 'details'
20
+ }],
21
+ transform: function transform(result) {
22
+ return result.activity;
23
+ }
24
+ }
25
+ };
26
+ };
27
+ var handleSubmit = function handleSubmit(_ref2) {
28
+ var submissionId = _ref2.submissionId,
29
+ activityId = _ref2.activityId;
30
+ return function (values) {
31
+ return (activityId ? _apis.updateSubmissionActivity : _apis.createSubmissionActivity)({
32
+ submissionId: submissionId,
33
+ activityId: activityId,
34
+ activity: values.toJS()
35
+ }).then(function (_ref3) {
36
+ var kapp = _ref3.kapp,
37
+ error = _ref3.error;
38
+ if (error) {
39
+ throw error.statusCode === 400 && error.message || 'There was an error saving the activity';
40
+ }
41
+ return kapp;
42
+ });
43
+ };
44
+ };
45
+ var fields = function fields(_ref4) {
46
+ var submissionId = _ref4.submissionId,
47
+ activityId = _ref4.activityId;
48
+ return function (_ref5) {
49
+ var activity = _ref5.activity;
50
+ return submissionId && (!activityId || activity) && [{
51
+ name: 'type',
52
+ label: 'Type',
53
+ type: 'text',
54
+ initialValue: (0, _immutable.get)(activity, 'type')
55
+ }, {
56
+ name: 'label',
57
+ label: 'Label',
58
+ type: 'text',
59
+ initialValue: (0, _immutable.get)(activity, 'label')
60
+ }, {
61
+ name: 'description',
62
+ label: 'Description',
63
+ type: 'text',
64
+ initialValue: (0, _immutable.get)(activity, 'description')
65
+ }, {
66
+ name: 'data',
67
+ label: 'Data',
68
+ type: 'text',
69
+ initialValue: (0, _immutable.get)(activity, 'data')
70
+ }];
71
+ };
72
+ };
73
+ var SubmissionActivityForm = exports.SubmissionActivityForm = (0, _Form.generateForm)({
74
+ formOptions: ['submissionId', 'activityId'],
75
+ dataSources: dataSources,
76
+ fields: fields,
77
+ handleSubmit: handleSubmit
78
+ });
79
+ SubmissionActivityForm.displayName = 'SubmissionActivityForm';
@@ -20,12 +20,22 @@ var dataSources = function dataSources(_ref) {
20
20
  fn: _apis.fetchSubmission,
21
21
  params: submissionId && [{
22
22
  id: submissionId,
23
- include: 'details,values.raw,form,form.fields,form.fields.details,form.pages'
23
+ include: 'details,values.raw,form,form.fields,form.fields.details,form.pages,origin,origin.form,origin.form.kapp,parent,parent.form,parent.form.kapp'
24
24
  }],
25
25
  transform: function transform(result) {
26
26
  return result.submission;
27
27
  }
28
28
  },
29
+ activities: {
30
+ fn: _apis.fetchSubmissionActivities,
31
+ params: submissionId && [{
32
+ submissionId: submissionId,
33
+ include: 'details'
34
+ }],
35
+ transform: function transform(result) {
36
+ return result.activities;
37
+ }
38
+ },
29
39
  form: {
30
40
  fn: _apis.fetchForm,
31
41
  params: kappSlug && formSlug && [{
@@ -136,7 +146,7 @@ var getInitialValue = function getInitialValue(submission, element, type) {
136
146
  return attachment.set('documentId', (0, _immutable.getIn)(rawValue, [i, 'documentId'], null));
137
147
  });
138
148
  }
139
- return type === 'datetime' && value ? (0, _moment["default"])(value).format('yyyy-MM-DDThh:mm') : type === 'date' && value ? (0, _moment["default"])(value).format('yyyy-MM-DD') : value;
149
+ return type === 'datetime' && value ? (0, _moment["default"])(value).format('YYYY-MM-DDTHH:mm') : type === 'date' && value ? (0, _moment["default"])(value).format('YYYY-MM-DD') : value;
140
150
  };
141
151
  var serializer = function serializer(element) {
142
152
  return function (_ref7) {