@instructure/quiz-core 17.54.2-rc.7 → 17.55.0
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/es/banks/api/banks.js +6 -3
- package/es/banks/components/BanksList/presenter.js +17 -0
- package/es/banks/components/SharingModal/ShareList/index.js +23 -12
- package/es/banks/components/SharingModal/asyncSearch.js +17 -10
- package/es/banks/components/SharingModal/index.js +4 -1
- package/es/banks/components/SharingModal/presenter.js +211 -106
- package/lib/banks/api/banks.js +6 -3
- package/lib/banks/components/BanksList/presenter.js +17 -0
- package/lib/banks/components/SharingModal/ShareList/index.js +23 -12
- package/lib/banks/components/SharingModal/asyncSearch.js +17 -10
- package/lib/banks/components/SharingModal/index.js +5 -1
- package/lib/banks/components/SharingModal/presenter.js +214 -106
- package/package.json +10 -10
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
1
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
5
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
@@ -12,6 +14,7 @@ import React, { Component } from 'react';
|
|
|
12
14
|
import PropTypes from 'prop-types';
|
|
13
15
|
import { List, Map } from 'immutable';
|
|
14
16
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
17
|
+
import partial from 'lodash/partial';
|
|
15
18
|
import { Modal, ModalHeader, ModalBody, ModalFooter, CAN_EDIT, READ_ONLY, REMOVED_ACCESS } from '@instructure/quiz-common';
|
|
16
19
|
import { Heading } from '@instructure/ui-heading';
|
|
17
20
|
import { Button, CloseButton } from '@instructure/ui-buttons';
|
|
@@ -39,13 +42,13 @@ import t from '@instructure/quiz-i18n/es/format-message';
|
|
|
39
42
|
|
|
40
43
|
var noop = function noop() {};
|
|
41
44
|
|
|
42
|
-
var
|
|
45
|
+
var _ref6 = /*#__PURE__*/React.createElement(Grid.Col, {
|
|
43
46
|
width: "auto"
|
|
44
47
|
}, /*#__PURE__*/React.createElement(IconAdminLine, {
|
|
45
48
|
size: "medium"
|
|
46
49
|
}));
|
|
47
50
|
|
|
48
|
-
var
|
|
51
|
+
var _ref7 = /*#__PURE__*/React.createElement(Spinner, null);
|
|
49
52
|
|
|
50
53
|
export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
|
|
51
54
|
_inherits(SharingModalPresenter, _Component);
|
|
@@ -158,14 +161,7 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
158
161
|
_this.newEntitiesToSubmit().forEach(function (entity) {
|
|
159
162
|
_this.props.onShare(entity.toJS());
|
|
160
163
|
|
|
161
|
-
|
|
162
|
-
entityType: entity.get('entityType'),
|
|
163
|
-
entityId: entity.get('entityId'),
|
|
164
|
-
title: entity.get('title'),
|
|
165
|
-
bankId: _this.props.bank.id,
|
|
166
|
-
permission: entity.get('permission')
|
|
167
|
-
};
|
|
168
|
-
promises.push(_this.props.shareBank(sharedBank, _this.props.getUserInfo));
|
|
164
|
+
promises.push(_this.props.shareBank(_this.sharedBankForEntity(entity), _this.props.getUserInfo));
|
|
169
165
|
}); // call the update api if any shared bank permission was updated
|
|
170
166
|
|
|
171
167
|
|
|
@@ -206,34 +202,42 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
206
202
|
_this.props.updateSharedCount(_this.state.shares.size - _this.numEntitiesToRemove());
|
|
207
203
|
};
|
|
208
204
|
|
|
209
|
-
_this.
|
|
205
|
+
_this.originalPermissionForEntity = function (entity) {
|
|
210
206
|
var originalEntity = _this.props.sharedBanks.find(function (sb) {
|
|
211
|
-
return sb.get('id') == id;
|
|
207
|
+
return sb.get('id') == entity.get('id');
|
|
212
208
|
}) || Map();
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
return originalEntity.get('permission', CAN_EDIT);
|
|
210
|
+
};
|
|
215
211
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
212
|
+
_this.handleEntityRemove = function (entity, undoRemove) {
|
|
213
|
+
if (_this.props.subAccountBankSharingEnabled) {
|
|
214
|
+
_this.confirmPermissionChange(entity, REMOVED_ACCESS);
|
|
215
|
+
} else {
|
|
216
|
+
var permission = undoRemove ? _this.originalPermissionForEntity(entity) : REMOVED_ACCESS;
|
|
217
|
+
|
|
218
|
+
_this.setState(function (prevState) {
|
|
219
|
+
var sharesIndex = prevState.shares.findIndex(function (e) {
|
|
220
|
+
return e.get('id') == entity.get('id');
|
|
221
|
+
});
|
|
222
|
+
var newEntitiesIndex = prevState.newEntities.findIndex(function (e) {
|
|
223
|
+
return e.get('id') == entity.get('id');
|
|
224
|
+
});
|
|
225
|
+
var removedNewEntity = newEntitiesIndex > -1;
|
|
226
|
+
var newShares = removedNewEntity ? prevState.shares.delete(sharesIndex) : prevState.shares.setIn([sharesIndex, 'permission'], permission);
|
|
227
|
+
var newEntities = removedNewEntity ? prevState.newEntities.delete(newEntitiesIndex) : prevState.newEntities;
|
|
228
|
+
return {
|
|
229
|
+
shares: newShares,
|
|
230
|
+
newEntities: newEntities,
|
|
231
|
+
entitiesWithChangedPermission: Object.assign({}, prevState.entitiesWithChangedPermission, _defineProperty({}, entity.get('id'), permission))
|
|
232
|
+
};
|
|
233
|
+
}, _this.updateEntitiesCount);
|
|
234
|
+
}
|
|
232
235
|
};
|
|
233
236
|
|
|
234
237
|
_this.handleSearchPermissionChange = function (e, _ref3) {
|
|
235
238
|
var value = _ref3.value;
|
|
236
|
-
|
|
239
|
+
|
|
240
|
+
_this.setState({
|
|
237
241
|
searchPermission: value
|
|
238
242
|
});
|
|
239
243
|
};
|
|
@@ -259,23 +263,90 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
259
263
|
});
|
|
260
264
|
}));
|
|
261
265
|
|
|
262
|
-
_this.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
266
|
+
if (_this.props.subAccountBankSharingEnabled) {
|
|
267
|
+
newEntities.forEach(function (entity) {
|
|
268
|
+
_this.props.onShare(entity.toJS());
|
|
269
|
+
|
|
270
|
+
_this.props.shareBank(_this.sharedBankForEntity(entity), _this.props.getUserInfo);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
_this.setState({
|
|
274
|
+
searchSelection: []
|
|
275
|
+
});
|
|
276
|
+
} else {
|
|
277
|
+
_this.setState({
|
|
278
|
+
searchSelection: [],
|
|
279
|
+
shares: newEntities.concat(_this.state.shares),
|
|
280
|
+
newEntities: newEntities.concat(_this.state.newEntities)
|
|
281
|
+
}, _this.updateEntitiesCount);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
_this.updatePermission = /*#__PURE__*/function () {
|
|
286
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(entity, permission) {
|
|
287
|
+
var _this$props, updateSharedBankPermission, getBank, bank;
|
|
288
|
+
|
|
289
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
290
|
+
while (1) {
|
|
291
|
+
switch (_context.prev = _context.next) {
|
|
292
|
+
case 0:
|
|
293
|
+
_this$props = _this.props, updateSharedBankPermission = _this$props.updateSharedBankPermission, getBank = _this$props.getBank, bank = _this$props.bank;
|
|
294
|
+
_context.next = 3;
|
|
295
|
+
return updateSharedBankPermission(bank.id, entity.get('id'), permission);
|
|
296
|
+
|
|
297
|
+
case 3:
|
|
298
|
+
getBank(bank.id); // make sure the user still has access to the bank
|
|
299
|
+
|
|
300
|
+
case 4:
|
|
301
|
+
case "end":
|
|
302
|
+
return _context.stop();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}, _callee);
|
|
306
|
+
}));
|
|
307
|
+
|
|
308
|
+
return function (_x, _x2) {
|
|
309
|
+
return _ref4.apply(this, arguments);
|
|
310
|
+
};
|
|
311
|
+
}();
|
|
312
|
+
|
|
313
|
+
_this.translatedPermissionLevel = function (permission) {
|
|
314
|
+
var _CAN_EDIT$READ_ONLY$p;
|
|
315
|
+
|
|
316
|
+
return (_CAN_EDIT$READ_ONLY$p = {}, _defineProperty(_CAN_EDIT$READ_ONLY$p, CAN_EDIT, t('edit')), _defineProperty(_CAN_EDIT$READ_ONLY$p, READ_ONLY, t('view')), _CAN_EDIT$READ_ONLY$p)[permission];
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
_this.confirmPermissionChange = function (entity, permission) {
|
|
320
|
+
var confirmText = permission === REMOVED_ACCESS ? t('You are about to remove { accessLevel } access for { entityTitle } to this bank.', {
|
|
321
|
+
accessLevel: _this.translatedPermissionLevel(_this.originalPermissionForEntity(entity)),
|
|
322
|
+
entityTitle: entity.get('title')
|
|
323
|
+
}) : t('You are about to change access level for { entityTitle } from { originalAccessLevel } to { permission }.', {
|
|
324
|
+
entityTitle: entity.get('title'),
|
|
325
|
+
originalAccessLevel: _this.translatedPermissionLevel(_this.originalPermissionForEntity(entity)),
|
|
326
|
+
permission: _this.translatedPermissionLevel(permission)
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
_this.props.withConfirm(partial(_this.updatePermission, entity, permission), {
|
|
330
|
+
title: t('Change Permission'),
|
|
331
|
+
text: confirmText,
|
|
332
|
+
continueText: t('Confirm')
|
|
333
|
+
});
|
|
267
334
|
};
|
|
268
335
|
|
|
269
336
|
_this.handleEntityPermissionChange = function (entity, permission) {
|
|
270
|
-
_this.
|
|
271
|
-
|
|
272
|
-
|
|
337
|
+
if (_this.props.subAccountBankSharingEnabled) {
|
|
338
|
+
_this.confirmPermissionChange(entity, permission);
|
|
339
|
+
} else {
|
|
340
|
+
_this.setState(function (prevState) {
|
|
341
|
+
var index = prevState.shares.findIndex(function (share) {
|
|
342
|
+
return share.get('id') === entity.get('id');
|
|
343
|
+
});
|
|
344
|
+
return {
|
|
345
|
+
shares: prevState.shares.setIn([index, 'permission'], permission),
|
|
346
|
+
entitiesWithChangedPermission: Object.assign({}, prevState.entitiesWithChangedPermission, _defineProperty({}, entity.get('id'), permission))
|
|
347
|
+
};
|
|
273
348
|
});
|
|
274
|
-
|
|
275
|
-
shares: prevState.shares.setIn([index, 'permission'], permission),
|
|
276
|
-
entitiesWithChangedPermission: Object.assign({}, prevState.entitiesWithChangedPermission, _defineProperty({}, entity.get('id'), permission))
|
|
277
|
-
};
|
|
278
|
-
});
|
|
349
|
+
}
|
|
279
350
|
};
|
|
280
351
|
|
|
281
352
|
_this.toggleAccountShare = function (event) {
|
|
@@ -286,8 +357,8 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
286
357
|
});
|
|
287
358
|
};
|
|
288
359
|
|
|
289
|
-
_this.handleAccountPermissionChange = function (e,
|
|
290
|
-
var value =
|
|
360
|
+
_this.handleAccountPermissionChange = function (e, _ref5) {
|
|
361
|
+
var value = _ref5.value;
|
|
291
362
|
return _this.setState({
|
|
292
363
|
accountPermission: value
|
|
293
364
|
});
|
|
@@ -301,6 +372,45 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
301
372
|
_this.shareButtonRef = node;
|
|
302
373
|
};
|
|
303
374
|
|
|
375
|
+
_this.renderSearchSection = function (searchType) {
|
|
376
|
+
if (_this.props.bank.canEdit()) {
|
|
377
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, {
|
|
378
|
+
vAlign: "bottom",
|
|
379
|
+
colSpacing: "small"
|
|
380
|
+
}, /*#__PURE__*/React.createElement(Grid.Row, null, /*#__PURE__*/React.createElement(Grid.Col, null, /*#__PURE__*/React.createElement(AsyncSearch, {
|
|
381
|
+
getShareableCourses: _this.props.getShareableCourses,
|
|
382
|
+
getShareableUsers: _this.props.getShareableUsers,
|
|
383
|
+
improvedBankSharingEnabled: _this.props.improvedBankSharingEnabled,
|
|
384
|
+
minChars: _this.props.minChars,
|
|
385
|
+
onSelectionChange: _this.handleSearchSelectionChange,
|
|
386
|
+
searchType: searchType,
|
|
387
|
+
selectedOption: _this.state.searchSelection,
|
|
388
|
+
selectionFilter: _this.handleSearchFilter
|
|
389
|
+
})), _this.props.improvedBankSharingEnabled && /*#__PURE__*/React.createElement(Grid.Col, {
|
|
390
|
+
width: "auto"
|
|
391
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect, {
|
|
392
|
+
onChange: _this.handleSearchPermissionChange,
|
|
393
|
+
value: _this.state.searchPermission,
|
|
394
|
+
renderLabel: t('Access')
|
|
395
|
+
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
|
396
|
+
id: "sharing-modal-search-section-select-option-can-view",
|
|
397
|
+
value: READ_ONLY
|
|
398
|
+
}, t('Can view')), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
|
399
|
+
id: "sharing-modal-search-section-select-option-can-edit",
|
|
400
|
+
value: CAN_EDIT
|
|
401
|
+
}, t('Can edit')))), /*#__PURE__*/React.createElement(Grid.Col, {
|
|
402
|
+
width: "auto"
|
|
403
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
404
|
+
"data-automation": "sdk-shared-bank-add-user-button",
|
|
405
|
+
ref: _this.handleShareButtonRef,
|
|
406
|
+
onClick: _this.handleShare,
|
|
407
|
+
variant: _this.state.searchSelection.length ? 'success' : 'default'
|
|
408
|
+
}, t('Add'))))), /*#__PURE__*/React.createElement("div", {
|
|
409
|
+
className: styles.separator
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
304
414
|
return _this;
|
|
305
415
|
}
|
|
306
416
|
|
|
@@ -323,15 +433,26 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
323
433
|
// HELPERS
|
|
324
434
|
// =============
|
|
325
435
|
|
|
436
|
+
}, {
|
|
437
|
+
key: "sharedBankForEntity",
|
|
438
|
+
value: function sharedBankForEntity(entity) {
|
|
439
|
+
return {
|
|
440
|
+
entityType: entity.get('entityType'),
|
|
441
|
+
entityId: entity.get('entityId'),
|
|
442
|
+
title: entity.get('title'),
|
|
443
|
+
bankId: this.props.bank.id,
|
|
444
|
+
permission: entity.get('permission')
|
|
445
|
+
};
|
|
446
|
+
}
|
|
326
447
|
}, {
|
|
327
448
|
key: "renderAccountPermissions",
|
|
328
449
|
// =============
|
|
329
450
|
// RENDERING
|
|
330
451
|
// =============
|
|
331
452
|
value: function renderAccountPermissions() {
|
|
332
|
-
var _this$
|
|
333
|
-
currentUser = _this$
|
|
334
|
-
improvedBankSharingEnabled = _this$
|
|
453
|
+
var _this$props2 = this.props,
|
|
454
|
+
currentUser = _this$props2.currentUser,
|
|
455
|
+
improvedBankSharingEnabled = _this$props2.improvedBankSharingEnabled;
|
|
335
456
|
var roles = currentUser && currentUser.enrollment_names || [];
|
|
336
457
|
|
|
337
458
|
if (improvedBankSharingEnabled && roles.includes('admin')) {
|
|
@@ -340,7 +461,7 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
340
461
|
margin: "0 0 medium 0"
|
|
341
462
|
}, /*#__PURE__*/React.createElement(Grid, {
|
|
342
463
|
colSpacing: "small"
|
|
343
|
-
}, /*#__PURE__*/React.createElement(Grid.Row, null,
|
|
464
|
+
}, /*#__PURE__*/React.createElement(Grid.Row, null, _ref6, /*#__PURE__*/React.createElement(Grid.Col, null, /*#__PURE__*/React.createElement(View, {
|
|
344
465
|
as: "div",
|
|
345
466
|
padding: "0 0 x-small 0"
|
|
346
467
|
}, currentUser && currentUser.account_name || t('Account')), /*#__PURE__*/React.createElement(Checkbox, {
|
|
@@ -364,59 +485,54 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
364
485
|
}, t('Can edit')))))));
|
|
365
486
|
}
|
|
366
487
|
}
|
|
367
|
-
}, {
|
|
368
|
-
key: "renderSearchSection",
|
|
369
|
-
value: function renderSearchSection() {
|
|
370
|
-
return /*#__PURE__*/React.createElement(Grid, {
|
|
371
|
-
vAlign: "bottom",
|
|
372
|
-
colSpacing: "small"
|
|
373
|
-
}, /*#__PURE__*/React.createElement(Grid.Row, null, /*#__PURE__*/React.createElement(Grid.Col, null, /*#__PURE__*/React.createElement(AsyncSearch, {
|
|
374
|
-
getShareableCourses: this.props.getShareableCourses,
|
|
375
|
-
getShareableUsers: this.props.getShareableUsers,
|
|
376
|
-
improvedBankSharingEnabled: this.props.improvedBankSharingEnabled,
|
|
377
|
-
minChars: this.props.minChars,
|
|
378
|
-
onSelectionChange: this.handleSearchSelectionChange,
|
|
379
|
-
selectedOption: this.state.searchSelection,
|
|
380
|
-
selectionFilter: this.handleSearchFilter
|
|
381
|
-
})), this.props.improvedBankSharingEnabled && /*#__PURE__*/React.createElement(Grid.Col, {
|
|
382
|
-
width: "auto"
|
|
383
|
-
}, /*#__PURE__*/React.createElement(SimpleSelect, {
|
|
384
|
-
onChange: this.handleSearchPermissionChange,
|
|
385
|
-
value: this.state.searchPermission,
|
|
386
|
-
renderLabel: t('Access')
|
|
387
|
-
}, /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
|
388
|
-
id: "sharing-modal-search-section-select-option-can-view",
|
|
389
|
-
value: READ_ONLY
|
|
390
|
-
}, t('Can view')), /*#__PURE__*/React.createElement(SimpleSelect.Option, {
|
|
391
|
-
id: "sharing-modal-search-section-select-option-can-edit",
|
|
392
|
-
value: CAN_EDIT
|
|
393
|
-
}, t('Can edit')))), /*#__PURE__*/React.createElement(Grid.Col, {
|
|
394
|
-
width: "auto"
|
|
395
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
396
|
-
"data-automation": "sdk-shared-bank-add-user-button",
|
|
397
|
-
ref: this.handleShareButtonRef,
|
|
398
|
-
onClick: this.handleShare,
|
|
399
|
-
variant: this.state.searchSelection.length ? 'success' : 'default'
|
|
400
|
-
}, t('Add')))));
|
|
401
|
-
}
|
|
402
488
|
}, {
|
|
403
489
|
key: "renderEntitiesSection",
|
|
404
490
|
value: function renderEntitiesSection() {
|
|
405
491
|
return /*#__PURE__*/React.createElement(ShareList, {
|
|
406
|
-
ref: this.handleShareListRef,
|
|
407
|
-
improvedBankSharingEnabled: this.props.improvedBankSharingEnabled,
|
|
408
492
|
canEdit: this.props.bank.canEdit(),
|
|
493
|
+
entitiesWithChangedPermission: this.state.entitiesWithChangedPermission,
|
|
494
|
+
improvedBankSharingEnabled: this.props.improvedBankSharingEnabled,
|
|
409
495
|
newEntities: this.state.newEntities,
|
|
496
|
+
onEntityRemove: this.handleEntityRemove,
|
|
497
|
+
onPermissionChange: this.handleEntityPermissionChange,
|
|
498
|
+
ref: this.handleShareListRef,
|
|
499
|
+
renderSearchSection: this.renderSearchSection // searchPermission and searchSelection are not used directly by ShareList,
|
|
500
|
+
// but are needed as props so that AsyncSearch/Select rerenders when those values change
|
|
501
|
+
,
|
|
502
|
+
searchPermission: this.state.searchPermission,
|
|
503
|
+
searchSelection: this.state.searchSelection,
|
|
410
504
|
sharedBanks: this.props.sharedBanks,
|
|
411
505
|
shares: this.state.shares,
|
|
412
|
-
|
|
413
|
-
onEntityRemove: this.handleEntityRemove,
|
|
414
|
-
entitiesWithChangedPermission: this.state.entitiesWithChangedPermission
|
|
506
|
+
subAccountBankSharingEnabled: this.props.subAccountBankSharingEnabled
|
|
415
507
|
});
|
|
416
508
|
}
|
|
509
|
+
}, {
|
|
510
|
+
key: "renderFooter",
|
|
511
|
+
value: function renderFooter() {
|
|
512
|
+
if (this.props.subAccountBankSharingEnabled) {
|
|
513
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
514
|
+
variant: "primary",
|
|
515
|
+
margin: "0 x-small 0 0",
|
|
516
|
+
onClick: this.handleDismiss
|
|
517
|
+
}, t('Close'));
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
521
|
+
"data-automation": "sdk-shared-bank-cancel-button",
|
|
522
|
+
variant: "light",
|
|
523
|
+
onClick: this.handleDismiss,
|
|
524
|
+
margin: "0 x-small 0 0"
|
|
525
|
+
}, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
526
|
+
"data-automation": "sdk-shared-bank-done-button",
|
|
527
|
+
variant: "primary",
|
|
528
|
+
onClick: this.handleSubmit,
|
|
529
|
+
margin: "0 x-small 0 0"
|
|
530
|
+
}, t('Done')));
|
|
531
|
+
}
|
|
417
532
|
}, {
|
|
418
533
|
key: "render",
|
|
419
534
|
value: function render() {
|
|
535
|
+
var subAccountBankSharingEnabled = this.props.subAccountBankSharingEnabled;
|
|
420
536
|
return /*#__PURE__*/React.createElement(Modal, {
|
|
421
537
|
open: this.props.isOpen,
|
|
422
538
|
onDismiss: this.handleDismiss,
|
|
@@ -429,21 +545,7 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
429
545
|
placement: "end",
|
|
430
546
|
offset: "medium",
|
|
431
547
|
screenReaderLabel: t('Close')
|
|
432
|
-
})), /*#__PURE__*/React.createElement(ModalBody, null, this.renderAccountPermissions(), this.
|
|
433
|
-
className: "fs-mask"
|
|
434
|
-
}, this.renderSearchSection()), /*#__PURE__*/React.createElement("div", {
|
|
435
|
-
className: styles.separator
|
|
436
|
-
})), this.state.shares.size > 0 ? this.renderEntitiesSection() : _ref6), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
437
|
-
"data-automation": "sdk-shared-bank-cancel-button",
|
|
438
|
-
variant: "light",
|
|
439
|
-
onClick: this.handleDismiss,
|
|
440
|
-
margin: "0 x-small 0 0"
|
|
441
|
-
}, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
442
|
-
"data-automation": "sdk-shared-bank-done-button",
|
|
443
|
-
variant: "primary",
|
|
444
|
-
onClick: this.handleSubmit,
|
|
445
|
-
margin: "0 x-small 0 0"
|
|
446
|
-
}, t('Done'))));
|
|
548
|
+
})), /*#__PURE__*/React.createElement(ModalBody, null, !subAccountBankSharingEnabled && this.renderAccountPermissions(), !subAccountBankSharingEnabled && this.renderSearchSection(), this.state.shares.size > 0 ? this.renderEntitiesSection() : _ref7), /*#__PURE__*/React.createElement(ModalFooter, null, this.renderFooter()));
|
|
447
549
|
}
|
|
448
550
|
}]);
|
|
449
551
|
|
|
@@ -476,9 +578,11 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
476
578
|
removeSharedBank: PropTypes.func.isRequired,
|
|
477
579
|
shareBank: PropTypes.func.isRequired,
|
|
478
580
|
sharedBanks: ImmutablePropTypes.list,
|
|
581
|
+
subAccountBankSharingEnabled: PropTypes.bool,
|
|
479
582
|
updateBank: PropTypes.func.isRequired,
|
|
480
583
|
updateSharedBankPermission: PropTypes.func.isRequired,
|
|
481
|
-
updateSharedCount: PropTypes.func
|
|
584
|
+
updateSharedCount: PropTypes.func,
|
|
585
|
+
withConfirm: PropTypes.func.isRequired
|
|
482
586
|
}, _class2.defaultProps = {
|
|
483
587
|
bank: null,
|
|
484
588
|
currentUser: null,
|
|
@@ -489,6 +593,7 @@ export var SharingModalPresenter = (_dec = themeable(theme, styles), _dec(_class
|
|
|
489
593
|
onDismiss: noop,
|
|
490
594
|
onShare: function onShare() {},
|
|
491
595
|
sharedBanks: List(),
|
|
596
|
+
subAccountBankSharingEnabled: false,
|
|
492
597
|
updateSharedCount: Function.prototype
|
|
493
598
|
}, _temp)) || _class);
|
|
494
599
|
export default SharingModalPresenter;
|
package/lib/banks/api/banks.js
CHANGED
|
@@ -95,8 +95,12 @@ var getBank = function getBank(bankId) {
|
|
|
95
95
|
});
|
|
96
96
|
return fetcher.get("".concat(banksApiEndpoint, "/").concat(bankId)).then(function (response) {
|
|
97
97
|
return dispatch((0, _callHandlers.handleBanksResponse)([response]));
|
|
98
|
-
}).catch(function () {
|
|
98
|
+
}).catch(function (err) {
|
|
99
|
+
if (err.response.status === 404) {
|
|
100
|
+
dispatch((0, _ui.clear)(_quizCommon.BANKS_BANK_PAGINATION));
|
|
101
|
+
} // Do nothing because this case is handled elsewhere.
|
|
99
102
|
// This catch is to suppress an console error for "unhandled in promise".
|
|
103
|
+
|
|
100
104
|
});
|
|
101
105
|
};
|
|
102
106
|
};
|
|
@@ -241,7 +245,7 @@ var shareBank = function shareBank(_shareBank, getUserInfo) {
|
|
|
241
245
|
var sharedBank = {
|
|
242
246
|
id: sharedBankInfo.id,
|
|
243
247
|
entityType: _quizCommon.SHARED_WITH_COURSE,
|
|
244
|
-
entityId: _shareBank.
|
|
248
|
+
entityId: _shareBank.entityId,
|
|
245
249
|
title: _shareBank.title,
|
|
246
250
|
permission: sharedBankInfo.permission,
|
|
247
251
|
bankId: _shareBank.bankId
|
|
@@ -344,7 +348,6 @@ var updateSharedBankPermission = function updateSharedBankPermission(bankId, sha
|
|
|
344
348
|
body: shareBankData
|
|
345
349
|
}).then(function (sharedBank) {
|
|
346
350
|
if (permission === _quizCommon.REMOVED_ACCESS) {
|
|
347
|
-
dispatch((0, _ui.clear)(_quizCommon.BANKS_BANK_PAGINATION));
|
|
348
351
|
dispatch((0, _sharedBanks.removeSharedBank)(sharedBankId));
|
|
349
352
|
} else {
|
|
350
353
|
dispatch((0, _sharedBanks.updateSharedBankPermission)(sharedBankId, permission));
|
|
@@ -299,6 +299,23 @@ var BanksList = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _de
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
(0, _createClass2.default)(BanksList, [{
|
|
302
|
+
key: "componentDidUpdate",
|
|
303
|
+
value: function componentDidUpdate() {
|
|
304
|
+
var _this2 = this;
|
|
305
|
+
|
|
306
|
+
if (this.state.sharingModalBank) {
|
|
307
|
+
var bankFromList = this.props.banks.find(function (bank) {
|
|
308
|
+
return bank.get('id') === _this2.state.sharingModalBank.get('id');
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
if (!this.state.sharingModalBank.equals(bankFromList)) {
|
|
312
|
+
this.setState({
|
|
313
|
+
sharingModalBank: bankFromList
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}, {
|
|
302
319
|
key: "renderDetails",
|
|
303
320
|
value: function renderDetails(bank) {
|
|
304
321
|
var separator = ' | ';
|
|
@@ -96,7 +96,7 @@ var ShareList = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _de
|
|
|
96
96
|
var entity = _ref2.entity,
|
|
97
97
|
isEntityRemoved = _ref2.isEntityRemoved;
|
|
98
98
|
|
|
99
|
-
_this.props.onEntityRemove(entity
|
|
99
|
+
_this.props.onEntityRemove(entity, isEntityRemoved);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
_this.handlePermissionChange = function (entity) {
|
|
@@ -186,7 +186,9 @@ var ShareList = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _de
|
|
|
186
186
|
}, {
|
|
187
187
|
key: "render",
|
|
188
188
|
value: function render() {
|
|
189
|
-
var
|
|
189
|
+
var _this$props = this.props,
|
|
190
|
+
shares = _this$props.shares,
|
|
191
|
+
subAccountBankSharingEnabled = _this$props.subAccountBankSharingEnabled;
|
|
190
192
|
var newEntityIds = this.props.newEntities.map(function (e) {
|
|
191
193
|
return e.get('id');
|
|
192
194
|
});
|
|
@@ -201,30 +203,37 @@ var ShareList = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _de
|
|
|
201
203
|
});
|
|
202
204
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
203
205
|
className: "fs-mask"
|
|
204
|
-
}, /*#__PURE__*/_react.default.createElement(_uiText.Text, {
|
|
206
|
+
}, !subAccountBankSharingEnabled && /*#__PURE__*/_react.default.createElement(_uiText.Text, {
|
|
205
207
|
as: "div",
|
|
206
208
|
weight: "bold"
|
|
207
209
|
}, (0, _formatMessage.default)('Currently shared with')), /*#__PURE__*/_react.default.createElement(_uiView.View, {
|
|
208
210
|
as: "div",
|
|
209
|
-
padding: "small 0 0 0",
|
|
210
211
|
"data-automation": "sdk-shared-bank-user-list"
|
|
211
|
-
}, this.renderNewEntities(), /*#__PURE__*/_react.default.createElement(_uiTabs.Tabs, {
|
|
212
|
+
}, !subAccountBankSharingEnabled && this.renderNewEntities(), /*#__PURE__*/_react.default.createElement(_uiTabs.Tabs, {
|
|
212
213
|
onRequestTabChange: this.handleTabChange
|
|
213
214
|
}, /*#__PURE__*/_react.default.createElement(_uiTabs.Tabs.Panel, {
|
|
214
215
|
renderTitle: (0, _formatMessage.default)('People ({ peopleCount })', {
|
|
215
216
|
peopleCount: existingPeople.size
|
|
216
217
|
}),
|
|
217
218
|
isSelected: this.state.selectedTabIndex === 0,
|
|
218
|
-
padding: "
|
|
219
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
219
|
+
padding: "large 0 0 0"
|
|
220
|
+
}, subAccountBankSharingEnabled && this.props.renderSearchSection(_quizCommon.SHARED_WITH_USER), subAccountBankSharingEnabled && /*#__PURE__*/_react.default.createElement(_uiText.Text, {
|
|
221
|
+
as: "div",
|
|
222
|
+
weight: "bold",
|
|
223
|
+
lineHeight: "double"
|
|
224
|
+
}, (0, _formatMessage.default)('Currently shared with')), /*#__PURE__*/_react.default.createElement(_uiGrid.Grid, {
|
|
220
225
|
vAlign: "middle"
|
|
221
|
-
}, existingPeople.map(this.renderEntity))), !existingCourses.isEmpty() && /*#__PURE__*/_react.default.createElement(_uiTabs.Tabs.Panel, {
|
|
226
|
+
}, existingPeople.map(this.renderEntity))), (!existingCourses.isEmpty() || subAccountBankSharingEnabled) && /*#__PURE__*/_react.default.createElement(_uiTabs.Tabs.Panel, {
|
|
222
227
|
renderTitle: (0, _formatMessage.default)('Courses ({ coursesCount })', {
|
|
223
228
|
coursesCount: existingCourses.size
|
|
224
229
|
}),
|
|
225
230
|
isSelected: this.state.selectedTabIndex === 1,
|
|
226
|
-
padding: "
|
|
227
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
231
|
+
padding: "large 0 0 0"
|
|
232
|
+
}, subAccountBankSharingEnabled && this.props.renderSearchSection(_quizCommon.SHARED_WITH_COURSE), subAccountBankSharingEnabled && /*#__PURE__*/_react.default.createElement(_uiText.Text, {
|
|
233
|
+
as: "div",
|
|
234
|
+
weight: "bold",
|
|
235
|
+
lineHeight: "double"
|
|
236
|
+
}, (0, _formatMessage.default)('Currently shared with')), /*#__PURE__*/_react.default.createElement(_uiGrid.Grid, {
|
|
228
237
|
vAlign: "middle"
|
|
229
238
|
}, existingCourses.map(this.renderEntity))))));
|
|
230
239
|
}
|
|
@@ -235,6 +244,9 @@ var ShareList = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _de
|
|
|
235
244
|
canEdit: _propTypes.default.bool.isRequired,
|
|
236
245
|
improvedBankSharingEnabled: _propTypes.default.bool.isRequired,
|
|
237
246
|
newEntities: _reactImmutableProptypes.default.list,
|
|
247
|
+
onEntityRemove: _propTypes.default.func.isRequired,
|
|
248
|
+
onPermissionChange: _propTypes.default.func.isRequired,
|
|
249
|
+
renderSearchSection: _propTypes.default.func.isRequired,
|
|
238
250
|
sharedBanks: _reactImmutableProptypes.default.list,
|
|
239
251
|
shares: _reactImmutableProptypes.default.listOf(_reactImmutableProptypes.default.contains({
|
|
240
252
|
avatar: _propTypes.default.string,
|
|
@@ -244,8 +256,7 @@ var ShareList = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _de
|
|
|
244
256
|
permission: _propTypes.default.string.isRequired,
|
|
245
257
|
id: _propTypes.default.string.isRequired
|
|
246
258
|
})).isRequired,
|
|
247
|
-
|
|
248
|
-
onEntityRemove: _propTypes.default.func.isRequired
|
|
259
|
+
subAccountBankSharingEnabled: _propTypes.default.bool.isRequired
|
|
249
260
|
}, _class2.defaultProps = {
|
|
250
261
|
newEntities: (0, _immutable.List)(),
|
|
251
262
|
sharedBanks: (0, _immutable.List)()
|
|
@@ -195,18 +195,22 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
|
|
|
195
195
|
};
|
|
196
196
|
|
|
197
197
|
_this.search = (0, _debounce.default)(_this.props.debounceDelay, function (value) {
|
|
198
|
-
|
|
199
|
-
_this.props.
|
|
200
|
-
var filteredUsers = _this.filterOptions(shareableUsers);
|
|
198
|
+
var shouldSearchPeople = !_this.props.searchType || _this.props.searchType === _quizCommon.SHARED_WITH_USER;
|
|
199
|
+
var shouldSearchCourses = !_this.props.searchType || _this.props.searchType === _quizCommon.SHARED_WITH_COURSE; // TODO add the promise cancellation for avoiding having disordered requests
|
|
201
200
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
if (shouldSearchPeople) {
|
|
202
|
+
_this.props.getShareableUsers(value).then(function (shareableUsers) {
|
|
203
|
+
var filteredUsers = _this.filterOptions(shareableUsers);
|
|
204
|
+
|
|
205
|
+
_this.setState({
|
|
206
|
+
shareableUsers: shareableUsers,
|
|
207
|
+
highlightedOptionId: filteredUsers.length ? filteredUsers[0].uuid : _this.state.highlightedOptionId,
|
|
208
|
+
isLoading: false
|
|
209
|
+
});
|
|
206
210
|
});
|
|
207
|
-
}
|
|
211
|
+
}
|
|
208
212
|
|
|
209
|
-
if (_this.props.improvedBankSharingEnabled) {
|
|
213
|
+
if (_this.props.improvedBankSharingEnabled && shouldSearchCourses) {
|
|
210
214
|
_this.props.getShareableCourses(value).then(function (shareableCourses) {
|
|
211
215
|
var filteredCourses = _this.filterOptions(shareableCourses);
|
|
212
216
|
|
|
@@ -350,10 +354,11 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
|
|
|
350
354
|
var _this$state = this.state,
|
|
351
355
|
inputValue = _this$state.inputValue,
|
|
352
356
|
isShowingOptions = _this$state.isShowingOptions;
|
|
357
|
+
var placeholder = this.props.searchType === _quizCommon.SHARED_WITH_COURSE ? (0, _formatMessage.default)('Enter course name or course id') : (0, _formatMessage.default)('Enter name or login id');
|
|
353
358
|
return /*#__PURE__*/_react.default.createElement(_uiSelect.Select, {
|
|
354
359
|
"data-automation": "sdk-item-bank-share-input",
|
|
355
360
|
renderLabel: (0, _formatMessage.default)('Share With'),
|
|
356
|
-
placeholder:
|
|
361
|
+
placeholder: placeholder,
|
|
357
362
|
inputValue: inputValue,
|
|
358
363
|
isShowingOptions: isShowingOptions,
|
|
359
364
|
inputRef: this.setInputRef,
|
|
@@ -380,6 +385,7 @@ AsyncSearch.propTypes = {
|
|
|
380
385
|
onSelectionChange: _propTypes.default.func.isRequired,
|
|
381
386
|
getShareableCourses: _propTypes.default.func.isRequired,
|
|
382
387
|
getShareableUsers: _propTypes.default.func.isRequired,
|
|
388
|
+
searchType: _propTypes.default.string,
|
|
383
389
|
selectedOption: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
384
390
|
avatar: _propTypes.default.string,
|
|
385
391
|
fullName: _propTypes.default.string,
|
|
@@ -391,6 +397,7 @@ AsyncSearch.propTypes = {
|
|
|
391
397
|
AsyncSearch.defaultProps = {
|
|
392
398
|
debounceDelay: 500,
|
|
393
399
|
minChars: 1,
|
|
400
|
+
searchType: null,
|
|
394
401
|
selectionFilter: function selectionFilter(value) {
|
|
395
402
|
return value;
|
|
396
403
|
}
|