@instructure/quiz-core 20.10.1-rc.4 → 20.10.1-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,7 +59,7 @@ export var RootAccountSharing = (_dec = withStyle(generateStyle, generateCompone
59
59
  }, /*#__PURE__*/React.createElement(Grid.Row, null, _ref, /*#__PURE__*/React.createElement(Grid.Col, null, /*#__PURE__*/React.createElement(View, {
60
60
  as: "div",
61
61
  padding: "0 0 x-small 0"
62
- }, this.props.accountName || t('Account')), /*#__PURE__*/React.createElement(Checkbox, {
62
+ }, this.props.accountName), /*#__PURE__*/React.createElement(Checkbox, {
63
63
  label: t('Share with Institution'),
64
64
  variant: "toggle",
65
65
  value: "accountPermission",
@@ -84,11 +84,12 @@ export var RootAccountSharing = (_dec = withStyle(generateStyle, generateCompone
84
84
  RootAccountSharing.displayName = "RootAccountSharing";
85
85
  return RootAccountSharing;
86
86
  }(Component), _class2.propTypes = {
87
- accountName: PropTypes.string.isRequired,
87
+ accountName: PropTypes.string,
88
88
  onShareChange: PropTypes.func.isRequired,
89
89
  onShareTypeChange: PropTypes.func.isRequired,
90
90
  accountPermission: PropTypes.string
91
91
  }, _class2.defaultProps = {
92
+ accountName: t('Account'),
92
93
  accountPermission: null
93
94
  }, _temp)) || _class);
94
95
  export default RootAccountSharing;
@@ -8,24 +8,20 @@ var _dec, _class, _class2, _temp;
8
8
  /** @jsx jsx */
9
9
  import { Component } from 'react';
10
10
  import PropTypes from 'prop-types';
11
- import { List, Map } from 'immutable';
12
11
  import ImmutablePropTypes from 'react-immutable-proptypes';
12
+ import { Map } from 'immutable';
13
13
  import { IconCoursesLine, IconTrashLine, IconResetLine } from '@instructure/ui-icons';
14
- import { ScreenReaderContent } from '@instructure/ui-a11y-content';
15
- import { View } from '@instructure/ui-view';
16
14
  import { Grid } from '@instructure/ui-grid';
17
- import { Text } from '@instructure/ui-text';
18
15
  import { Avatar } from '@instructure/ui-avatar';
19
- import { Tabs } from '@instructure/ui-tabs';
16
+ import { SimpleSelect } from '@instructure/ui-simple-select';
17
+ import { ScreenReaderContent } from '@instructure/ui-a11y-content';
20
18
  import { withStyle, jsx } from '@instructure/emotion';
19
+ import { CAN_EDIT, READ_ONLY, REMOVED_ACCESS, SHARED_WITH_COURSE } from '@instructure/quiz-common';
20
+ import t from '@instructure/quiz-i18n/es/format-message';
21
21
  import { ContextualIconButton } from "../ContextualIconButton/index.js";
22
- import RootAccountSharing from "../RootAccountSharing.js";
23
- import { SimpleSelect } from '@instructure/ui-simple-select';
24
22
  import generateStyle from "./styles.js";
25
- import { CAN_EDIT, READ_ONLY, REMOVED_ACCESS, SHARED_WITH_USER, SHARED_WITH_COURSE, SHARED_WITH_ACCOUNT } from '@instructure/quiz-common';
26
- import t from '@instructure/quiz-i18n/es/format-message';
27
23
 
28
- var _ref4 = jsx(IconCoursesLine, {
24
+ var _ref3 = jsx(IconCoursesLine, {
29
25
  size: "small"
30
26
  });
31
27
 
@@ -44,16 +40,13 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
44
40
  }
45
41
 
46
42
  _this = _super.call.apply(_super, [this].concat(args));
47
- _this.state = {
48
- selectedTabIndex: 0
49
- };
50
43
 
51
- _this.handleTabChange = function (event, _ref) {
52
- var index = _ref.index;
44
+ _this.handlePermissionChange = function (entity) {
45
+ return function (e, _ref) {
46
+ var value = _ref.value;
53
47
 
54
- _this.setState({
55
- selectedTabIndex: index
56
- });
48
+ _this.props.onPermissionChange(entity, value);
49
+ };
57
50
  };
58
51
 
59
52
  _this.handleEntityRemove = function (e, _ref2) {
@@ -63,15 +56,7 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
63
56
  _this.props.onEntityRemove(entity, isEntityRemoved);
64
57
  };
65
58
 
66
- _this.handlePermissionChange = function (entity) {
67
- return function (e, _ref3) {
68
- var value = _ref3.value;
69
-
70
- _this.props.onPermissionChange(entity, value);
71
- };
72
- };
73
-
74
- _this.removeButton = function (entity, isEntityRemoved) {
59
+ _this.renderRemoveButton = function (entity, isEntityRemoved) {
75
60
  var context = {
76
61
  entity: entity,
77
62
  isEntityRemoved: isEntityRemoved
@@ -90,7 +75,7 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
90
75
  });
91
76
  };
92
77
 
93
- _this.renderEntity = function (entity, index) {
78
+ _this.renderEntity = function (entity) {
94
79
  var isEntityRemoved = entity.get('permission') === REMOVED_ACCESS;
95
80
  var isCourse = entity.get('entityType') === SHARED_WITH_COURSE;
96
81
  var isOnlyEntity = _this.props.shares.size <= 1;
@@ -103,7 +88,7 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
103
88
  "data-automation": "sdk-shared-with-entity-row"
104
89
  }, jsx(Grid.Col, {
105
90
  width: "small"
106
- }, isCourse ? _ref4 : jsx(Avatar, {
91
+ }, isCourse ? _ref3 : jsx(Avatar, {
107
92
  name: entity.get('title'),
108
93
  src: entity.get('avatar'),
109
94
  size: "small"
@@ -127,98 +112,18 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
127
112
  value: CAN_EDIT
128
113
  }, t('Can edit')))), jsx(Grid.Col, {
129
114
  width: "auto"
130
- }, !isOnlyEntity && _this.props.canEdit && (_this.props.improvedBankSharingEnabled || !isCourse) && _this.removeButton(entity, isEntityRemoved)));
115
+ }, !isOnlyEntity && _this.props.canEdit && (_this.props.improvedBankSharingEnabled || !isCourse) && _this.renderRemoveButton(entity, isEntityRemoved)));
131
116
  };
132
117
 
133
118
  return _this;
134
119
  }
135
120
 
136
121
  _createClass(ShareList, [{
137
- key: "renderNewEntities",
138
- value: function renderNewEntities() {
139
- if (!this.props.newEntities.isEmpty()) {
140
- return jsx(View, {
141
- as: "div",
142
- margin: "0 0 medium 0"
143
- }, jsx(Grid, {
144
- vAlign: "middle"
145
- }, this.props.newEntities.map(this.renderEntity)));
146
- }
147
- }
148
- }, {
149
122
  key: "render",
150
123
  value: function render() {
151
- var _this$props = this.props,
152
- shares = _this$props.shares,
153
- subAccountBankSharingEnabled = _this$props.subAccountBankSharingEnabled,
154
- currentUser = _this$props.currentUser;
155
- var newEntityIds = this.props.newEntities.map(function (e) {
156
- return e.get('id');
157
- });
158
- var existingShares = shares.filterNot(function (s) {
159
- return newEntityIds.includes(s.get('id'));
160
- });
161
- var existingPeople = existingShares.filter(function (s) {
162
- return s.get('entityType') === SHARED_WITH_USER;
163
- });
164
- var existingCourses = existingShares.filter(function (s) {
165
- return s.get('entityType') === SHARED_WITH_COURSE;
166
- });
167
- var existingAccounts = existingShares.filter(function (s) {
168
- return s.get('entityType') === SHARED_WITH_ACCOUNT;
169
- });
170
- return jsx("div", {
171
- className: "fs-mask"
172
- }, !subAccountBankSharingEnabled && jsx(Text, {
173
- as: "div",
174
- weight: "bold"
175
- }, t('Currently shared with')), jsx(View, {
176
- as: "div",
177
- "data-automation": "sdk-shared-bank-user-list"
178
- }, !subAccountBankSharingEnabled && this.renderNewEntities(), jsx(Tabs, {
179
- onRequestTabChange: this.handleTabChange
180
- }, jsx(Tabs.Panel, {
181
- renderTitle: t('People ({ peopleCount })', {
182
- peopleCount: existingPeople.size
183
- }),
184
- isSelected: this.state.selectedTabIndex === 0,
185
- padding: "large small small small"
186
- }, subAccountBankSharingEnabled && this.props.renderSearchSection(SHARED_WITH_USER), subAccountBankSharingEnabled && jsx(Text, {
187
- as: "div",
188
- weight: "bold",
189
- lineHeight: "double"
190
- }, t('Currently shared with')), jsx(Grid, {
191
- vAlign: "middle"
192
- }, existingPeople.map(this.renderEntity))), (!existingCourses.isEmpty() || subAccountBankSharingEnabled) && jsx(Tabs.Panel, {
193
- renderTitle: t('Courses ({ coursesCount })', {
194
- coursesCount: existingCourses.size
195
- }),
196
- isSelected: this.state.selectedTabIndex === 1,
197
- padding: "large small small small"
198
- }, subAccountBankSharingEnabled && this.props.renderSearchSection(SHARED_WITH_COURSE), subAccountBankSharingEnabled && jsx(Text, {
199
- as: "div",
200
- weight: "bold",
201
- lineHeight: "double"
202
- }, t('Currently shared with')), jsx(Grid, {
124
+ return jsx(Grid, {
203
125
  vAlign: "middle"
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
- }),
208
- isSelected: this.state.selectedTabIndex === 2,
209
- padding: "large small small small"
210
- }, (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) && jsx(RootAccountSharing, {
211
- accountName: this.props.accountName,
212
- onShareChange: this.props.onToggleAccountShare,
213
- onShareTypeChange: this.props.onAccountPermissionChange,
214
- accountPermission: this.props.accountPermission
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))))));
126
+ }, this.props.entities.map(this.renderEntity));
222
127
  }
223
128
  }]);
224
129
 
@@ -226,15 +131,15 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
226
131
  return ShareList;
227
132
  }(Component), _class2.propTypes = {
228
133
  canEdit: PropTypes.bool.isRequired,
229
- currentUser: PropTypes.shape({
230
- bank_admin: PropTypes.bool,
231
- can_share_banks_with_subaccounts: PropTypes.bool
232
- }),
134
+ entities: ImmutablePropTypes.listOf(ImmutablePropTypes.contains({
135
+ entityType: PropTypes.string.isRequired,
136
+ entityId: PropTypes.string.isRequired,
137
+ permission: PropTypes.string.isRequired,
138
+ id: PropTypes.string.isRequired
139
+ })).isRequired,
233
140
  improvedBankSharingEnabled: PropTypes.bool.isRequired,
234
- newEntities: ImmutablePropTypes.list,
235
- onEntityRemove: PropTypes.func.isRequired,
236
141
  onPermissionChange: PropTypes.func.isRequired,
237
- renderSearchSection: PropTypes.func.isRequired,
142
+ onEntityRemove: PropTypes.func.isRequired,
238
143
  sharedBanks: ImmutablePropTypes.list,
239
144
  shares: ImmutablePropTypes.listOf(ImmutablePropTypes.contains({
240
145
  avatar: PropTypes.string,
@@ -244,18 +149,7 @@ export var ShareList = (_dec = withStyle(generateStyle, null), _dec(_class = (_t
244
149
  permission: PropTypes.string.isRequired,
245
150
  id: PropTypes.string.isRequired
246
151
  })).isRequired,
247
- subAccountBankSharingEnabled: PropTypes.bool.isRequired,
248
152
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
249
- styles: PropTypes.object,
250
- accountName: PropTypes.string,
251
- onAccountPermissionChange: PropTypes.func.isRequired,
252
- onToggleAccountShare: PropTypes.func.isRequired,
253
- accountPermission: PropTypes.string
254
- }, _class2.defaultProps = {
255
- accountName: t('Account'),
256
- accountPermission: null,
257
- currentUser: null,
258
- newEntities: List(),
259
- sharedBanks: List()
153
+ styles: PropTypes.object
260
154
  }, _temp)) || _class);
261
155
  export default ShareList;
@@ -18,20 +18,20 @@ import PropTypes from 'prop-types';
18
18
  import { List, Map } from 'immutable';
19
19
  import ImmutablePropTypes from 'react-immutable-proptypes';
20
20
  import partial from 'lodash/partial';
21
- import { Modal, ModalHeader, ModalBody, ModalFooter, CAN_EDIT, READ_ONLY, REMOVED_ACCESS } from '@instructure/quiz-common';
21
+ import { Modal, ModalHeader, ModalBody, ModalFooter, CAN_EDIT, READ_ONLY, REMOVED_ACCESS, SHARED_WITH_USER, SHARED_WITH_COURSE, SHARED_WITH_ACCOUNT } from '@instructure/quiz-common';
22
22
  import { Heading } from '@instructure/ui-heading';
23
23
  import { Button, CloseButton } from '@instructure/ui-buttons';
24
- import { IconAdminLine } from '@instructure/ui-icons';
25
- import { Checkbox } from '@instructure/ui-checkbox';
26
24
  import { View } from '@instructure/ui-view';
27
25
  import { Grid } from '@instructure/ui-grid';
28
- import { ScreenReaderContent } from '@instructure/ui-a11y-content';
26
+ import { Tabs } from '@instructure/ui-tabs';
27
+ import { Text } from '@instructure/ui-text';
29
28
  import { SimpleSelect } from '@instructure/ui-simple-select';
30
29
  import { withStyle, jsx } from '@instructure/emotion';
31
30
  import elementsForSelectors from "../../../common/util/ElementsForSelectors.js";
32
31
  import CustomPropTypes from "../../../common/util/CustomPropTypes.js";
33
32
  import ShareList from "./ShareList/index.js";
34
33
  import AsyncSearch from "../AsyncSearch/index.js";
34
+ import RootAccountSharing from "./RootAccountSharing.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";
@@ -39,12 +39,6 @@ import t from '@instructure/quiz-i18n/es/format-message';
39
39
 
40
40
  var noop = function noop() {};
41
41
 
42
- var _ref6 = jsx(Grid.Col, {
43
- width: "auto"
44
- }, jsx(IconAdminLine, {
45
- size: "medium"
46
- }));
47
-
48
42
  var _ref7 = jsx(Spinner, null);
49
43
 
50
44
  export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
@@ -68,7 +62,8 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
68
62
  newEntities: List(),
69
63
  searchSelection: [],
70
64
  searchPermission: READ_ONLY,
71
- entitiesWithChangedPermission: {}
65
+ entitiesWithChangedPermission: {},
66
+ selectedTabIndex: 0
72
67
  };
73
68
  _this.shareListRef = null;
74
69
  _this.shareButtonRef = null;
@@ -90,6 +85,14 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
90
85
  }
91
86
  };
92
87
 
88
+ _this.handleTabChange = function (event, _ref) {
89
+ var index = _ref.index;
90
+
91
+ _this.setState({
92
+ selectedTabIndex: index
93
+ });
94
+ };
95
+
93
96
  _this.modalDismissCleanup = function () {
94
97
  var focusCreateBank = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
95
98
 
@@ -162,10 +165,10 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
162
165
  }); // call the update api if any shared bank permission was updated
163
166
 
164
167
 
165
- Object.entries(_this.state.entitiesWithChangedPermission).forEach(function (_ref) {
166
- var _ref2 = _slicedToArray(_ref, 2),
167
- sharedBankId = _ref2[0],
168
- permission = _ref2[1];
168
+ Object.entries(_this.state.entitiesWithChangedPermission).forEach(function (_ref2) {
169
+ var _ref3 = _slicedToArray(_ref2, 2),
170
+ sharedBankId = _ref3[0],
171
+ permission = _ref3[1];
169
172
 
170
173
  var sharedBank = _this.props.sharedBanks.find(function (sharedBank) {
171
174
  return sharedBank.get('id') === sharedBankId;
@@ -231,8 +234,8 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
231
234
  }
232
235
  };
233
236
 
234
- _this.handleSearchPermissionChange = function (e, _ref3) {
235
- var value = _ref3.value;
237
+ _this.handleSearchPermissionChange = function (e, _ref4) {
238
+ var value = _ref4.value;
236
239
 
237
240
  _this.setState({
238
241
  searchPermission: value
@@ -280,7 +283,7 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
280
283
  };
281
284
 
282
285
  _this.updatePermission = /*#__PURE__*/function () {
283
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(entity, permission) {
286
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(entity, permission) {
284
287
  var _this$props, updateSharedBankPermission, getBank, bank;
285
288
 
286
289
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -303,7 +306,7 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
303
306
  }));
304
307
 
305
308
  return function (_x, _x2) {
306
- return _ref4.apply(this, arguments);
309
+ return _ref5.apply(this, arguments);
307
310
  };
308
311
  }();
309
312
 
@@ -354,8 +357,8 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
354
357
  });
355
358
  };
356
359
 
357
- _this.handleAccountPermissionChange = function (e, _ref5) {
358
- var value = _ref5.value;
360
+ _this.handleAccountPermissionChange = function (e, _ref6) {
361
+ var value = _ref6.value;
359
362
  return _this.setState({
360
363
  accountPermission: value
361
364
  });
@@ -409,6 +412,18 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
409
412
  }
410
413
  };
411
414
 
415
+ _this.renderShareList = function (entities) {
416
+ return jsx(ShareList, {
417
+ canEdit: _this.props.bank.canEdit(),
418
+ entities: entities,
419
+ improvedBankSharingEnabled: _this.props.improvedBankSharingEnabled,
420
+ onPermissionChange: _this.handleEntityPermissionChange,
421
+ onEntityRemove: _this.handleEntityRemove,
422
+ sharedBanks: _this.props.sharedBanks,
423
+ shares: _this.state.shares
424
+ });
425
+ };
426
+
412
427
  return _this;
413
428
  }
414
429
 
@@ -451,70 +466,115 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
451
466
  };
452
467
  }
453
468
  }, {
454
- key: "renderAccountPermissions",
469
+ key: "renderRootAccountSharing",
455
470
  // =============
456
471
  // RENDERING
457
472
  // =============
458
- value: function renderAccountPermissions() {
459
- var _this$props2 = this.props,
460
- currentUser = _this$props2.currentUser,
461
- improvedBankSharingEnabled = _this$props2.improvedBankSharingEnabled;
462
-
463
- if (improvedBankSharingEnabled && (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin)) {
464
- return jsx(View, {
465
- as: "div",
466
- margin: "0 0 medium 0"
467
- }, jsx(Grid, {
468
- colSpacing: "small"
469
- }, jsx(Grid.Row, null, _ref6, jsx(Grid.Col, null, jsx(View, {
470
- as: "div",
471
- padding: "0 0 x-small 0"
472
- }, currentUser && currentUser.account_name || t('Account')), jsx(Checkbox, {
473
- label: t('Share with Institution'),
474
- variant: "toggle",
475
- value: "accountPermission",
476
- checked: this.isSharedWithAccount(),
477
- onChange: this.toggleAccountShare
478
- })), this.isSharedWithAccount() && jsx(Grid.Col, {
479
- width: "auto"
480
- }, jsx(SimpleSelect, {
481
- onChange: this.handleAccountPermissionChange,
482
- value: this.state.accountPermission,
483
- renderLabel: jsx(ScreenReaderContent, null, t('Access for account'))
484
- }, jsx(SimpleSelect.Option, {
485
- id: "sharing-modal-account-perm-select-option-can-view",
486
- value: READ_ONLY
487
- }, t('Can view')), jsx(SimpleSelect.Option, {
488
- id: "sharing-modal-account-perm-select-option-can-edit",
489
- value: CAN_EDIT
490
- }, t('Can edit')))))));
491
- }
473
+ value: function renderRootAccountSharing() {
474
+ var _this$props$currentUs;
475
+
476
+ return jsx(RootAccountSharing, {
477
+ accountName: (_this$props$currentUs = this.props.currentUser) === null || _this$props$currentUs === void 0 ? void 0 : _this$props$currentUs.account_name,
478
+ onShareChange: this.toggleAccountShare,
479
+ onShareTypeChange: this.handleAccountPermissionChange,
480
+ accountPermission: this.state.accountPermission
481
+ });
482
+ }
483
+ }, {
484
+ key: "renderSubaccountSharingEnabledEntities",
485
+ value: function renderSubaccountSharingEnabledEntities(existingPeople, existingCourses, existingAccounts) {
486
+ var currentUser = this.props.currentUser;
487
+ return jsx(View, {
488
+ as: "div",
489
+ "data-automation": "sdk-shared-bank-user-list"
490
+ }, jsx(Tabs, {
491
+ onRequestTabChange: this.handleTabChange
492
+ }, jsx(Tabs.Panel, {
493
+ renderTitle: t('People ({ peopleCount })', {
494
+ peopleCount: existingPeople.size
495
+ }),
496
+ isSelected: this.state.selectedTabIndex === 0,
497
+ padding: "large small small small"
498
+ }, this.renderSearchSection(SHARED_WITH_USER), jsx(Text, {
499
+ as: "div",
500
+ weight: "bold",
501
+ lineHeight: "double"
502
+ }, t('Currently shared with')), this.renderShareList(existingPeople)), jsx(Tabs.Panel, {
503
+ renderTitle: t('Courses ({ coursesCount })', {
504
+ coursesCount: existingCourses.size
505
+ }),
506
+ isSelected: this.state.selectedTabIndex === 1,
507
+ padding: "large small small small"
508
+ }, this.renderSearchSection(SHARED_WITH_COURSE), jsx(Text, {
509
+ as: "div",
510
+ weight: "bold",
511
+ lineHeight: "double"
512
+ }, t('Currently shared with')), this.renderShareList(existingCourses)), ((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, {
513
+ renderTitle: t('Accounts ({ accountsCount })', {
514
+ accountsCount: existingAccounts.size
515
+ }),
516
+ isSelected: this.state.selectedTabIndex === 2,
517
+ padding: "large small small small"
518
+ }, (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) && this.renderRootAccountSharing(), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.can_share_banks_with_subaccounts) && this.renderSearchSection(SHARED_WITH_ACCOUNT), jsx(Text, {
519
+ as: "div",
520
+ weight: "bold",
521
+ lineHeight: "double"
522
+ }, t('Currently shared with')), this.renderShareList(existingAccounts))));
523
+ }
524
+ }, {
525
+ key: "renderOriginalDesignEntities",
526
+ value: function renderOriginalDesignEntities(existingPeople, existingCourses) {
527
+ return jsx("div", {
528
+ className: "fs-mask"
529
+ }, jsx(Text, {
530
+ as: "div",
531
+ weight: "bold"
532
+ }, t('Currently shared with')), jsx(View, {
533
+ as: "div",
534
+ "data-automation": "sdk-shared-bank-user-list"
535
+ }, !this.state.newEntities.isEmpty() && jsx(View, {
536
+ as: "div",
537
+ margin: "0 0 medium 0"
538
+ }, this.renderShareList(this.state.newEntities)), jsx(Tabs, {
539
+ onRequestTabChange: this.handleTabChange
540
+ }, jsx(Tabs.Panel, {
541
+ renderTitle: t('People ({ peopleCount })', {
542
+ peopleCount: existingPeople.size
543
+ }),
544
+ isSelected: this.state.selectedTabIndex === 0,
545
+ padding: "large small small small"
546
+ }, this.renderShareList(existingPeople)), !existingCourses.isEmpty() && jsx(Tabs.Panel, {
547
+ renderTitle: t('Courses ({ coursesCount })', {
548
+ coursesCount: existingCourses.size
549
+ }),
550
+ isSelected: this.state.selectedTabIndex === 1,
551
+ padding: "large small small small"
552
+ }, this.renderShareList(existingCourses)))));
492
553
  }
493
554
  }, {
494
555
  key: "renderEntitiesSection",
495
556
  value: function renderEntitiesSection() {
496
- return jsx(ShareList, {
497
- accountName: this.props.currentUser.account_name,
498
- accountPermission: this.state.accountPermission,
499
- canEdit: this.props.bank.canEdit(),
500
- currentUser: this.props.currentUser,
501
- entitiesWithChangedPermission: this.state.entitiesWithChangedPermission,
502
- improvedBankSharingEnabled: this.props.improvedBankSharingEnabled,
503
- newEntities: this.state.newEntities,
504
- onAccountPermissionChange: this.handleAccountPermissionChange,
505
- onEntityRemove: this.handleEntityRemove,
506
- onPermissionChange: this.handleEntityPermissionChange,
507
- onToggleAccountShare: this.toggleAccountShare,
508
- ref: this.handleShareListRef,
509
- renderSearchSection: this.renderSearchSection // searchPermission and searchSelection are not used directly by ShareList,
510
- // but are needed as props so that AsyncSearch/Select rerenders when those values change
511
- ,
512
- searchPermission: this.state.searchPermission,
513
- searchSelection: this.state.searchSelection,
514
- sharedBanks: this.props.sharedBanks,
515
- shares: this.state.shares,
516
- subAccountBankSharingEnabled: this.props.subAccountBankSharingEnabled
557
+ var newEntityIds = this.state.newEntities.map(function (e) {
558
+ return e.get('id');
517
559
  });
560
+ var existingShares = this.state.shares.filterNot(function (s) {
561
+ return newEntityIds.includes(s.get('id'));
562
+ });
563
+ var existingPeople = existingShares.filter(function (s) {
564
+ return s.get('entityType') === SHARED_WITH_USER;
565
+ });
566
+ var existingCourses = existingShares.filter(function (s) {
567
+ return s.get('entityType') === SHARED_WITH_COURSE;
568
+ });
569
+ var existingAccounts = existingShares.filter(function (s) {
570
+ return s.get('entityType') === SHARED_WITH_ACCOUNT;
571
+ });
572
+
573
+ if (this.props.subAccountBankSharingEnabled) {
574
+ return this.renderSubaccountSharingEnabledEntities(existingPeople, existingCourses, existingAccounts);
575
+ }
576
+
577
+ return this.renderOriginalDesignEntities(existingPeople, existingCourses);
518
578
  }
519
579
  }, {
520
580
  key: "renderFooter",
@@ -555,7 +615,7 @@ export var SharingModalPresenter = (_dec = withStyle(generateStyle, generateComp
555
615
  placement: "end",
556
616
  offset: "medium",
557
617
  screenReaderLabel: t('Close')
558
- })), jsx(ModalBody, null, !subAccountBankSharingEnabled && this.renderAccountPermissions(), !subAccountBankSharingEnabled && this.renderSearchSection(), this.state.shares.size > 0 ? this.renderEntitiesSection() : _ref7), jsx(ModalFooter, null, this.renderFooter()));
618
+ })), jsx(ModalBody, null, !subAccountBankSharingEnabled && this.renderRootAccountSharing(), !subAccountBankSharingEnabled && this.renderSearchSection(), this.state.shares.size > 0 ? this.renderEntitiesSection() : _ref7), jsx(ModalFooter, null, this.renderFooter()));
559
619
  }
560
620
  }]);
561
621
 
@@ -85,7 +85,7 @@ var RootAccountSharing = (_dec = (0, _emotion.withStyle)(_styles.default, _theme
85
85
  }, /*#__PURE__*/_react.default.createElement(_uiGrid.Grid.Row, null, _ref, /*#__PURE__*/_react.default.createElement(_uiGrid.Grid.Col, null, /*#__PURE__*/_react.default.createElement(_uiView.View, {
86
86
  as: "div",
87
87
  padding: "0 0 x-small 0"
88
- }, this.props.accountName || (0, _formatMessage.default)('Account')), /*#__PURE__*/_react.default.createElement(_uiCheckbox.Checkbox, {
88
+ }, this.props.accountName), /*#__PURE__*/_react.default.createElement(_uiCheckbox.Checkbox, {
89
89
  label: (0, _formatMessage.default)('Share with Institution'),
90
90
  variant: "toggle",
91
91
  value: "accountPermission",
@@ -109,11 +109,12 @@ var RootAccountSharing = (_dec = (0, _emotion.withStyle)(_styles.default, _theme
109
109
  RootAccountSharing.displayName = "RootAccountSharing";
110
110
  return RootAccountSharing;
111
111
  }(_react.Component), _class2.propTypes = {
112
- accountName: _propTypes.default.string.isRequired,
112
+ accountName: _propTypes.default.string,
113
113
  onShareChange: _propTypes.default.func.isRequired,
114
114
  onShareTypeChange: _propTypes.default.func.isRequired,
115
115
  accountPermission: _propTypes.default.string
116
116
  }, _class2.defaultProps = {
117
+ accountName: (0, _formatMessage.default)('Account'),
117
118
  accountPermission: null
118
119
  }, _temp)) || _class);
119
120
  exports.RootAccountSharing = RootAccountSharing;
@@ -19,41 +19,33 @@ var _react = require("react");
19
19
 
20
20
  var _propTypes = _interopRequireDefault(require("prop-types"));
21
21
 
22
- var _immutable = require("immutable");
23
-
24
22
  var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
25
23
 
26
- var _uiIcons = require("@instructure/ui-icons");
27
-
28
- var _uiA11yContent = require("@instructure/ui-a11y-content");
24
+ var _immutable = require("immutable");
29
25
 
30
- var _uiView = require("@instructure/ui-view");
26
+ var _uiIcons = require("@instructure/ui-icons");
31
27
 
32
28
  var _uiGrid = require("@instructure/ui-grid");
33
29
 
34
- var _uiText = require("@instructure/ui-text");
35
-
36
30
  var _uiAvatar = require("@instructure/ui-avatar");
37
31
 
38
- var _uiTabs = require("@instructure/ui-tabs");
32
+ var _uiSimpleSelect = require("@instructure/ui-simple-select");
33
+
34
+ var _uiA11yContent = require("@instructure/ui-a11y-content");
39
35
 
40
36
  var _emotion = require("@instructure/emotion");
41
37
 
42
- var _index = require("../ContextualIconButton/index.js");
38
+ var _quizCommon = require("@instructure/quiz-common");
43
39
 
44
- var _RootAccountSharing = _interopRequireDefault(require("../RootAccountSharing.js"));
40
+ var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
45
41
 
46
- var _uiSimpleSelect = require("@instructure/ui-simple-select");
42
+ var _index = require("../ContextualIconButton/index.js");
47
43
 
48
44
  var _styles = _interopRequireDefault(require("./styles.js"));
49
45
 
50
- var _quizCommon = require("@instructure/quiz-common");
51
-
52
- var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
53
-
54
46
  var _dec, _class, _class2, _temp;
55
47
 
56
- var _ref4 = (0, _emotion.jsx)(_uiIcons.IconCoursesLine, {
48
+ var _ref3 = (0, _emotion.jsx)(_uiIcons.IconCoursesLine, {
57
49
  size: "small"
58
50
  });
59
51
 
@@ -72,16 +64,13 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
72
64
  }
73
65
 
74
66
  _this = _super.call.apply(_super, [this].concat(args));
75
- _this.state = {
76
- selectedTabIndex: 0
77
- };
78
67
 
79
- _this.handleTabChange = function (event, _ref) {
80
- var index = _ref.index;
68
+ _this.handlePermissionChange = function (entity) {
69
+ return function (e, _ref) {
70
+ var value = _ref.value;
81
71
 
82
- _this.setState({
83
- selectedTabIndex: index
84
- });
72
+ _this.props.onPermissionChange(entity, value);
73
+ };
85
74
  };
86
75
 
87
76
  _this.handleEntityRemove = function (e, _ref2) {
@@ -91,15 +80,7 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
91
80
  _this.props.onEntityRemove(entity, isEntityRemoved);
92
81
  };
93
82
 
94
- _this.handlePermissionChange = function (entity) {
95
- return function (e, _ref3) {
96
- var value = _ref3.value;
97
-
98
- _this.props.onPermissionChange(entity, value);
99
- };
100
- };
101
-
102
- _this.removeButton = function (entity, isEntityRemoved) {
83
+ _this.renderRemoveButton = function (entity, isEntityRemoved) {
103
84
  var context = {
104
85
  entity: entity,
105
86
  isEntityRemoved: isEntityRemoved
@@ -118,7 +99,7 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
118
99
  });
119
100
  };
120
101
 
121
- _this.renderEntity = function (entity, index) {
102
+ _this.renderEntity = function (entity) {
122
103
  var isEntityRemoved = entity.get('permission') === _quizCommon.REMOVED_ACCESS;
123
104
 
124
105
  var isCourse = entity.get('entityType') === _quizCommon.SHARED_WITH_COURSE;
@@ -133,7 +114,7 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
133
114
  "data-automation": "sdk-shared-with-entity-row"
134
115
  }, (0, _emotion.jsx)(_uiGrid.Grid.Col, {
135
116
  width: "small"
136
- }, isCourse ? _ref4 : (0, _emotion.jsx)(_uiAvatar.Avatar, {
117
+ }, isCourse ? _ref3 : (0, _emotion.jsx)(_uiAvatar.Avatar, {
137
118
  name: entity.get('title'),
138
119
  src: entity.get('avatar'),
139
120
  size: "small"
@@ -157,113 +138,33 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
157
138
  value: _quizCommon.CAN_EDIT
158
139
  }, (0, _formatMessage.default)('Can edit')))), (0, _emotion.jsx)(_uiGrid.Grid.Col, {
159
140
  width: "auto"
160
- }, !isOnlyEntity && _this.props.canEdit && (_this.props.improvedBankSharingEnabled || !isCourse) && _this.removeButton(entity, isEntityRemoved)));
141
+ }, !isOnlyEntity && _this.props.canEdit && (_this.props.improvedBankSharingEnabled || !isCourse) && _this.renderRemoveButton(entity, isEntityRemoved)));
161
142
  };
162
143
 
163
144
  return _this;
164
145
  }
165
146
 
166
147
  (0, _createClass2.default)(ShareList, [{
167
- key: "renderNewEntities",
168
- value: function renderNewEntities() {
169
- if (!this.props.newEntities.isEmpty()) {
170
- return (0, _emotion.jsx)(_uiView.View, {
171
- as: "div",
172
- margin: "0 0 medium 0"
173
- }, (0, _emotion.jsx)(_uiGrid.Grid, {
174
- vAlign: "middle"
175
- }, this.props.newEntities.map(this.renderEntity)));
176
- }
177
- }
178
- }, {
179
148
  key: "render",
180
149
  value: function render() {
181
- var _this$props = this.props,
182
- shares = _this$props.shares,
183
- subAccountBankSharingEnabled = _this$props.subAccountBankSharingEnabled,
184
- currentUser = _this$props.currentUser;
185
- var newEntityIds = this.props.newEntities.map(function (e) {
186
- return e.get('id');
187
- });
188
- var existingShares = shares.filterNot(function (s) {
189
- return newEntityIds.includes(s.get('id'));
190
- });
191
- var existingPeople = existingShares.filter(function (s) {
192
- return s.get('entityType') === _quizCommon.SHARED_WITH_USER;
193
- });
194
- var existingCourses = existingShares.filter(function (s) {
195
- return s.get('entityType') === _quizCommon.SHARED_WITH_COURSE;
196
- });
197
- var existingAccounts = existingShares.filter(function (s) {
198
- return s.get('entityType') === _quizCommon.SHARED_WITH_ACCOUNT;
199
- });
200
- return (0, _emotion.jsx)("div", {
201
- className: "fs-mask"
202
- }, !subAccountBankSharingEnabled && (0, _emotion.jsx)(_uiText.Text, {
203
- as: "div",
204
- weight: "bold"
205
- }, (0, _formatMessage.default)('Currently shared with')), (0, _emotion.jsx)(_uiView.View, {
206
- as: "div",
207
- "data-automation": "sdk-shared-bank-user-list"
208
- }, !subAccountBankSharingEnabled && this.renderNewEntities(), (0, _emotion.jsx)(_uiTabs.Tabs, {
209
- onRequestTabChange: this.handleTabChange
210
- }, (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
211
- renderTitle: (0, _formatMessage.default)('People ({ peopleCount })', {
212
- peopleCount: existingPeople.size
213
- }),
214
- isSelected: this.state.selectedTabIndex === 0,
215
- padding: "large small small small"
216
- }, subAccountBankSharingEnabled && this.props.renderSearchSection(_quizCommon.SHARED_WITH_USER), subAccountBankSharingEnabled && (0, _emotion.jsx)(_uiText.Text, {
217
- as: "div",
218
- weight: "bold",
219
- lineHeight: "double"
220
- }, (0, _formatMessage.default)('Currently shared with')), (0, _emotion.jsx)(_uiGrid.Grid, {
221
- vAlign: "middle"
222
- }, existingPeople.map(this.renderEntity))), (!existingCourses.isEmpty() || subAccountBankSharingEnabled) && (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
223
- renderTitle: (0, _formatMessage.default)('Courses ({ coursesCount })', {
224
- coursesCount: existingCourses.size
225
- }),
226
- isSelected: this.state.selectedTabIndex === 1,
227
- padding: "large small small small"
228
- }, subAccountBankSharingEnabled && this.props.renderSearchSection(_quizCommon.SHARED_WITH_COURSE), subAccountBankSharingEnabled && (0, _emotion.jsx)(_uiText.Text, {
229
- as: "div",
230
- weight: "bold",
231
- lineHeight: "double"
232
- }, (0, _formatMessage.default)('Currently shared with')), (0, _emotion.jsx)(_uiGrid.Grid, {
150
+ return (0, _emotion.jsx)(_uiGrid.Grid, {
233
151
  vAlign: "middle"
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
- }),
238
- isSelected: this.state.selectedTabIndex === 2,
239
- padding: "large small small small"
240
- }, (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) && (0, _emotion.jsx)(_RootAccountSharing.default, {
241
- accountName: this.props.accountName,
242
- onShareChange: this.props.onToggleAccountShare,
243
- onShareTypeChange: this.props.onAccountPermissionChange,
244
- accountPermission: this.props.accountPermission
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))))));
152
+ }, this.props.entities.map(this.renderEntity));
252
153
  }
253
154
  }]);
254
155
  ShareList.displayName = "ShareList";
255
156
  return ShareList;
256
157
  }(_react.Component), _class2.propTypes = {
257
158
  canEdit: _propTypes.default.bool.isRequired,
258
- currentUser: _propTypes.default.shape({
259
- bank_admin: _propTypes.default.bool,
260
- can_share_banks_with_subaccounts: _propTypes.default.bool
261
- }),
159
+ entities: _reactImmutableProptypes.default.listOf(_reactImmutableProptypes.default.contains({
160
+ entityType: _propTypes.default.string.isRequired,
161
+ entityId: _propTypes.default.string.isRequired,
162
+ permission: _propTypes.default.string.isRequired,
163
+ id: _propTypes.default.string.isRequired
164
+ })).isRequired,
262
165
  improvedBankSharingEnabled: _propTypes.default.bool.isRequired,
263
- newEntities: _reactImmutableProptypes.default.list,
264
- onEntityRemove: _propTypes.default.func.isRequired,
265
166
  onPermissionChange: _propTypes.default.func.isRequired,
266
- renderSearchSection: _propTypes.default.func.isRequired,
167
+ onEntityRemove: _propTypes.default.func.isRequired,
267
168
  sharedBanks: _reactImmutableProptypes.default.list,
268
169
  shares: _reactImmutableProptypes.default.listOf(_reactImmutableProptypes.default.contains({
269
170
  avatar: _propTypes.default.string,
@@ -273,19 +174,8 @@ var ShareList = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_cl
273
174
  permission: _propTypes.default.string.isRequired,
274
175
  id: _propTypes.default.string.isRequired
275
176
  })).isRequired,
276
- subAccountBankSharingEnabled: _propTypes.default.bool.isRequired,
277
177
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
278
- styles: _propTypes.default.object,
279
- accountName: _propTypes.default.string,
280
- onAccountPermissionChange: _propTypes.default.func.isRequired,
281
- onToggleAccountShare: _propTypes.default.func.isRequired,
282
- accountPermission: _propTypes.default.string
283
- }, _class2.defaultProps = {
284
- accountName: (0, _formatMessage.default)('Account'),
285
- accountPermission: null,
286
- currentUser: null,
287
- newEntities: (0, _immutable.List)(),
288
- sharedBanks: (0, _immutable.List)()
178
+ styles: _propTypes.default.object
289
179
  }, _temp)) || _class);
290
180
  exports.ShareList = ShareList;
291
181
  var _default = ShareList;
@@ -43,15 +43,13 @@ var _uiHeading = require("@instructure/ui-heading");
43
43
 
44
44
  var _uiButtons = require("@instructure/ui-buttons");
45
45
 
46
- var _uiIcons = require("@instructure/ui-icons");
47
-
48
- var _uiCheckbox = require("@instructure/ui-checkbox");
49
-
50
46
  var _uiView = require("@instructure/ui-view");
51
47
 
52
48
  var _uiGrid = require("@instructure/ui-grid");
53
49
 
54
- var _uiA11yContent = require("@instructure/ui-a11y-content");
50
+ var _uiTabs = require("@instructure/ui-tabs");
51
+
52
+ var _uiText = require("@instructure/ui-text");
55
53
 
56
54
  var _uiSimpleSelect = require("@instructure/ui-simple-select");
57
55
 
@@ -65,6 +63,8 @@ var _index = _interopRequireDefault(require("./ShareList/index.js"));
65
63
 
66
64
  var _index2 = _interopRequireDefault(require("../AsyncSearch/index.js"));
67
65
 
66
+ var _RootAccountSharing = _interopRequireDefault(require("./RootAccountSharing.js"));
67
+
68
68
  var _Spinner = _interopRequireDefault(require("../../../common/components/shared/spinner/Spinner.js"));
69
69
 
70
70
  var _styles = _interopRequireDefault(require("./styles.js"));
@@ -77,12 +77,6 @@ var _dec, _class, _class2, _temp;
77
77
 
78
78
  var noop = function noop() {};
79
79
 
80
- var _ref6 = (0, _emotion.jsx)(_uiGrid.Grid.Col, {
81
- width: "auto"
82
- }, (0, _emotion.jsx)(_uiIcons.IconAdminLine, {
83
- size: "medium"
84
- }));
85
-
86
80
  var _ref7 = (0, _emotion.jsx)(_Spinner.default, null);
87
81
 
88
82
  var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
@@ -106,7 +100,8 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
106
100
  newEntities: (0, _immutable.List)(),
107
101
  searchSelection: [],
108
102
  searchPermission: _quizCommon.READ_ONLY,
109
- entitiesWithChangedPermission: {}
103
+ entitiesWithChangedPermission: {},
104
+ selectedTabIndex: 0
110
105
  };
111
106
  _this.shareListRef = null;
112
107
  _this.shareButtonRef = null;
@@ -128,6 +123,14 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
128
123
  }
129
124
  };
130
125
 
126
+ _this.handleTabChange = function (event, _ref) {
127
+ var index = _ref.index;
128
+
129
+ _this.setState({
130
+ selectedTabIndex: index
131
+ });
132
+ };
133
+
131
134
  _this.modalDismissCleanup = function () {
132
135
  var focusCreateBank = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
133
136
 
@@ -200,10 +203,10 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
200
203
  }); // call the update api if any shared bank permission was updated
201
204
 
202
205
 
203
- Object.entries(_this.state.entitiesWithChangedPermission).forEach(function (_ref) {
204
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
205
- sharedBankId = _ref2[0],
206
- permission = _ref2[1];
206
+ Object.entries(_this.state.entitiesWithChangedPermission).forEach(function (_ref2) {
207
+ var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
208
+ sharedBankId = _ref3[0],
209
+ permission = _ref3[1];
207
210
 
208
211
  var sharedBank = _this.props.sharedBanks.find(function (sharedBank) {
209
212
  return sharedBank.get('id') === sharedBankId;
@@ -269,8 +272,8 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
269
272
  }
270
273
  };
271
274
 
272
- _this.handleSearchPermissionChange = function (e, _ref3) {
273
- var value = _ref3.value;
275
+ _this.handleSearchPermissionChange = function (e, _ref4) {
276
+ var value = _ref4.value;
274
277
 
275
278
  _this.setState({
276
279
  searchPermission: value
@@ -318,7 +321,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
318
321
  };
319
322
 
320
323
  _this.updatePermission = /*#__PURE__*/function () {
321
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(entity, permission) {
324
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(entity, permission) {
322
325
  var _this$props, updateSharedBankPermission, getBank, bank;
323
326
 
324
327
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -341,7 +344,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
341
344
  }));
342
345
 
343
346
  return function (_x, _x2) {
344
- return _ref4.apply(this, arguments);
347
+ return _ref5.apply(this, arguments);
345
348
  };
346
349
  }();
347
350
 
@@ -392,8 +395,8 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
392
395
  });
393
396
  };
394
397
 
395
- _this.handleAccountPermissionChange = function (e, _ref5) {
396
- var value = _ref5.value;
398
+ _this.handleAccountPermissionChange = function (e, _ref6) {
399
+ var value = _ref6.value;
397
400
  return _this.setState({
398
401
  accountPermission: value
399
402
  });
@@ -447,6 +450,18 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
447
450
  }
448
451
  };
449
452
 
453
+ _this.renderShareList = function (entities) {
454
+ return (0, _emotion.jsx)(_index.default, {
455
+ canEdit: _this.props.bank.canEdit(),
456
+ entities: entities,
457
+ improvedBankSharingEnabled: _this.props.improvedBankSharingEnabled,
458
+ onPermissionChange: _this.handleEntityPermissionChange,
459
+ onEntityRemove: _this.handleEntityRemove,
460
+ sharedBanks: _this.props.sharedBanks,
461
+ shares: _this.state.shares
462
+ });
463
+ };
464
+
450
465
  return _this;
451
466
  }
452
467
 
@@ -489,70 +504,115 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
489
504
  };
490
505
  }
491
506
  }, {
492
- key: "renderAccountPermissions",
507
+ key: "renderRootAccountSharing",
493
508
  // =============
494
509
  // RENDERING
495
510
  // =============
496
- value: function renderAccountPermissions() {
497
- var _this$props2 = this.props,
498
- currentUser = _this$props2.currentUser,
499
- improvedBankSharingEnabled = _this$props2.improvedBankSharingEnabled;
500
-
501
- if (improvedBankSharingEnabled && (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin)) {
502
- return (0, _emotion.jsx)(_uiView.View, {
503
- as: "div",
504
- margin: "0 0 medium 0"
505
- }, (0, _emotion.jsx)(_uiGrid.Grid, {
506
- colSpacing: "small"
507
- }, (0, _emotion.jsx)(_uiGrid.Grid.Row, null, _ref6, (0, _emotion.jsx)(_uiGrid.Grid.Col, null, (0, _emotion.jsx)(_uiView.View, {
508
- as: "div",
509
- padding: "0 0 x-small 0"
510
- }, currentUser && currentUser.account_name || (0, _formatMessage.default)('Account')), (0, _emotion.jsx)(_uiCheckbox.Checkbox, {
511
- label: (0, _formatMessage.default)('Share with Institution'),
512
- variant: "toggle",
513
- value: "accountPermission",
514
- checked: this.isSharedWithAccount(),
515
- onChange: this.toggleAccountShare
516
- })), this.isSharedWithAccount() && (0, _emotion.jsx)(_uiGrid.Grid.Col, {
517
- width: "auto"
518
- }, (0, _emotion.jsx)(_uiSimpleSelect.SimpleSelect, {
519
- onChange: this.handleAccountPermissionChange,
520
- value: this.state.accountPermission,
521
- renderLabel: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage.default)('Access for account'))
522
- }, (0, _emotion.jsx)(_uiSimpleSelect.SimpleSelect.Option, {
523
- id: "sharing-modal-account-perm-select-option-can-view",
524
- value: _quizCommon.READ_ONLY
525
- }, (0, _formatMessage.default)('Can view')), (0, _emotion.jsx)(_uiSimpleSelect.SimpleSelect.Option, {
526
- id: "sharing-modal-account-perm-select-option-can-edit",
527
- value: _quizCommon.CAN_EDIT
528
- }, (0, _formatMessage.default)('Can edit')))))));
529
- }
511
+ value: function renderRootAccountSharing() {
512
+ var _this$props$currentUs;
513
+
514
+ return (0, _emotion.jsx)(_RootAccountSharing.default, {
515
+ accountName: (_this$props$currentUs = this.props.currentUser) === null || _this$props$currentUs === void 0 ? void 0 : _this$props$currentUs.account_name,
516
+ onShareChange: this.toggleAccountShare,
517
+ onShareTypeChange: this.handleAccountPermissionChange,
518
+ accountPermission: this.state.accountPermission
519
+ });
520
+ }
521
+ }, {
522
+ key: "renderSubaccountSharingEnabledEntities",
523
+ value: function renderSubaccountSharingEnabledEntities(existingPeople, existingCourses, existingAccounts) {
524
+ var currentUser = this.props.currentUser;
525
+ return (0, _emotion.jsx)(_uiView.View, {
526
+ as: "div",
527
+ "data-automation": "sdk-shared-bank-user-list"
528
+ }, (0, _emotion.jsx)(_uiTabs.Tabs, {
529
+ onRequestTabChange: this.handleTabChange
530
+ }, (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
531
+ renderTitle: (0, _formatMessage.default)('People ({ peopleCount })', {
532
+ peopleCount: existingPeople.size
533
+ }),
534
+ isSelected: this.state.selectedTabIndex === 0,
535
+ padding: "large small small small"
536
+ }, this.renderSearchSection(_quizCommon.SHARED_WITH_USER), (0, _emotion.jsx)(_uiText.Text, {
537
+ as: "div",
538
+ weight: "bold",
539
+ lineHeight: "double"
540
+ }, (0, _formatMessage.default)('Currently shared with')), this.renderShareList(existingPeople)), (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
541
+ renderTitle: (0, _formatMessage.default)('Courses ({ coursesCount })', {
542
+ coursesCount: existingCourses.size
543
+ }),
544
+ isSelected: this.state.selectedTabIndex === 1,
545
+ padding: "large small small small"
546
+ }, this.renderSearchSection(_quizCommon.SHARED_WITH_COURSE), (0, _emotion.jsx)(_uiText.Text, {
547
+ as: "div",
548
+ weight: "bold",
549
+ lineHeight: "double"
550
+ }, (0, _formatMessage.default)('Currently shared with')), this.renderShareList(existingCourses)), ((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, {
551
+ renderTitle: (0, _formatMessage.default)('Accounts ({ accountsCount })', {
552
+ accountsCount: existingAccounts.size
553
+ }),
554
+ isSelected: this.state.selectedTabIndex === 2,
555
+ padding: "large small small small"
556
+ }, (currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) && this.renderRootAccountSharing(), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.can_share_banks_with_subaccounts) && this.renderSearchSection(_quizCommon.SHARED_WITH_ACCOUNT), (0, _emotion.jsx)(_uiText.Text, {
557
+ as: "div",
558
+ weight: "bold",
559
+ lineHeight: "double"
560
+ }, (0, _formatMessage.default)('Currently shared with')), this.renderShareList(existingAccounts))));
561
+ }
562
+ }, {
563
+ key: "renderOriginalDesignEntities",
564
+ value: function renderOriginalDesignEntities(existingPeople, existingCourses) {
565
+ return (0, _emotion.jsx)("div", {
566
+ className: "fs-mask"
567
+ }, (0, _emotion.jsx)(_uiText.Text, {
568
+ as: "div",
569
+ weight: "bold"
570
+ }, (0, _formatMessage.default)('Currently shared with')), (0, _emotion.jsx)(_uiView.View, {
571
+ as: "div",
572
+ "data-automation": "sdk-shared-bank-user-list"
573
+ }, !this.state.newEntities.isEmpty() && (0, _emotion.jsx)(_uiView.View, {
574
+ as: "div",
575
+ margin: "0 0 medium 0"
576
+ }, this.renderShareList(this.state.newEntities)), (0, _emotion.jsx)(_uiTabs.Tabs, {
577
+ onRequestTabChange: this.handleTabChange
578
+ }, (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
579
+ renderTitle: (0, _formatMessage.default)('People ({ peopleCount })', {
580
+ peopleCount: existingPeople.size
581
+ }),
582
+ isSelected: this.state.selectedTabIndex === 0,
583
+ padding: "large small small small"
584
+ }, this.renderShareList(existingPeople)), !existingCourses.isEmpty() && (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
585
+ renderTitle: (0, _formatMessage.default)('Courses ({ coursesCount })', {
586
+ coursesCount: existingCourses.size
587
+ }),
588
+ isSelected: this.state.selectedTabIndex === 1,
589
+ padding: "large small small small"
590
+ }, this.renderShareList(existingCourses)))));
530
591
  }
531
592
  }, {
532
593
  key: "renderEntitiesSection",
533
594
  value: function renderEntitiesSection() {
534
- return (0, _emotion.jsx)(_index.default, {
535
- accountName: this.props.currentUser.account_name,
536
- accountPermission: this.state.accountPermission,
537
- canEdit: this.props.bank.canEdit(),
538
- currentUser: this.props.currentUser,
539
- entitiesWithChangedPermission: this.state.entitiesWithChangedPermission,
540
- improvedBankSharingEnabled: this.props.improvedBankSharingEnabled,
541
- newEntities: this.state.newEntities,
542
- onAccountPermissionChange: this.handleAccountPermissionChange,
543
- onEntityRemove: this.handleEntityRemove,
544
- onPermissionChange: this.handleEntityPermissionChange,
545
- onToggleAccountShare: this.toggleAccountShare,
546
- ref: this.handleShareListRef,
547
- renderSearchSection: this.renderSearchSection // searchPermission and searchSelection are not used directly by ShareList,
548
- // but are needed as props so that AsyncSearch/Select rerenders when those values change
549
- ,
550
- searchPermission: this.state.searchPermission,
551
- searchSelection: this.state.searchSelection,
552
- sharedBanks: this.props.sharedBanks,
553
- shares: this.state.shares,
554
- subAccountBankSharingEnabled: this.props.subAccountBankSharingEnabled
595
+ var newEntityIds = this.state.newEntities.map(function (e) {
596
+ return e.get('id');
597
+ });
598
+ var existingShares = this.state.shares.filterNot(function (s) {
599
+ return newEntityIds.includes(s.get('id'));
600
+ });
601
+ var existingPeople = existingShares.filter(function (s) {
602
+ return s.get('entityType') === _quizCommon.SHARED_WITH_USER;
603
+ });
604
+ var existingCourses = existingShares.filter(function (s) {
605
+ return s.get('entityType') === _quizCommon.SHARED_WITH_COURSE;
606
+ });
607
+ var existingAccounts = existingShares.filter(function (s) {
608
+ return s.get('entityType') === _quizCommon.SHARED_WITH_ACCOUNT;
555
609
  });
610
+
611
+ if (this.props.subAccountBankSharingEnabled) {
612
+ return this.renderSubaccountSharingEnabledEntities(existingPeople, existingCourses, existingAccounts);
613
+ }
614
+
615
+ return this.renderOriginalDesignEntities(existingPeople, existingCourses);
556
616
  }
557
617
  }, {
558
618
  key: "renderFooter",
@@ -593,7 +653,7 @@ var SharingModalPresenter = (_dec = (0, _emotion.withStyle)(_styles.default, _th
593
653
  placement: "end",
594
654
  offset: "medium",
595
655
  screenReaderLabel: (0, _formatMessage.default)('Close')
596
- })), (0, _emotion.jsx)(_quizCommon.ModalBody, null, !subAccountBankSharingEnabled && this.renderAccountPermissions(), !subAccountBankSharingEnabled && this.renderSearchSection(), this.state.shares.size > 0 ? this.renderEntitiesSection() : _ref7), (0, _emotion.jsx)(_quizCommon.ModalFooter, null, this.renderFooter()));
656
+ })), (0, _emotion.jsx)(_quizCommon.ModalBody, null, !subAccountBankSharingEnabled && this.renderRootAccountSharing(), !subAccountBankSharingEnabled && this.renderSearchSection(), this.state.shares.size > 0 ? this.renderEntitiesSection() : _ref7), (0, _emotion.jsx)(_quizCommon.ModalFooter, null, this.renderFooter()));
597
657
  }
598
658
  }]);
599
659
  SharingModalPresenter.displayName = "SharingModalPresenter";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.10.1-rc.4+9acb43863",
3
+ "version": "20.10.1-rc.5+000550e27",
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.4+9acb43863",
48
- "@instructure/quiz-i18n": "20.10.1-rc.4+9acb43863",
49
- "@instructure/quiz-interactions": "20.10.1-rc.4+9acb43863",
50
- "@instructure/quiz-number-input": "20.10.1-rc.4+9acb43863",
51
- "@instructure/quiz-rce": "20.10.1-rc.4+9acb43863",
47
+ "@instructure/quiz-common": "20.10.1-rc.5+000550e27",
48
+ "@instructure/quiz-i18n": "20.10.1-rc.5+000550e27",
49
+ "@instructure/quiz-interactions": "20.10.1-rc.5+000550e27",
50
+ "@instructure/quiz-number-input": "20.10.1-rc.5+000550e27",
51
+ "@instructure/quiz-rce": "20.10.1-rc.5+000550e27",
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.4+9acb43863",
115
+ "instructure-validations": "20.10.1-rc.5+000550e27",
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.4+9acb43863",
166
+ "quiz-presets": "20.10.1-rc.5+000550e27",
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": "9acb4386324ea4b9b5a7d896782821bbacc44778"
182
+ "gitHead": "000550e2798491a2c0ecb006d4be4abc227fc685"
183
183
  }