@instructure/quiz-core 20.10.1-rc.7 → 20.11.0

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.
@@ -25,6 +25,12 @@ var _uiMenu = require("@instructure/ui-menu");
25
25
 
26
26
  var _uiIcons = require("@instructure/ui-icons");
27
27
 
28
+ var _uiView = require("@instructure/ui-view");
29
+
30
+ var _uiDrilldown = require("@instructure/ui-drilldown");
31
+
32
+ var _uiTopNavBar = require("@instructure/ui-top-nav-bar");
33
+
28
34
  var _index = _interopRequireDefault(require("../../../../../common/components/shared/PrintTrigger/index.js"));
29
35
 
30
36
  var _quizCommon = require("@instructure/quiz-common");
@@ -39,6 +45,8 @@ var _theme = _interopRequireDefault(require("./theme.js"));
39
45
 
40
46
  var _dec, _class, _class2, _temp;
41
47
 
48
+ var _ref = (0, _emotion.jsx)(_uiIcons.IconSpeedGraderLine, null);
49
+
42
50
  var BuildingButtons = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
43
51
  (0, _inherits2.default)(BuildingButtons, _Component);
44
52
 
@@ -95,6 +103,16 @@ var BuildingButtons = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.de
95
103
  }
96
104
 
97
105
  (0, _createClass2.default)(BuildingButtons, [{
106
+ key: "componentDidMount",
107
+ value: function componentDidMount() {
108
+ this.props.makeStyles();
109
+ }
110
+ }, {
111
+ key: "componentWillUnmount",
112
+ value: function componentWillUnmount() {
113
+ this.props.makeStyles();
114
+ }
115
+ }, {
98
116
  key: "renderSavingMessage",
99
117
  value: function renderSavingMessage() {
100
118
  if (this.props.quizSaving) {
@@ -108,6 +126,214 @@ var BuildingButtons = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.de
108
126
  value: function isBuildingPage() {
109
127
  return 'building' === this.props.app;
110
128
  }
129
+ }, {
130
+ key: "renderSpeedGraderButton",
131
+ value: function renderSpeedGraderButton() {
132
+ var key = 'speedgrader';
133
+ var text = (0, _formatMessage.default)('Speedgrader');
134
+
135
+ if (this.props.iceTopNavBarEnabled) {
136
+ return (0, _emotion.jsx)(_uiDrilldown.Drilldown.Option, {
137
+ id: key,
138
+ key: key,
139
+ onOptionClick: this.openSpeedgraderLink
140
+ }, _ref, (0, _emotion.jsx)(_uiView.View, {
141
+ as: "span",
142
+ margin: "0 0 0 x-small"
143
+ }, text));
144
+ }
145
+
146
+ return (0, _emotion.jsx)(_uiMenu.Menu.Item, {
147
+ key: key,
148
+ onSelect: this.openSpeedgraderLink
149
+ }, (0, _emotion.jsx)(_uiIcons.IconSpeedGraderLine, {
150
+ css: this.props.styles.menuIcon
151
+ }), text);
152
+ }
153
+ }, {
154
+ key: "renderImportContentButton",
155
+ value: function renderImportContentButton() {
156
+ var key = 'import';
157
+ var text = (0, _formatMessage.default)('Import Content');
158
+ var onClick = this.props.openModal;
159
+ var disabled = !this.props.canImport;
160
+ var menuItemDataAutomation = 'sdk-import-content-menuitem';
161
+ var iconDataAutomation = 'sdk-import-content-icon';
162
+
163
+ if (this.props.iceTopNavBarEnabled) {
164
+ return (0, _emotion.jsx)(_uiDrilldown.Drilldown.Option, {
165
+ id: key,
166
+ key: key,
167
+ disabled: disabled,
168
+ onOptionClick: onClick,
169
+ "data-automation": menuItemDataAutomation
170
+ }, (0, _emotion.jsx)(_uiIcons.IconImportLine, {
171
+ "data-automation": iconDataAutomation
172
+ }), (0, _emotion.jsx)(_uiView.View, {
173
+ as: "span",
174
+ margin: "0 0 0 x-small"
175
+ }, text));
176
+ }
177
+
178
+ return (0, _emotion.jsx)(_uiMenu.Menu.Item, {
179
+ key: key,
180
+ disabled: disabled,
181
+ onSelect: onClick,
182
+ "data-automation": menuItemDataAutomation
183
+ }, (0, _emotion.jsx)(_uiIcons.IconImportLine, {
184
+ css: this.props.styles.menuIcon,
185
+ "data-automation": iconDataAutomation
186
+ }), text);
187
+ }
188
+ }, {
189
+ key: "renderContentExportButton",
190
+ value: function renderContentExportButton() {
191
+ var key = 'export';
192
+ var text = (0, _formatMessage.default)('Export Content');
193
+ var onClick = this.startQuizExportJob;
194
+ var disabled = !this.props.canExport;
195
+ var menuItemDataAutomation = 'sdk-export-content-menuitem';
196
+ var iconDataAutomation = 'sdk-export-content-icon';
197
+
198
+ if (this.props.iceTopNavBarEnabled) {
199
+ return (0, _emotion.jsx)(_uiDrilldown.Drilldown.Option, {
200
+ id: key,
201
+ key: key,
202
+ disabled: disabled,
203
+ onOptionClick: onClick,
204
+ "data-automation": menuItemDataAutomation
205
+ }, (0, _emotion.jsx)(_uiIcons.IconExportLine, {
206
+ "data-automation": iconDataAutomation
207
+ }), (0, _emotion.jsx)(_uiView.View, {
208
+ as: "span",
209
+ margin: "0 0 0 x-small"
210
+ }, text));
211
+ }
212
+
213
+ return (0, _emotion.jsx)(_uiMenu.Menu.Item, {
214
+ key: key,
215
+ disabled: disabled,
216
+ onSelect: onClick,
217
+ "data-automation": menuItemDataAutomation
218
+ }, (0, _emotion.jsx)(_uiIcons.IconExportLine, {
219
+ css: this.props.styles.menuIcon,
220
+ "data-automation": iconDataAutomation
221
+ }), text);
222
+ }
223
+ }, {
224
+ key: "renderManageItemBanksButton",
225
+ value: function renderManageItemBanksButton() {
226
+ var key = 'banks';
227
+ var text = (0, _formatMessage.default)('Manage Item Banks');
228
+ var onClick = this.props.navigateToBanks;
229
+ var menuItemDataAutomation = 'sdk-manage-item-banks-menuitem';
230
+ var iconDataAutomation = 'sdk-manage-item-banks-icon';
231
+
232
+ if (this.props.iceTopNavBarEnabled) {
233
+ return (0, _emotion.jsx)(_uiDrilldown.Drilldown.Option, {
234
+ id: key,
235
+ key: key,
236
+ onOptionClick: onClick,
237
+ "data-automation": menuItemDataAutomation
238
+ }, (0, _emotion.jsx)(_uiIcons.IconBankLine, {
239
+ "data-automation": iconDataAutomation
240
+ }), (0, _emotion.jsx)(_uiView.View, {
241
+ as: "span",
242
+ margin: "0 0 0 x-small"
243
+ }, text));
244
+ }
245
+
246
+ return (0, _emotion.jsx)(_uiMenu.Menu.Item, {
247
+ key: key,
248
+ onSelect: onClick,
249
+ "data-automation": menuItemDataAutomation
250
+ }, (0, _emotion.jsx)(_uiIcons.IconBankLine, {
251
+ css: this.props.styles.menuIcon,
252
+ "data-automation": iconDataAutomation
253
+ }), text);
254
+ }
255
+ }, {
256
+ key: "renderPrintKeyButton",
257
+ value: function renderPrintKeyButton(handlePrint) {
258
+ var key = 'printKey';
259
+ var text = (0, _formatMessage.default)('Print Key (With Answers)');
260
+
261
+ var onClick = function onClick() {
262
+ return handlePrint(_quizCommon.PRINT_CURRENT_PAGE);
263
+ };
264
+
265
+ var disabled = !this.props.hasQuestions || this.props.isEditing;
266
+ var menuItemDataAutomation = 'sdk-print-key-menuitem';
267
+ var iconDataAutomation = 'sdk-print-icon';
268
+
269
+ if (this.props.iceTopNavBarEnabled) {
270
+ return (0, _emotion.jsx)(_uiDrilldown.Drilldown.Option, {
271
+ id: key,
272
+ key: key,
273
+ disabled: disabled,
274
+ onOptionClick: onClick // eslint-disable-line react/jsx-no-bind
275
+ ,
276
+ "data-automation": menuItemDataAutomation
277
+ }, (0, _emotion.jsx)(_uiIcons.IconPrinterLine, {
278
+ "data-automation": iconDataAutomation
279
+ }), (0, _emotion.jsx)(_uiView.View, {
280
+ as: "span",
281
+ margin: "0 0 0 x-small"
282
+ }, text));
283
+ }
284
+
285
+ return (0, _emotion.jsx)(_uiMenu.Menu.Item, {
286
+ key: key,
287
+ disabled: disabled,
288
+ onSelect: onClick // eslint-disable-line react/jsx-no-bind
289
+ ,
290
+ "data-automation": menuItemDataAutomation
291
+ }, (0, _emotion.jsx)(_uiIcons.IconPrinterLine, {
292
+ css: this.props.styles.menuIcon,
293
+ "data-automation": iconDataAutomation
294
+ }), text);
295
+ }
296
+ }, {
297
+ key: "renderPrintBlankButton",
298
+ value: function renderPrintBlankButton(handlePrint) {
299
+ var key = 'printBlank';
300
+ var text = (0, _formatMessage.default)('Print Blank Quiz');
301
+
302
+ var onClick = function onClick() {
303
+ return handlePrint(_quizCommon.PRINT_BLANK);
304
+ };
305
+
306
+ var disabled = !this.props.hasQuestions || this.props.isEditing;
307
+ var menuItemDataAutomation = 'sdk-print-blank-menuitem';
308
+ var iconDataAutomation = 'sdk-print-blank-icon';
309
+
310
+ if (this.props.iceTopNavBarEnabled) {
311
+ return (0, _emotion.jsx)(_uiDrilldown.Drilldown.Option, {
312
+ id: key,
313
+ key: key,
314
+ disabled: disabled,
315
+ onOptionClick: onClick // eslint-disable-line react/jsx-no-bind
316
+ ,
317
+ "data-automation": menuItemDataAutomation
318
+ }, (0, _emotion.jsx)(_uiIcons.IconPrinterLine, {
319
+ "data-automation": iconDataAutomation
320
+ }), (0, _emotion.jsx)(_uiView.View, {
321
+ as: "span",
322
+ margin: "0 0 0 x-small"
323
+ }, text));
324
+ }
325
+
326
+ return (0, _emotion.jsx)(_uiMenu.Menu.Item, {
327
+ key: key,
328
+ disabled: disabled,
329
+ onSelect: onClick // eslint-disable-line react/jsx-no-bind
330
+ ,
331
+ "data-automation": menuItemDataAutomation
332
+ }, (0, _emotion.jsx)(_uiIcons.IconPrinterLine, {
333
+ css: this.props.styles.menuIcon,
334
+ "data-automation": iconDataAutomation
335
+ }), text);
336
+ }
111
337
  }, {
112
338
  key: "renderMenu",
113
339
  value: function renderMenu(handlePrint) {
@@ -115,79 +341,40 @@ var BuildingButtons = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.de
115
341
  var menuItems = [];
116
342
 
117
343
  if (this.props.speedgraderLink) {
118
- menuItems.push((0, _emotion.jsx)(_uiMenu.Menu.Item, {
119
- key: "speedgrader",
120
- onSelect: this.openSpeedgraderLink
121
- }, (0, _emotion.jsx)(_uiIcons.IconSpeedGraderLine, {
122
- css: this.props.styles.menuIcon
123
- }), (0, _formatMessage.default)('Speedgrader')));
344
+ menuItems.push(this.renderSpeedGraderButton());
124
345
  }
125
346
 
126
- menuItems.push((0, _emotion.jsx)(_uiMenu.Menu.Item, {
127
- key: "import",
128
- disabled: !this.props.canImport,
129
- onSelect: this.props.openModal,
130
- "data-automation": "sdk-import-content-menuitem"
131
- }, (0, _emotion.jsx)(_uiIcons.IconImportLine, {
132
- css: this.props.styles.menuIcon,
133
- "data-automation": "sdk-import-content-icon"
134
- }), (0, _formatMessage.default)('Import Content')));
347
+ menuItems.push(this.renderImportContentButton());
135
348
 
136
349
  if (this.props.contentExportEnabled) {
137
- menuItems.push((0, _emotion.jsx)(_uiMenu.Menu.Item, {
138
- key: "export",
139
- disabled: !this.props.canExport,
140
- onSelect: this.startQuizExportJob,
141
- "data-automation": "sdk-export-content-menuitem"
142
- }, (0, _emotion.jsx)(_uiIcons.IconExportLine, {
143
- css: this.props.styles.menuIcon,
144
- "data-automation": "sdk-export-content-icon"
145
- }), (0, _formatMessage.default)('Export Content')));
350
+ menuItems.push(this.renderContentExportButton());
146
351
  }
147
352
 
148
353
  if (this.props.enableItemBanking) {
149
- menuItems.push((0, _emotion.jsx)(_uiMenu.Menu.Item, {
150
- key: "banks",
151
- onSelect: this.props.navigateToBanks,
152
- "data-automation": "sdk-manage-item-banks-menuitem"
153
- }, (0, _emotion.jsx)(_uiIcons.IconBankLine, {
154
- css: this.props.styles.menuIcon,
155
- "data-automation": "sdk-manage-item-banks-icon"
156
- }), (0, _formatMessage.default)('Manage Item Banks')));
354
+ menuItems.push(this.renderManageItemBanksButton());
157
355
  }
158
356
 
159
357
  if (this.props.printingEnabled) {
160
- {
161
- /* eslint-disable react/jsx-no-bind */
162
- }
163
- menuItems.push((0, _emotion.jsx)(_uiMenu.Menu.Item, {
164
- key: "printKey",
165
- disabled: !this.props.hasQuestions || this.props.isEditing,
166
- onSelect: function onSelect() {
167
- return handlePrint(_quizCommon.PRINT_CURRENT_PAGE);
168
- },
169
- "data-automation": "sdk-print-key-menuitem"
170
- }, (0, _emotion.jsx)(_uiIcons.IconPrinterLine, {
171
- css: this.props.styles.menuIcon,
172
- "data-automation": "sdk-print-icon"
173
- }), (0, _formatMessage.default)('Print Key (With Answers)')));
174
- menuItems.push((0, _emotion.jsx)(_uiMenu.Menu.Item, {
175
- key: "printBlank",
176
- disabled: !this.props.hasQuestions || this.props.isEditing,
177
- onSelect: function onSelect() {
178
- return handlePrint(_quizCommon.PRINT_BLANK);
179
- },
180
- "data-automation": "sdk-print-blank-menuitem"
181
- }, (0, _emotion.jsx)(_uiIcons.IconPrinterLine, {
182
- css: this.props.styles.menuIcon,
183
- "data-automation": "sdk-print-blank-icon"
184
- }), (0, _formatMessage.default)('Print Blank Quiz')));
185
- {
186
- /* eslint-enable react/jsx-no-bind */
187
- }
358
+ menuItems.push(this.renderPrintKeyButton(handlePrint));
359
+ menuItems.push(this.renderPrintBlankButton(handlePrint));
188
360
  }
189
361
 
190
362
  if (menuItems.length < 1) return;
363
+
364
+ if (this.props.iceTopNavBarEnabled) {
365
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Item, {
366
+ id: this.props.id,
367
+ variant: "icon",
368
+ renderIcon: this.props.renderIcon,
369
+ showSubmenuChevron: false,
370
+ renderSubmenu: (0, _emotion.jsx)(_uiDrilldown.Drilldown, {
371
+ rootPageId: "root"
372
+ }, (0, _emotion.jsx)(_uiDrilldown.Drilldown.Page, {
373
+ id: "root"
374
+ }, menuItems))
375
+ }, (0, _formatMessage.default)('More'));
376
+ }
377
+
191
378
  return (0, _emotion.jsx)(_uiMenu.Menu, {
192
379
  trigger: (0, _emotion.jsx)(_uiButtons.IconButton, {
193
380
  renderIcon: _uiIcons.IconMoreSolid,
@@ -237,6 +424,10 @@ var BuildingButtons = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.de
237
424
  speedgraderLink: _propTypes.default.string,
238
425
  startExport: _propTypes.default.func.isRequired,
239
426
  contextUuid: _propTypes.default.string,
427
+ iceTopNavBarEnabled: _propTypes.default.bool,
428
+ id: _propTypes.default.string,
429
+ renderIcon: _propTypes.default.element,
430
+ makeStyles: _propTypes.default.func,
240
431
  styles: _propTypes.default.object
241
432
  }, _class2.defaultProps = {
242
433
  activeQuizId: null,
@@ -247,7 +438,10 @@ var BuildingButtons = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.de
247
438
  enableItemBanking: true,
248
439
  quizSaving: false,
249
440
  speedgraderLink: null,
250
- contextUuid: null
441
+ contextUuid: null,
442
+ iceTopNavBarEnabled: false,
443
+ id: 'MoreButton',
444
+ renderIcon: (0, _emotion.jsx)(_uiIcons.IconMoreSolid, null)
251
445
  }, _temp)) || _class);
252
446
  exports.BuildingButtons = BuildingButtons;
253
447
  var _default = BuildingButtons;
@@ -1,22 +1,28 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
8
- var generateStyle = function generateStyle(componentTheme) {
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var generateStyle = function generateStyle(componentTheme, props) {
13
+ var iceTopNavBarEnabled = props.iceTopNavBarEnabled;
9
14
  return {
10
15
  quizSaving: {
11
16
  color: componentTheme.quizSavingColor,
12
17
  margin: componentTheme.quizSavingMargin
13
18
  },
14
- buttonsHolder: {
15
- height: '100%',
19
+ buttonsHolder: (0, _objectSpread2.default)({
20
+ height: '100%'
21
+ }, !iceTopNavBarEnabled && {
16
22
  marginRight: componentTheme.buttonsHolderMargin,
17
23
  display: 'flex',
18
24
  alignItems: 'center'
19
- },
25
+ }),
20
26
  menuIcon: {
21
27
  verticalAlign: 'middle',
22
28
  marginRight: componentTheme.menuIconMargin,