@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.
- package/cjs/assets/queue.gif.js +1 -1
- package/cjs/assets/runbox_logo.png.js +1 -1
- package/cjs/assets/terminated.png.js +1 -1
- package/cjs/components/material-runbox/MaterialRunbox.js +17 -19
- package/cjs/components/material-runbox/MaterialRunboxBody.js +15 -12
- package/cjs/components/material-runbox/MaterialRunboxContent.js +94 -101
- package/cjs/components/material-runbox/MaterialRunboxFooter.js +17 -22
- package/cjs/components/material-runbox/MaterialRunboxHeader.d.ts +3 -0
- package/cjs/components/material-runbox/MaterialRunboxHeader.js +77 -81
- package/cjs/components/material-runbox/actions/MaterialRunboxActionAutoShutdown.js +26 -22
- package/cjs/components/material-runbox/actions/MaterialRunboxActionGrade.js +140 -180
- package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +8 -0
- package/cjs/components/material-runbox/actions/MaterialRunboxActionMenu.js +65 -0
- package/cjs/components/material-runbox/actions/MaterialRunboxActionReset.d.ts +3 -1
- package/cjs/components/material-runbox/actions/MaterialRunboxActionReset.js +73 -110
- package/cjs/components/material-runbox/actions/MaterialRunboxActionRestart.d.ts +3 -1
- package/cjs/components/material-runbox/actions/MaterialRunboxActionRestart.js +54 -70
- package/cjs/components/material-runbox/actions/MaterialRunboxActionShare.d.ts +4 -1
- package/cjs/components/material-runbox/actions/MaterialRunboxActionShare.js +67 -41
- package/cjs/components/material-runbox/contexts/MaterialRunboxApiContext.js +16 -27
- package/cjs/components/material-runbox/contexts/MaterialRunboxCommandContext.js +38 -53
- package/cjs/components/material-runbox/contexts/MaterialRunboxContext.js +9 -11
- package/cjs/components/material-runbox/hooks/useRunboxControl.js +39 -65
- package/cjs/components/material-runbox/locales/en.json.js +2 -2
- package/cjs/components/material-runbox/locales/index.js +2 -4
- package/cjs/components/material-runbox/locales/ko.json.js +2 -2
- package/cjs/components/material-runbox/runtime/Runtime.js +18 -26
- package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.js +10 -17
- package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.js +16 -18
- package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.js +27 -33
- package/cjs/index.js +1 -3
- package/es/components/material-runbox/MaterialRunbox.js +11 -9
- package/es/components/material-runbox/MaterialRunboxBody.js +13 -5
- package/es/components/material-runbox/MaterialRunboxContent.js +80 -82
- package/es/components/material-runbox/MaterialRunboxFooter.js +11 -11
- package/es/components/material-runbox/MaterialRunboxHeader.d.ts +3 -0
- package/es/components/material-runbox/MaterialRunboxHeader.js +72 -71
- package/es/components/material-runbox/actions/MaterialRunboxActionAutoShutdown.js +22 -13
- package/es/components/material-runbox/actions/MaterialRunboxActionGrade.js +120 -155
- package/es/components/material-runbox/actions/MaterialRunboxActionMenu.d.ts +8 -0
- package/es/components/material-runbox/actions/MaterialRunboxActionMenu.js +61 -0
- package/es/components/material-runbox/actions/MaterialRunboxActionReset.d.ts +3 -1
- package/es/components/material-runbox/actions/MaterialRunboxActionReset.js +65 -98
- package/es/components/material-runbox/actions/MaterialRunboxActionRestart.d.ts +3 -1
- package/es/components/material-runbox/actions/MaterialRunboxActionRestart.js +47 -59
- package/es/components/material-runbox/actions/MaterialRunboxActionShare.d.ts +4 -1
- package/es/components/material-runbox/actions/MaterialRunboxActionShare.js +68 -38
- package/es/components/material-runbox/contexts/MaterialRunboxApiContext.js +13 -20
- package/es/components/material-runbox/contexts/MaterialRunboxCommandContext.js +35 -46
- package/es/components/material-runbox/contexts/MaterialRunboxContext.js +6 -4
- package/es/components/material-runbox/hooks/useRunboxControl.js +39 -63
- package/es/components/material-runbox/locales/en.json.js +1 -1
- package/es/components/material-runbox/locales/ko.json.js +1 -1
- package/es/components/material-runbox/runtime/Runtime.js +14 -18
- package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.js +3 -6
- package/es/components/material-runbox/runtime/RuntimeOverlayQueued.js +6 -4
- package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.js +12 -14
- package/package.json +13 -9
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -399
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -387
|
@@ -1,68 +1,73 @@
|
|
|
1
|
-
import
|
|
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
|
|
6
|
-
import {
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
42
|
-
runtime
|
|
49
|
+
courseId,
|
|
50
|
+
runtime
|
|
43
51
|
}],
|
|
44
|
-
queryFn:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
67
|
+
const renderHeaderSubmitInfo = () => {
|
|
63
68
|
var _a, _b;
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
-
if (!
|
|
103
|
+
const renderHeaderActionGrade = () => {
|
|
104
|
+
if (!runbox.submission.enabled) {
|
|
100
105
|
return null;
|
|
101
106
|
}
|
|
102
|
-
return React.createElement(
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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(),
|
|
153
|
+
}, renderHeaderSubmitInfo(), renderHeaderActionAutoShutdown(), renderOptionMenu(), renderHeaderActionGrade()));
|
|
153
154
|
};
|
|
154
155
|
|
|
155
156
|
export { MaterialRunboxHeader as default };
|
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
const MaterialRunboxActionAutoShutdown = ({
|
|
27
|
+
runtime,
|
|
28
|
+
runtimeTemplate,
|
|
29
|
+
courseId,
|
|
30
|
+
refetch
|
|
31
|
+
}) => {
|
|
23
32
|
var _a;
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
const intl = useIntl();
|
|
34
|
+
const materialRunboxApi = useMaterialRunboxApiContext();
|
|
26
35
|
/**
|
|
27
36
|
*
|
|
28
37
|
*/
|
|
29
|
-
|
|
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(
|
|
48
|
+
}).then(refetch).catch(() => {
|
|
40
49
|
//
|
|
41
50
|
});
|
|
42
51
|
};
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
22
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
const MaterialRunboxActionGrade = ({
|
|
69
|
+
runtime,
|
|
70
|
+
courseId
|
|
71
|
+
}) => {
|
|
63
72
|
var _a;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
77
|
-
runtime
|
|
88
|
+
courseId,
|
|
89
|
+
runtime
|
|
78
90
|
}],
|
|
79
|
-
queryFn:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
112
|
+
const handleGradeResultDialogOpen = () => {
|
|
114
113
|
setGradeResultDialogOpen(true);
|
|
115
114
|
};
|
|
116
115
|
/**
|
|
117
116
|
*
|
|
118
117
|
*/
|
|
119
|
-
|
|
118
|
+
const handleGradeResultDialogClose = () => {
|
|
120
119
|
setGradeResultDialogOpen(false);
|
|
121
120
|
};
|
|
122
121
|
/**
|
|
123
122
|
*
|
|
124
123
|
*/
|
|
125
|
-
|
|
124
|
+
const handleSubmitCountInfoDialogClose = () => {
|
|
126
125
|
setSubmitCountInfoDialogOpen(false);
|
|
127
126
|
};
|
|
128
127
|
/**
|
|
129
128
|
*
|
|
130
129
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
205
|
-
return setGradeResultDialogOpen(isGradeDoneWithOutput);
|
|
206
|
-
}, [isGradeDoneWithOutput]);
|
|
173
|
+
React.useEffect(() => setGradeResultDialogOpen(isGradeDoneWithOutput), [isGradeDoneWithOutput]);
|
|
207
174
|
/**
|
|
208
175
|
*
|
|
209
176
|
*/
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|