@instructure/quiz-core 20.10.1-rc.4 → 20.10.1-rc.6
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.
- package/es/banks/components/SharingModal/RootAccountSharing.js +3 -2
- package/es/banks/components/SharingModal/ShareList/index.js +25 -131
- package/es/banks/components/SharingModal/presenter.js +138 -78
- package/es/common/components/ImportModal/presenter.js +29 -33
- package/es/common/components/ImportModal/styles.js +9 -0
- package/es/common/components/ImportModal/theme.js +4 -2
- package/es/common/components/SDKApp/index.js +13 -17
- package/es/common/components/SDKApp/styles.js +9 -0
- package/es/common/components/resources/stimulus/StimulusShow/index.js +26 -32
- package/es/common/components/resources/stimulus/StimulusShow/styles.js +33 -0
- package/es/common/components/resources/stimulus/StimulusShow/theme.js +4 -2
- package/lib/banks/components/SharingModal/RootAccountSharing.js +3 -2
- package/lib/banks/components/SharingModal/ShareList/index.js +28 -138
- package/lib/banks/components/SharingModal/presenter.js +139 -79
- package/lib/common/components/ImportModal/presenter.js +28 -34
- package/lib/common/components/ImportModal/styles.js +17 -0
- package/lib/common/components/ImportModal/theme.js +6 -3
- package/lib/common/components/SDKApp/index.js +11 -20
- package/lib/common/components/SDKApp/styles.js +17 -0
- package/lib/common/components/resources/stimulus/StimulusShow/index.js +26 -36
- package/lib/common/components/resources/stimulus/StimulusShow/styles.js +41 -0
- package/lib/common/components/resources/stimulus/StimulusShow/theme.js +6 -3
- package/package.json +9 -9
- package/es/common/components/SDKApp/theme.js +0 -3
- package/lib/common/components/SDKApp/theme.js +0 -10
|
@@ -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
|
|
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
|
|
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 {
|
|
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
|
|
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.
|
|
52
|
-
|
|
44
|
+
_this.handlePermissionChange = function (entity) {
|
|
45
|
+
return function (e, _ref) {
|
|
46
|
+
var value = _ref.value;
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
|
|
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.
|
|
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
|
|
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 ?
|
|
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.
|
|
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
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
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 {
|
|
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 (
|
|
166
|
-
var
|
|
167
|
-
sharedBankId =
|
|
168
|
-
permission =
|
|
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,
|
|
235
|
-
var 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
|
|
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
|
|
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,
|
|
358
|
-
var 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: "
|
|
469
|
+
key: "renderRootAccountSharing",
|
|
455
470
|
// =============
|
|
456
471
|
// RENDERING
|
|
457
472
|
// =============
|
|
458
|
-
value: function
|
|
459
|
-
var _this$
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
},
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
},
|
|
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
|
-
|
|
497
|
-
|
|
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.
|
|
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
|
|