@instructure/quiz-core 20.9.1-rc.5 → 20.9.1-rc.7

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.
@@ -51,9 +51,9 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
51
51
  if (allOptions.length === 1) {
52
52
  var onlyOption = allOptions[0]; // automatically select the matching option
53
53
 
54
- var label = onlyOption.label || onlyOption.fullName;
54
+ var label = onlyOption.label || onlyOption.fullName || onlyOption.title || onlyOption.name;
55
55
 
56
- if (label.toLowerCase() === _this.state.inputValue.toLowerCase()) {
56
+ if (label && label.toLowerCase() === _this.state.inputValue.toLowerCase()) {
57
57
  _this.changeSelectedOption([].concat(_toConsumableArray(_this.props.selectedOption.map(function (option) {
58
58
  return option.uuid;
59
59
  })), [onlyOption.uuid]));
@@ -372,6 +372,10 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
372
372
  }, {
373
373
  key: "placeholder",
374
374
  value: function placeholder() {
375
+ if (this.props.placeholderLabel) {
376
+ return this.props.placeholderLabel;
377
+ }
378
+
375
379
  if (this.props.searchType === SHARED_WITH_ACCOUNT) {
376
380
  return t('Enter subaccount name');
377
381
  } else if (this.props.searchType === SHARED_WITH_COURSE) {
@@ -388,7 +392,7 @@ export var AsyncSearch = /*#__PURE__*/function (_Component) {
388
392
  isShowingOptions = _this$state.isShowingOptions;
389
393
  return /*#__PURE__*/React.createElement(Select, {
390
394
  "data-automation": "sdk-item-bank-share-input",
391
- renderLabel: t('Share With'),
395
+ renderLabel: this.props.searchLabel,
392
396
  placeholder: this.placeholder(),
393
397
  inputValue: inputValue,
394
398
  isShowingOptions: isShowingOptions,
@@ -413,9 +417,9 @@ AsyncSearch.propTypes = {
413
417
  improvedBankSharingEnabled: PropTypes.bool.isRequired,
414
418
  minChars: PropTypes.number,
415
419
  onSelectionChange: PropTypes.func.isRequired,
416
- getShareableCourses: PropTypes.func.isRequired,
417
- getShareableUsers: PropTypes.func.isRequired,
418
- getShareableSubaccounts: PropTypes.func.isRequired,
420
+ getShareableCourses: PropTypes.func,
421
+ getShareableUsers: PropTypes.func,
422
+ getShareableSubaccounts: PropTypes.func,
419
423
  searchType: PropTypes.string,
420
424
  selectedOption: PropTypes.arrayOf(PropTypes.shape({
421
425
  avatar: PropTypes.string,
@@ -423,7 +427,9 @@ AsyncSearch.propTypes = {
423
427
  title: PropTypes.string,
424
428
  uuid: PropTypes.string.isRequired
425
429
  })).isRequired,
426
- selectionFilter: PropTypes.func
430
+ selectionFilter: PropTypes.func,
431
+ searchLabel: PropTypes.string,
432
+ placeholderLabel: PropTypes.string
427
433
  };
428
434
  AsyncSearch.defaultProps = {
429
435
  debounceDelay: 500,
@@ -431,6 +437,11 @@ AsyncSearch.defaultProps = {
431
437
  searchType: null,
432
438
  selectionFilter: function selectionFilter(value) {
433
439
  return value;
434
- }
440
+ },
441
+ getShareableCourses: null,
442
+ getShareableUsers: null,
443
+ getShareableSubaccounts: null,
444
+ searchLabel: t('Share With'),
445
+ placeholder: null
435
446
  };
436
447
  export default AsyncSearch;
@@ -1,7 +1,7 @@
1
1
  import { bindActionCreators } from 'redux';
2
2
  import { Map } from 'immutable';
3
3
  import { Banks as BanksPresenter } from "./presenter.js";
4
- import { clear, merge } from "../../../common/actions/ui.js";
4
+ import { set as setUI, clear, merge } from "../../../common/actions/ui.js";
5
5
  import { connect } from "../../../common/react-redux.js";
6
6
  import { getBanks } from "../../../banks/api/banks.js";
7
7
  import * as modalActions from "../../../common/actions/modal.js";
@@ -15,15 +15,18 @@ function mapStateToProps(state, props) {
15
15
  var sortBy = pageData.get('sortBy', 'name');
16
16
  var sortOrder = pageData.get('sortOrder', 'ascending');
17
17
  var searchTerms = pageData.get('searchTerms', null);
18
+ var searchSelection = pageData.get('searchSelection', []);
18
19
  return {
19
20
  itemBankSearchTableEnabled: featureOn('item_bank_search_table'),
20
- filtersEnabled: featureOn('improved_bank_sharing'),
21
+ improvedBankSharingEnabled: featureOn('improved_bank_sharing'),
21
22
  newItemBankFilterNamesEnabled: featureOn('new_item_bank_filter_names'),
22
23
  usedByCourseEnabled: featureOn('filter_item_banks_used_by_course'),
24
+ subAccountBankSharingEnabled: featureOn('sub_account_bank_sharing'),
23
25
  scopeType: scopeType,
24
26
  sortBy: sortBy,
25
27
  sortOrder: sortOrder,
26
- searchTerms: searchTerms
28
+ searchTerms: searchTerms,
29
+ searchSelection: searchSelection
27
30
  };
28
31
  }
29
32
 
@@ -33,7 +36,8 @@ function mapDispatchToProps(dispatch) {
33
36
  getBanks: bindActionCreators(getBanks, dispatch),
34
37
  openModal: bindActionCreators(modalActions.openModal, dispatch),
35
38
  clear: bindActionCreators(clear, dispatch),
36
- merge: bindActionCreators(merge, dispatch)
39
+ merge: bindActionCreators(merge, dispatch),
40
+ setUI: bindActionCreators(setUI, dispatch)
37
41
  };
38
42
  }
39
43
 
@@ -9,6 +9,7 @@ var _dec, _class, _class2, _temp;
9
9
  /** @jsx jsx */
10
10
  import React, { Component } from 'react';
11
11
  import PropTypes from 'prop-types';
12
+ import isEqual from 'lodash/isEqual';
12
13
  import { Heading } from '@instructure/ui-heading';
13
14
  import { Img } from '@instructure/ui-img';
14
15
  import { AccessibleContent, ScreenReaderContent } from '@instructure/ui-a11y-content';
@@ -18,17 +19,20 @@ import { Button } from '@instructure/ui-buttons';
18
19
  import { TextInput } from '@instructure/ui-text-input';
19
20
  import { SimpleSelect } from '@instructure/ui-simple-select';
20
21
  import { withStyle, jsx } from '@instructure/emotion';
22
+ import { Grid } from '@instructure/ui-grid';
23
+ import { View } from '@instructure/ui-view';
21
24
  import debounce from 'lodash/fp/debounce';
22
25
  import Page from "../../../common/components/layout/Page/index.js";
23
26
  import PaginatedCollection from "../../../common/components/shared/PaginatedCollection/index.js";
24
27
  import t from '@instructure/quiz-i18n/es/format-message';
25
- import { BANKS_BANK_FILTERS, BANKS_BANK_PAGINATION, CREATE_BANK_MODAL } from '@instructure/quiz-common';
28
+ import { BANKS_BANK_FILTERS, BANKS_BANK_PAGINATION, CREATE_BANK_MODAL, SHARED_WITH_ACCOUNT } from '@instructure/quiz-common';
26
29
  import BanksList from "../../../banks/components/BanksList/index.js";
27
30
  import CreateBankModal from "../../../banks/components/CreateBankModal/index.js";
28
31
  import NavWrapper from "../NavWrapper/index.js";
29
32
  import noResults from '../noResults.svg';
30
33
  import generateStyle from "./styles.js";
31
34
  import generateComponentTheme from "./theme.js";
35
+ import AsyncSearch from "../AsyncSearch/index.js";
32
36
  var sortOrderIcons = {
33
37
  ascending: IconArrowUpLine,
34
38
  descending: IconArrowDownLine
@@ -89,6 +93,12 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
89
93
  params['search'] = _this.props.searchTerms;
90
94
  }
91
95
 
96
+ if (_this.props.searchSelection.length > 0) {
97
+ params['account_uuids'] = _this.props.searchSelection.map(function (account) {
98
+ return account.uuid;
99
+ });
100
+ }
101
+
92
102
  return params;
93
103
  };
94
104
 
@@ -166,6 +176,10 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
166
176
  _this.search(value);
167
177
  };
168
178
 
179
+ _this.handleSearchSelectionChange = function (searchSelection) {
180
+ _this.props.setUI([BANKS_BANK_FILTERS, 'searchSelection'], searchSelection);
181
+ };
182
+
169
183
  _this.renderRecords = function (recordIds) {
170
184
  return jsx(BanksList, {
171
185
  createBankButton: _this.createBankButton,
@@ -190,7 +204,7 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
190
204
  };
191
205
 
192
206
  _this.emptyPage = function () {
193
- if (_this.props.searchTerms) {
207
+ if (_this.props.searchTerms || _this.props.searchSelection.length > 0) {
194
208
  var message;
195
209
 
196
210
  if (_this.props.scopeType === 'course') {
@@ -224,7 +238,7 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
224
238
  _createClass(Banks, [{
225
239
  key: "componentDidUpdate",
226
240
  value: function componentDidUpdate(prevProps, prevState) {
227
- if (prevProps.sortBy !== this.props.sortBy || prevProps.sortOrder !== this.props.sortOrder || prevProps.searchTerms !== this.props.searchTerms || prevProps.scopeType !== this.props.scopeType) {
241
+ if (prevProps.sortBy !== this.props.sortBy || prevProps.sortOrder !== this.props.sortOrder || prevProps.searchTerms !== this.props.searchTerms || prevProps.scopeType !== this.props.scopeType || !isEqual(prevProps.searchSelection, this.props.searchSelection)) {
228
242
  this.props.clear(BANKS_BANK_PAGINATION);
229
243
  }
230
244
  }
@@ -269,12 +283,20 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
269
283
  display: false
270
284
  }];
271
285
  var searchFiltersSelectOptionIdPrefix = 'banks-search-filters-select-option-';
272
- var searchFilters = jsx(React.Fragment, null, jsx("div", {
273
- display: "inline-block"
286
+ var searchFilters = jsx(View, {
287
+ as: "div",
288
+ width: "100%"
289
+ }, jsx(Grid, {
290
+ startAt: "medium",
291
+ colSpacing: "small",
292
+ rowSpacing: "small",
293
+ vAlign: "bottom"
294
+ }, jsx(Grid.Row, null, jsx(Grid.Col, {
295
+ width: "auto"
274
296
  }, jsx(SimpleSelect, {
275
297
  onChange: this.handleBanksParentChange,
276
298
  value: this.props.scopeType,
277
- renderLabel: jsx(ScreenReaderContent, null, t('Bank scope')),
299
+ renderLabel: t('Filter By'),
278
300
  width: "13rem"
279
301
  }, scopeOptions.map(function (option) {
280
302
  return jsx(SimpleSelect.Option, {
@@ -282,16 +304,27 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
282
304
  key: option.slug,
283
305
  value: option.slug
284
306
  }, option.translation);
285
- }))), jsx("div", {
286
- css: this.props.styles.searchBarContainer
307
+ }))), jsx(Grid.Col, {
308
+ width: 4
287
309
  }, jsx(TextInput, {
288
- renderLabel: jsx(ScreenReaderContent, null, t('Search...')),
310
+ renderLabel: t('Bank'),
289
311
  type: "search",
290
312
  value: this.state.searchTerms,
291
313
  onChange: this.handleSearchInputChange,
292
- placeholder: t('Search...'),
314
+ placeholder: t('Search Banks'),
293
315
  "data-automation": "sdk-search-bank-textinput"
294
- })));
316
+ })), this.props.subAccountBankSharingEnabled && jsx(Grid.Col, {
317
+ width: 4
318
+ }, jsx(AsyncSearch, {
319
+ getShareableSubaccounts: this.props.getShareableSubaccounts,
320
+ improvedBankSharingEnabled: this.props.improvedBankSharingEnabled,
321
+ minChars: this.props.minChars,
322
+ onSelectionChange: this.handleSearchSelectionChange,
323
+ searchType: SHARED_WITH_ACCOUNT,
324
+ selectedOption: this.props.searchSelection,
325
+ searchLabel: t('Account'),
326
+ placeholderLabel: t('Search Accounts')
327
+ })))));
295
328
  var sortingFiltersSelectOptionIdPrefix = 'banks-sorting-filters-select-option-';
296
329
  var sortingFilters = jsx(React.Fragment, null, jsx("div", {
297
330
  display: "inline-block",
@@ -345,7 +378,7 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
345
378
  key: "renderHeader",
346
379
  value: function renderHeader() {
347
380
  return jsx("div", {
348
- css: [this.props.styles.filters, !this.props.filtersEnabled ? this.props.styles.borderedBottom : {}]
381
+ css: [this.props.styles.filters, !this.props.improvedBankSharingEnabled ? this.props.styles.borderedBottom : {}]
349
382
  }, jsx(Heading, {
350
383
  as: this.props.isCompact ? 'h2' : 'h1',
351
384
  level: "h1"
@@ -391,7 +424,7 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
391
424
  value: function render() {
392
425
  return jsx(Page, null, this.renderNav(), jsx("div", {
393
426
  css: this.props.styles.content
394
- }, this.renderHeader(), this.props.filtersEnabled && this.renderFilters(), this.renderBanksSearchResults(), jsx(CreateBankModal, {
427
+ }, this.renderHeader(), this.props.improvedBankSharingEnabled && this.renderFilters(), this.renderBanksSearchResults(), jsx(CreateBankModal, {
395
428
  itemBanksScope: this.props.scope
396
429
  })));
397
430
  }
@@ -412,8 +445,8 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
412
445
  account_name: PropTypes.string
413
446
  }),
414
447
  // from consumer
415
- clear: PropTypes.func,
416
- filtersEnabled: PropTypes.bool,
448
+ clear: PropTypes.func.isRequired,
449
+ improvedBankSharingEnabled: PropTypes.bool,
417
450
  getBanks: PropTypes.func.isRequired,
418
451
  getCourseInfo: PropTypes.func,
419
452
  // from consumer
@@ -449,10 +482,18 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
449
482
  }).isRequired,
450
483
  scopeType: PropTypes.string,
451
484
  searchTerms: PropTypes.string,
485
+ searchSelection: PropTypes.arrayOf(PropTypes.shape({
486
+ avatar: PropTypes.string,
487
+ fullName: PropTypes.string,
488
+ title: PropTypes.string,
489
+ uuid: PropTypes.string.isRequired
490
+ })),
452
491
  sortBy: PropTypes.string,
453
492
  sortOrder: PropTypes.string,
454
493
  usedByCourseEnabled: PropTypes.bool,
455
494
  itemBankSearchTableEnabled: PropTypes.bool,
495
+ setUI: PropTypes.func.isRequired,
496
+ subAccountBankSharingEnabled: PropTypes.bool,
456
497
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
457
498
  styles: PropTypes.object
458
499
  }, _class2.defaultProps = {
@@ -469,18 +510,18 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
469
510
  isCompact: false,
470
511
  navigateToBuild: null,
471
512
  onShare: function onShare() {},
472
- clear: function clear() {},
473
- merge: function merge() {},
474
513
  scope: {},
475
514
  returnToUrl: null,
476
- filtersEnabled: false,
515
+ improvedBankSharingEnabled: false,
477
516
  scopeType: 'user',
478
517
  sortBy: 'name',
479
518
  sortOrder: 'ascending',
480
519
  searchTerms: null,
520
+ searchSelection: [],
481
521
  newItemBankFilterNamesEnabled: false,
482
522
  usedByCourseEnabled: false,
483
- itemBankSearchTableEnabled: false
523
+ itemBankSearchTableEnabled: false,
524
+ subAccountBankSharingEnabled: false
484
525
  }, _class2.contextTypes = {
485
526
  locale: PropTypes.string
486
527
  }, _temp)) || _class);
@@ -20,11 +20,6 @@ var generateStyle = function generateStyle(componentTheme) {
20
20
  marginTop: '1.5rem',
21
21
  display: 'flex',
22
22
  flexDirection: 'row'
23
- },
24
- searchBarContainer: {
25
- flexGrow: 0.25,
26
- padding: '0 1rem',
27
- display: 'inline-block'
28
23
  }
29
24
  };
30
25
  };
@@ -31,7 +31,7 @@ import { withStyle, jsx } from '@instructure/emotion';
31
31
  import elementsForSelectors from "../../../common/util/ElementsForSelectors.js";
32
32
  import CustomPropTypes from "../../../common/util/CustomPropTypes.js";
33
33
  import ShareList from "./ShareList/index.js";
34
- import AsyncSearch from "./asyncSearch.js";
34
+ import AsyncSearch from "../AsyncSearch/index.js";
35
35
  import Spinner from "../../../common/components/shared/spinner/Spinner.js";
36
36
  import generateStyle from "./styles.js";
37
37
  import generateComponentTheme from "./theme.js";
@@ -20,7 +20,7 @@ export default (function () {
20
20
  return state.mergeDeepIn([action.payload.key], action.payload.value);
21
21
 
22
22
  case SET_UI:
23
- return state.set(action.payload.key, action.payload.value);
23
+ return state.setIn([action.payload.key].flat(), action.payload.value);
24
24
 
25
25
  case TOGGLE_UI:
26
26
  return toggle(state, action.payload);
@@ -76,9 +76,9 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
76
76
  if (allOptions.length === 1) {
77
77
  var onlyOption = allOptions[0]; // automatically select the matching option
78
78
 
79
- var label = onlyOption.label || onlyOption.fullName;
79
+ var label = onlyOption.label || onlyOption.fullName || onlyOption.title || onlyOption.name;
80
80
 
81
- if (label.toLowerCase() === _this.state.inputValue.toLowerCase()) {
81
+ if (label && label.toLowerCase() === _this.state.inputValue.toLowerCase()) {
82
82
  _this.changeSelectedOption([].concat((0, _toConsumableArray2.default)(_this.props.selectedOption.map(function (option) {
83
83
  return option.uuid;
84
84
  })), [onlyOption.uuid]));
@@ -397,6 +397,10 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
397
397
  }, {
398
398
  key: "placeholder",
399
399
  value: function placeholder() {
400
+ if (this.props.placeholderLabel) {
401
+ return this.props.placeholderLabel;
402
+ }
403
+
400
404
  if (this.props.searchType === _quizCommon.SHARED_WITH_ACCOUNT) {
401
405
  return (0, _formatMessage.default)('Enter subaccount name');
402
406
  } else if (this.props.searchType === _quizCommon.SHARED_WITH_COURSE) {
@@ -413,7 +417,7 @@ var AsyncSearch = /*#__PURE__*/function (_Component) {
413
417
  isShowingOptions = _this$state.isShowingOptions;
414
418
  return /*#__PURE__*/_react.default.createElement(_uiSelect.Select, {
415
419
  "data-automation": "sdk-item-bank-share-input",
416
- renderLabel: (0, _formatMessage.default)('Share With'),
420
+ renderLabel: this.props.searchLabel,
417
421
  placeholder: this.placeholder(),
418
422
  inputValue: inputValue,
419
423
  isShowingOptions: isShowingOptions,
@@ -439,9 +443,9 @@ AsyncSearch.propTypes = {
439
443
  improvedBankSharingEnabled: _propTypes.default.bool.isRequired,
440
444
  minChars: _propTypes.default.number,
441
445
  onSelectionChange: _propTypes.default.func.isRequired,
442
- getShareableCourses: _propTypes.default.func.isRequired,
443
- getShareableUsers: _propTypes.default.func.isRequired,
444
- getShareableSubaccounts: _propTypes.default.func.isRequired,
446
+ getShareableCourses: _propTypes.default.func,
447
+ getShareableUsers: _propTypes.default.func,
448
+ getShareableSubaccounts: _propTypes.default.func,
445
449
  searchType: _propTypes.default.string,
446
450
  selectedOption: _propTypes.default.arrayOf(_propTypes.default.shape({
447
451
  avatar: _propTypes.default.string,
@@ -449,7 +453,9 @@ AsyncSearch.propTypes = {
449
453
  title: _propTypes.default.string,
450
454
  uuid: _propTypes.default.string.isRequired
451
455
  })).isRequired,
452
- selectionFilter: _propTypes.default.func
456
+ selectionFilter: _propTypes.default.func,
457
+ searchLabel: _propTypes.default.string,
458
+ placeholderLabel: _propTypes.default.string
453
459
  };
454
460
  AsyncSearch.defaultProps = {
455
461
  debounceDelay: 500,
@@ -457,7 +463,12 @@ AsyncSearch.defaultProps = {
457
463
  searchType: null,
458
464
  selectionFilter: function selectionFilter(value) {
459
465
  return value;
460
- }
466
+ },
467
+ getShareableCourses: null,
468
+ getShareableUsers: null,
469
+ getShareableSubaccounts: null,
470
+ searchLabel: (0, _formatMessage.default)('Share With'),
471
+ placeholder: null
461
472
  };
462
473
  var _default = AsyncSearch;
463
474
  exports.default = _default;
@@ -33,15 +33,18 @@ function mapStateToProps(state, props) {
33
33
  var sortBy = pageData.get('sortBy', 'name');
34
34
  var sortOrder = pageData.get('sortOrder', 'ascending');
35
35
  var searchTerms = pageData.get('searchTerms', null);
36
+ var searchSelection = pageData.get('searchSelection', []);
36
37
  return {
37
38
  itemBankSearchTableEnabled: (0, _featureCheck.featureOn)('item_bank_search_table'),
38
- filtersEnabled: (0, _featureCheck.featureOn)('improved_bank_sharing'),
39
+ improvedBankSharingEnabled: (0, _featureCheck.featureOn)('improved_bank_sharing'),
39
40
  newItemBankFilterNamesEnabled: (0, _featureCheck.featureOn)('new_item_bank_filter_names'),
40
41
  usedByCourseEnabled: (0, _featureCheck.featureOn)('filter_item_banks_used_by_course'),
42
+ subAccountBankSharingEnabled: (0, _featureCheck.featureOn)('sub_account_bank_sharing'),
41
43
  scopeType: scopeType,
42
44
  sortBy: sortBy,
43
45
  sortOrder: sortOrder,
44
- searchTerms: searchTerms
46
+ searchTerms: searchTerms,
47
+ searchSelection: searchSelection
45
48
  };
46
49
  }
47
50
 
@@ -51,7 +54,8 @@ function mapDispatchToProps(dispatch) {
51
54
  getBanks: (0, _redux.bindActionCreators)(_banks.getBanks, dispatch),
52
55
  openModal: (0, _redux.bindActionCreators)(modalActions.openModal, dispatch),
53
56
  clear: (0, _redux.bindActionCreators)(_ui.clear, dispatch),
54
- merge: (0, _redux.bindActionCreators)(_ui.merge, dispatch)
57
+ merge: (0, _redux.bindActionCreators)(_ui.merge, dispatch),
58
+ setUI: (0, _redux.bindActionCreators)(_ui.set, dispatch)
55
59
  };
56
60
  }
57
61
 
@@ -23,6 +23,8 @@ var _react = _interopRequireWildcard(require("react"));
23
23
 
24
24
  var _propTypes = _interopRequireDefault(require("prop-types"));
25
25
 
26
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
27
+
26
28
  var _uiHeading = require("@instructure/ui-heading");
27
29
 
28
30
  var _uiImg = require("@instructure/ui-img");
@@ -41,6 +43,10 @@ var _uiSimpleSelect = require("@instructure/ui-simple-select");
41
43
 
42
44
  var _emotion = require("@instructure/emotion");
43
45
 
46
+ var _uiGrid = require("@instructure/ui-grid");
47
+
48
+ var _uiView = require("@instructure/ui-view");
49
+
44
50
  var _debounce = _interopRequireDefault(require("lodash/fp/debounce"));
45
51
 
46
52
  var _index = _interopRequireDefault(require("../../../common/components/layout/Page/index.js"));
@@ -63,6 +69,8 @@ var _styles = _interopRequireDefault(require("./styles.js"));
63
69
 
64
70
  var _theme = _interopRequireDefault(require("./theme.js"));
65
71
 
72
+ var _index6 = _interopRequireDefault(require("../AsyncSearch/index.js"));
73
+
66
74
  var _dec, _class, _class2, _temp;
67
75
 
68
76
  var sortOrderIcons = {
@@ -124,6 +132,12 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
124
132
  params['search'] = _this.props.searchTerms;
125
133
  }
126
134
 
135
+ if (_this.props.searchSelection.length > 0) {
136
+ params['account_uuids'] = _this.props.searchSelection.map(function (account) {
137
+ return account.uuid;
138
+ });
139
+ }
140
+
127
141
  return params;
128
142
  };
129
143
 
@@ -201,6 +215,10 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
201
215
  _this.search(value);
202
216
  };
203
217
 
218
+ _this.handleSearchSelectionChange = function (searchSelection) {
219
+ _this.props.setUI([_quizCommon.BANKS_BANK_FILTERS, 'searchSelection'], searchSelection);
220
+ };
221
+
204
222
  _this.renderRecords = function (recordIds) {
205
223
  return (0, _emotion.jsx)(_index3.default, {
206
224
  createBankButton: _this.createBankButton,
@@ -225,7 +243,7 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
225
243
  };
226
244
 
227
245
  _this.emptyPage = function () {
228
- if (_this.props.searchTerms) {
246
+ if (_this.props.searchTerms || _this.props.searchSelection.length > 0) {
229
247
  var message;
230
248
 
231
249
  if (_this.props.scopeType === 'course') {
@@ -259,7 +277,7 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
259
277
  (0, _createClass2.default)(Banks, [{
260
278
  key: "componentDidUpdate",
261
279
  value: function componentDidUpdate(prevProps, prevState) {
262
- if (prevProps.sortBy !== this.props.sortBy || prevProps.sortOrder !== this.props.sortOrder || prevProps.searchTerms !== this.props.searchTerms || prevProps.scopeType !== this.props.scopeType) {
280
+ if (prevProps.sortBy !== this.props.sortBy || prevProps.sortOrder !== this.props.sortOrder || prevProps.searchTerms !== this.props.searchTerms || prevProps.scopeType !== this.props.scopeType || !(0, _isEqual.default)(prevProps.searchSelection, this.props.searchSelection)) {
263
281
  this.props.clear(_quizCommon.BANKS_BANK_PAGINATION);
264
282
  }
265
283
  }
@@ -304,12 +322,20 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
304
322
  display: false
305
323
  }];
306
324
  var searchFiltersSelectOptionIdPrefix = 'banks-search-filters-select-option-';
307
- var searchFilters = (0, _emotion.jsx)(_react.default.Fragment, null, (0, _emotion.jsx)("div", {
308
- display: "inline-block"
325
+ var searchFilters = (0, _emotion.jsx)(_uiView.View, {
326
+ as: "div",
327
+ width: "100%"
328
+ }, (0, _emotion.jsx)(_uiGrid.Grid, {
329
+ startAt: "medium",
330
+ colSpacing: "small",
331
+ rowSpacing: "small",
332
+ vAlign: "bottom"
333
+ }, (0, _emotion.jsx)(_uiGrid.Grid.Row, null, (0, _emotion.jsx)(_uiGrid.Grid.Col, {
334
+ width: "auto"
309
335
  }, (0, _emotion.jsx)(_uiSimpleSelect.SimpleSelect, {
310
336
  onChange: this.handleBanksParentChange,
311
337
  value: this.props.scopeType,
312
- renderLabel: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage.default)('Bank scope')),
338
+ renderLabel: (0, _formatMessage.default)('Filter By'),
313
339
  width: "13rem"
314
340
  }, scopeOptions.map(function (option) {
315
341
  return (0, _emotion.jsx)(_uiSimpleSelect.SimpleSelect.Option, {
@@ -317,16 +343,27 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
317
343
  key: option.slug,
318
344
  value: option.slug
319
345
  }, option.translation);
320
- }))), (0, _emotion.jsx)("div", {
321
- css: this.props.styles.searchBarContainer
346
+ }))), (0, _emotion.jsx)(_uiGrid.Grid.Col, {
347
+ width: 4
322
348
  }, (0, _emotion.jsx)(_uiTextInput.TextInput, {
323
- renderLabel: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage.default)('Search...')),
349
+ renderLabel: (0, _formatMessage.default)('Bank'),
324
350
  type: "search",
325
351
  value: this.state.searchTerms,
326
352
  onChange: this.handleSearchInputChange,
327
- placeholder: (0, _formatMessage.default)('Search...'),
353
+ placeholder: (0, _formatMessage.default)('Search Banks'),
328
354
  "data-automation": "sdk-search-bank-textinput"
329
- })));
355
+ })), this.props.subAccountBankSharingEnabled && (0, _emotion.jsx)(_uiGrid.Grid.Col, {
356
+ width: 4
357
+ }, (0, _emotion.jsx)(_index6.default, {
358
+ getShareableSubaccounts: this.props.getShareableSubaccounts,
359
+ improvedBankSharingEnabled: this.props.improvedBankSharingEnabled,
360
+ minChars: this.props.minChars,
361
+ onSelectionChange: this.handleSearchSelectionChange,
362
+ searchType: _quizCommon.SHARED_WITH_ACCOUNT,
363
+ selectedOption: this.props.searchSelection,
364
+ searchLabel: (0, _formatMessage.default)('Account'),
365
+ placeholderLabel: (0, _formatMessage.default)('Search Accounts')
366
+ })))));
330
367
  var sortingFiltersSelectOptionIdPrefix = 'banks-sorting-filters-select-option-';
331
368
  var sortingFilters = (0, _emotion.jsx)(_react.default.Fragment, null, (0, _emotion.jsx)("div", {
332
369
  display: "inline-block",
@@ -380,7 +417,7 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
380
417
  key: "renderHeader",
381
418
  value: function renderHeader() {
382
419
  return (0, _emotion.jsx)("div", {
383
- css: [this.props.styles.filters, !this.props.filtersEnabled ? this.props.styles.borderedBottom : {}]
420
+ css: [this.props.styles.filters, !this.props.improvedBankSharingEnabled ? this.props.styles.borderedBottom : {}]
384
421
  }, (0, _emotion.jsx)(_uiHeading.Heading, {
385
422
  as: this.props.isCompact ? 'h2' : 'h1',
386
423
  level: "h1"
@@ -426,7 +463,7 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
426
463
  value: function render() {
427
464
  return (0, _emotion.jsx)(_index.default, null, this.renderNav(), (0, _emotion.jsx)("div", {
428
465
  css: this.props.styles.content
429
- }, this.renderHeader(), this.props.filtersEnabled && this.renderFilters(), this.renderBanksSearchResults(), (0, _emotion.jsx)(_index4.default, {
466
+ }, this.renderHeader(), this.props.improvedBankSharingEnabled && this.renderFilters(), this.renderBanksSearchResults(), (0, _emotion.jsx)(_index4.default, {
430
467
  itemBanksScope: this.props.scope
431
468
  })));
432
469
  }
@@ -446,8 +483,8 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
446
483
  account_name: _propTypes.default.string
447
484
  }),
448
485
  // from consumer
449
- clear: _propTypes.default.func,
450
- filtersEnabled: _propTypes.default.bool,
486
+ clear: _propTypes.default.func.isRequired,
487
+ improvedBankSharingEnabled: _propTypes.default.bool,
451
488
  getBanks: _propTypes.default.func.isRequired,
452
489
  getCourseInfo: _propTypes.default.func,
453
490
  // from consumer
@@ -483,10 +520,18 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
483
520
  }).isRequired,
484
521
  scopeType: _propTypes.default.string,
485
522
  searchTerms: _propTypes.default.string,
523
+ searchSelection: _propTypes.default.arrayOf(_propTypes.default.shape({
524
+ avatar: _propTypes.default.string,
525
+ fullName: _propTypes.default.string,
526
+ title: _propTypes.default.string,
527
+ uuid: _propTypes.default.string.isRequired
528
+ })),
486
529
  sortBy: _propTypes.default.string,
487
530
  sortOrder: _propTypes.default.string,
488
531
  usedByCourseEnabled: _propTypes.default.bool,
489
532
  itemBankSearchTableEnabled: _propTypes.default.bool,
533
+ setUI: _propTypes.default.func.isRequired,
534
+ subAccountBankSharingEnabled: _propTypes.default.bool,
490
535
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
491
536
  styles: _propTypes.default.object
492
537
  }, _class2.defaultProps = {
@@ -503,18 +548,18 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
503
548
  isCompact: false,
504
549
  navigateToBuild: null,
505
550
  onShare: function onShare() {},
506
- clear: function clear() {},
507
- merge: function merge() {},
508
551
  scope: {},
509
552
  returnToUrl: null,
510
- filtersEnabled: false,
553
+ improvedBankSharingEnabled: false,
511
554
  scopeType: 'user',
512
555
  sortBy: 'name',
513
556
  sortOrder: 'ascending',
514
557
  searchTerms: null,
558
+ searchSelection: [],
515
559
  newItemBankFilterNamesEnabled: false,
516
560
  usedByCourseEnabled: false,
517
- itemBankSearchTableEnabled: false
561
+ itemBankSearchTableEnabled: false,
562
+ subAccountBankSharingEnabled: false
518
563
  }, _class2.contextTypes = {
519
564
  locale: _propTypes.default.string
520
565
  }, _temp)) || _class);
@@ -27,11 +27,6 @@ var generateStyle = function generateStyle(componentTheme) {
27
27
  marginTop: '1.5rem',
28
28
  display: 'flex',
29
29
  flexDirection: 'row'
30
- },
31
- searchBarContainer: {
32
- flexGrow: 0.25,
33
- padding: '0 1rem',
34
- display: 'inline-block'
35
30
  }
36
31
  };
37
32
  };
@@ -63,7 +63,7 @@ var _CustomPropTypes = _interopRequireDefault(require("../../../common/util/Cust
63
63
 
64
64
  var _index = _interopRequireDefault(require("./ShareList/index.js"));
65
65
 
66
- var _asyncSearch = _interopRequireDefault(require("./asyncSearch.js"));
66
+ var _index2 = _interopRequireDefault(require("../AsyncSearch/index.js"));
67
67
 
68
68
  var _Spinner = _interopRequireDefault(require("../../../common/components/shared/spinner/Spinner.js"));
69
69
 
@@ -412,7 +412,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
412
412
  return (0, _emotion.jsx)(_react.default.Fragment, null, (0, _emotion.jsx)(_uiGrid.Grid, {
413
413
  vAlign: "bottom",
414
414
  colSpacing: "small"
415
- }, (0, _emotion.jsx)(_uiGrid.Grid.Row, null, (0, _emotion.jsx)(_uiGrid.Grid.Col, null, (0, _emotion.jsx)(_asyncSearch.default, {
415
+ }, (0, _emotion.jsx)(_uiGrid.Grid.Row, null, (0, _emotion.jsx)(_uiGrid.Grid.Col, null, (0, _emotion.jsx)(_index2.default, {
416
416
  getShareableCourses: _this.props.getShareableCourses,
417
417
  getShareableUsers: _this.props.getShareableUsers,
418
418
  getShareableSubaccounts: _this.props.getShareableSubaccounts,
@@ -29,7 +29,7 @@ var _default = function _default() {
29
29
  return state.mergeDeepIn([action.payload.key], action.payload.value);
30
30
 
31
31
  case _quizCommon.SET_UI:
32
- return state.set(action.payload.key, action.payload.value);
32
+ return state.setIn([action.payload.key].flat(), action.payload.value);
33
33
 
34
34
  case _quizCommon.TOGGLE_UI:
35
35
  return toggle(state, action.payload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.9.1-rc.5+813bd63b2",
3
+ "version": "20.9.1-rc.7+7d9df0379",
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.9.1-rc.5+813bd63b2",
48
- "@instructure/quiz-i18n": "20.9.1-rc.5+813bd63b2",
49
- "@instructure/quiz-interactions": "20.9.1-rc.5+813bd63b2",
50
- "@instructure/quiz-number-input": "20.9.1-rc.5+813bd63b2",
51
- "@instructure/quiz-rce": "20.9.1-rc.5+813bd63b2",
47
+ "@instructure/quiz-common": "20.9.1-rc.7+7d9df0379",
48
+ "@instructure/quiz-i18n": "20.9.1-rc.7+7d9df0379",
49
+ "@instructure/quiz-interactions": "20.9.1-rc.7+7d9df0379",
50
+ "@instructure/quiz-number-input": "20.9.1-rc.7+7d9df0379",
51
+ "@instructure/quiz-rce": "20.9.1-rc.7+7d9df0379",
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.9.1-rc.5+813bd63b2",
115
+ "instructure-validations": "20.9.1-rc.7+7d9df0379",
116
116
  "ipaddr.js": "^1.5.4",
117
117
  "isomorphic-fetch": "^2.2.0",
118
118
  "isuuid": "^0.1.0",
@@ -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.9.1-rc.5+813bd63b2",
166
+ "quiz-presets": "20.9.1-rc.7+7d9df0379",
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": "813bd63b275ad613c4a995bae449c2e610fe1526"
182
+ "gitHead": "7d9df037951d6e2565087a758c70b5daafed5eed"
183
183
  }