@instructure/quiz-core 20.8.0 → 20.8.1-rc.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.
@@ -11,7 +11,7 @@ import { clear, newActiveBankEntry, newActiveBank } from "../../common/actions/u
11
11
  import t from '@instructure/quiz-i18n/es/format-message';
12
12
  import { handleError } from "../../common/api/helpers.js";
13
13
  import { removeFromPolling } from "./copyingBanksPoller.js";
14
- import { BANKS_BANK_PAGINATION, BANKS_BANK_ENTRY_PAGINATION, DELETE_BANK_CALL, UPDATE_BANK_CALL, CAN_EDIT, READ_ONLY, REMOVED_ACCESS, SHARED_WITH_USER, SHARED_WITH_COURSE } from '@instructure/quiz-common';
14
+ import { BANKS_BANK_PAGINATION, BANKS_BANK_ENTRY_PAGINATION, DELETE_BANK_CALL, UPDATE_BANK_CALL, CAN_EDIT, READ_ONLY, REMOVED_ACCESS, SHARED_WITH_USER, SHARED_WITH_COURSE, SHARED_WITH_ACCOUNT } from '@instructure/quiz-common';
15
15
  import { noop } from 'lodash';
16
16
  import { NIL } from 'uuid';
17
17
  var banksApiEndpoint = '/api/banks';
@@ -226,10 +226,10 @@ export var shareBank = function shareBank(_shareBank) {
226
226
  };
227
227
  dispatch(handleShareBankResponse(sharedBank));
228
228
  });
229
- } else if (_shareBank.entityType === SHARED_WITH_COURSE) {
229
+ } else {
230
230
  var sharedBank = {
231
231
  id: sharedBankInfo.id,
232
- entityType: SHARED_WITH_COURSE,
232
+ entityType: _shareBank.entityType,
233
233
  entityId: _shareBank.entityId,
234
234
  title: _shareBank.title,
235
235
  permission: sharedBankInfo.permission,
@@ -272,10 +272,8 @@ export var getSharedBank = function getSharedBank(bankId, entityType, entityId)
272
272
  });
273
273
  };
274
274
  };
275
- export var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourseInfo) {
275
+ export var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourseInfo, getAccountInfo) {
276
276
  var url = "".concat(banksApiEndpoint, "/").concat(bank.id, "/shared_banks");
277
- var userSharedBanks = [];
278
- var courseSharedBanks = [];
279
277
  return function (dispatch, getState) {
280
278
  var fetcher = new Fetcher({
281
279
  onError: handleError(dispatch, t('Failed to fetch shared banks.'))
@@ -290,8 +288,10 @@ export var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourse
290
288
  permission: CAN_EDIT,
291
289
  bank_id: bank.id
292
290
  });
293
- }
291
+ } // USERS
292
+
294
293
 
294
+ var userSharedBanks = [];
295
295
  var userUuids = sharedBanksInfo.filter(function (sb) {
296
296
  return sb.entity_type === SHARED_WITH_USER;
297
297
  }).map(function (sb) {
@@ -316,7 +316,9 @@ export var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourse
316
316
  }
317
317
  });
318
318
  dispatch(handleShareBanksResponse(userSharedBanks));
319
- });
319
+ }); // COURSES
320
+
321
+ var courseSharedBanks = [];
320
322
  var courseUuids = sharedBanksInfo.filter(function (sb) {
321
323
  return sb.entity_type === SHARED_WITH_COURSE;
322
324
  }).map(function (sb) {
@@ -340,6 +342,32 @@ export var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourse
340
342
  }
341
343
  });
342
344
  dispatch(handleShareBanksResponse(courseSharedBanks));
345
+ }); // ACCOUNTS
346
+
347
+ var accountSharedBanks = [];
348
+ var accountUuids = sharedBanksInfo.filter(function (sb) {
349
+ return sb.entity_type === SHARED_WITH_ACCOUNT;
350
+ }).map(function (sb) {
351
+ return sb.entity_id;
352
+ });
353
+ getAccountInfo(accountUuids).then(function (accountsInfo) {
354
+ accountsInfo.forEach(function (accountInfo) {
355
+ var sharedBankInfo = sharedBanksInfo.find(function (sb) {
356
+ return sb.entity_type === SHARED_WITH_ACCOUNT && sb.entity_id === accountInfo.uuid;
357
+ });
358
+
359
+ if (sharedBankInfo) {
360
+ accountSharedBanks.push({
361
+ id: sharedBankInfo.id,
362
+ entityType: sharedBankInfo.entity_type,
363
+ entityId: sharedBankInfo.entity_id,
364
+ title: accountInfo.name,
365
+ permission: sharedBankInfo.permission,
366
+ bankId: sharedBankInfo.bank_id
367
+ });
368
+ }
369
+ });
370
+ dispatch(handleShareBanksResponse(accountSharedBanks));
343
371
  });
344
372
  });
345
373
  };
@@ -173,8 +173,10 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
173
173
  focusCreateBankButton: _this.focusCreateBankButton,
174
174
  getCourseInfo: _this.props.getCourseInfo,
175
175
  getUserInfo: _this.props.getUserInfo,
176
+ getSubaccountInfo: _this.props.getSubaccountInfo,
176
177
  getShareableCourses: _this.props.getShareableCourses,
177
178
  getShareableUsers: _this.props.getShareableUsers,
179
+ getShareableSubaccounts: _this.props.getShareableSubaccounts,
178
180
  isCompact: _this.props.isCompact,
179
181
  itemBankSearchTableEnabled: _this.props.itemBankSearchTableEnabled,
180
182
  minChars: _this.props.minChars,
@@ -402,6 +404,7 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
402
404
  createBank: PropTypes.func.isRequired,
403
405
  currentUser: PropTypes.shape({
404
406
  bank_admin: PropTypes.bool,
407
+ can_share_banks_with_subaccounts: PropTypes.bool,
405
408
  email: PropTypes.string,
406
409
  enrollment_names: PropTypes.arrayOf(PropTypes.string),
407
410
  full_name: PropTypes.string,
@@ -419,7 +422,11 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
419
422
  getShareableCourses: PropTypes.func,
420
423
  // from consumer
421
424
  getShareableUsers: PropTypes.func,
422
- // from consumer,
425
+ // from consumer
426
+ getShareableSubaccounts: PropTypes.func,
427
+ // from consumer
428
+ getSubaccountInfo: PropTypes.func,
429
+ // from consumer
423
430
  getCourseAssignments: PropTypes.func,
424
431
  // from consumer
425
432
  isCompact: PropTypes.bool,
@@ -456,6 +463,8 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
456
463
  getShareableCourses: null,
457
464
  getShareableUsers: null,
458
465
  getCourseAssignments: null,
466
+ getShareableSubaccounts: null,
467
+ getSubaccountInfo: null,
459
468
  minChars: void 0,
460
469
  isCompact: false,
461
470
  navigateToBuild: null,
@@ -399,6 +399,7 @@ export var BanksList = (_dec = withStyle(generateStyle, generateComponentTheme),
399
399
  focusCreateBankButton: this.props.focusCreateBankButton,
400
400
  getCourseInfo: this.props.getCourseInfo,
401
401
  getUserInfo: this.props.getUserInfo,
402
+ getSubaccountInfo: this.props.getSubaccountInfo,
402
403
  isOpen: this.state.sharingModalOpen,
403
404
  minChars: this.props.minChars,
404
405
  modalTrigger: this.sharingButtons[this.state.sharingModalBank.id],
@@ -406,6 +407,7 @@ export var BanksList = (_dec = withStyle(generateStyle, generateComponentTheme),
406
407
  onShare: this.props.onShare,
407
408
  getShareableCourses: this.props.getShareableCourses,
408
409
  getShareableUsers: this.props.getShareableUsers,
410
+ getShareableSubaccounts: this.props.getShareableSubaccounts,
409
411
  updateSharedCount: this.updateSharedCount
410
412
  });
411
413
  }
@@ -510,6 +512,7 @@ export var BanksList = (_dec = withStyle(generateStyle, generateComponentTheme),
510
512
  createBankCloneJob: PropTypes.func.isRequired,
511
513
  currentUser: PropTypes.shape({
512
514
  bank_admin: PropTypes.bool,
515
+ can_share_banks_with_subaccounts: PropTypes.bool,
513
516
  email: PropTypes.string,
514
517
  enrollment_names: PropTypes.arrayOf(PropTypes.string),
515
518
  full_name: PropTypes.string,
@@ -523,6 +526,7 @@ export var BanksList = (_dec = withStyle(generateStyle, generateComponentTheme),
523
526
  getUserInfo: PropTypes.func,
524
527
  getShareableCourses: PropTypes.func,
525
528
  getShareableUsers: PropTypes.func,
529
+ getShareableSubaccounts: PropTypes.func,
526
530
  minChars: PropTypes.number,
527
531
  navigateToBank: PropTypes.func.isRequired,
528
532
  onShare: PropTypes.func,
@@ -538,6 +542,7 @@ export var BanksList = (_dec = withStyle(generateStyle, generateComponentTheme),
538
542
  getUserInfo: null,
539
543
  getShareableCourses: null,
540
544
  getShareableUsers: null,
545
+ getShareableSubaccounts: null,
541
546
  minChars: void 0,
542
547
  locale: null,
543
548
  timezone: null,
@@ -22,7 +22,7 @@ import { ContextualIconButton } from "../ContextualIconButton/index.js";
22
22
  import RootAccountSharing from "../RootAccountSharing.js";
23
23
  import { SimpleSelect } from '@instructure/ui-simple-select';
24
24
  import generateStyle from "./styles.js";
25
- import { CAN_EDIT, READ_ONLY, REMOVED_ACCESS, SHARED_WITH_USER, SHARED_WITH_COURSE } from '@instructure/quiz-common';
25
+ import { CAN_EDIT, READ_ONLY, REMOVED_ACCESS, SHARED_WITH_USER, SHARED_WITH_COURSE, SHARED_WITH_ACCOUNT } from '@instructure/quiz-common';
26
26
  import t from '@instructure/quiz-i18n/es/format-message';
27
27
 
28
28
  var _ref4 = jsx(IconCoursesLine, {
@@ -148,11 +148,10 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
148
148
  }, {
149
149
  key: "render",
150
150
  value: function render() {
151
- var _this$props$currentUs;
152
-
153
151
  var _this$props = this.props,
154
152
  shares = _this$props.shares,
155
- subAccountBankSharingEnabled = _this$props.subAccountBankSharingEnabled;
153
+ subAccountBankSharingEnabled = _this$props.subAccountBankSharingEnabled,
154
+ currentUser = _this$props.currentUser;
156
155
  var newEntityIds = this.props.newEntities.map(function (e) {
157
156
  return e.get('id');
158
157
  });
@@ -165,6 +164,9 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
165
164
  var existingCourses = existingShares.filter(function (s) {
166
165
  return s.get('entityType') === SHARED_WITH_COURSE;
167
166
  });
167
+ var existingAccounts = existingShares.filter(function (s) {
168
+ return s.get('entityType') === SHARED_WITH_ACCOUNT;
169
+ });
168
170
  return jsx("div", {
169
171
  className: "fs-mask"
170
172
  }, !subAccountBankSharingEnabled && jsx(Text, {
@@ -199,16 +201,24 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
199
201
  lineHeight: "double"
200
202
  }, t('Currently shared with')), jsx(Grid, {
201
203
  vAlign: "middle"
202
- }, existingCourses.map(this.renderEntity))), subAccountBankSharingEnabled && jsx(Tabs.Panel, {
203
- renderTitle: t('Accounts'),
204
+ }, existingCourses.map(this.renderEntity))), subAccountBankSharingEnabled && ((currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) || (currentUser === null || currentUser === void 0 ? void 0 : currentUser.can_share_banks_with_subaccounts)) && jsx(Tabs.Panel, {
205
+ renderTitle: t('Accounts ({ accountsCount })', {
206
+ accountsCount: existingAccounts.size
207
+ }),
204
208
  isSelected: this.state.selectedTabIndex === 2,
205
209
  padding: "large small small small"
206
- }, ((_this$props$currentUs = this.props.currentUser) === null || _this$props$currentUs === void 0 ? void 0 : _this$props$currentUs.bank_admin) && jsx(RootAccountSharing, {
210
+ }, (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) && jsx(RootAccountSharing, {
207
211
  accountName: this.props.accountName,
208
212
  onShareChange: this.props.onToggleAccountShare,
209
213
  onShareTypeChange: this.props.onAccountPermissionChange,
210
214
  accountPermission: this.props.accountPermission
211
- })))));
215
+ }), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.can_share_banks_with_subaccounts) && this.props.renderSearchSection(SHARED_WITH_ACCOUNT), jsx(Text, {
216
+ as: "div",
217
+ weight: "bold",
218
+ lineHeight: "double"
219
+ }, t('Currently shared with')), jsx(Grid, {
220
+ vAlign: "middle"
221
+ }, existingAccounts.map(this.renderEntity))))));
212
222
  }
213
223
  }]);
214
224
 
@@ -217,7 +227,8 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
217
227
  }(Component), _class2.propTypes = {
218
228
  canEdit: PropTypes.bool.isRequired,
219
229
  currentUser: PropTypes.shape({
220
- bank_admin: PropTypes.bool
230
+ bank_admin: PropTypes.bool,
231
+ can_share_banks_with_subaccounts: PropTypes.bool
221
232
  }),
222
233
  improvedBankSharingEnabled: PropTypes.bool.isRequired,
223
234
  newEntities: ImmutablePropTypes.list,
@@ -12,7 +12,7 @@ import t from '@instructure/quiz-i18n/es/format-message';
12
12
  import { Select } from '@instructure/ui-select';
13
13
  import { Spinner } from '@instructure/ui-spinner';
14
14
  import TagWrapper from "../../../common/components/shared/TagWrapper/index.js";
15
- import { SHARED_WITH_USER, SHARED_WITH_COURSE, SELECT_EMPTY_OPTION } from '@instructure/quiz-common';
15
+ import { SHARED_WITH_USER, SHARED_WITH_COURSE, SHARED_WITH_ACCOUNT, SELECT_EMPTY_OPTION } from '@instructure/quiz-common';
16
16
  export var AsyncSearch = /*#__PURE__*/function (_Component) {
17
17
  _inherits(AsyncSearch, _Component);
18
18
 
@@ -34,6 +34,7 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
34
34
  isShowingOptions: false,
35
35
  isLoading: false,
36
36
  highlightedOptionId: null,
37
+ shareableSubaccounts: [],
37
38
  shareableCourses: [],
38
39
  shareableUsers: []
39
40
  };
@@ -45,7 +46,7 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
45
46
  };
46
47
 
47
48
  _this.handleHideOptions = function () {
48
- var allOptions = [].concat(_toConsumableArray(_this.filterOptions(_this.state.shareableCourses)), _toConsumableArray(_this.filterOptions(_this.state.shareableUsers))); // an option matching user input exists
49
+ var allOptions = [].concat(_toConsumableArray(_this.filterOptions(_this.state.shareableSubaccounts)), _toConsumableArray(_this.filterOptions(_this.state.shareableCourses)), _toConsumableArray(_this.filterOptions(_this.state.shareableUsers))); // an option matching user input exists
49
50
 
50
51
  if (allOptions.length === 1) {
51
52
  var onlyOption = allOptions[0]; // automatically select the matching option
@@ -166,7 +167,8 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
166
167
 
167
168
  _this.search = debounce(_this.props.debounceDelay, function (value) {
168
169
  var shouldSearchPeople = !_this.props.searchType || _this.props.searchType === SHARED_WITH_USER;
169
- var shouldSearchCourses = !_this.props.searchType || _this.props.searchType === SHARED_WITH_COURSE; // TODO add the promise cancellation for avoiding having disordered requests
170
+ var shouldSearchCourses = !_this.props.searchType || _this.props.searchType === SHARED_WITH_COURSE;
171
+ var shouldSearchSubaccounts = _this.props.searchType === SHARED_WITH_ACCOUNT; // TODO add the promise cancellation for avoiding having disordered requests
170
172
 
171
173
  if (shouldSearchPeople) {
172
174
  _this.props.getShareableUsers(value).then(function (shareableUsers) {
@@ -191,6 +193,18 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
191
193
  });
192
194
  });
193
195
  }
196
+
197
+ if (shouldSearchSubaccounts) {
198
+ _this.props.getShareableSubaccounts(value).then(function (shareableSubaccounts) {
199
+ var filteredAccounts = _this.filterOptions(shareableSubaccounts);
200
+
201
+ _this.setState({
202
+ shareableSubaccounts: shareableSubaccounts,
203
+ highlightedOptionId: filteredAccounts.length ? filteredAccounts[0].uuid : _this.state.highlightedOptionId,
204
+ isLoading: false
205
+ });
206
+ });
207
+ }
194
208
  });
195
209
  return _this;
196
210
  }
@@ -218,6 +232,16 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
218
232
  });
219
233
  }
220
234
 
235
+ var account = find({
236
+ uuid: id
237
+ }, this.state.shareableSubaccounts);
238
+
239
+ if (account) {
240
+ return _objectSpread(_objectSpread({}, account), {}, {
241
+ entityType: SHARED_WITH_ACCOUNT
242
+ });
243
+ }
244
+
221
245
  return find({
222
246
  uuid: id
223
247
  }, this.props.selectedOption);
@@ -232,7 +256,7 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
232
256
  key: option.uuid,
233
257
  id: option.uuid,
234
258
  index: index,
235
- text: option.fullName || option.title,
259
+ text: option.fullName || option.title || option.name,
236
260
  onClick: _this2.dismissTag
237
261
  });
238
262
  });
@@ -284,6 +308,24 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
284
308
  }, course.title);
285
309
  }));
286
310
  }
311
+ }, {
312
+ key: "renderSubaccountsOptions",
313
+ value: function renderSubaccountsOptions(subaccounts) {
314
+ var _this6 = this;
315
+
316
+ return /*#__PURE__*/React.createElement(Select.Group, {
317
+ key: SHARED_WITH_ACCOUNT,
318
+ renderLabel: t('Accounts')
319
+ }, subaccounts.map(function (subaccount) {
320
+ return /*#__PURE__*/React.createElement(Select.Option, {
321
+ // eslint-disable-next-line react/jsx-no-literals
322
+ "data-automation": "sdk-item-bank-option-subaccount-".concat(subaccount.uuid),
323
+ id: subaccount.uuid,
324
+ key: subaccount.uuid,
325
+ isHighlighted: subaccount.uuid === _this6.state.highlightedOptionId
326
+ }, subaccount.name);
327
+ }));
328
+ }
287
329
  }, {
288
330
  key: "emptyOption",
289
331
  value: function emptyOption() {
@@ -313,6 +355,12 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
313
355
  groups.push(this.renderCoursesOptions(courses));
314
356
  }
315
357
 
358
+ var subaccounts = this.filterOptions(this.state.shareableSubaccounts);
359
+
360
+ if (subaccounts.length) {
361
+ groups.push(this.renderSubaccountsOptions(subaccounts));
362
+ }
363
+
316
364
  return groups.length ? groups : /*#__PURE__*/React.createElement(Select.Option, {
317
365
  id: SELECT_EMPTY_OPTION,
318
366
  key: SELECT_EMPTY_OPTION
@@ -321,17 +369,27 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
321
369
  size: "x-small"
322
370
  }) : this.emptyOption());
323
371
  }
372
+ }, {
373
+ key: "placeholder",
374
+ value: function placeholder() {
375
+ if (this.props.searchType === SHARED_WITH_ACCOUNT) {
376
+ return t('Enter subaccount name');
377
+ } else if (this.props.searchType === SHARED_WITH_COURSE) {
378
+ return t('Enter course name or course id');
379
+ } else {
380
+ return t('Enter name or login id');
381
+ }
382
+ }
324
383
  }, {
325
384
  key: "render",
326
385
  value: function render() {
327
386
  var _this$state = this.state,
328
387
  inputValue = _this$state.inputValue,
329
388
  isShowingOptions = _this$state.isShowingOptions;
330
- var placeholder = this.props.searchType === SHARED_WITH_COURSE ? t('Enter course name or course id') : t('Enter name or login id');
331
389
  return /*#__PURE__*/React.createElement(Select, {
332
390
  "data-automation": "sdk-item-bank-share-input",
333
391
  renderLabel: t('Share With'),
334
- placeholder: placeholder,
392
+ placeholder: this.placeholder(),
335
393
  inputValue: inputValue,
336
394
  isShowingOptions: isShowingOptions,
337
395
  inputRef: this.setInputRef,
@@ -357,6 +415,7 @@ AsyncSearch.propTypes = {
357
415
  onSelectionChange: PropTypes.func.isRequired,
358
416
  getShareableCourses: PropTypes.func.isRequired,
359
417
  getShareableUsers: PropTypes.func.isRequired,
418
+ getShareableSubaccounts: PropTypes.func.isRequired,
360
419
  searchType: PropTypes.string,
361
420
  selectedOption: PropTypes.arrayOf(PropTypes.shape({
362
421
  avatar: PropTypes.string,
@@ -81,7 +81,7 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
81
81
  var size = _this.props.sharedBanks.size;
82
82
 
83
83
  if (size >= 0 && size !== _this.props.bank.sharedCount || size === 0) {
84
- _this.props.getSharedBanks(_this.props.bank, _this.props.getUserInfo, _this.props.getCourseInfo);
84
+ _this.props.getSharedBanks(_this.props.bank, _this.props.getUserInfo, _this.props.getCourseInfo, _this.props.getSubaccountInfo);
85
85
  } else {
86
86
  // eslint-disable-next-line react/no-did-mount-set-state
87
87
  _this.setState({
@@ -253,7 +253,7 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
253
253
  id: entity.uuid,
254
254
  entityType: entity.entityType,
255
255
  entityId: entity.uuid,
256
- title: entity.fullName || entity.title,
256
+ title: entity.fullName || entity.title || entity.name,
257
257
  avatar: entity.avatar,
258
258
  email: entity.email,
259
259
  permission: _this.state.searchPermission
@@ -377,6 +377,7 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
377
377
  }, jsx(Grid.Row, null, jsx(Grid.Col, null, jsx(AsyncSearch, {
378
378
  getShareableCourses: _this.props.getShareableCourses,
379
379
  getShareableUsers: _this.props.getShareableUsers,
380
+ getShareableSubaccounts: _this.props.getShareableSubaccounts,
380
381
  improvedBankSharingEnabled: _this.props.improvedBankSharingEnabled,
381
382
  minChars: _this.props.minChars,
382
383
  onSelectionChange: _this.handleSearchSelectionChange,
@@ -565,6 +566,7 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
565
566
  bank: ImmutablePropTypes.record.isRequired,
566
567
  currentUser: PropTypes.shape({
567
568
  bank_admin: PropTypes.bool,
569
+ can_share_banks_with_subaccounts: PropTypes.bool,
568
570
  email: PropTypes.string,
569
571
  enrollment_names: PropTypes.arrayOf(PropTypes.string),
570
572
  full_name: PropTypes.string,
@@ -578,6 +580,8 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
578
580
  getShareableUsers: PropTypes.func.isRequired,
579
581
  getSharedBanks: PropTypes.func.isRequired,
580
582
  getUserInfo: PropTypes.func.isRequired,
583
+ getShareableSubaccounts: PropTypes.func.isRequired,
584
+ getSubaccountInfo: PropTypes.func.isRequired,
581
585
  improvedBankSharingEnabled: PropTypes.bool,
582
586
  isOpen: PropTypes.bool,
583
587
  minChars: PropTypes.number,
@@ -108,8 +108,10 @@ export var BanksTray = /*#__PURE__*/function (_Component) {
108
108
  getCourseInfo: this.props.getCourseInfo,
109
109
  getCourseAssignments: this.props.getCourseAssignments,
110
110
  getUserInfo: this.props.getUserInfo,
111
+ getSubaccountInfo: this.props.getSubaccountInfo,
111
112
  getShareableCourses: this.props.getShareableCourses,
112
113
  getShareableUsers: this.props.getShareableUsers,
114
+ getShareableSubaccounts: this.props.getShareableSubaccounts,
113
115
  minChars: this.props.minChars,
114
116
  onShare: this.props.onShare,
115
117
  scope: this.props.itemBanksScope
@@ -171,6 +173,7 @@ BanksTray.propTypes = {
171
173
  clear: PropTypes.func.isRequired,
172
174
  currentUser: PropTypes.shape({
173
175
  bank_admin: PropTypes.bool,
176
+ can_share_banks_with_subaccounts: PropTypes.bool,
174
177
  email: PropTypes.string,
175
178
  enrollment_names: PropTypes.arrayOf(PropTypes.string),
176
179
  full_name: PropTypes.string,
@@ -182,6 +185,8 @@ BanksTray.propTypes = {
182
185
  getUserInfo: PropTypes.func,
183
186
  getShareableCourses: PropTypes.func,
184
187
  getShareableUsers: PropTypes.func,
188
+ getShareableSubaccounts: PropTypes.func,
189
+ getSubaccountInfo: PropTypes.func,
185
190
  minChars: PropTypes.number,
186
191
  newActiveBank: PropTypes.func.isRequired,
187
192
  newActiveBankEntry: PropTypes.func.isRequired,
@@ -204,6 +209,8 @@ BanksTray.defaultProps = {
204
209
  currentUser: null,
205
210
  getShareableCourses: null,
206
211
  getShareableUsers: null,
212
+ getShareableSubaccounts: null,
213
+ getSubaccountInfo: null,
207
214
  minChars: void 0,
208
215
  getCourseInfo: null,
209
216
  getCourseAssignments: null,
@@ -274,10 +274,10 @@ var shareBank = function shareBank(_shareBank) {
274
274
  };
275
275
  dispatch((0, _callHandlers.handleShareBankResponse)(sharedBank));
276
276
  });
277
- } else if (_shareBank.entityType === _quizCommon.SHARED_WITH_COURSE) {
277
+ } else {
278
278
  var sharedBank = {
279
279
  id: sharedBankInfo.id,
280
- entityType: _quizCommon.SHARED_WITH_COURSE,
280
+ entityType: _shareBank.entityType,
281
281
  entityId: _shareBank.entityId,
282
282
  title: _shareBank.title,
283
283
  permission: sharedBankInfo.permission,
@@ -326,10 +326,8 @@ var getSharedBank = function getSharedBank(bankId, entityType, entityId) {
326
326
 
327
327
  exports.getSharedBank = getSharedBank;
328
328
 
329
- var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourseInfo) {
329
+ var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourseInfo, getAccountInfo) {
330
330
  var url = "".concat(banksApiEndpoint, "/").concat(bank.id, "/shared_banks");
331
- var userSharedBanks = [];
332
- var courseSharedBanks = [];
333
331
  return function (dispatch, getState) {
334
332
  var fetcher = new _Fetcher.default({
335
333
  onError: (0, _helpers.handleError)(dispatch, (0, _formatMessage.default)('Failed to fetch shared banks.'))
@@ -344,8 +342,10 @@ var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourseInfo) {
344
342
  permission: _quizCommon.CAN_EDIT,
345
343
  bank_id: bank.id
346
344
  });
347
- }
345
+ } // USERS
346
+
348
347
 
348
+ var userSharedBanks = [];
349
349
  var userUuids = sharedBanksInfo.filter(function (sb) {
350
350
  return sb.entity_type === _quizCommon.SHARED_WITH_USER;
351
351
  }).map(function (sb) {
@@ -370,7 +370,9 @@ var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourseInfo) {
370
370
  }
371
371
  });
372
372
  dispatch((0, _callHandlers.handleShareBanksResponse)(userSharedBanks));
373
- });
373
+ }); // COURSES
374
+
375
+ var courseSharedBanks = [];
374
376
  var courseUuids = sharedBanksInfo.filter(function (sb) {
375
377
  return sb.entity_type === _quizCommon.SHARED_WITH_COURSE;
376
378
  }).map(function (sb) {
@@ -394,6 +396,32 @@ var getSharedBanks = function getSharedBanks(bank, getUserInfo, getCourseInfo) {
394
396
  }
395
397
  });
396
398
  dispatch((0, _callHandlers.handleShareBanksResponse)(courseSharedBanks));
399
+ }); // ACCOUNTS
400
+
401
+ var accountSharedBanks = [];
402
+ var accountUuids = sharedBanksInfo.filter(function (sb) {
403
+ return sb.entity_type === _quizCommon.SHARED_WITH_ACCOUNT;
404
+ }).map(function (sb) {
405
+ return sb.entity_id;
406
+ });
407
+ getAccountInfo(accountUuids).then(function (accountsInfo) {
408
+ accountsInfo.forEach(function (accountInfo) {
409
+ var sharedBankInfo = sharedBanksInfo.find(function (sb) {
410
+ return sb.entity_type === _quizCommon.SHARED_WITH_ACCOUNT && sb.entity_id === accountInfo.uuid;
411
+ });
412
+
413
+ if (sharedBankInfo) {
414
+ accountSharedBanks.push({
415
+ id: sharedBankInfo.id,
416
+ entityType: sharedBankInfo.entity_type,
417
+ entityId: sharedBankInfo.entity_id,
418
+ title: accountInfo.name,
419
+ permission: sharedBankInfo.permission,
420
+ bankId: sharedBankInfo.bank_id
421
+ });
422
+ }
423
+ });
424
+ dispatch((0, _callHandlers.handleShareBanksResponse)(accountSharedBanks));
397
425
  });
398
426
  });
399
427
  };
@@ -208,8 +208,10 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
208
208
  focusCreateBankButton: _this.focusCreateBankButton,
209
209
  getCourseInfo: _this.props.getCourseInfo,
210
210
  getUserInfo: _this.props.getUserInfo,
211
+ getSubaccountInfo: _this.props.getSubaccountInfo,
211
212
  getShareableCourses: _this.props.getShareableCourses,
212
213
  getShareableUsers: _this.props.getShareableUsers,
214
+ getShareableSubaccounts: _this.props.getShareableSubaccounts,
213
215
  isCompact: _this.props.isCompact,
214
216
  itemBankSearchTableEnabled: _this.props.itemBankSearchTableEnabled,
215
217
  minChars: _this.props.minChars,
@@ -436,6 +438,7 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
436
438
  createBank: _propTypes.default.func.isRequired,
437
439
  currentUser: _propTypes.default.shape({
438
440
  bank_admin: _propTypes.default.bool,
441
+ can_share_banks_with_subaccounts: _propTypes.default.bool,
439
442
  email: _propTypes.default.string,
440
443
  enrollment_names: _propTypes.default.arrayOf(_propTypes.default.string),
441
444
  full_name: _propTypes.default.string,
@@ -453,7 +456,11 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
453
456
  getShareableCourses: _propTypes.default.func,
454
457
  // from consumer
455
458
  getShareableUsers: _propTypes.default.func,
456
- // from consumer,
459
+ // from consumer
460
+ getShareableSubaccounts: _propTypes.default.func,
461
+ // from consumer
462
+ getSubaccountInfo: _propTypes.default.func,
463
+ // from consumer
457
464
  getCourseAssignments: _propTypes.default.func,
458
465
  // from consumer
459
466
  isCompact: _propTypes.default.bool,
@@ -490,6 +497,8 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
490
497
  getShareableCourses: null,
491
498
  getShareableUsers: null,
492
499
  getCourseAssignments: null,
500
+ getShareableSubaccounts: null,
501
+ getSubaccountInfo: null,
493
502
  minChars: void 0,
494
503
  isCompact: false,
495
504
  navigateToBuild: null,
@@ -434,6 +434,7 @@ var BanksList = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
434
434
  focusCreateBankButton: this.props.focusCreateBankButton,
435
435
  getCourseInfo: this.props.getCourseInfo,
436
436
  getUserInfo: this.props.getUserInfo,
437
+ getSubaccountInfo: this.props.getSubaccountInfo,
437
438
  isOpen: this.state.sharingModalOpen,
438
439
  minChars: this.props.minChars,
439
440
  modalTrigger: this.sharingButtons[this.state.sharingModalBank.id],
@@ -441,6 +442,7 @@ var BanksList = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
441
442
  onShare: this.props.onShare,
442
443
  getShareableCourses: this.props.getShareableCourses,
443
444
  getShareableUsers: this.props.getShareableUsers,
445
+ getShareableSubaccounts: this.props.getShareableSubaccounts,
444
446
  updateSharedCount: this.updateSharedCount
445
447
  });
446
448
  }
@@ -544,6 +546,7 @@ var BanksList = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
544
546
  createBankCloneJob: _propTypes.default.func.isRequired,
545
547
  currentUser: _propTypes.default.shape({
546
548
  bank_admin: _propTypes.default.bool,
549
+ can_share_banks_with_subaccounts: _propTypes.default.bool,
547
550
  email: _propTypes.default.string,
548
551
  enrollment_names: _propTypes.default.arrayOf(_propTypes.default.string),
549
552
  full_name: _propTypes.default.string,
@@ -557,6 +560,7 @@ var BanksList = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
557
560
  getUserInfo: _propTypes.default.func,
558
561
  getShareableCourses: _propTypes.default.func,
559
562
  getShareableUsers: _propTypes.default.func,
563
+ getShareableSubaccounts: _propTypes.default.func,
560
564
  minChars: _propTypes.default.number,
561
565
  navigateToBank: _propTypes.default.func.isRequired,
562
566
  onShare: _propTypes.default.func,
@@ -572,6 +576,7 @@ var BanksList = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
572
576
  getUserInfo: null,
573
577
  getShareableCourses: null,
574
578
  getShareableUsers: null,
579
+ getShareableSubaccounts: null,
575
580
  minChars: void 0,
576
581
  locale: null,
577
582
  timezone: null,
@@ -178,11 +178,10 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
178
178
  }, {
179
179
  key: "render",
180
180
  value: function render() {
181
- var _this$props$currentUs;
182
-
183
181
  var _this$props = this.props,
184
182
  shares = _this$props.shares,
185
- subAccountBankSharingEnabled = _this$props.subAccountBankSharingEnabled;
183
+ subAccountBankSharingEnabled = _this$props.subAccountBankSharingEnabled,
184
+ currentUser = _this$props.currentUser;
186
185
  var newEntityIds = this.props.newEntities.map(function (e) {
187
186
  return e.get('id');
188
187
  });
@@ -195,6 +194,9 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
195
194
  var existingCourses = existingShares.filter(function (s) {
196
195
  return s.get('entityType') === _quizCommon.SHARED_WITH_COURSE;
197
196
  });
197
+ var existingAccounts = existingShares.filter(function (s) {
198
+ return s.get('entityType') === _quizCommon.SHARED_WITH_ACCOUNT;
199
+ });
198
200
  return (0, _emotion.jsx)("div", {
199
201
  className: "fs-mask"
200
202
  }, !subAccountBankSharingEnabled && (0, _emotion.jsx)(_uiText.Text, {
@@ -229,16 +231,24 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
229
231
  lineHeight: "double"
230
232
  }, (0, _formatMessage.default)('Currently shared with')), (0, _emotion.jsx)(_uiGrid.Grid, {
231
233
  vAlign: "middle"
232
- }, existingCourses.map(this.renderEntity))), subAccountBankSharingEnabled && (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
233
- renderTitle: (0, _formatMessage.default)('Accounts'),
234
+ }, existingCourses.map(this.renderEntity))), subAccountBankSharingEnabled && ((currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) || (currentUser === null || currentUser === void 0 ? void 0 : currentUser.can_share_banks_with_subaccounts)) && (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
235
+ renderTitle: (0, _formatMessage.default)('Accounts ({ accountsCount })', {
236
+ accountsCount: existingAccounts.size
237
+ }),
234
238
  isSelected: this.state.selectedTabIndex === 2,
235
239
  padding: "large small small small"
236
- }, ((_this$props$currentUs = this.props.currentUser) === null || _this$props$currentUs === void 0 ? void 0 : _this$props$currentUs.bank_admin) && (0, _emotion.jsx)(_RootAccountSharing.default, {
240
+ }, (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) && (0, _emotion.jsx)(_RootAccountSharing.default, {
237
241
  accountName: this.props.accountName,
238
242
  onShareChange: this.props.onToggleAccountShare,
239
243
  onShareTypeChange: this.props.onAccountPermissionChange,
240
244
  accountPermission: this.props.accountPermission
241
- })))));
245
+ }), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.can_share_banks_with_subaccounts) && this.props.renderSearchSection(_quizCommon.SHARED_WITH_ACCOUNT), (0, _emotion.jsx)(_uiText.Text, {
246
+ as: "div",
247
+ weight: "bold",
248
+ lineHeight: "double"
249
+ }, (0, _formatMessage.default)('Currently shared with')), (0, _emotion.jsx)(_uiGrid.Grid, {
250
+ vAlign: "middle"
251
+ }, existingAccounts.map(this.renderEntity))))));
242
252
  }
243
253
  }]);
244
254
  ShareList.displayName = "ShareList";
@@ -246,7 +256,8 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
246
256
  }(_react.Component), _class2.propTypes = {
247
257
  canEdit: _propTypes.default.bool.isRequired,
248
258
  currentUser: _propTypes.default.shape({
249
- bank_admin: _propTypes.default.bool
259
+ bank_admin: _propTypes.default.bool,
260
+ can_share_banks_with_subaccounts: _propTypes.default.bool
250
261
  }),
251
262
  improvedBankSharingEnabled: _propTypes.default.bool.isRequired,
252
263
  newEntities: _reactImmutableProptypes.default.list,
@@ -59,6 +59,7 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
59
59
  isShowingOptions: false,
60
60
  isLoading: false,
61
61
  highlightedOptionId: null,
62
+ shareableSubaccounts: [],
62
63
  shareableCourses: [],
63
64
  shareableUsers: []
64
65
  };
@@ -70,7 +71,7 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
70
71
  };
71
72
 
72
73
  _this.handleHideOptions = function () {
73
- var allOptions = [].concat((0, _toConsumableArray2.default)(_this.filterOptions(_this.state.shareableCourses)), (0, _toConsumableArray2.default)(_this.filterOptions(_this.state.shareableUsers))); // an option matching user input exists
74
+ var allOptions = [].concat((0, _toConsumableArray2.default)(_this.filterOptions(_this.state.shareableSubaccounts)), (0, _toConsumableArray2.default)(_this.filterOptions(_this.state.shareableCourses)), (0, _toConsumableArray2.default)(_this.filterOptions(_this.state.shareableUsers))); // an option matching user input exists
74
75
 
75
76
  if (allOptions.length === 1) {
76
77
  var onlyOption = allOptions[0]; // automatically select the matching option
@@ -191,7 +192,8 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
191
192
 
192
193
  _this.search = (0, _debounce.default)(_this.props.debounceDelay, function (value) {
193
194
  var shouldSearchPeople = !_this.props.searchType || _this.props.searchType === _quizCommon.SHARED_WITH_USER;
194
- var shouldSearchCourses = !_this.props.searchType || _this.props.searchType === _quizCommon.SHARED_WITH_COURSE; // TODO add the promise cancellation for avoiding having disordered requests
195
+ var shouldSearchCourses = !_this.props.searchType || _this.props.searchType === _quizCommon.SHARED_WITH_COURSE;
196
+ var shouldSearchSubaccounts = _this.props.searchType === _quizCommon.SHARED_WITH_ACCOUNT; // TODO add the promise cancellation for avoiding having disordered requests
195
197
 
196
198
  if (shouldSearchPeople) {
197
199
  _this.props.getShareableUsers(value).then(function (shareableUsers) {
@@ -216,6 +218,18 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
216
218
  });
217
219
  });
218
220
  }
221
+
222
+ if (shouldSearchSubaccounts) {
223
+ _this.props.getShareableSubaccounts(value).then(function (shareableSubaccounts) {
224
+ var filteredAccounts = _this.filterOptions(shareableSubaccounts);
225
+
226
+ _this.setState({
227
+ shareableSubaccounts: shareableSubaccounts,
228
+ highlightedOptionId: filteredAccounts.length ? filteredAccounts[0].uuid : _this.state.highlightedOptionId,
229
+ isLoading: false
230
+ });
231
+ });
232
+ }
219
233
  });
220
234
  return _this;
221
235
  }
@@ -243,6 +257,16 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
243
257
  });
244
258
  }
245
259
 
260
+ var account = (0, _find.default)({
261
+ uuid: id
262
+ }, this.state.shareableSubaccounts);
263
+
264
+ if (account) {
265
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, account), {}, {
266
+ entityType: _quizCommon.SHARED_WITH_ACCOUNT
267
+ });
268
+ }
269
+
246
270
  return (0, _find.default)({
247
271
  uuid: id
248
272
  }, this.props.selectedOption);
@@ -257,7 +281,7 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
257
281
  key: option.uuid,
258
282
  id: option.uuid,
259
283
  index: index,
260
- text: option.fullName || option.title,
284
+ text: option.fullName || option.title || option.name,
261
285
  onClick: _this2.dismissTag
262
286
  });
263
287
  });
@@ -309,6 +333,24 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
309
333
  }, course.title);
310
334
  }));
311
335
  }
336
+ }, {
337
+ key: "renderSubaccountsOptions",
338
+ value: function renderSubaccountsOptions(subaccounts) {
339
+ var _this6 = this;
340
+
341
+ return /*#__PURE__*/_react.default.createElement(_uiSelect.Select.Group, {
342
+ key: _quizCommon.SHARED_WITH_ACCOUNT,
343
+ renderLabel: (0, _formatMessage.default)('Accounts')
344
+ }, subaccounts.map(function (subaccount) {
345
+ return /*#__PURE__*/_react.default.createElement(_uiSelect.Select.Option, {
346
+ // eslint-disable-next-line react/jsx-no-literals
347
+ "data-automation": "sdk-item-bank-option-subaccount-".concat(subaccount.uuid),
348
+ id: subaccount.uuid,
349
+ key: subaccount.uuid,
350
+ isHighlighted: subaccount.uuid === _this6.state.highlightedOptionId
351
+ }, subaccount.name);
352
+ }));
353
+ }
312
354
  }, {
313
355
  key: "emptyOption",
314
356
  value: function emptyOption() {
@@ -338,6 +380,12 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
338
380
  groups.push(this.renderCoursesOptions(courses));
339
381
  }
340
382
 
383
+ var subaccounts = this.filterOptions(this.state.shareableSubaccounts);
384
+
385
+ if (subaccounts.length) {
386
+ groups.push(this.renderSubaccountsOptions(subaccounts));
387
+ }
388
+
341
389
  return groups.length ? groups : /*#__PURE__*/_react.default.createElement(_uiSelect.Select.Option, {
342
390
  id: _quizCommon.SELECT_EMPTY_OPTION,
343
391
  key: _quizCommon.SELECT_EMPTY_OPTION
@@ -346,17 +394,27 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
346
394
  size: "x-small"
347
395
  }) : this.emptyOption());
348
396
  }
397
+ }, {
398
+ key: "placeholder",
399
+ value: function placeholder() {
400
+ if (this.props.searchType === _quizCommon.SHARED_WITH_ACCOUNT) {
401
+ return (0, _formatMessage.default)('Enter subaccount name');
402
+ } else if (this.props.searchType === _quizCommon.SHARED_WITH_COURSE) {
403
+ return (0, _formatMessage.default)('Enter course name or course id');
404
+ } else {
405
+ return (0, _formatMessage.default)('Enter name or login id');
406
+ }
407
+ }
349
408
  }, {
350
409
  key: "render",
351
410
  value: function render() {
352
411
  var _this$state = this.state,
353
412
  inputValue = _this$state.inputValue,
354
413
  isShowingOptions = _this$state.isShowingOptions;
355
- 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');
356
414
  return /*#__PURE__*/_react.default.createElement(_uiSelect.Select, {
357
415
  "data-automation": "sdk-item-bank-share-input",
358
416
  renderLabel: (0, _formatMessage.default)('Share With'),
359
- placeholder: placeholder,
417
+ placeholder: this.placeholder(),
360
418
  inputValue: inputValue,
361
419
  isShowingOptions: isShowingOptions,
362
420
  inputRef: this.setInputRef,
@@ -383,6 +441,7 @@ AsyncSearch.propTypes = {
383
441
  onSelectionChange: _propTypes.default.func.isRequired,
384
442
  getShareableCourses: _propTypes.default.func.isRequired,
385
443
  getShareableUsers: _propTypes.default.func.isRequired,
444
+ getShareableSubaccounts: _propTypes.default.func.isRequired,
386
445
  searchType: _propTypes.default.string,
387
446
  selectedOption: _propTypes.default.arrayOf(_propTypes.default.shape({
388
447
  avatar: _propTypes.default.string,
@@ -119,7 +119,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
119
119
  var size = _this.props.sharedBanks.size;
120
120
 
121
121
  if (size >= 0 && size !== _this.props.bank.sharedCount || size === 0) {
122
- _this.props.getSharedBanks(_this.props.bank, _this.props.getUserInfo, _this.props.getCourseInfo);
122
+ _this.props.getSharedBanks(_this.props.bank, _this.props.getUserInfo, _this.props.getCourseInfo, _this.props.getSubaccountInfo);
123
123
  } else {
124
124
  // eslint-disable-next-line react/no-did-mount-set-state
125
125
  _this.setState({
@@ -291,7 +291,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
291
291
  id: entity.uuid,
292
292
  entityType: entity.entityType,
293
293
  entityId: entity.uuid,
294
- title: entity.fullName || entity.title,
294
+ title: entity.fullName || entity.title || entity.name,
295
295
  avatar: entity.avatar,
296
296
  email: entity.email,
297
297
  permission: _this.state.searchPermission
@@ -415,6 +415,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
415
415
  }, (0, _emotion.jsx)(_uiGrid.Grid.Row, null, (0, _emotion.jsx)(_uiGrid.Grid.Col, null, (0, _emotion.jsx)(_asyncSearch.default, {
416
416
  getShareableCourses: _this.props.getShareableCourses,
417
417
  getShareableUsers: _this.props.getShareableUsers,
418
+ getShareableSubaccounts: _this.props.getShareableSubaccounts,
418
419
  improvedBankSharingEnabled: _this.props.improvedBankSharingEnabled,
419
420
  minChars: _this.props.minChars,
420
421
  onSelectionChange: _this.handleSearchSelectionChange,
@@ -602,6 +603,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
602
603
  bank: _reactImmutableProptypes.default.record.isRequired,
603
604
  currentUser: _propTypes.default.shape({
604
605
  bank_admin: _propTypes.default.bool,
606
+ can_share_banks_with_subaccounts: _propTypes.default.bool,
605
607
  email: _propTypes.default.string,
606
608
  enrollment_names: _propTypes.default.arrayOf(_propTypes.default.string),
607
609
  full_name: _propTypes.default.string,
@@ -615,6 +617,8 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
615
617
  getShareableUsers: _propTypes.default.func.isRequired,
616
618
  getSharedBanks: _propTypes.default.func.isRequired,
617
619
  getUserInfo: _propTypes.default.func.isRequired,
620
+ getShareableSubaccounts: _propTypes.default.func.isRequired,
621
+ getSubaccountInfo: _propTypes.default.func.isRequired,
618
622
  improvedBankSharingEnabled: _propTypes.default.bool,
619
623
  isOpen: _propTypes.default.bool,
620
624
  minChars: _propTypes.default.number,
@@ -136,8 +136,10 @@ var BanksTray = /*#__PURE__*/function (_Component) {
136
136
  getCourseInfo: this.props.getCourseInfo,
137
137
  getCourseAssignments: this.props.getCourseAssignments,
138
138
  getUserInfo: this.props.getUserInfo,
139
+ getSubaccountInfo: this.props.getSubaccountInfo,
139
140
  getShareableCourses: this.props.getShareableCourses,
140
141
  getShareableUsers: this.props.getShareableUsers,
142
+ getShareableSubaccounts: this.props.getShareableSubaccounts,
141
143
  minChars: this.props.minChars,
142
144
  onShare: this.props.onShare,
143
145
  scope: this.props.itemBanksScope
@@ -200,6 +202,7 @@ BanksTray.propTypes = {
200
202
  clear: _propTypes.default.func.isRequired,
201
203
  currentUser: _propTypes.default.shape({
202
204
  bank_admin: _propTypes.default.bool,
205
+ can_share_banks_with_subaccounts: _propTypes.default.bool,
203
206
  email: _propTypes.default.string,
204
207
  enrollment_names: _propTypes.default.arrayOf(_propTypes.default.string),
205
208
  full_name: _propTypes.default.string,
@@ -211,6 +214,8 @@ BanksTray.propTypes = {
211
214
  getUserInfo: _propTypes.default.func,
212
215
  getShareableCourses: _propTypes.default.func,
213
216
  getShareableUsers: _propTypes.default.func,
217
+ getShareableSubaccounts: _propTypes.default.func,
218
+ getSubaccountInfo: _propTypes.default.func,
214
219
  minChars: _propTypes.default.number,
215
220
  newActiveBank: _propTypes.default.func.isRequired,
216
221
  newActiveBankEntry: _propTypes.default.func.isRequired,
@@ -233,6 +238,8 @@ BanksTray.defaultProps = {
233
238
  currentUser: null,
234
239
  getShareableCourses: null,
235
240
  getShareableUsers: null,
241
+ getShareableSubaccounts: null,
242
+ getSubaccountInfo: null,
236
243
  minChars: void 0,
237
244
  getCourseInfo: null,
238
245
  getCourseAssignments: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.8.0",
3
+ "version": "20.8.1-rc.0+7ddfe123f",
4
4
  "license": "MIT",
5
5
  "description": "The Quiz React SDK by Instructure Inc.",
6
6
  "author": "Instructure, Inc. Engineering and Product Design",
@@ -44,11 +44,11 @@
44
44
  "@instructure/emotion": "^8.51.0",
45
45
  "@instructure/grading-utils": "^1.0.0",
46
46
  "@instructure/outcomes-ui": "^3.1.0",
47
- "@instructure/quiz-common": "^20.8.0",
48
- "@instructure/quiz-i18n": "^20.8.0",
49
- "@instructure/quiz-interactions": "^20.8.0",
50
- "@instructure/quiz-number-input": "^20.8.0",
51
- "@instructure/quiz-rce": "^20.8.0",
47
+ "@instructure/quiz-common": "20.8.1-rc.0+7ddfe123f",
48
+ "@instructure/quiz-i18n": "20.8.1-rc.0+7ddfe123f",
49
+ "@instructure/quiz-interactions": "20.8.1-rc.0+7ddfe123f",
50
+ "@instructure/quiz-number-input": "20.8.1-rc.0+7ddfe123f",
51
+ "@instructure/quiz-rce": "20.8.1-rc.0+7ddfe123f",
52
52
  "@instructure/ui-a11y-content": "^8.51.0",
53
53
  "@instructure/ui-alerts": "^8.51.0",
54
54
  "@instructure/ui-avatar": "^8.51.0",
@@ -112,7 +112,7 @@
112
112
  "file-saver": "~2.0.5",
113
113
  "humps": "^2.0.0",
114
114
  "immutable": "^3.8.1",
115
- "instructure-validations": "^20.8.0",
115
+ "instructure-validations": "20.8.1-rc.0+7ddfe123f",
116
116
  "ipaddr.js": "^1.5.4",
117
117
  "isomorphic-fetch": "^2.2.0",
118
118
  "isuuid": "^0.1.0",
@@ -143,7 +143,7 @@
143
143
  "uuid": "^3.2.1"
144
144
  },
145
145
  "devDependencies": {
146
- "@instructure/quiz-scripts": "^20.8.0",
146
+ "@instructure/quiz-scripts": "20.8.0",
147
147
  "@instructure/ui-axe-check": "^8.51.0",
148
148
  "@instructure/ui-babel-preset": "^7.22.1",
149
149
  "@instructure/ui-karma-config": "^7.22.1",
@@ -163,7 +163,7 @@
163
163
  "intl": "^1.2.4",
164
164
  "jquery": "^2.2.3",
165
165
  "most-subject": "^5.3.0",
166
- "quiz-presets": "^20.8.0",
166
+ "quiz-presets": "20.8.1-rc.0+7ddfe123f",
167
167
  "react": "^16.8.6",
168
168
  "react-addons-test-utils": "^15.6.2",
169
169
  "react-dom": "^16.8.6",
@@ -179,5 +179,5 @@
179
179
  "publishConfig": {
180
180
  "access": "public"
181
181
  },
182
- "gitHead": "18da7f69fb9bae61a56a7794b7a9e935fb9a8340"
182
+ "gitHead": "7ddfe123f7affbad1dc83267ac782ef96b1b24c0"
183
183
  }