@instructure/quiz-core 20.10.1-rc.3 → 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.
Files changed (15) hide show
  1. package/es/banks/components/SharingModal/RootAccountSharing.js +3 -2
  2. package/es/banks/components/SharingModal/ShareList/index.js +25 -131
  3. package/es/banks/components/SharingModal/presenter.js +138 -78
  4. package/es/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/MatchingType/CategorizationType.js +3 -1
  5. package/es/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/shared/AfsTableWrapper/presenter.js +8 -2
  6. package/es/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/shared/AggregationTable/presenter.js +2 -6
  7. package/lib/banks/components/SharingModal/RootAccountSharing.js +3 -2
  8. package/lib/banks/components/SharingModal/ShareList/index.js +28 -138
  9. package/lib/banks/components/SharingModal/presenter.js +139 -79
  10. package/lib/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/MatchingType/CategorizationType.js +3 -1
  11. package/lib/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/shared/AfsTableWrapper/presenter.js +10 -2
  12. package/lib/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/shared/AggregationTable/presenter.js +2 -8
  13. package/package.json +9 -9
  14. /package/es/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/shared/{AggregationTable → AfsTableWrapper}/popoverContent.js +0 -0
  15. /package/lib/reporting/components/resources/NewQuizAndItemAnalysis/AnswerFrequencySummary/shared/{AggregationTable → AfsTableWrapper}/popoverContent.js +0 -0
@@ -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
 
@@ -50,7 +50,9 @@ export var CategorizationType = /*#__PURE__*/function (_Component) {
50
50
 
51
51
  var updatedAnswerSummary = _this.updateAnswerBody(answerSummary);
52
52
 
53
- return /*#__PURE__*/React.createElement(AfsTableWrapper, null, /*#__PURE__*/React.createElement(AfsPartsContainer, {
53
+ return /*#__PURE__*/React.createElement(AfsTableWrapper, {
54
+ noAnswerMissingPopover: true
55
+ }, /*#__PURE__*/React.createElement(AfsPartsContainer, {
54
56
  afsTable: /*#__PURE__*/React.createElement(MatchingTypeTable, {
55
57
  itemId: itemId,
56
58
  answerSummary: updatedAnswerSummary,
@@ -12,6 +12,8 @@ import { Heading } from '@instructure/ui-heading';
12
12
  import { withStyle, jsx } from '@instructure/emotion';
13
13
  import generateStyle from "./styles.js";
14
14
  import PropTypes from 'prop-types';
15
+ import { noAnswerMissing } from "./popoverContent.js";
16
+ import MetricPopover from "../../../MetricPopover/index.js";
15
17
  export var AfsTableWrapper = (_dec = withStyle(generateStyle, null), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
16
18
  _inherits(AfsTableWrapper, _Component);
17
19
 
@@ -34,6 +36,7 @@ export var AfsTableWrapper = (_dec = withStyle(generateStyle, null), _dec(_class
34
36
  };
35
37
 
36
38
  _this.render = function () {
39
+ var noAnswerMissingPopover = _this.props.noAnswerMissingPopover;
37
40
  return jsx(Flex, {
38
41
  direction: "row",
39
42
  "data-testid": "AfsTableWrapper"
@@ -46,7 +49,9 @@ export var AfsTableWrapper = (_dec = withStyle(generateStyle, null), _dec(_class
46
49
  level: "h3",
47
50
  weight: "bold",
48
51
  color: "primary"
49
- }, _this.getHeader()), _this.props.children)));
52
+ }, jsx(Flex, {
53
+ gap: "x-small"
54
+ }, jsx(Flex.Item, null, _this.getHeader()), jsx(Flex.Item, null, noAnswerMissingPopover && jsx(MetricPopover, noAnswerMissing)))), _this.props.children)));
50
55
  };
51
56
 
52
57
  return _this;
@@ -56,5 +61,6 @@ export var AfsTableWrapper = (_dec = withStyle(generateStyle, null), _dec(_class
56
61
  }(Component), _class2.propTypes = {
57
62
  children: PropTypes.node.isRequired,
58
63
  styles: PropTypes.object,
59
- tableHeader: PropTypes.string
64
+ tableHeader: PropTypes.string,
65
+ noAnswerMissingPopover: PropTypes.bool
60
66
  }, _temp)) || _class);
@@ -35,8 +35,6 @@ var styles = {
35
35
  import { Flex } from '@instructure/ui-flex';
36
36
  import classNames from 'classnames';
37
37
  import { Text } from '@instructure/ui-text';
38
- import MetricPopover from "../../../MetricPopover/index.js";
39
- import { noAnswerMissing } from "./popoverContent.js";
40
38
  var noAnswerKey = 'noAnswer';
41
39
  var incorrectKey = 'incorrect';
42
40
  var correctKey = 'correct';
@@ -74,11 +72,9 @@ export var AggregationTable = (_dec = themeable(theme, styles), _dec(_class = (_
74
72
  var percentageHeaderId = "answer-frequency-summary-aggregate-percentage-".concat(itemId);
75
73
  return /*#__PURE__*/React.createElement(Table.Head, null, /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.ColHeader, {
76
74
  id: answerHeaderId
77
- }, /*#__PURE__*/React.createElement(Flex, {
78
- gap: "x-small"
79
- }, /*#__PURE__*/React.createElement(Flex.Item, null, /*#__PURE__*/React.createElement("span", {
75
+ }, /*#__PURE__*/React.createElement("span", {
80
76
  className: classNames(styles.firstHeaderCell)
81
- }, t('Result'))), /*#__PURE__*/React.createElement(Flex.Item, null, popover && /*#__PURE__*/React.createElement(MetricPopover, noAnswerMissing)))), /*#__PURE__*/React.createElement(Table.ColHeader, {
77
+ }, t('Result'))), /*#__PURE__*/React.createElement(Table.ColHeader, {
82
78
  id: respondentsHeaderId,
83
79
  textAlign: "center"
84
80
  }, t('Respondents')), /*#__PURE__*/React.createElement(Table.ColHeader, {
@@ -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;