@kineticdata/react 6.0.3 → 6.0.5

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.
@@ -43,88 +43,132 @@ var remember = function remember(state, treeKey) {
43
43
  (0, _store.regSaga)((0, _effects.takeEvery)('TREE_CONFIGURE', function (_ref) {
44
44
  var payload = _ref.payload;
45
45
  return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
46
- var _getPlatformItemSlugs, name, sourceGroup, sourceName, treeKey, webApiProps, _yield$all, _yield$all2, tree, categories, webApi, platformItem, result, _yield$call, workflow;
46
+ var name, sourceGroup, sourceName, treeKey, platformSourceName, webApiProps, workflowProps, _yield$all, _yield$all2, _yield$all2$, tree, treeError, _yield$all2$2, workflow, workflowError, categories, _yield$all2$3, webApi, webApiError, workflowObject, workflowObjectError, _yield$call, platformItem, platformItemError, _yield$call2, linkedWorkflow, linkedError, treeObject, loadError;
47
47
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
48
48
  while (1) switch (_context.prev = _context.next) {
49
49
  case 0:
50
50
  _context.prev = 0;
51
- name = payload.name, sourceGroup = payload.sourceGroup, sourceName = payload.sourceName, treeKey = payload.treeKey;
51
+ name = payload.name, sourceGroup = payload.sourceGroup, sourceName = payload.sourceName, treeKey = payload.treeKey, platformSourceName = payload.platformSourceName;
52
52
  webApiProps = getWebApiProps(payload);
53
- _context.next = 5;
54
- return (0, _effects.all)([(0, _effects.call)(_apis.fetchTree, {
53
+ workflowProps = getWorkflowProps(payload);
54
+ _context.next = 6;
55
+ return (0, _effects.all)([
56
+ // Fetch the tree if not a linked workflow
57
+ !workflowProps ? (0, _effects.call)(_apis.fetchTree, {
55
58
  name: name,
56
59
  sourceGroup: sourceGroup,
57
60
  sourceName: sourceName,
58
61
  include: 'bindings,categories,details,treeJson,inputs,outputs'
59
- }), (0, _effects.call)(_apis.fetchTaskCategories, {
62
+ }) : {},
63
+ // Fetch the workflow if it is a linked workflow
64
+ workflowProps ? (0, _effects.call)(_apis.fetchWorkflow, (0, _objectSpread2["default"])({}, workflowProps)) : {},
65
+ // Fetch task categories
66
+ (0, _effects.call)(_apis.fetchTaskCategories, {
60
67
  include: 'handlers.results,handlers.parameters,trees.parameters,trees.inputs,trees.outputs'
61
- }), webApiProps ? (0, _effects.call)(_apis.fetchWebApi, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, webApiProps), {}, {
68
+ }),
69
+ // Fetch the webAPI if applicable
70
+ webApiProps ? (0, _effects.call)(_apis.fetchWebApi, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, webApiProps), {}, {
62
71
  include: 'details,securityPolicies'
63
72
  })) : {}]);
64
- case 5:
73
+ case 6:
65
74
  _yield$all = _context.sent;
66
- _yield$all2 = (0, _slicedToArray2["default"])(_yield$all, 3);
67
- tree = _yield$all2[0].tree;
68
- categories = _yield$all2[1].categories;
69
- webApi = _yield$all2[2].webApi;
70
- platformItem = null;
71
- if (!tree.event) {
72
- _context.next = 21;
75
+ _yield$all2 = (0, _slicedToArray2["default"])(_yield$all, 4);
76
+ _yield$all2$ = _yield$all2[0];
77
+ tree = _yield$all2$.tree;
78
+ treeError = _yield$all2$.error;
79
+ _yield$all2$2 = _yield$all2[1];
80
+ workflow = _yield$all2$2.workflow;
81
+ workflowError = _yield$all2$2.error;
82
+ categories = _yield$all2[2].categories;
83
+ _yield$all2$3 = _yield$all2[3];
84
+ webApi = _yield$all2$3.webApi;
85
+ webApiError = _yield$all2$3.error;
86
+ workflowObject = workflow;
87
+ workflowObjectError = workflowError; // If a tree was fetched and the tree has platform item data, fetch the
88
+ // platform item and then retrieve the workflow
89
+ if (!(tree && tree.platformItemId && tree.platformItemType)) {
90
+ _context.next = 37;
73
91
  break;
74
92
  }
75
- _context.next = 14;
93
+ _context.next = 23;
76
94
  return (0, _effects.call)(_apis.fetchPlatformItem, {
77
95
  type: tree.platformItemType,
78
96
  id: tree.platformItemId
79
97
  });
80
- case 14:
81
- result = _context.sent;
82
- platformItem = result.platformItem;
83
- _context.next = 18;
98
+ case 23:
99
+ _yield$call = _context.sent;
100
+ platformItem = _yield$call.platformItem;
101
+ platformItemError = _yield$call.error;
102
+ if (!platformItem) {
103
+ _context.next = 36;
104
+ break;
105
+ }
106
+ _context.next = 29;
84
107
  return (0, _effects.call)(_apis.fetchWorkflow, (0, _objectSpread2["default"])({
85
108
  workflowId: sourceGroup
86
109
  }, getPlatformItemSlugs(platformItem)));
87
- case 18:
88
- _yield$call = _context.sent;
89
- workflow = _yield$call.workflow;
90
- // Add workflow filter from core to the tree to be used in the Settings > WorkflowForm
91
- tree['filter'] = workflow ? workflow.filter : '';
92
- case 21:
93
- _context.next = 23;
110
+ case 29:
111
+ _yield$call2 = _context.sent;
112
+ linkedWorkflow = _yield$call2.workflow;
113
+ linkedError = _yield$call2.error;
114
+ workflowObject = linkedWorkflow;
115
+ workflowObjectError = linkedError;
116
+ _context.next = 37;
117
+ break;
118
+ case 36:
119
+ // If platform item was not retrieved, show an error because we don't
120
+ // want to render a workflow using a tree route
121
+ workflowObjectError = platformItemError || 'Failed to load linked workflow.';
122
+ case 37:
123
+ // If workflow, set sourceName to platformSourceName since the value is
124
+ // needed when creating new runs
125
+ treeObject = workflowObject ? (0, _objectSpread2["default"])({
126
+ sourceName: platformSourceName
127
+ }, workflowObject) : tree;
128
+ loadError = workflowObjectError || treeError || webApiError;
129
+ _context.next = 41;
94
130
  return (0, _effects.put)((0, _store.action)('TREE_LOADED', {
95
131
  categories: categories,
96
- kappSlug: webApiProps && webApiProps.kappSlug || ((_getPlatformItemSlugs = getPlatformItemSlugs(platformItem)) === null || _getPlatformItemSlugs === void 0 ? void 0 : _getPlatformItemSlugs.kappSlug),
97
- platformItem: platformItem,
132
+ kappSlug: (webApiProps === null || webApiProps === void 0 ? void 0 : webApiProps.kappSlug) || (workflowProps === null || workflowProps === void 0 ? void 0 : workflowProps.kappSlug),
133
+ formSlug: workflowProps === null || workflowProps === void 0 ? void 0 : workflowProps.formSlug,
98
134
  treeKey: treeKey,
99
- tree: (0, _models.deserializeTree)(tree),
100
- webApi: webApiProps && (0, _models.deserializeWebApi)(webApi, webApiProps.kappSlug)
135
+ tree:
136
+ // Don't set the tree if it's for a webApi but the webApi errors
137
+ treeObject && (!webApiProps || webApi) ? (0, _models.deserializeTree)(treeObject) : null,
138
+ webApi: webApi ? (0, _models.deserializeWebApi)(webApi, webApiProps.kappSlug) : null,
139
+ error: loadError ? loadError.message || loadError : null
101
140
  }));
102
- case 23:
103
- _context.next = 28;
141
+ case 41:
142
+ _context.next = 46;
104
143
  break;
105
- case 25:
106
- _context.prev = 25;
144
+ case 43:
145
+ _context.prev = 43;
107
146
  _context.t0 = _context["catch"](0);
108
147
  console.error('Caught error loading tree', _context.t0);
109
- case 28:
148
+ case 46:
110
149
  case "end":
111
150
  return _context.stop();
112
151
  }
113
- }, _callee, null, [[0, 25]]);
152
+ }, _callee, null, [[0, 43]]);
114
153
  })();
115
154
  }));
116
155
  var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
117
- return platformItem !== null && platformItem !== void 0 && platformItem.kapp ? {
118
- formSlug: platformItem.slug,
119
- kappSlug: platformItem.kapp.slug
120
- } : platformItem !== null && platformItem !== void 0 && platformItem.space ? {
121
- kappSlug: platformItem.slug
122
- } : {};
156
+ return (
157
+ // If platform item has a kapp property, then it's a form object
158
+ platformItem !== null && platformItem !== void 0 && platformItem.kapp ? {
159
+ formSlug: platformItem.slug,
160
+ kappSlug: platformItem.kapp.slug
161
+ } :
162
+ // If platform item has a space property, than it's a kapp object
163
+ platformItem !== null && platformItem !== void 0 && platformItem.space ? {
164
+ kappSlug: platformItem.slug
165
+ } : {}
166
+ );
123
167
  };
124
168
  (0, _store.regSaga)((0, _effects.takeEvery)('TREE_SAVE', function (_ref2) {
125
169
  var payload = _ref2.payload;
126
170
  return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2() {
127
- var newName, onError, onSave, overwrite, treeKey, _yield$select, kappSlug, lastSave, lastWebApi, platformItem, tree, webApi, name, sourceGroup, sourceName, _yield, error1, newTree, newWorkflow, _yield2, error2, error;
171
+ var newName, onError, onSave, overwrite, treeKey, _yield$select, kappSlug, formSlug, lastSave, lastWebApi, tree, webApi, name, sourceGroup, sourceName, _yield, error1, newTree, newWorkflow, _yield2, error2, error;
128
172
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
129
173
  while (1) switch (_context2.prev = _context2.next) {
130
174
  case 0:
@@ -139,9 +183,9 @@ var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
139
183
  case 4:
140
184
  _yield$select = _context2.sent;
141
185
  kappSlug = _yield$select.kappSlug;
186
+ formSlug = _yield$select.formSlug;
142
187
  lastSave = _yield$select.lastSave;
143
188
  lastWebApi = _yield$select.lastWebApi;
144
- platformItem = _yield$select.platformItem;
145
189
  tree = _yield$select.tree;
146
190
  webApi = _yield$select.webApi;
147
191
  name = lastSave.name, sourceGroup = lastSave.sourceGroup, sourceName = lastSave.sourceName; // if a newName was passed we will be creating a new tree with the builder
@@ -149,18 +193,22 @@ var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
149
193
  // additionally, if the tree is a linked workflow then we call a core
150
194
  // endpoint to create the workflow
151
195
  _context2.next = 14;
152
- return newName ? tree.event ? (0, _effects.call)(_apis.createWorkflow, (0, _objectSpread2["default"])({
196
+ return newName ? tree.event ? (0, _effects.call)(_apis.createWorkflow, {
153
197
  workflow: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _models.serializeTree)(tree)), {}, {
154
198
  name: newName
155
- })
156
- }, getPlatformItemSlugs(platformItem))) : (0, _effects.call)(_apis.createTree, {
199
+ }),
200
+ kappSlug: kappSlug,
201
+ formSlug: formSlug
202
+ }) : (0, _effects.call)(_apis.createTree, {
157
203
  tree: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _models.serializeTree)(tree, true)), {}, {
158
204
  name: newName
159
205
  })
160
- }) : tree.event ? (0, _effects.call)(_apis.updateWorkflow, (0, _objectSpread2["default"])({
206
+ }) : tree.event ? (0, _effects.call)(_apis.updateWorkflow, {
161
207
  workflowId: sourceGroup,
162
- workflow: (0, _models.serializeTree)(tree, overwrite)
163
- }, getPlatformItemSlugs(platformItem))) : (0, _effects.call)(_apis.updateTree, {
208
+ workflow: (0, _models.serializeTree)(tree, overwrite),
209
+ kappSlug: kappSlug,
210
+ formSlug: formSlug
211
+ }) : (0, _effects.call)(_apis.updateTree, {
164
212
  name: name,
165
213
  sourceGroup: sourceGroup,
166
214
  sourceName: sourceName,
@@ -191,7 +239,11 @@ var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
191
239
  treeKey: treeKey,
192
240
  tree: newTree || newWorkflow,
193
241
  webApi: webApi,
194
- onSave: onSave
242
+ onSave: onSave,
243
+ scope: {
244
+ kappSlug: kappSlug,
245
+ formSlug: formSlug
246
+ }
195
247
  }));
196
248
  case 25:
197
249
  _context2.next = 30;
@@ -240,7 +292,8 @@ var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
240
292
  var _ref4$payload = _ref4.payload,
241
293
  onSave = _ref4$payload.onSave,
242
294
  previousTree = _ref4$payload.previousTree,
243
- treeKey = _ref4$payload.treeKey;
295
+ treeKey = _ref4$payload.treeKey,
296
+ scope = _ref4$payload.scope;
244
297
  return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee4() {
245
298
  var tree;
246
299
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee4$(_context4) {
@@ -258,7 +311,7 @@ var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
258
311
  case 4:
259
312
  tree = _context4.sent;
260
313
  _context4.next = 7;
261
- return (0, _effects.call)(onSave, tree, previousTree);
314
+ return (0, _effects.call)(onSave, tree, previousTree, scope);
262
315
  case 7:
263
316
  _context4.next = 12;
264
317
  break;
@@ -293,19 +346,20 @@ var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
293
346
  var _ref8$payload = _ref8.payload,
294
347
  categories = _ref8$payload.categories,
295
348
  kappSlug = _ref8$payload.kappSlug,
296
- platformItem = _ref8$payload.platformItem,
349
+ formSlug = _ref8$payload.formSlug,
297
350
  treeKey = _ref8$payload.treeKey,
298
351
  tree = _ref8$payload.tree,
299
- webApi = _ref8$payload.webApi;
352
+ webApi = _ref8$payload.webApi,
353
+ error = _ref8$payload.error;
300
354
  return state.mergeIn(['trees', treeKey], {
301
355
  kappSlug: kappSlug,
356
+ formSlug: formSlug,
302
357
  lastSave: tree,
303
358
  lastWebApi: webApi,
304
359
  loading: false,
305
- platformItem: platformItem,
306
360
  tasks: (0, _immutable.List)(categories).map(function (category) {
307
361
  return category.name === 'System Controls' ? (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, category), {}, {
308
- handlers: [].concat((0, _toConsumableArray2["default"])(category.handlers), [(0, _helpers.treeReturnTask)(tree)])
362
+ handlers: [].concat((0, _toConsumableArray2["default"])(category.handlers), [tree ? (0, _helpers.treeReturnTask)(tree) : null]).filter(Boolean)
309
363
  }) : category;
310
364
  }).flatMap(function (category) {
311
365
  return [].concat((0, _toConsumableArray2["default"])(category.handlers), (0, _toConsumableArray2["default"])(category.trees));
@@ -315,7 +369,8 @@ var getPlatformItemSlugs = function getPlatformItemSlugs(platformItem) {
315
369
  return reduction.set(task.definitionId, task);
316
370
  }, (0, _immutable.OrderedMap)()),
317
371
  tree: tree,
318
- webApi: webApi
372
+ webApi: webApi,
373
+ error: error
319
374
  });
320
375
  },
321
376
  TREE_SAVE: function TREE_SAVE(state, _ref9) {
@@ -530,4 +585,18 @@ var getWebApiProps = function getWebApiProps(_ref25) {
530
585
  };
531
586
  }
532
587
  return null;
588
+ };
589
+ var getWorkflowProps = function getWorkflowProps(_ref26) {
590
+ var type = _ref26.type,
591
+ sourceGroup = _ref26.sourceGroup,
592
+ kappSlug = _ref26.kappSlug,
593
+ formSlug = _ref26.formSlug;
594
+ if (type === 'workflow') {
595
+ return {
596
+ workflowId: sourceGroup,
597
+ kappSlug: kappSlug,
598
+ formSlug: formSlug
599
+ };
600
+ }
601
+ return null;
533
602
  };
@@ -28,7 +28,7 @@ var WebApi = exports.WebApi = (0, _immutable.Record)({
28
28
  updatedBy: null
29
29
  });
30
30
  var Tree = exports.Tree = (0, _immutable.Record)({
31
- bindings: (0, _immutable.OrderedMap)(),
31
+ bindings: {},
32
32
  categories: (0, _immutable.List)(),
33
33
  connectors: (0, _immutable.OrderedMap)(),
34
34
  definitionId: null,
@@ -90,11 +90,11 @@ var Connector = exports.Connector = (0, _immutable.Record)({
90
90
  var TreeBuilderState = exports.TreeBuilderState = (0, _immutable.Record)({
91
91
  categories: (0, _immutable.OrderedMap)(),
92
92
  error: null,
93
+ formSlug: null,
93
94
  kappSlug: null,
94
95
  lastSave: null,
95
96
  lastWebApi: null,
96
97
  loading: true,
97
- platformItem: null,
98
98
  redoStack: (0, _immutable.List)(),
99
99
  saving: false,
100
100
  tasks: (0, _immutable.OrderedMap)(),
@@ -182,6 +182,7 @@ var deserializeTree = exports.deserializeTree = function deserializeTree(_ref4)
182
182
  event = _ref4.event,
183
183
  filter = _ref4.filter,
184
184
  guid = _ref4.guid,
185
+ id = _ref4.id,
185
186
  inputs = _ref4.inputs,
186
187
  name = _ref4.name,
187
188
  notes = _ref4.notes,
@@ -206,7 +207,7 @@ var deserializeTree = exports.deserializeTree = function deserializeTree(_ref4)
206
207
  definitionId: definitionId,
207
208
  event: event,
208
209
  filter: filter,
209
- guid: guid,
210
+ guid: guid || id,
210
211
  inputs: (0, _immutable.List)(inputs).map(_immutable.Map),
211
212
  name: name,
212
213
  notes: notes,
@@ -25,7 +25,8 @@ var dataSources = function dataSources(_ref) {
25
25
  handlers: {
26
26
  fn: _apis.fetchHandlers,
27
27
  params: [{
28
- include: 'details'
28
+ include: 'details',
29
+ limit: 0
29
30
  }],
30
31
  transform: function transform(result) {
31
32
  return result.handlers;
@@ -35,7 +36,8 @@ var dataSources = function dataSources(_ref) {
35
36
  fn: _apis.fetchTrees,
36
37
  params: [{
37
38
  type: 'Global Routine',
38
- include: 'details'
39
+ include: 'details',
40
+ limit: 0
39
41
  }],
40
42
  transform: function transform(result) {
41
43
  return result.trees;
@@ -45,7 +47,8 @@ var dataSources = function dataSources(_ref) {
45
47
  fn: _apis.fetchPolicyRules,
46
48
  params: [{
47
49
  type: 'Category Access',
48
- include: 'details'
50
+ include: 'details',
51
+ limit: 0
49
52
  }],
50
53
  transform: function transform(result) {
51
54
  return result.policyRules;
@@ -148,7 +148,7 @@ var fields = function fields(_ref5) {
148
148
  label: 'Filter',
149
149
  type: 'code',
150
150
  language: 'js',
151
- initialValue: workflow ? workflow.get('filter') : '',
151
+ initialValue: workflow && workflow.get('filter') || '',
152
152
  required: false,
153
153
  // use event to show filter on linked workflows
154
154
  visible: workflow && !!workflow.get('event'),
@@ -157,7 +157,8 @@ var fields = function fields(_ref5) {
157
157
  kapp = _ref9.kapp,
158
158
  values = _ref9.values;
159
159
  var type = ['File Resource', 'Kapp', 'Form', 'Submission', 'Team', 'User'].find(function (scope) {
160
- return values.get('event').includes(scope);
160
+ var _values$get;
161
+ return (_values$get = values.get('event')) === null || _values$get === void 0 ? void 0 : _values$get.includes(scope);
161
162
  });
162
163
  return (0, _helpers.buildBindings)({
163
164
  space: space,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kineticdata/react",
3
- "version": "6.0.3",
3
+ "version": "6.0.5",
4
4
  "description": "A React library for the Kinetic Platform",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -19,7 +19,7 @@
19
19
  "prepublishOnly": "yarn build"
20
20
  },
21
21
  "dependencies": {
22
- "axios": "^1.6.0",
22
+ "axios": "^1.6.7",
23
23
  "classnames": "^2.2.6",
24
24
  "deepequal": "^0.0.1",
25
25
  "draft-js": "^0.11.7",
@@ -77,5 +77,5 @@
77
77
  "classNameTemplate": "{classname}",
78
78
  "titleTemplate": "{title}"
79
79
  },
80
- "gitHead": "ed053959bc74a8673ef9f09884f4a6eba83ec317"
80
+ "gitHead": "46bbd148a831a29c1a81ec3a081b3e60cdccb03e"
81
81
  }
@@ -1,162 +0,0 @@
1
- "use strict";
2
-
3
- var _Table = require("./Table.redux");
4
- var _immutable = require("immutable");
5
- describe('<Table /> redux', function () {
6
- describe('setup', function () {
7
- test('true dat', function () {
8
- expect(true).toBeTruthy();
9
- });
10
- });
11
- describe('client-side operations', function () {
12
- test('startsWith', function () {
13
- var op = _Table.operations.get('startsWith');
14
- expect(op('currentValue', 'cur')).toBeTruthy();
15
- });
16
- test('equals', function () {
17
- var op = _Table.operations.get('equals');
18
- expect(op('currentValue', 'cur')).toBeFalsy();
19
- expect(op('currentValue', 'currentValue')).toBeTruthy();
20
- expect(op('CURRENTVALUE', 'currentValue')).toBeTruthy();
21
- expect(op(1, 2)).toBeFalsy();
22
- expect(op(1, 1)).toBeTruthy();
23
- });
24
- test('lt', function () {
25
- var op = _Table.operations.get('lt');
26
- expect(op(10, 9)).toBeFalsy();
27
- expect(op(10, 11)).toBeTruthy();
28
- });
29
- test('lteq', function () {
30
- var op = _Table.operations.get('lteq');
31
- expect(op(10, 9)).toBeFalsy();
32
- expect(op(10, 10)).toBeTruthy();
33
- expect(op(10, 11)).toBeTruthy();
34
- });
35
- test('gt', function () {
36
- var op = _Table.operations.get('gt');
37
- expect(op(10, 9)).toBeTruthy();
38
- expect(op(10, 11)).toBeFalsy();
39
- });
40
- test('gteq', function () {
41
- var op = _Table.operations.get('gteq');
42
- expect(op(10, 9)).toBeTruthy();
43
- expect(op(10, 10)).toBeTruthy();
44
- expect(op(10, 11)).toBeFalsy();
45
- });
46
- test('between', function () {
47
- var op = _Table.operations.get('between');
48
- expect(op(10, (0, _immutable.List)([1, 20]))).toBeTruthy();
49
- expect(op(1, (0, _immutable.List)([1, 20]))).toBeTruthy();
50
- expect(op(20, (0, _immutable.List)([1, 20]))).toBeFalsy();
51
- expect(op(21, (0, _immutable.List)([1, 20]))).toBeFalsy();
52
- expect(op(0, (0, _immutable.List)([1, 20]))).toBeFalsy();
53
- });
54
- test('in', function () {
55
- var op = _Table.operations.get('in');
56
- expect(op('a', (0, _immutable.List)(['a', 'b', 'c']))).toBeTruthy();
57
- expect(op('A', (0, _immutable.List)(['a', 'b', 'c']))).toBeTruthy();
58
- expect(op('b', (0, _immutable.List)(['a', 'b', 'c']))).toBeTruthy();
59
- expect(op('c', (0, _immutable.List)(['a', 'b', 'c']))).toBeTruthy();
60
- expect(op('d', (0, _immutable.List)(['a', 'b', 'c']))).toBeFalsy();
61
- });
62
- });
63
- describe('#isValueEmpty', function () {
64
- test('is empty when undefined', function () {
65
- var a;
66
- expect((0, _Table.isValueEmpty)(a)).toBeTruthy();
67
- });
68
- test('is empty when empty string', function () {
69
- var a = '';
70
- expect((0, _Table.isValueEmpty)(a)).toBeTruthy();
71
- });
72
- test('is not empty when it is string', function () {
73
- var a = 'a';
74
- expect((0, _Table.isValueEmpty)(a)).toBeFalsy();
75
- });
76
- test('is empty when empty List', function () {
77
- var a = (0, _immutable.List)();
78
- expect((0, _Table.isValueEmpty)(a)).toBeTruthy();
79
- });
80
- test('is empty when List of empty strings', function () {
81
- var a = (0, _immutable.List)(['', '']);
82
- expect((0, _Table.isValueEmpty)(a)).toBeTruthy();
83
- });
84
- test('is not empty when List of items', function () {
85
- var a = (0, _immutable.List)(['a', 'b']);
86
- expect((0, _Table.isValueEmpty)(a)).toBeFalsy();
87
- a = (0, _immutable.List)([1, 2]);
88
- expect((0, _Table.isValueEmpty)(a)).toBeFalsy();
89
- });
90
- });
91
- describe('#clientSideGotoPage', function () {
92
- var tableData;
93
- beforeEach(function () {
94
- tableData = (0, _immutable.Map)({
95
- pageSize: 5,
96
- pageOffset: 0,
97
- data: (0, _immutable.Range)(1, 25).toList()
98
- });
99
- });
100
- describe('when pageNumber is invalid', function () {
101
- test('invalid type does not affect tableData', function () {
102
- expect((0, _Table.clientSideGotoPage)(tableData, 'foo')).toEqualImmutable(tableData);
103
- });
104
- test('invalid number does not affect tableData', function () {
105
- expect((0, _Table.clientSideGotoPage)(tableData, -1)).toEqualImmutable(tableData);
106
- });
107
- });
108
- test('pageNumber 1 offset is 0', function () {
109
- var newTableData = (0, _Table.clientSideGotoPage)(tableData.set('pageOffset', 10), 1);
110
- expect(newTableData.get('pageOffset')).toBe(0);
111
- });
112
- test('pageNumber 2 offset is 5', function () {
113
- var newTableData = (0, _Table.clientSideGotoPage)(tableData, 2);
114
- expect(newTableData.get('pageOffset')).toBe(5);
115
- });
116
- test('pageNumber 6 offset is unchanged (past the end of the data)', function () {
117
- var newTableData = (0, _Table.clientSideGotoPage)(tableData, 6);
118
- expect(newTableData.get('pageOffset')).toBe(0);
119
- });
120
- test('pageNumber 5 offset is 20 (last page)', function () {
121
- var newTableData = (0, _Table.clientSideGotoPage)(tableData, 5);
122
- expect(newTableData.get('pageOffset')).toBe(20);
123
- });
124
- });
125
- describe('#serverSideGotoPage', function () {
126
- var tableData;
127
- beforeEach(function () {
128
- tableData = (0, _immutable.Map)({
129
- loading: false,
130
- nextPageToken: 'abc',
131
- pageTokens: (0, _immutable.List)([2, 3, 4])
132
- });
133
- });
134
- describe('when pageNumber is invalid', function () {
135
- test('invalid type does not affect tableData', function () {
136
- expect((0, _Table.serverSideGotoPage)(tableData, 'foo')).toEqualImmutable(tableData);
137
- });
138
- test('invalid number does not affect tableData', function () {
139
- expect((0, _Table.serverSideGotoPage)(tableData, -1)).toEqualImmutable(tableData);
140
- });
141
- });
142
- test('when there are not enough pageTokens it does not affect tableData', function () {
143
- expect((0, _Table.serverSideGotoPage)(tableData, 5)).toEqualImmutable(tableData);
144
- });
145
- test('when going to the first page reset the page tokens', function () {
146
- var newTableData = (0, _Table.serverSideGotoPage)(tableData, 1);
147
- expect(newTableData.get('loading')).toBe(true);
148
- expect(newTableData.get('nextPageToken')).toBeNull();
149
- expect(newTableData.get('pageTokens').size).toBe(0);
150
- });
151
- test('when going to a valid page use its pageToken and adjust the page tokens', function () {
152
- var secondTableData = (0, _Table.serverSideGotoPage)(tableData, 2);
153
- var thirdTableData = (0, _Table.serverSideGotoPage)(tableData, 3);
154
- expect(secondTableData.get('loading')).toBe(true);
155
- expect(secondTableData.get('nextPageToken')).toBe(2);
156
- expect(secondTableData.get('pageTokens').size).toBe(0);
157
- expect(thirdTableData.get('loading')).toBe(true);
158
- expect(thirdTableData.get('nextPageToken')).toBe(3);
159
- expect(thirdTableData.get('pageTokens').size).toBe(1);
160
- });
161
- });
162
- });