@instructure/quiz-core 20.10.1-rc.6 → 20.10.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.
@@ -16,6 +16,7 @@ function mapStateToProps(state, props) {
16
16
  var sortOrder = pageData.get('sortOrder', 'ascending');
17
17
  var searchTerms = pageData.get('searchTerms', null);
18
18
  var searchSelection = pageData.get('searchSelection', []);
19
+ var rootAccountUuid = state.getIn(['outcomes', 'contextUuid']);
19
20
  return {
20
21
  itemBankSearchTableEnabled: featureOn('item_bank_search_table'),
21
22
  improvedBankSharingEnabled: featureOn('improved_bank_sharing'),
@@ -26,7 +27,8 @@ function mapStateToProps(state, props) {
26
27
  sortBy: sortBy,
27
28
  sortOrder: sortOrder,
28
29
  searchTerms: searchTerms,
29
- searchSelection: searchSelection
30
+ searchSelection: searchSelection,
31
+ rootAccountUuid: rootAccountUuid
30
32
  };
31
33
  }
32
34
 
@@ -55,6 +55,10 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
55
55
 
56
56
  _this = _super.apply(this, arguments);
57
57
 
58
+ _this.hideAccountSearch = function () {
59
+ return _this.props.scopeType === 'account' && _this.props.scope.type === 'account' && _this.props.scope.launch_context_uuid && _this.props.rootAccountUuid && _this.props.scope.launch_context_uuid !== _this.props.rootAccountUuid;
60
+ };
61
+
58
62
  _this.onCreateBank = function () {
59
63
  _this.props.createBank({
60
64
  language: _this.context.locale
@@ -94,7 +98,9 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
94
98
  params['search'] = _this.props.searchTerms;
95
99
  }
96
100
 
97
- if (_this.props.searchSelection.length > 0) {
101
+ if (_this.props.subAccountBankSharingEnabled && _this.hideAccountSearch()) {
102
+ params['account_uuids'] = [_this.props.scope.launch_context_uuid];
103
+ } else if (_this.props.searchSelection.length > 0) {
98
104
  params['account_uuids'] = _this.props.searchSelection.map(function (account) {
99
105
  return account.uuid;
100
106
  });
@@ -125,6 +131,12 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
125
131
  _this.props.merge(BANKS_BANK_FILTERS, {
126
132
  scopeType: scopeType
127
133
  });
134
+
135
+ if (scopeType === 'account') {
136
+ _this.setState({
137
+ hiddenAccountSearch: true
138
+ });
139
+ }
128
140
  };
129
141
 
130
142
  _this.getSortingOrderIcon = function () {
@@ -211,7 +223,11 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
211
223
  if (_this.props.scopeType === 'course') {
212
224
  message = t("Your filter is set to \"Courses\" which will narrow what you can search for.\n Try adjusting the filter to \"Institution\" or \"All My Banks\"");
213
225
  } else if (_this.props.scopeType === 'account') {
214
- message = t("Your filter is set to \"Institution\" which will narrow what you can search for.\n Try adjusting the filter to \"All My Banks\"");
226
+ if (_this.props.subAccountBankSharingEnabled && _this.hideAccountSearch()) {
227
+ message = t("Your filter is set to \"This Account\" which will narrow what you can search for.\n Try adjusting the filter to \"All My Banks\"");
228
+ } else {
229
+ message = t("Your filter is set to \"Institution\" which will narrow what you can search for.\n Try adjusting the filter to \"All My Banks\"");
230
+ }
215
231
  }
216
232
 
217
233
  return jsx(Billboard, {
@@ -242,7 +258,9 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
242
258
  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)) {
243
259
  this.props.clear(BANKS_BANK_PAGINATION);
244
260
  }
245
- }
261
+ } // When the launch is from a subaccount, we want to silently add the subaccount to the account search
262
+ // if the user is on the "This Account" filter
263
+
246
264
  }, {
247
265
  key: "renderFilters",
248
266
  value: function renderFilters() {
@@ -251,7 +269,7 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
251
269
  translation: this.props.newItemBankFilterNamesEnabled ? t('All Banks') : t('All My Banks')
252
270
  }, {
253
271
  slug: 'account',
254
- translation: t('Institution Banks')
272
+ translation: this.props.subAccountBankSharingEnabled && this.hideAccountSearch() ? t('This Account') : t('Institution Banks')
255
273
  }, {
256
274
  slug: 'courses',
257
275
  translation: this.props.newItemBankFilterNamesEnabled ? t('Banks Shared to Course') : t('All My Course Banks')
@@ -314,7 +332,7 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
314
332
  onChange: this.handleSearchInputChange,
315
333
  placeholder: t('Search Banks'),
316
334
  "data-automation": "sdk-search-bank-textinput"
317
- })), this.props.subAccountBankSharingEnabled && jsx(Grid.Col, {
335
+ })), this.props.subAccountBankSharingEnabled && !this.hideAccountSearch() && jsx(Grid.Col, {
318
336
  width: 4
319
337
  }, jsx(AsyncSearch, {
320
338
  getShareableSubaccounts: this.props.getShareableSubaccounts,
@@ -488,7 +506,9 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
488
506
  scope: PropTypes.shape({
489
507
  type: PropTypes.string,
490
508
  uuid: PropTypes.string,
491
- title: PropTypes.string
509
+ title: PropTypes.string,
510
+ launch_context_uuid: PropTypes.string,
511
+ root_account_name: PropTypes.string
492
512
  }).isRequired,
493
513
  scopeType: PropTypes.string,
494
514
  searchTerms: PropTypes.string,
@@ -506,7 +526,8 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
506
526
  subAccountBankSharingEnabled: PropTypes.bool,
507
527
  iceTopNavBarEnabled: PropTypes.bool,
508
528
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
509
- styles: PropTypes.object
529
+ styles: PropTypes.object,
530
+ rootAccountUuid: PropTypes.string
510
531
  }, _class2.defaultProps = {
511
532
  closeTray: null,
512
533
  currentUser: null,
@@ -533,7 +554,8 @@ export var Banks = (_dec = withStyle(generateStyle, generateComponentTheme), _de
533
554
  usedByCourseEnabled: false,
534
555
  itemBankSearchTableEnabled: false,
535
556
  subAccountBankSharingEnabled: false,
536
- iceTopNavBarEnabled: false
557
+ iceTopNavBarEnabled: false,
558
+ rootAccountUuid: null
537
559
  }, _class2.contextTypes = {
538
560
  locale: PropTypes.string
539
561
  }, _temp)) || _class);
@@ -34,6 +34,7 @@ function mapStateToProps(state, props) {
34
34
  var sortOrder = pageData.get('sortOrder', 'ascending');
35
35
  var searchTerms = pageData.get('searchTerms', null);
36
36
  var searchSelection = pageData.get('searchSelection', []);
37
+ var rootAccountUuid = state.getIn(['outcomes', 'contextUuid']);
37
38
  return {
38
39
  itemBankSearchTableEnabled: (0, _featureCheck.featureOn)('item_bank_search_table'),
39
40
  improvedBankSharingEnabled: (0, _featureCheck.featureOn)('improved_bank_sharing'),
@@ -44,7 +45,8 @@ function mapStateToProps(state, props) {
44
45
  sortBy: sortBy,
45
46
  sortOrder: sortOrder,
46
47
  searchTerms: searchTerms,
47
- searchSelection: searchSelection
48
+ searchSelection: searchSelection,
49
+ rootAccountUuid: rootAccountUuid
48
50
  };
49
51
  }
50
52
 
@@ -95,6 +95,10 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
95
95
  (0, _classCallCheck2.default)(this, Banks);
96
96
  _this = _super.apply(this, arguments);
97
97
 
98
+ _this.hideAccountSearch = function () {
99
+ return _this.props.scopeType === 'account' && _this.props.scope.type === 'account' && _this.props.scope.launch_context_uuid && _this.props.rootAccountUuid && _this.props.scope.launch_context_uuid !== _this.props.rootAccountUuid;
100
+ };
101
+
98
102
  _this.onCreateBank = function () {
99
103
  _this.props.createBank({
100
104
  language: _this.context.locale
@@ -134,7 +138,9 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
134
138
  params['search'] = _this.props.searchTerms;
135
139
  }
136
140
 
137
- if (_this.props.searchSelection.length > 0) {
141
+ if (_this.props.subAccountBankSharingEnabled && _this.hideAccountSearch()) {
142
+ params['account_uuids'] = [_this.props.scope.launch_context_uuid];
143
+ } else if (_this.props.searchSelection.length > 0) {
138
144
  params['account_uuids'] = _this.props.searchSelection.map(function (account) {
139
145
  return account.uuid;
140
146
  });
@@ -165,6 +171,12 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
165
171
  _this.props.merge(_quizCommon.BANKS_BANK_FILTERS, {
166
172
  scopeType: scopeType
167
173
  });
174
+
175
+ if (scopeType === 'account') {
176
+ _this.setState({
177
+ hiddenAccountSearch: true
178
+ });
179
+ }
168
180
  };
169
181
 
170
182
  _this.getSortingOrderIcon = function () {
@@ -251,7 +263,11 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
251
263
  if (_this.props.scopeType === 'course') {
252
264
  message = (0, _formatMessage.default)("Your filter is set to \"Courses\" which will narrow what you can search for.\n Try adjusting the filter to \"Institution\" or \"All My Banks\"");
253
265
  } else if (_this.props.scopeType === 'account') {
254
- message = (0, _formatMessage.default)("Your filter is set to \"Institution\" which will narrow what you can search for.\n Try adjusting the filter to \"All My Banks\"");
266
+ if (_this.props.subAccountBankSharingEnabled && _this.hideAccountSearch()) {
267
+ message = (0, _formatMessage.default)("Your filter is set to \"This Account\" which will narrow what you can search for.\n Try adjusting the filter to \"All My Banks\"");
268
+ } else {
269
+ message = (0, _formatMessage.default)("Your filter is set to \"Institution\" which will narrow what you can search for.\n Try adjusting the filter to \"All My Banks\"");
270
+ }
255
271
  }
256
272
 
257
273
  return (0, _emotion.jsx)(_uiBillboard.Billboard, {
@@ -282,7 +298,9 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
282
298
  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)) {
283
299
  this.props.clear(_quizCommon.BANKS_BANK_PAGINATION);
284
300
  }
285
- }
301
+ } // When the launch is from a subaccount, we want to silently add the subaccount to the account search
302
+ // if the user is on the "This Account" filter
303
+
286
304
  }, {
287
305
  key: "renderFilters",
288
306
  value: function renderFilters() {
@@ -291,7 +309,7 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
291
309
  translation: this.props.newItemBankFilterNamesEnabled ? (0, _formatMessage.default)('All Banks') : (0, _formatMessage.default)('All My Banks')
292
310
  }, {
293
311
  slug: 'account',
294
- translation: (0, _formatMessage.default)('Institution Banks')
312
+ translation: this.props.subAccountBankSharingEnabled && this.hideAccountSearch() ? (0, _formatMessage.default)('This Account') : (0, _formatMessage.default)('Institution Banks')
295
313
  }, {
296
314
  slug: 'courses',
297
315
  translation: this.props.newItemBankFilterNamesEnabled ? (0, _formatMessage.default)('Banks Shared to Course') : (0, _formatMessage.default)('All My Course Banks')
@@ -354,7 +372,7 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
354
372
  onChange: this.handleSearchInputChange,
355
373
  placeholder: (0, _formatMessage.default)('Search Banks'),
356
374
  "data-automation": "sdk-search-bank-textinput"
357
- })), this.props.subAccountBankSharingEnabled && (0, _emotion.jsx)(_uiGrid.Grid.Col, {
375
+ })), this.props.subAccountBankSharingEnabled && !this.hideAccountSearch() && (0, _emotion.jsx)(_uiGrid.Grid.Col, {
358
376
  width: 4
359
377
  }, (0, _emotion.jsx)(_index7.default, {
360
378
  getShareableSubaccounts: this.props.getShareableSubaccounts,
@@ -527,7 +545,9 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
527
545
  scope: _propTypes.default.shape({
528
546
  type: _propTypes.default.string,
529
547
  uuid: _propTypes.default.string,
530
- title: _propTypes.default.string
548
+ title: _propTypes.default.string,
549
+ launch_context_uuid: _propTypes.default.string,
550
+ root_account_name: _propTypes.default.string
531
551
  }).isRequired,
532
552
  scopeType: _propTypes.default.string,
533
553
  searchTerms: _propTypes.default.string,
@@ -545,7 +565,8 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
545
565
  subAccountBankSharingEnabled: _propTypes.default.bool,
546
566
  iceTopNavBarEnabled: _propTypes.default.bool,
547
567
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
548
- styles: _propTypes.default.object
568
+ styles: _propTypes.default.object,
569
+ rootAccountUuid: _propTypes.default.string
549
570
  }, _class2.defaultProps = {
550
571
  closeTray: null,
551
572
  currentUser: null,
@@ -572,7 +593,8 @@ var Banks = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
572
593
  usedByCourseEnabled: false,
573
594
  itemBankSearchTableEnabled: false,
574
595
  subAccountBankSharingEnabled: false,
575
- iceTopNavBarEnabled: false
596
+ iceTopNavBarEnabled: false,
597
+ rootAccountUuid: null
576
598
  }, _class2.contextTypes = {
577
599
  locale: _propTypes.default.string
578
600
  }, _temp)) || _class);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.10.1-rc.6+608228b5c",
3
+ "version": "20.10.1-rc.7+c0ed1ff3f",
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.10.1-rc.6+608228b5c",
48
- "@instructure/quiz-i18n": "20.10.1-rc.6+608228b5c",
49
- "@instructure/quiz-interactions": "20.10.1-rc.6+608228b5c",
50
- "@instructure/quiz-number-input": "20.10.1-rc.6+608228b5c",
51
- "@instructure/quiz-rce": "20.10.1-rc.6+608228b5c",
47
+ "@instructure/quiz-common": "20.10.1-rc.7+c0ed1ff3f",
48
+ "@instructure/quiz-i18n": "20.10.1-rc.7+c0ed1ff3f",
49
+ "@instructure/quiz-interactions": "20.10.1-rc.7+c0ed1ff3f",
50
+ "@instructure/quiz-number-input": "20.10.1-rc.7+c0ed1ff3f",
51
+ "@instructure/quiz-rce": "20.10.1-rc.7+c0ed1ff3f",
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.10.1-rc.6+608228b5c",
115
+ "instructure-validations": "20.10.1-rc.7+c0ed1ff3f",
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.10.1-rc.6+608228b5c",
166
+ "quiz-presets": "20.10.1-rc.7+c0ed1ff3f",
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": "608228b5cd5d4366f332cd20ec0eb7e6676b488d"
182
+ "gitHead": "c0ed1ff3f93fd948f16d8073e223cbb46dab4a74"
183
183
  }