@elice/material-runbox 1.231212.0 → 1.231228.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.
Files changed (60) hide show
  1. package/cjs/assets/queue.gif.js +1 -1
  2. package/cjs/assets/runbox_logo.png.js +1 -1
  3. package/cjs/assets/terminated.png.js +1 -1
  4. package/cjs/components/material-runbox/MaterialRunbox.js +17 -19
  5. package/cjs/components/material-runbox/MaterialRunboxBody.js +15 -12
  6. package/cjs/components/material-runbox/MaterialRunboxContent.js +94 -101
  7. package/cjs/components/material-runbox/MaterialRunboxFooter.js +17 -22
  8. package/cjs/components/material-runbox/MaterialRunboxHeader.d.ts +3 -0
  9. package/cjs/components/material-runbox/MaterialRunboxHeader.js +77 -81
  10. package/cjs/components/material-runbox/actions/MaterialRunboxActionAutoShutdown.js +26 -22
  11. package/cjs/components/material-runbox/actions/MaterialRunboxActionGrade.js +140 -180
  12. package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +8 -0
  13. package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.js +65 -0
  14. package/cjs/components/material-runbox/actions/MaterialRunboxActionReset.d.ts +3 -1
  15. package/cjs/components/material-runbox/actions/MaterialRunboxActionReset.js +73 -110
  16. package/cjs/components/material-runbox/actions/MaterialRunboxActionRestart.d.ts +3 -1
  17. package/cjs/components/material-runbox/actions/MaterialRunboxActionRestart.js +54 -70
  18. package/cjs/components/material-runbox/actions/MaterialRunboxActionShare.d.ts +4 -1
  19. package/cjs/components/material-runbox/actions/MaterialRunboxActionShare.js +67 -41
  20. package/cjs/components/material-runbox/contexts/MaterialRunboxApiContext.js +16 -27
  21. package/cjs/components/material-runbox/contexts/MaterialRunboxCommandContext.js +38 -53
  22. package/cjs/components/material-runbox/contexts/MaterialRunboxContext.js +9 -11
  23. package/cjs/components/material-runbox/hooks/useRunboxControl.js +39 -65
  24. package/cjs/components/material-runbox/locales/en.json.js +2 -2
  25. package/cjs/components/material-runbox/locales/index.js +2 -4
  26. package/cjs/components/material-runbox/locales/ko.json.js +2 -2
  27. package/cjs/components/material-runbox/runtime/Runtime.js +18 -26
  28. package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.js +10 -17
  29. package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.js +16 -18
  30. package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.js +27 -33
  31. package/cjs/index.js +1 -3
  32. package/es/components/material-runbox/MaterialRunbox.js +11 -9
  33. package/es/components/material-runbox/MaterialRunboxBody.js +13 -5
  34. package/es/components/material-runbox/MaterialRunboxContent.js +80 -82
  35. package/es/components/material-runbox/MaterialRunboxFooter.js +11 -11
  36. package/es/components/material-runbox/MaterialRunboxHeader.d.ts +3 -0
  37. package/es/components/material-runbox/MaterialRunboxHeader.js +72 -71
  38. package/es/components/material-runbox/actions/MaterialRunboxActionAutoShutdown.js +22 -13
  39. package/es/components/material-runbox/actions/MaterialRunboxActionGrade.js +120 -155
  40. package/es/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +8 -0
  41. package/es/components/material-runbox/actions/MaterialRunboxActionMenu.js +61 -0
  42. package/es/components/material-runbox/actions/MaterialRunboxActionReset.d.ts +3 -1
  43. package/es/components/material-runbox/actions/MaterialRunboxActionReset.js +65 -98
  44. package/es/components/material-runbox/actions/MaterialRunboxActionRestart.d.ts +3 -1
  45. package/es/components/material-runbox/actions/MaterialRunboxActionRestart.js +47 -59
  46. package/es/components/material-runbox/actions/MaterialRunboxActionShare.d.ts +4 -1
  47. package/es/components/material-runbox/actions/MaterialRunboxActionShare.js +68 -38
  48. package/es/components/material-runbox/contexts/MaterialRunboxApiContext.js +13 -20
  49. package/es/components/material-runbox/contexts/MaterialRunboxCommandContext.js +35 -46
  50. package/es/components/material-runbox/contexts/MaterialRunboxContext.js +6 -4
  51. package/es/components/material-runbox/hooks/useRunboxControl.js +39 -63
  52. package/es/components/material-runbox/locales/en.json.js +1 -1
  53. package/es/components/material-runbox/locales/ko.json.js +1 -1
  54. package/es/components/material-runbox/runtime/Runtime.js +14 -18
  55. package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.js +3 -6
  56. package/es/components/material-runbox/runtime/RuntimeOverlayQueued.js +6 -4
  57. package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.js +12 -14
  58. package/package.json +13 -9
  59. package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -399
  60. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -387
@@ -1,68 +1,73 @@
1
- import { taggedTemplateLiteral as _taggedTemplateLiteral } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import _styled from '@emotion/styled/base';
2
2
  import React from 'react';
3
3
  import { FormattedMessage } from 'react-intl';
4
- import { Tag } from '@elice/mui-elements';
5
- import styled from '@emotion/styled';
6
- import { Box, Stack } from '@mui/material';
4
+ import { Tag, EliceIcon } from '@elice/mui-elements';
5
+ import { useEliceRunboxRunning } from '@elice/runbox-client';
6
+ import { faEllipsisVertical } from '@fortawesome/pro-solid-svg-icons';
7
+ import { Box, Stack, IconButton } from '@mui/material';
7
8
  import { useQuery } from '@tanstack/react-query';
8
9
  import MaterialRunboxActionAutoShutdown from './actions/MaterialRunboxActionAutoShutdown.js';
9
10
  import MaterialRunboxActionGrade from './actions/MaterialRunboxActionGrade.js';
10
- import MaterialRunboxActionReset from './actions/MaterialRunboxActionReset.js';
11
- import MaterialRunboxActionRestart from './actions/MaterialRunboxActionRestart.js';
12
- import MaterialRunboxActionShare from './actions/MaterialRunboxActionShare.js';
11
+ import MaterialRunboxActionMenu from './actions/MaterialRunboxActionMenu.js';
13
12
  import { useMaterialRunboxApiContext } from './contexts/MaterialRunboxApiContext.js';
14
13
  import './contexts/MaterialRunboxCommandContext.js';
15
14
  import { useMaterialRunboxContext } from './contexts/MaterialRunboxContext.js';
16
15
  import runboxLogoImage from '../../assets/runbox_logo.png.js';
17
16
 
18
- var _templateObject;
17
+ const StyledHeader = /*#__PURE__*/_styled("div", {
18
+ target: "e110d0bp0"
19
+ })("position:relative;flex:0 0 3rem;display:flex;justify-content:space-between;align-items:center;padding:0 1rem;width:100%;border-bottom:1px solid ", ({
20
+ theme
21
+ }) => theme.palette.divider, ";overflow:hidden;");
19
22
  //
20
23
  //
21
24
  //
22
- var StyledHeader = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n flex: 0 0 3rem;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 1rem;\n width: 100%;\n border-bottom: 1px solid ", ";\n overflow: hidden;\n"])), function (_ref) {
23
- var theme = _ref.theme;
24
- return theme.palette.divider;
25
- });
26
- //
27
- //
28
- //
29
- var MaterialRunboxHeader = function MaterialRunboxHeader(_ref2) {
30
- var runbox = _ref2.runbox,
31
- runtime = _ref2.runtime,
32
- runtimeTemplate = _ref2.runtimeTemplate,
33
- courseId = _ref2.courseId,
34
- refetch = _ref2.refetch;
35
- var _useMaterialRunboxCon = useMaterialRunboxContext(),
36
- enableAutoShutdownToggle = _useMaterialRunboxCon.enableAutoShutdownToggle,
37
- enableUrlShare = _useMaterialRunboxCon.enableUrlShare;
38
- var materialRunboxApi = useMaterialRunboxApiContext();
39
- var leaderboardSubmitInfoQuery = useQuery({
25
+ const MaterialRunboxHeader = ({
26
+ runbox,
27
+ runtime,
28
+ runtimeTemplate,
29
+ courseId,
30
+ refetch
31
+ }) => {
32
+ const {
33
+ enableAutoShutdownToggle
34
+ } = useMaterialRunboxContext();
35
+ const [menuAnchorEl, setMenuAnchorEl] = React.useState(null);
36
+ const {
37
+ status
38
+ } = useEliceRunboxRunning();
39
+ const isRunboxRunning = status === 'running';
40
+ /**
41
+ *
42
+ */
43
+ const handleMenuClose = () => {
44
+ setMenuAnchorEl(null);
45
+ };
46
+ const materialRunboxApi = useMaterialRunboxApiContext();
47
+ const leaderboardSubmitInfoQuery = useQuery({
40
48
  queryKey: ['eliceMaterialRunboxRunboxApi.runboxRunboxIdSubmitInfoGet', {
41
- courseId: courseId,
42
- runtime: runtime
49
+ courseId,
50
+ runtime
43
51
  }],
44
- queryFn: function queryFn(_ref3) {
45
- var signal = _ref3.signal;
46
- return materialRunboxApi.runbox.runboxRunboxIdSubmitInfoGet({
47
- eliceCourseId: courseId,
48
- runboxId: runtime === null || runtime === void 0 ? void 0 : runtime.runboxId
49
- }, {
50
- signal: signal
51
- });
52
- },
53
- refetchInterval: function refetchInterval(data) {
54
- return !(data === null || data === void 0 ? void 0 : data.remainSubmitCount) ? false : 5 * 1000;
55
- },
52
+ queryFn: ({
53
+ signal
54
+ }) => materialRunboxApi.runbox.runboxRunboxIdSubmitInfoGet({
55
+ eliceCourseId: courseId,
56
+ runboxId: runtime === null || runtime === void 0 ? void 0 : runtime.runboxId
57
+ }, {
58
+ signal
59
+ }),
60
+ refetchInterval: data => !(data === null || data === void 0 ? void 0 : data.remainSubmitCount) ? false : 5 * 1000,
56
61
  enabled: Boolean(runtime === null || runtime === void 0 ? void 0 : runtime.runboxId),
57
62
  retry: false
58
63
  });
59
64
  /**
60
65
  *
61
66
  */
62
- var renderHeaderSubmitInfo = function renderHeaderSubmitInfo() {
67
+ const renderHeaderSubmitInfo = () => {
63
68
  var _a, _b;
64
- var remainSubmitCount = (_a = leaderboardSubmitInfoQuery.data) === null || _a === void 0 ? void 0 : _a.remainSubmitCount;
65
- var totalSubmitCount = (_b = leaderboardSubmitInfoQuery.data) === null || _b === void 0 ? void 0 : _b.submitCountLimit;
69
+ const remainSubmitCount = (_a = leaderboardSubmitInfoQuery.data) === null || _a === void 0 ? void 0 : _a.remainSubmitCount;
70
+ const totalSubmitCount = (_b = leaderboardSubmitInfoQuery.data) === null || _b === void 0 ? void 0 : _b.submitCountLimit;
66
71
  if (leaderboardSubmitInfoQuery.isInitialLoading || remainSubmitCount === null) {
67
72
  return null;
68
73
  }
@@ -81,7 +86,7 @@ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref2) {
81
86
  /**
82
87
  *
83
88
  */
84
- var renderHeaderActionAutoShutdown = function renderHeaderActionAutoShutdown() {
89
+ const renderHeaderActionAutoShutdown = () => {
85
90
  if (!enableAutoShutdownToggle) {
86
91
  return null;
87
92
  }
@@ -95,27 +100,11 @@ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref2) {
95
100
  /**
96
101
  *
97
102
  */
98
- var renderHeaderActionShare = function renderHeaderActionShare() {
99
- if (!enableUrlShare) {
103
+ const renderHeaderActionGrade = () => {
104
+ if (!runbox.submission.enabled) {
100
105
  return null;
101
106
  }
102
- return React.createElement(MaterialRunboxActionShare, null);
103
- };
104
- /**
105
- *
106
- */
107
- var renderHeaderActionRestart = function renderHeaderActionRestart() {
108
- return React.createElement(MaterialRunboxActionRestart, {
109
- runbox: runbox,
110
- courseId: courseId,
111
- refetch: refetch
112
- });
113
- };
114
- /**
115
- *
116
- */
117
- var renderHeaderActionReset = function renderHeaderActionReset() {
118
- return React.createElement(MaterialRunboxActionReset, {
107
+ return React.createElement(MaterialRunboxActionGrade, {
119
108
  runtime: runtime,
120
109
  courseId: courseId
121
110
  });
@@ -123,14 +112,26 @@ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref2) {
123
112
  /**
124
113
  *
125
114
  */
126
- var renderHeaderActionGrade = function renderHeaderActionGrade() {
127
- if (!runbox.submission.enabled) {
128
- return null;
129
- }
130
- return React.createElement(MaterialRunboxActionGrade, {
115
+ const renderOptionMenu = () => {
116
+ return React.createElement(React.Fragment, null, React.createElement(IconButton, {
117
+ disabled: !isRunboxRunning,
118
+ onClick: e => {
119
+ if (Boolean(menuAnchorEl)) {
120
+ setMenuAnchorEl(null);
121
+ } else {
122
+ setMenuAnchorEl(e.currentTarget);
123
+ }
124
+ }
125
+ }, React.createElement(EliceIcon, {
126
+ icon: faEllipsisVertical
127
+ })), React.createElement(MaterialRunboxActionMenu, {
128
+ runbox: runbox,
131
129
  runtime: runtime,
132
- courseId: courseId
133
- });
130
+ courseId: courseId,
131
+ menuAnchorEl: menuAnchorEl,
132
+ refetch: refetch,
133
+ handleMenuClose: handleMenuClose
134
+ }));
134
135
  };
135
136
  //
136
137
  //
@@ -149,7 +150,7 @@ var MaterialRunboxHeader = function MaterialRunboxHeader(_ref2) {
149
150
  direction: "row",
150
151
  alignItems: "center",
151
152
  gap: "0.5rem"
152
- }, renderHeaderSubmitInfo(), renderHeaderActionAutoShutdown(), renderHeaderActionShare(), renderHeaderActionRestart(), renderHeaderActionReset(), renderHeaderActionGrade()));
153
+ }, renderHeaderSubmitInfo(), renderHeaderActionAutoShutdown(), renderOptionMenu(), renderHeaderActionGrade()));
153
154
  };
154
155
 
155
156
  export { MaterialRunboxHeader as default };
@@ -1,32 +1,41 @@
1
- import { taggedTemplateLiteral as _taggedTemplateLiteral } from '../../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import _styled from '@emotion/styled/base';
2
2
  import React from 'react';
3
3
  import { useIntl } from 'react-intl';
4
- import styled from '@emotion/styled';
5
4
  import { FormControlLabel, Tooltip, Switch } from '@mui/material';
6
5
  import { useMaterialRunboxApiContext } from '../contexts/MaterialRunboxApiContext.js';
7
6
  import '../contexts/MaterialRunboxCommandContext.js';
8
7
  import '../contexts/MaterialRunboxContext.js';
9
8
 
10
- var _templateObject;
9
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
11
10
  //
12
11
  //
13
12
  //
14
- var StyledFormControlLabel = styled(FormControlLabel)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin: 0 !important;\n"])));
13
+ const StyledFormControlLabel = /*#__PURE__*/_styled(FormControlLabel, {
14
+ target: "e1ket70c0"
15
+ })("production" === "production" ? {
16
+ name: "1ep9nyp",
17
+ styles: "margin:0!important"
18
+ } : {
19
+ name: "1ep9nyp",
20
+ styles: "margin:0!important",
21
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
22
+ });
15
23
  //
16
24
  //
17
25
  //
18
- var MaterialRunboxActionAutoShutdown = function MaterialRunboxActionAutoShutdown(_ref) {
19
- var runtime = _ref.runtime,
20
- runtimeTemplate = _ref.runtimeTemplate,
21
- courseId = _ref.courseId,
22
- refetch = _ref.refetch;
26
+ const MaterialRunboxActionAutoShutdown = ({
27
+ runtime,
28
+ runtimeTemplate,
29
+ courseId,
30
+ refetch
31
+ }) => {
23
32
  var _a;
24
- var intl = useIntl();
25
- var materialRunboxApi = useMaterialRunboxApiContext();
33
+ const intl = useIntl();
34
+ const materialRunboxApi = useMaterialRunboxApiContext();
26
35
  /**
27
36
  *
28
37
  */
29
- var handleAction = function handleAction(_, shutdown) {
38
+ const handleAction = (_, shutdown) => {
30
39
  if (!runtime) {
31
40
  return;
32
41
  }
@@ -36,7 +45,7 @@ var MaterialRunboxActionAutoShutdown = function MaterialRunboxActionAutoShutdown
36
45
  autoShutdown: !shutdown
37
46
  },
38
47
  eliceCourseId: courseId
39
- }).then(refetch).catch(function () {
48
+ }).then(refetch).catch(() => {
40
49
  //
41
50
  });
42
51
  };
@@ -1,25 +1,24 @@
1
- import { taggedTemplateLiteral as _taggedTemplateLiteral, slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import _styled from '@emotion/styled/base';
2
2
  import React from 'react';
3
3
  import { useIntl, FormattedMessage } from 'react-intl';
4
4
  import { Transition } from 'react-transition-group';
5
+ import { useSnackbar } from '@elice/mui-x-snackbar';
5
6
  import { CommandType } from '@elice/openapi-client-material-runbox';
6
7
  import { useEliceRunboxRunning } from '@elice/runbox-client';
7
- import styled from '@emotion/styled';
8
8
  import { Terminal } from '@mui/icons-material';
9
9
  import { LoadingButton } from '@mui/lab';
10
- import { Button, Tooltip, ButtonGroup, Badge, Dialog, DialogTitle, DialogContent, Stack, Alert, DialogActions, Typography } from '@mui/material';
10
+ import { Tooltip, ButtonGroup, Badge, Dialog, DialogTitle, DialogContent, Stack, Alert, DialogActions, Button, Typography } from '@mui/material';
11
11
  import { useQuery } from '@tanstack/react-query';
12
- import { useSnackbar } from 'notistack';
13
12
  import { useMaterialRunboxApiContext } from '../contexts/MaterialRunboxApiContext.js';
14
13
  import { useMaterialRunboxCommandContext } from '../contexts/MaterialRunboxCommandContext.js';
15
14
  import '../contexts/MaterialRunboxContext.js';
16
15
 
17
- var _templateObject, _templateObject2, _templateObject3;
16
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
18
17
  //
19
18
  //
20
19
  //
21
- var TRANSITION_DURATION = 300;
22
- var TRANSITION_STYLE_MAP = {
20
+ const TRANSITION_DURATION = 300;
21
+ const TRANSITION_STYLE_MAP = {
23
22
  entering: {
24
23
  maxWidth: 0
25
24
  },
@@ -39,181 +38,149 @@ var TRANSITION_STYLE_MAP = {
39
38
  //
40
39
  //
41
40
  //
42
- var StyledMainActionButton = styled(LoadingButton)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: 4rem !important;\n"])));
43
- var StyledSubActionButton = styled(Button)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n transition: max-width ", "ms\n cubic-bezier(0.25, 0.46, 0.45, 1);\n"])), TRANSITION_DURATION);
44
- var StyledTerminal = styled.textarea(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 1rem;\n width: 100%;\n color: ", ";\n background-color: ", ";\n border: none;\n border-radius: 0.5rem;\n font-family: 'Elice Digital Coding', monospace;\n font-size: ", ";\n line-height: ", ";\n outline: none;\n resize: none;\n"])), function (_ref) {
45
- var theme = _ref.theme;
46
- return theme.palette.common.white;
47
- }, function (_ref2) {
48
- var theme = _ref2.theme;
49
- return theme.palette.common.black;
50
- }, function (_ref3) {
51
- var theme = _ref3.theme;
52
- return theme.typography.body2.fontSize;
53
- }, function (_ref4) {
54
- var theme = _ref4.theme;
55
- return theme.typography.body2.lineHeight;
41
+ const StyledMainActionButton = /*#__PURE__*/_styled(LoadingButton, {
42
+ target: "eae460y2"
43
+ })("production" === "production" ? {
44
+ name: "tssn5p",
45
+ styles: "min-width:4rem!important"
46
+ } : {
47
+ name: "tssn5p",
48
+ styles: "min-width:4rem!important",
49
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
56
50
  });
51
+ const StyledSubActionButton = /*#__PURE__*/_styled(Button, {
52
+ target: "eae460y1"
53
+ })("transition:max-width ", TRANSITION_DURATION, "ms cubic-bezier(0.25, 0.46, 0.45, 1);");
54
+ const StyledTerminal = /*#__PURE__*/_styled("textarea", {
55
+ target: "eae460y0"
56
+ })("padding:1rem;width:100%;color:", ({
57
+ theme
58
+ }) => theme.palette.common.white, ";background-color:", ({
59
+ theme
60
+ }) => theme.palette.common.black, ";border:none;border-radius:0.5rem;font-family:'Elice Digital Coding',monospace;font-size:", ({
61
+ theme
62
+ }) => theme.typography.body2.fontSize, ";line-height:", ({
63
+ theme
64
+ }) => theme.typography.body2.lineHeight, ";outline:none;resize:none;");
57
65
  //
58
66
  //
59
67
  //
60
- var MaterialRunboxActionGrade = function MaterialRunboxActionGrade(_ref5) {
61
- var runtime = _ref5.runtime,
62
- courseId = _ref5.courseId;
68
+ const MaterialRunboxActionGrade = ({
69
+ runtime,
70
+ courseId
71
+ }) => {
63
72
  var _a;
64
- var _useSnackbar = useSnackbar(),
65
- enqueueSnackbar = _useSnackbar.enqueueSnackbar;
66
- var intl = useIntl();
67
- var materialRunboxApi = useMaterialRunboxApiContext();
68
- var _useMaterialRunboxCom = useMaterialRunboxCommandContext(),
69
- isLastCommandRunning = _useMaterialRunboxCom.isLastCommandRunning,
70
- lastCommand = _useMaterialRunboxCom.lastCommand,
71
- setCommandIdToPing = _useMaterialRunboxCom.setCommandIdToPing;
72
- var _useEliceRunboxRunnin = useEliceRunboxRunning(),
73
- status = _useEliceRunboxRunnin.status;
74
- var leaderboardSubmitInfoQuery = useQuery({
73
+ const intl = useIntl();
74
+ const {
75
+ enqueueSnackbar
76
+ } = useSnackbar();
77
+ const materialRunboxApi = useMaterialRunboxApiContext();
78
+ const {
79
+ isLastCommandRunning,
80
+ lastCommand,
81
+ setCommandIdToPing
82
+ } = useMaterialRunboxCommandContext();
83
+ const {
84
+ status
85
+ } = useEliceRunboxRunning();
86
+ const leaderboardSubmitInfoQuery = useQuery({
75
87
  queryKey: ['eliceMaterialRunboxRunboxApi.runboxRunboxIdSubmitInfoGet', {
76
- courseId: courseId,
77
- runtime: runtime
88
+ courseId,
89
+ runtime
78
90
  }],
79
- queryFn: function queryFn(_ref6) {
80
- var signal = _ref6.signal;
81
- return materialRunboxApi.runbox.runboxRunboxIdSubmitInfoGet({
82
- eliceCourseId: courseId,
83
- runboxId: runtime === null || runtime === void 0 ? void 0 : runtime.runboxId
84
- }, {
85
- signal: signal
86
- });
87
- },
91
+ queryFn: ({
92
+ signal
93
+ }) => materialRunboxApi.runbox.runboxRunboxIdSubmitInfoGet({
94
+ eliceCourseId: courseId,
95
+ runboxId: runtime === null || runtime === void 0 ? void 0 : runtime.runboxId
96
+ }, {
97
+ signal
98
+ }),
88
99
  enabled: Boolean(runtime === null || runtime === void 0 ? void 0 : runtime.runboxId),
89
100
  retry: false
90
101
  });
91
- var isSubmitCountRemained = ((_a = leaderboardSubmitInfoQuery.data) === null || _a === void 0 ? void 0 : _a.remainSubmitCount) !== 0;
92
- var _React$useState = React.useState(false),
93
- _React$useState2 = _slicedToArray(_React$useState, 2),
94
- isActionLoading = _React$useState2[0],
95
- setActionLoading = _React$useState2[1];
96
- var _React$useState3 = React.useState(false),
97
- _React$useState4 = _slicedToArray(_React$useState3, 2),
98
- isGradeResultDialogOpen = _React$useState4[0],
99
- setGradeResultDialogOpen = _React$useState4[1];
100
- var _React$useState5 = React.useState(false),
101
- _React$useState6 = _slicedToArray(_React$useState5, 2),
102
- isSubmitCountInfoDialogOpen = _React$useState6[0],
103
- setSubmitCountInfoDialogOpen = _React$useState6[1];
104
- var _React$useState7 = React.useState(false),
105
- _React$useState8 = _slicedToArray(_React$useState7, 2),
106
- hasUnreadResult = _React$useState8[0],
107
- setHasUnreadResult = _React$useState8[1];
108
- var isRunboxRunning = status === 'running';
109
- var isGradeDoneWithOutput = !isLastCommandRunning && (lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.commandType) === CommandType.Grade && Boolean(lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.output);
102
+ const isSubmitCountRemained = ((_a = leaderboardSubmitInfoQuery.data) === null || _a === void 0 ? void 0 : _a.remainSubmitCount) !== 0;
103
+ const [isActionLoading, setActionLoading] = React.useState(false);
104
+ const [isGradeResultDialogOpen, setGradeResultDialogOpen] = React.useState(false);
105
+ const [isSubmitCountInfoDialogOpen, setSubmitCountInfoDialogOpen] = React.useState(false);
106
+ const [hasUnreadResult, setHasUnreadResult] = React.useState(false);
107
+ const isRunboxRunning = status === 'running';
108
+ const isGradeDoneWithOutput = !isLastCommandRunning && (lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.commandType) === CommandType.Grade && Boolean(lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.output);
110
109
  /**
111
110
  *
112
111
  */
113
- var handleGradeResultDialogOpen = function handleGradeResultDialogOpen() {
112
+ const handleGradeResultDialogOpen = () => {
114
113
  setGradeResultDialogOpen(true);
115
114
  };
116
115
  /**
117
116
  *
118
117
  */
119
- var handleGradeResultDialogClose = function handleGradeResultDialogClose() {
118
+ const handleGradeResultDialogClose = () => {
120
119
  setGradeResultDialogOpen(false);
121
120
  };
122
121
  /**
123
122
  *
124
123
  */
125
- var handleSubmitCountInfoDialogClose = function handleSubmitCountInfoDialogClose() {
124
+ const handleSubmitCountInfoDialogClose = () => {
126
125
  setSubmitCountInfoDialogOpen(false);
127
126
  };
128
127
  /**
129
128
  *
130
129
  */
131
- var handleAction = /*#__PURE__*/function () {
132
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
133
- var _yield$leaderboardSub, currentLeaderboardSubmitInfo, isCurrentSubmitCountEmpty, runtimeId, _yield$materialRunbox, commandId;
134
- return _regeneratorRuntime().wrap(function _callee$(_context) {
135
- while (1) switch (_context.prev = _context.next) {
136
- case 0:
137
- setActionLoading(true);
138
- _context.prev = 1;
139
- _context.next = 4;
140
- return leaderboardSubmitInfoQuery.refetch();
141
- case 4:
142
- _yield$leaderboardSub = _context.sent;
143
- currentLeaderboardSubmitInfo = _yield$leaderboardSub.data;
144
- isCurrentSubmitCountEmpty = (currentLeaderboardSubmitInfo === null || currentLeaderboardSubmitInfo === void 0 ? void 0 : currentLeaderboardSubmitInfo.remainSubmitCount) === 0;
145
- if (!isCurrentSubmitCountEmpty) {
146
- _context.next = 10;
147
- break;
148
- }
149
- setSubmitCountInfoDialogOpen(true);
150
- return _context.abrupt("return");
151
- case 10:
152
- runtimeId = runtime === null || runtime === void 0 ? void 0 : runtime.id;
153
- _context.next = 13;
154
- return materialRunboxApi.runtime.runtimeRuntimeIdCommandPost({
155
- runtimeId: runtimeId,
156
- eliceCourseId: courseId,
157
- runboxCommandPostRequest: {
158
- commandType: CommandType.Grade
159
- }
160
- });
161
- case 13:
162
- _yield$materialRunbox = _context.sent;
163
- commandId = _yield$materialRunbox.id;
164
- setCommandIdToPing(commandId);
165
- _context.next = 21;
166
- break;
167
- case 18:
168
- _context.prev = 18;
169
- _context.t0 = _context["catch"](1);
170
- enqueueSnackbar(intl.formatMessage({
171
- id: 'runbox.action.grade.noti.error'
172
- }), {
173
- variant: 'error'
174
- });
175
- case 21:
176
- _context.prev = 21;
177
- setActionLoading(false);
178
- return _context.finish(21);
179
- case 24:
180
- case "end":
181
- return _context.stop();
130
+ const handleAction = async () => {
131
+ setActionLoading(true);
132
+ try {
133
+ const {
134
+ data: currentLeaderboardSubmitInfo
135
+ } = await leaderboardSubmitInfoQuery.refetch();
136
+ const isCurrentSubmitCountEmpty = (currentLeaderboardSubmitInfo === null || currentLeaderboardSubmitInfo === void 0 ? void 0 : currentLeaderboardSubmitInfo.remainSubmitCount) === 0;
137
+ if (isCurrentSubmitCountEmpty) {
138
+ setSubmitCountInfoDialogOpen(true);
139
+ return;
140
+ }
141
+ const runtimeId = runtime === null || runtime === void 0 ? void 0 : runtime.id;
142
+ const {
143
+ id: commandId
144
+ } = await materialRunboxApi.runtime.runtimeRuntimeIdCommandPost({
145
+ runtimeId,
146
+ eliceCourseId: courseId,
147
+ runboxCommandPostRequest: {
148
+ commandType: CommandType.Grade
182
149
  }
183
- }, _callee, null, [[1, 18, 21, 24]]);
184
- }));
185
- return function handleAction() {
186
- return _ref7.apply(this, arguments);
187
- };
188
- }();
150
+ });
151
+ setCommandIdToPing(commandId);
152
+ } catch (err) {
153
+ enqueueSnackbar(intl.formatMessage({
154
+ id: 'runbox.action.grade.noti.error'
155
+ }), {
156
+ variant: 'error'
157
+ });
158
+ } finally {
159
+ setActionLoading(false);
160
+ }
161
+ };
189
162
  //
190
163
  // set `hasUnreadResult` when last command output exists
191
164
  //
192
- React.useEffect(function () {
193
- return setHasUnreadResult(isGradeDoneWithOutput);
194
- }, [isGradeDoneWithOutput]);
165
+ React.useEffect(() => setHasUnreadResult(isGradeDoneWithOutput), [isGradeDoneWithOutput]);
195
166
  //
196
167
  // reset `hasUnreadResult` when dialog state toggled
197
168
  //
198
- React.useEffect(function () {
199
- return setHasUnreadResult(false);
200
- }, [isGradeResultDialogOpen]);
169
+ React.useEffect(() => setHasUnreadResult(false), [isGradeResultDialogOpen]);
201
170
  //
202
171
  // toggle dialog state when last command output exists
203
172
  //
204
- React.useEffect(function () {
205
- return setGradeResultDialogOpen(isGradeDoneWithOutput);
206
- }, [isGradeDoneWithOutput]);
173
+ React.useEffect(() => setGradeResultDialogOpen(isGradeDoneWithOutput), [isGradeDoneWithOutput]);
207
174
  /**
208
175
  *
209
176
  */
210
- var renderActionButton = function renderActionButton() {
211
- var isGradeType = (lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.commandType) === CommandType.Grade;
212
- var isGrading = isActionLoading || isLastCommandRunning && isGradeType;
177
+ const renderActionButton = () => {
178
+ const isGradeType = (lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.commandType) === CommandType.Grade;
179
+ const isGrading = isActionLoading || isLastCommandRunning && isGradeType;
213
180
  /**
214
181
  *
215
182
  */
216
- var getActionTooltipMessage = function getActionTooltipMessage() {
183
+ const getActionTooltipMessage = () => {
217
184
  if (!isSubmitCountRemained) {
218
185
  return intl.formatMessage({
219
186
  id: 'runbox.action.submitCountInfo.tooltip.disabled'
@@ -239,30 +206,28 @@ var MaterialRunboxActionGrade = function MaterialRunboxActionGrade(_ref5) {
239
206
  onClick: handleAction
240
207
  }, React.createElement(FormattedMessage, {
241
208
  id: "runbox.action.grade.title"
242
- })), React.createElement(Transition, {
209
+ })), isGradeDoneWithOutput ? React.createElement(Transition, {
243
210
  in: isGradeDoneWithOutput,
244
211
  timeout: 0,
245
212
  mountOnEnter: true,
246
213
  unmountOnExit: true
247
- }, function (state) {
248
- return React.createElement(StyledSubActionButton, {
249
- size: "small",
250
- disabled: isLastCommandRunning,
251
- onClick: handleGradeResultDialogOpen,
252
- style: TRANSITION_STYLE_MAP[state]
253
- }, React.createElement(Badge, {
254
- color: "error",
255
- variant: "dot",
256
- invisible: !hasUnreadResult
257
- }, React.createElement(Terminal, {
258
- fontSize: "small"
259
- })));
260
- })));
214
+ }, state => React.createElement(StyledSubActionButton, {
215
+ size: "small",
216
+ disabled: isLastCommandRunning,
217
+ onClick: handleGradeResultDialogOpen,
218
+ style: TRANSITION_STYLE_MAP[state]
219
+ }, React.createElement(Badge, {
220
+ color: "error",
221
+ variant: "dot",
222
+ invisible: !hasUnreadResult
223
+ }, React.createElement(Terminal, {
224
+ fontSize: "small"
225
+ })))) : null));
261
226
  };
262
227
  /**
263
228
  *
264
229
  */
265
- var renderActionGradeResultDialog = function renderActionGradeResultDialog() {
230
+ const renderActionGradeResultDialog = () => {
266
231
  if ((lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.commandType) !== CommandType.Grade) {
267
232
  return null;
268
233
  }
@@ -298,7 +263,7 @@ var MaterialRunboxActionGrade = function MaterialRunboxActionGrade(_ref5) {
298
263
  /**
299
264
  *
300
265
  */
301
- var renderActionSubmitCountInfoDialog = function renderActionSubmitCountInfoDialog() {
266
+ const renderActionSubmitCountInfoDialog = () => {
302
267
  return React.createElement(Dialog, {
303
268
  fullWidth: true,
304
269
  maxWidth: "xs",
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { RuntimeProps } from '../runtime/Runtime';
3
+ type MaterialRunboxActionMenuProps = Pick<RuntimeProps, 'runbox' | 'runtime' | 'courseId' | 'refetch'> & {
4
+ menuAnchorEl: null | HTMLButtonElement;
5
+ handleMenuClose: () => void;
6
+ };
7
+ declare const MaterialRunboxActionMenu: React.FC<MaterialRunboxActionMenuProps>;
8
+ export default MaterialRunboxActionMenu;