@elice/material-runbox 1.260825.0-runboxusability.2 → 1.260825.0-runboxusability.4

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 (65) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +16 -0
  2. package/cjs/components/material-runbox/MaterialRunboxContent.js +8 -0
  3. package/cjs/components/material-runbox/MaterialRunboxHeader.js +22 -18
  4. package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.d.ts +13 -0
  5. package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.js +71 -0
  6. package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.d.ts +10 -0
  7. package/cjs/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.js +98 -0
  8. package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetButton.d.ts +10 -0
  9. package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetButton.js +68 -0
  10. package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetDialog.d.ts +14 -0
  11. package/cjs/components/material-runbox/disk/MaterialRunboxEnvResetDialog.js +103 -0
  12. package/cjs/components/material-runbox/disk/index.d.ts +8 -1
  13. package/cjs/components/material-runbox/disk/index.js +8 -2
  14. package/cjs/components/material-runbox/hooks/index.d.ts +2 -0
  15. package/cjs/components/material-runbox/hooks/index.js +6 -0
  16. package/cjs/components/material-runbox/hooks/useRunboxDiskUsage.d.ts +16 -0
  17. package/cjs/components/material-runbox/hooks/useRunboxDiskUsage.js +50 -0
  18. package/cjs/components/material-runbox/hooks/useRunboxEnvReset.d.ts +16 -0
  19. package/cjs/components/material-runbox/hooks/useRunboxEnvReset.js +95 -0
  20. package/cjs/components/material-runbox/locales/en.json.js +1 -1
  21. package/cjs/components/material-runbox/locales/ja.json.js +1 -1
  22. package/cjs/components/material-runbox/locales/ko.json.js +1 -1
  23. package/cjs/components/material-runbox/locales/th.json.js +1 -1
  24. package/cjs/components/material-runbox/runtime/Runtime.js +5 -2
  25. package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +4 -0
  26. package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.js +16 -4
  27. package/cjs/components/material-runbox/status/MaterialRunboxStatusButton.d.ts +4 -7
  28. package/cjs/components/material-runbox/status/MaterialRunboxStatusButton.js +43 -15
  29. package/cjs/components/material-runbox/status/MaterialRunboxStatusPopover.d.ts +4 -7
  30. package/cjs/components/material-runbox/status/MaterialRunboxStatusPopover.js +16 -3
  31. package/es/_virtual/_rollupPluginBabelHelpers.js +13 -1
  32. package/es/components/material-runbox/MaterialRunboxContent.js +8 -0
  33. package/es/components/material-runbox/MaterialRunboxHeader.js +22 -18
  34. package/es/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.d.ts +13 -0
  35. package/es/components/material-runbox/disk/MaterialRunboxDiskUsageAlert.js +67 -0
  36. package/es/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.d.ts +10 -0
  37. package/es/components/material-runbox/disk/MaterialRunboxDiskUsageDialog.js +94 -0
  38. package/es/components/material-runbox/disk/MaterialRunboxEnvResetButton.d.ts +10 -0
  39. package/es/components/material-runbox/disk/MaterialRunboxEnvResetButton.js +60 -0
  40. package/es/components/material-runbox/disk/MaterialRunboxEnvResetDialog.d.ts +14 -0
  41. package/es/components/material-runbox/disk/MaterialRunboxEnvResetDialog.js +95 -0
  42. package/es/components/material-runbox/disk/index.d.ts +8 -1
  43. package/es/components/material-runbox/disk/index.js +4 -1
  44. package/es/components/material-runbox/hooks/index.d.ts +2 -0
  45. package/es/components/material-runbox/hooks/index.js +2 -0
  46. package/es/components/material-runbox/hooks/useRunboxDiskUsage.d.ts +16 -0
  47. package/es/components/material-runbox/hooks/useRunboxDiskUsage.js +42 -0
  48. package/es/components/material-runbox/hooks/useRunboxEnvReset.d.ts +16 -0
  49. package/es/components/material-runbox/hooks/useRunboxEnvReset.js +89 -0
  50. package/es/components/material-runbox/locales/en.json.js +1 -1
  51. package/es/components/material-runbox/locales/ja.json.js +1 -1
  52. package/es/components/material-runbox/locales/ko.json.js +1 -1
  53. package/es/components/material-runbox/locales/th.json.js +1 -1
  54. package/es/components/material-runbox/runtime/Runtime.js +5 -2
  55. package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +4 -0
  56. package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.js +18 -6
  57. package/es/components/material-runbox/status/MaterialRunboxStatusButton.d.ts +4 -7
  58. package/es/components/material-runbox/status/MaterialRunboxStatusButton.js +46 -18
  59. package/es/components/material-runbox/status/MaterialRunboxStatusPopover.d.ts +4 -7
  60. package/es/components/material-runbox/status/MaterialRunboxStatusPopover.js +17 -4
  61. package/package.json +6 -6
  62. package/cjs/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.d.ts +0 -5
  63. package/cjs/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.js +0 -98
  64. package/es/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.d.ts +0 -5
  65. package/es/components/material-runbox/disk/MaterialRunboxDiskAlmostFullSnackbar.js +0 -94
@@ -13,6 +13,7 @@ var material = require('@mui/material');
13
13
  var MaterialRunboxStatusConnectionItem = require('./MaterialRunboxStatusConnectionItem.js');
14
14
  var MaterialRunboxStatusResourceItem = require('./MaterialRunboxStatusResourceItem.js');
15
15
  var useRunboxNetworkStatus = require('../hooks/useRunboxNetworkStatus.js');
16
+ var MaterialRunboxEnvResetButton = require('../disk/MaterialRunboxEnvResetButton.js');
16
17
 
17
18
  //
18
19
  //
@@ -26,8 +27,10 @@ var NETWORK_COLOR = Object.freeze(_rollupPluginBabelHelpers.defineProperty(_roll
26
27
  var MaterialRunboxStatusPopover = function MaterialRunboxStatusPopover(_a) {
27
28
  var open = _a.open,
28
29
  onClose = _a.onClose,
29
- bottomAction = _a.bottomAction,
30
- props = tslib.__rest(_a, ["open", "onClose", "bottomAction"]);
30
+ runtimeTemplateId = _a.runtimeTemplateId,
31
+ courseId = _a.courseId,
32
+ userId = _a.userId,
33
+ props = tslib.__rest(_a, ["open", "onClose", "runtimeTemplateId", "courseId", "userId"]);
31
34
  var intl$1 = intl.useRawEliceIntl();
32
35
  var _useEliceRunboxRunnin = runboxClient.useEliceRunboxRunning(),
33
36
  status = _useEliceRunboxRunnin.status;
@@ -134,7 +137,17 @@ var MaterialRunboxStatusPopover = function MaterialRunboxStatusPopover(_a) {
134
137
  }))
135
138
  })]
136
139
  })]
137
- }) : null, bottomAction]
140
+ }) : null, jsxRuntime.jsx(MaterialRunboxEnvResetButton.default, {
141
+ fullWidth: true,
142
+ variant: "contained",
143
+ color: "error",
144
+ startIcon: jsxRuntime.jsx(muiElements.EliceIcon, {
145
+ icon: proSolidSvgIcons.faArrowsRotate
146
+ }),
147
+ runtimeTemplateId: runtimeTemplateId,
148
+ courseId: courseId,
149
+ userId: userId
150
+ })]
138
151
  })
139
152
  }));
140
153
  };
@@ -6,6 +6,9 @@ function _arrayLikeToArray(r, a) {
6
6
  function _arrayWithHoles(r) {
7
7
  if (Array.isArray(r)) return r;
8
8
  }
9
+ function _arrayWithoutHoles(r) {
10
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
11
+ }
9
12
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
10
13
  try {
11
14
  var i = n[a](c),
@@ -39,6 +42,9 @@ function _defineProperty(e, r, t) {
39
42
  writable: true
40
43
  }) : e[r] = t, e;
41
44
  }
45
+ function _iterableToArray(r) {
46
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
47
+ }
42
48
  function _iterableToArrayLimit(r, l) {
43
49
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
44
50
  if (null != t) {
@@ -69,6 +75,9 @@ function _iterableToArrayLimit(r, l) {
69
75
  function _nonIterableRest() {
70
76
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
71
77
  }
78
+ function _nonIterableSpread() {
79
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
80
+ }
72
81
  function _regenerator() {
73
82
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
74
83
  var e,
@@ -187,6 +196,9 @@ function _taggedTemplateLiteral(e, t) {
187
196
  }
188
197
  }));
189
198
  }
199
+ function _toConsumableArray(r) {
200
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
201
+ }
190
202
  function _toPrimitive(t, r) {
191
203
  if ("object" != typeof t || !t) return t;
192
204
  var e = t[Symbol.toPrimitive];
@@ -209,4 +221,4 @@ function _unsupportedIterableToArray(r, a) {
209
221
  }
210
222
  }
211
223
 
212
- export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _asyncToGenerator as asyncToGenerator, _defineProperty as defineProperty, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _regenerator as regenerator, _regeneratorDefine as regeneratorDefine, _slicedToArray as slicedToArray, _taggedTemplateLiteral as taggedTemplateLiteral, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
224
+ export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _asyncToGenerator as asyncToGenerator, _defineProperty as defineProperty, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _regenerator as regenerator, _regeneratorDefine as regeneratorDefine, _slicedToArray as slicedToArray, _taggedTemplateLiteral as taggedTemplateLiteral, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
@@ -15,6 +15,8 @@ import MaterialRunboxHeader from './MaterialRunboxHeader.js';
15
15
  import { useMaterialRunboxContext } from './contexts/MaterialRunboxContext.js';
16
16
  import { useMaterialRunboxApiContext } from './contexts/MaterialRunboxApiContext.js';
17
17
  import MaterialRunboxCommandContextProvider from './contexts/MaterialRunboxCommandContext.js';
18
+ import MaterialRunboxDiskUsageAlert from './disk/MaterialRunboxDiskUsageAlert.js';
19
+ import MaterialRunboxDiskUsageDialog from './disk/MaterialRunboxDiskUsageDialog.js';
18
20
  import { useMaterialRunboxRunboxIdStarterGet } from './hooks/useMaterialRunboxRunboxIdStarterGet.js';
19
21
 
20
22
  var _templateObject;
@@ -280,6 +282,12 @@ var MaterialRunboxContent = function MaterialRunboxContent(_ref) {
280
282
  studentUserId: studentUserId,
281
283
  userId: userId,
282
284
  isTutoring: isTutoring
285
+ }), jsx(MaterialRunboxDiskUsageAlert, {
286
+ runtimeTemplateId: runtimeTemplate.id,
287
+ courseId: courseId,
288
+ userId: studentUserId
289
+ }), jsx(MaterialRunboxDiskUsageDialog, {
290
+ runboxId: runbox.id
283
291
  }), jsx(MaterialRunboxBody, Object.assign({
284
292
  setSnackbarRoot: setSnackbarRoot
285
293
  }, props))]
@@ -18,7 +18,6 @@ import { useMaterialRunboxContext } from './contexts/MaterialRunboxContext.js';
18
18
  import { useMaterialRunboxApiContext } from './contexts/MaterialRunboxApiContext.js';
19
19
  import MaterialRunboxTimer from './timer/MaterialRunboxTimer.js';
20
20
  import MaterialRunboxStatusButton from './status/MaterialRunboxStatusButton.js';
21
- import MaterialRunboxDiskAlmostFullSnackbar from './disk/MaterialRunboxDiskAlmostFullSnackbar.js';
22
21
  import { useRunboxControl } from './hooks/useRunboxControl.js';
23
22
 
24
23
  var StyledHeader = /*#__PURE__*/_styled("div", {
@@ -26,25 +25,28 @@ var StyledHeader = /*#__PURE__*/_styled("div", {
26
25
  })("position:relative;flex:0 0 3rem;display:flex;justify-content:flex-start;align-items:center;gap:1rem;padding:0 1rem;width:100%;border-bottom:1px solid ", function (_ref) {
27
26
  var theme = _ref.theme;
28
27
  return theme.palette.divider;
29
- }, ";overflow:hidden;background-color:", function (_ref2) {
28
+ }, ";overflow:hidden;color:", function (_ref2) {
30
29
  var theme = _ref2.theme;
30
+ return theme.palette.text.primary;
31
+ }, ";background-color:", function (_ref3) {
32
+ var theme = _ref3.theme;
31
33
  return theme.palette.background.paper;
32
34
  }, ";");
33
35
  //
34
36
  //
35
37
  //
36
- var MaterialRunboxHeader = function MaterialRunboxHeader(_ref3) {
37
- var runbox = _ref3.runbox,
38
- runtime = _ref3.runtime,
39
- runtimeTemplate = _ref3.runtimeTemplate,
40
- courseId = _ref3.courseId,
41
- userId = _ref3.userId,
42
- studentUserId = _ref3.studentUserId,
43
- isTutoring = _ref3.isTutoring,
44
- refetch = _ref3.refetch,
45
- getAchievementColor = _ref3.getAchievementColor,
46
- _ref3$hideTimerPopove = _ref3.hideTimerPopover,
47
- hideTimerPopover = _ref3$hideTimerPopove === void 0 ? false : _ref3$hideTimerPopove;
38
+ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref4) {
39
+ var runbox = _ref4.runbox,
40
+ runtime = _ref4.runtime,
41
+ runtimeTemplate = _ref4.runtimeTemplate,
42
+ courseId = _ref4.courseId,
43
+ userId = _ref4.userId,
44
+ studentUserId = _ref4.studentUserId,
45
+ isTutoring = _ref4.isTutoring,
46
+ refetch = _ref4.refetch,
47
+ getAchievementColor = _ref4.getAchievementColor,
48
+ _ref4$hideTimerPopove = _ref4.hideTimerPopover,
49
+ hideTimerPopover = _ref4$hideTimerPopove === void 0 ? false : _ref4$hideTimerPopove;
48
50
  var intl = useRawEliceIntl();
49
51
  var _useMaterialRunboxCon = useMaterialRunboxContext(),
50
52
  enableAutoShutdownToggle = _useMaterialRunboxCon.enableAutoShutdownToggle;
@@ -95,8 +97,8 @@ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref3) {
95
97
  courseId: courseId,
96
98
  runtime: runtime
97
99
  }],
98
- queryFn: function queryFn(_ref4) {
99
- var signal = _ref4.signal;
100
+ queryFn: function queryFn(_ref5) {
101
+ var signal = _ref5.signal;
100
102
  return materialRunboxApi.runbox.runboxRunboxIdSubmitInfoGet({
101
103
  eliceCourseId: courseId,
102
104
  runboxId: runtime === null || runtime === void 0 ? void 0 : runtime.runboxId
@@ -217,8 +219,10 @@ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref3) {
217
219
  stopRuntime: stopRuntime,
218
220
  hideTimerPopover: hideTimerPopover,
219
221
  isTutoring: isTutoring
220
- }) : null, jsx(MaterialRunboxStatusButton, {}), jsx(MaterialRunboxDiskAlmostFullSnackbar, {
221
- runboxId: runbox.id
222
+ }) : null, jsx(MaterialRunboxStatusButton, {
223
+ runtimeTemplateId: runtimeTemplate.id,
224
+ courseId: courseId,
225
+ userId: studentUserId
222
226
  }), jsxs(Stack, {
223
227
  direction: "row",
224
228
  alignItems: "center",
@@ -0,0 +1,13 @@
1
+ import type React from 'react';
2
+ export interface MaterialRunboxDiskUsageAlertProps {
3
+ runtimeTemplateId: string;
4
+ courseId: number;
5
+ /** User ID for tutoring. */
6
+ userId?: number;
7
+ }
8
+ /**
9
+ * Persistent bar under the header once disk usage passes 80%. Unlike the notice
10
+ * dialog it stays put, because it carries the only way out — the reset CTA.
11
+ */
12
+ declare const MaterialRunboxDiskUsageAlert: React.FC<MaterialRunboxDiskUsageAlertProps>;
13
+ export default MaterialRunboxDiskUsageAlert;
@@ -0,0 +1,67 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useRawEliceIntl } from '@elice/intl';
3
+ import { EliceIcon } from '@elice/mui-elements';
4
+ import { faArrowsRotate } from '@fortawesome/pro-solid-svg-icons';
5
+ import { Alert, Typography } from '@mui/material';
6
+ import MaterialRunboxEnvResetButton from './MaterialRunboxEnvResetButton.js';
7
+ import { useRunboxDiskUsage } from '../hooks/useRunboxDiskUsage.js';
8
+
9
+ //
10
+ //
11
+ //
12
+ /**
13
+ * Persistent bar under the header once disk usage passes 80%. Unlike the notice
14
+ * dialog it stays put, because it carries the only way out — the reset CTA.
15
+ */
16
+ var MaterialRunboxDiskUsageAlert = function MaterialRunboxDiskUsageAlert(_ref) {
17
+ var runtimeTemplateId = _ref.runtimeTemplateId,
18
+ courseId = _ref.courseId,
19
+ userId = _ref.userId;
20
+ var intl = useRawEliceIntl();
21
+ var _useRunboxDiskUsage = useRunboxDiskUsage(),
22
+ severity = _useRunboxDiskUsage.severity,
23
+ diskCurrent = _useRunboxDiskUsage.diskCurrent,
24
+ diskTotal = _useRunboxDiskUsage.diskTotal;
25
+ if (!severity) {
26
+ return null;
27
+ }
28
+ //
29
+ //
30
+ //
31
+ return jsx(Alert, {
32
+ severity: severity,
33
+ sx: {
34
+ width: '100%',
35
+ borderRadius: '0',
36
+ alignItems: 'center'
37
+ },
38
+ action: jsx(MaterialRunboxEnvResetButton, {
39
+ variant: "text",
40
+ size: "small",
41
+ color: "inherit",
42
+ startIcon: jsx(EliceIcon, {
43
+ icon: faArrowsRotate
44
+ }),
45
+ runtimeTemplateId: runtimeTemplateId,
46
+ courseId: courseId,
47
+ userId: userId
48
+ }),
49
+ children: jsx(Typography, {
50
+ variant: "body2",
51
+ children: intl.formatMessage({
52
+ id: "runbox.disk.usage.alert.".concat(severity)
53
+ }, {
54
+ used: intl.formatDataSize(diskCurrent, {
55
+ unitSystem: 'iec',
56
+ maximumFractionDigits: 2
57
+ }),
58
+ total: intl.formatDataSize(diskTotal, {
59
+ unitSystem: 'iec',
60
+ maximumFractionDigits: 2
61
+ })
62
+ })
63
+ })
64
+ });
65
+ };
66
+
67
+ export { MaterialRunboxDiskUsageAlert as default };
@@ -0,0 +1,10 @@
1
+ import type React from 'react';
2
+ export interface MaterialRunboxDiskUsageDialogProps {
3
+ runboxId: string;
4
+ }
5
+ /**
6
+ * Notice shown once per severity per runbox for the browser session. The reset
7
+ * CTA lives in the alert bar, so this only has to be acknowledged.
8
+ */
9
+ declare const MaterialRunboxDiskUsageDialog: React.FC<MaterialRunboxDiskUsageDialogProps>;
10
+ export default MaterialRunboxDiskUsageDialog;
@@ -0,0 +1,94 @@
1
+ import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useSessionStorage } from 'react-use';
4
+ import { useRawEliceIntl } from '@elice/intl';
5
+ import { EliceIcon } from '@elice/mui-elements';
6
+ import { faCircleExclamation, faTriangleExclamation } from '@fortawesome/pro-solid-svg-icons';
7
+ import { Dialog, DialogTitle, Stack, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material';
8
+ import { useRunboxDiskUsage } from '../hooks/useRunboxDiskUsage.js';
9
+
10
+ //
11
+ //
12
+ //
13
+ var SEEN_STORAGE_KEY = 'MaterialRunboxDiskUsage.seenNotice';
14
+ //
15
+ //
16
+ //
17
+ /**
18
+ * Notice shown once per severity per runbox for the browser session. The reset
19
+ * CTA lives in the alert bar, so this only has to be acknowledged.
20
+ */
21
+ var MaterialRunboxDiskUsageDialog = function MaterialRunboxDiskUsageDialog(_ref) {
22
+ var runboxId = _ref.runboxId;
23
+ var _a;
24
+ var intl = useRawEliceIntl();
25
+ var _useRunboxDiskUsage = useRunboxDiskUsage(),
26
+ severity = _useRunboxDiskUsage.severity,
27
+ diskCurrent = _useRunboxDiskUsage.diskCurrent,
28
+ diskTotal = _useRunboxDiskUsage.diskTotal;
29
+ var _useSessionStorage = useSessionStorage(SEEN_STORAGE_KEY, {}),
30
+ _useSessionStorage2 = _slicedToArray(_useSessionStorage, 2),
31
+ seen = _useSessionStorage2[0],
32
+ setSeen = _useSessionStorage2[1];
33
+ var seenSeverities = (_a = seen === null || seen === void 0 ? void 0 : seen[runboxId]) !== null && _a !== void 0 ? _a : [];
34
+ /**
35
+ *
36
+ */
37
+ var handleClose = function handleClose() {
38
+ if (!severity) {
39
+ return;
40
+ }
41
+ setSeen(Object.assign(Object.assign({}, seen), _defineProperty({}, runboxId, [].concat(_toConsumableArray(seenSeverities), [severity]))));
42
+ };
43
+ //
44
+ //
45
+ //
46
+ if (!severity) {
47
+ return null;
48
+ }
49
+ return jsxs(Dialog, {
50
+ fullWidth: true,
51
+ open: !seenSeverities.includes(severity),
52
+ maxWidth: "xs",
53
+ onClose: handleClose,
54
+ children: [jsx(DialogTitle, {
55
+ children: jsxs(Stack, {
56
+ direction: "row",
57
+ alignItems: "center",
58
+ gap: "0.5rem",
59
+ children: [jsx(EliceIcon, {
60
+ icon: severity === 'error' ? faCircleExclamation : faTriangleExclamation,
61
+ color: severity
62
+ }), intl.formatMessage({
63
+ id: 'runbox.disk.usage.dialog.title'
64
+ })]
65
+ })
66
+ }), jsx(DialogContent, {
67
+ children: jsx(DialogContentText, {
68
+ whiteSpace: "pre-line",
69
+ children: intl.formatMessage({
70
+ id: "runbox.disk.usage.dialog.description.".concat(severity)
71
+ }, {
72
+ used: intl.formatDataSize(diskCurrent, {
73
+ unitSystem: 'iec',
74
+ maximumFractionDigits: 2
75
+ }),
76
+ total: intl.formatDataSize(diskTotal, {
77
+ unitSystem: 'iec',
78
+ maximumFractionDigits: 2
79
+ })
80
+ })
81
+ })
82
+ }), jsx(DialogActions, {
83
+ children: jsx(Button, {
84
+ color: "inherit",
85
+ onClick: handleClose,
86
+ children: intl.formatMessage({
87
+ id: 'runbox.disk.usage.dialog.actions.close'
88
+ })
89
+ })
90
+ })]
91
+ });
92
+ };
93
+
94
+ export { MaterialRunboxDiskUsageDialog as default };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { ButtonProps } from '@mui/material';
3
+ export interface MaterialRunboxEnvResetButtonProps extends Omit<ButtonProps, 'onClick'> {
4
+ runtimeTemplateId: string;
5
+ courseId: number;
6
+ userId?: number;
7
+ onSuccess?: () => void;
8
+ }
9
+ declare const MaterialRunboxEnvResetButton: React.FC<MaterialRunboxEnvResetButtonProps>;
10
+ export default MaterialRunboxEnvResetButton;
@@ -0,0 +1,60 @@
1
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { __rest } from 'tslib';
3
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
4
+ import React from 'react';
5
+ import { useRawEliceIntl } from '@elice/intl';
6
+ import { Button } from '@mui/material';
7
+ import MaterialRunboxEnvResetDialog from './MaterialRunboxEnvResetDialog.js';
8
+ import { useRunboxEnvReset } from '../hooks/useRunboxEnvReset.js';
9
+
10
+ //
11
+ //
12
+ //
13
+ var MaterialRunboxEnvResetButton = function MaterialRunboxEnvResetButton(_a) {
14
+ var runtimeTemplateId = _a.runtimeTemplateId,
15
+ courseId = _a.courseId,
16
+ userId = _a.userId,
17
+ _onSuccess = _a.onSuccess,
18
+ props = __rest(_a, ["runtimeTemplateId", "courseId", "userId", "onSuccess"]);
19
+ var intl = useRawEliceIntl();
20
+ var _React$useState = React.useState(false),
21
+ _React$useState2 = _slicedToArray(_React$useState, 2),
22
+ isDialogOpened = _React$useState2[0],
23
+ setDialogOpened = _React$useState2[1];
24
+ var _useRunboxEnvReset = useRunboxEnvReset({
25
+ onSuccess: function onSuccess() {
26
+ setDialogOpened(false);
27
+ _onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess();
28
+ }
29
+ }),
30
+ reset = _useRunboxEnvReset.reset,
31
+ isResetting = _useRunboxEnvReset.isResetting;
32
+ //
33
+ //
34
+ //
35
+ return jsxs(Fragment, {
36
+ children: [jsx(Button, Object.assign({}, props, {
37
+ onClick: function onClick() {
38
+ return setDialogOpened(true);
39
+ },
40
+ children: intl.formatMessage({
41
+ id: 'runbox.disk.env_reset.title'
42
+ })
43
+ })), jsx(MaterialRunboxEnvResetDialog, {
44
+ open: isDialogOpened,
45
+ isResetting: isResetting,
46
+ onClose: function onClose() {
47
+ return setDialogOpened(false);
48
+ },
49
+ onConfirm: function onConfirm() {
50
+ return void reset({
51
+ runtimeTemplateId: runtimeTemplateId,
52
+ courseId: courseId,
53
+ userId: userId
54
+ });
55
+ }
56
+ })]
57
+ });
58
+ };
59
+
60
+ export { MaterialRunboxEnvResetButton as default };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface MaterialRunboxEnvResetDialogProps {
3
+ open: boolean;
4
+ isResetting?: boolean;
5
+ onClose: () => void;
6
+ onConfirm: () => void;
7
+ }
8
+ /**
9
+ * Confirms clearing the practice environment. The checkbox is the explicit
10
+ * acknowledgement `[R-3]` asks for: the delete action stays disabled until it
11
+ * is ticked.
12
+ */
13
+ declare const MaterialRunboxEnvResetDialog: React.FC<MaterialRunboxEnvResetDialogProps>;
14
+ export default MaterialRunboxEnvResetDialog;
@@ -0,0 +1,95 @@
1
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import React from 'react';
4
+ import { useRawEliceIntl } from '@elice/intl';
5
+ import { EliceIcon } from '@elice/mui-elements';
6
+ import { faCircleExclamation } from '@fortawesome/pro-solid-svg-icons';
7
+ import { LoadingButton } from '@mui/lab';
8
+ import { Dialog, DialogTitle, Stack, DialogContent, DialogContentText, FormControlLabel, Checkbox, DialogActions, Button } from '@mui/material';
9
+
10
+ //
11
+ //
12
+ //
13
+ /**
14
+ * Confirms clearing the practice environment. The checkbox is the explicit
15
+ * acknowledgement `[R-3]` asks for: the delete action stays disabled until it
16
+ * is ticked.
17
+ */
18
+ var MaterialRunboxEnvResetDialog = function MaterialRunboxEnvResetDialog(_ref) {
19
+ var open = _ref.open,
20
+ _ref$isResetting = _ref.isResetting,
21
+ isResetting = _ref$isResetting === void 0 ? false : _ref$isResetting,
22
+ onClose = _ref.onClose,
23
+ onConfirm = _ref.onConfirm;
24
+ var intl = useRawEliceIntl();
25
+ var _React$useState = React.useState(false),
26
+ _React$useState2 = _slicedToArray(_React$useState, 2),
27
+ isAcknowledged = _React$useState2[0],
28
+ setAcknowledged = _React$useState2[1];
29
+ React.useEffect(function () {
30
+ if (!open) {
31
+ setAcknowledged(false);
32
+ }
33
+ }, [open]);
34
+ //
35
+ //
36
+ //
37
+ return jsxs(Dialog, {
38
+ fullWidth: true,
39
+ open: open,
40
+ maxWidth: "xs",
41
+ onClose: onClose,
42
+ children: [jsx(DialogTitle, {
43
+ children: jsxs(Stack, {
44
+ direction: "row",
45
+ alignItems: "center",
46
+ gap: "0.5rem",
47
+ children: [jsx(EliceIcon, {
48
+ icon: faCircleExclamation,
49
+ color: "error"
50
+ }), intl.formatMessage({
51
+ id: 'runbox.disk.env_reset.dialog.title'
52
+ })]
53
+ })
54
+ }), jsxs(DialogContent, {
55
+ children: [jsx(DialogContentText, {
56
+ whiteSpace: "pre-line",
57
+ children: intl.formatMessage({
58
+ id: 'runbox.disk.env_reset.dialog.description'
59
+ })
60
+ }), jsx(FormControlLabel, {
61
+ sx: {
62
+ marginTop: '1rem'
63
+ },
64
+ control: jsx(Checkbox, {
65
+ checked: isAcknowledged,
66
+ onChange: function onChange(e) {
67
+ return setAcknowledged(e.target.checked);
68
+ }
69
+ }),
70
+ label: intl.formatMessage({
71
+ id: 'runbox.disk.env_reset.dialog.acknowledge'
72
+ })
73
+ })]
74
+ }), jsxs(DialogActions, {
75
+ children: [jsx(Button, {
76
+ color: "inherit",
77
+ disabled: isResetting,
78
+ onClick: onClose,
79
+ children: intl.formatMessage({
80
+ id: 'runbox.disk.env_reset.dialog.actions.cancel'
81
+ })
82
+ }), jsx(LoadingButton, {
83
+ color: "error",
84
+ loading: isResetting,
85
+ disabled: !isAcknowledged,
86
+ onClick: onConfirm,
87
+ children: intl.formatMessage({
88
+ id: 'runbox.disk.env_reset.dialog.actions.confirm'
89
+ })
90
+ })]
91
+ })]
92
+ });
93
+ };
94
+
95
+ export { MaterialRunboxEnvResetDialog as default };
@@ -1 +1,8 @@
1
- export { default as MaterialRunboxDiskAlmostFullSnackbar } from './MaterialRunboxDiskAlmostFullSnackbar';
1
+ export { default as MaterialRunboxDiskUsageAlert } from './MaterialRunboxDiskUsageAlert';
2
+ export { default as MaterialRunboxDiskUsageDialog } from './MaterialRunboxDiskUsageDialog';
3
+ export { default as MaterialRunboxEnvResetButton } from './MaterialRunboxEnvResetButton';
4
+ export { default as MaterialRunboxEnvResetDialog } from './MaterialRunboxEnvResetDialog';
5
+ export type { MaterialRunboxDiskUsageAlertProps } from './MaterialRunboxDiskUsageAlert';
6
+ export type { MaterialRunboxDiskUsageDialogProps } from './MaterialRunboxDiskUsageDialog';
7
+ export type { MaterialRunboxEnvResetButtonProps } from './MaterialRunboxEnvResetButton';
8
+ export type { MaterialRunboxEnvResetDialogProps } from './MaterialRunboxEnvResetDialog';
@@ -1 +1,4 @@
1
- export { default as MaterialRunboxDiskAlmostFullSnackbar } from './MaterialRunboxDiskAlmostFullSnackbar.js';
1
+ export { default as MaterialRunboxDiskUsageAlert } from './MaterialRunboxDiskUsageAlert.js';
2
+ export { default as MaterialRunboxDiskUsageDialog } from './MaterialRunboxDiskUsageDialog.js';
3
+ export { default as MaterialRunboxEnvResetButton } from './MaterialRunboxEnvResetButton.js';
4
+ export { default as MaterialRunboxEnvResetDialog } from './MaterialRunboxEnvResetDialog.js';
@@ -4,3 +4,5 @@ export * from './useRunboxTimer';
4
4
  export * from './useInfiniteRunboxRunboxIdGrade';
5
5
  export * from './useMaterialRunboxRunboxIdStarterGet';
6
6
  export * from './useRunboxNetworkStatus';
7
+ export * from './useRunboxDiskUsage';
8
+ export * from './useRunboxEnvReset';
@@ -4,3 +4,5 @@ export { useRunboxTimer } from './useRunboxTimer.js';
4
4
  export { useInfiniteRunboxRunboxIdGrade } from './useInfiniteRunboxRunboxIdGrade.js';
5
5
  export { useMaterialRunboxRunboxIdStarterGet } from './useMaterialRunboxRunboxIdStarterGet.js';
6
6
  export { RunboxNetworkStatus, useRunboxNetworkStatus } from './useRunboxNetworkStatus.js';
7
+ export { DISK_USAGE_ERROR_RATIO, DISK_USAGE_WARNING_RATIO, useRunboxDiskUsage } from './useRunboxDiskUsage.js';
8
+ export { useRunboxEnvReset } from './useRunboxEnvReset.js';
@@ -0,0 +1,16 @@
1
+ /** Matches MUI's `Alert` severity, which is where this value ends up. */
2
+ export type RunboxDiskUsageSeverity = 'warning' | 'error';
3
+ interface UseRunboxDiskUsageReturn {
4
+ /** `null` below the first threshold, or while the container reports no stats. */
5
+ severity: RunboxDiskUsageSeverity | null;
6
+ diskCurrent: number;
7
+ diskTotal: number;
8
+ }
9
+ export declare const DISK_USAGE_WARNING_RATIO = 0.8;
10
+ export declare const DISK_USAGE_ERROR_RATIO = 0.9;
11
+ /**
12
+ * Disk usage against the 80% / 90% thresholds. The numbers come from the
13
+ * container stats stream, so they are only available while the runtime is up.
14
+ */
15
+ export declare const useRunboxDiskUsage: () => UseRunboxDiskUsageReturn;
16
+ export {};
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { useEliceRunboxContainerStats } from '@elice/runbox-client';
3
+
4
+ //
5
+ //
6
+ //
7
+ var DISK_USAGE_WARNING_RATIO = 0.8;
8
+ var DISK_USAGE_ERROR_RATIO = 0.9;
9
+ //
10
+ //
11
+ //
12
+ /**
13
+ * Disk usage against the 80% / 90% thresholds. The numbers come from the
14
+ * container stats stream, so they are only available while the runtime is up.
15
+ */
16
+ var useRunboxDiskUsage = function useRunboxDiskUsage() {
17
+ var _a, _b;
18
+ var contStats = useEliceRunboxContainerStats();
19
+ var stats = contStats ? contStats[contStats.length - 1] : null;
20
+ var diskCurrent = (_a = stats === null || stats === void 0 ? void 0 : stats.diskCurrent) !== null && _a !== void 0 ? _a : 0;
21
+ var diskTotal = (_b = stats === null || stats === void 0 ? void 0 : stats.diskTotal) !== null && _b !== void 0 ? _b : 0;
22
+ var severity = React.useMemo(function () {
23
+ if (!stats || diskTotal <= 0) {
24
+ return null;
25
+ }
26
+ var ratio = diskCurrent / diskTotal;
27
+ if (ratio >= DISK_USAGE_ERROR_RATIO) {
28
+ return 'error';
29
+ }
30
+ if (ratio >= DISK_USAGE_WARNING_RATIO) {
31
+ return 'warning';
32
+ }
33
+ return null;
34
+ }, [stats, diskCurrent, diskTotal]);
35
+ return {
36
+ severity: severity,
37
+ diskCurrent: diskCurrent,
38
+ diskTotal: diskTotal
39
+ };
40
+ };
41
+
42
+ export { DISK_USAGE_ERROR_RATIO, DISK_USAGE_WARNING_RATIO, useRunboxDiskUsage };
@@ -0,0 +1,16 @@
1
+ interface RunboxEnvResetParams {
2
+ runtimeTemplateId: string;
3
+ courseId: number;
4
+ /** User ID for tutoring. */
5
+ userId?: number;
6
+ }
7
+ interface UseRunboxEnvResetParams {
8
+ /** Called once the reset has finished. */
9
+ onSuccess?: () => void;
10
+ }
11
+ interface UseRunboxEnvResetReturn {
12
+ reset: (params: RunboxEnvResetParams) => Promise<void>;
13
+ isResetting: boolean;
14
+ }
15
+ export declare const useRunboxEnvReset: ({ onSuccess, }?: UseRunboxEnvResetParams) => UseRunboxEnvResetReturn;
16
+ export {};