@elice/material-runbox 1.231227.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
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { useEliceRunboxRunning } from '@elice/runbox-client';
3
+ import { Menu } from '@mui/material';
4
+ import MaterialRunboxActionReset from './MaterialRunboxActionReset.js';
5
+ import MaterialRunboxActionRestart from './MaterialRunboxActionRestart.js';
6
+ import MaterialRunboxActionShare from './MaterialRunboxActionShare.js';
7
+
8
+ //
9
+ //
10
+ //
11
+ const MaterialRunboxActionMenu = ({
12
+ runbox,
13
+ runtime,
14
+ courseId,
15
+ menuAnchorEl,
16
+ refetch,
17
+ handleMenuClose
18
+ }) => {
19
+ const {
20
+ status
21
+ } = useEliceRunboxRunning();
22
+ const isRunboxRunning = status === 'running';
23
+ //
24
+ //
25
+ //
26
+ React.useEffect(() => {
27
+ if (!isRunboxRunning) {
28
+ handleMenuClose();
29
+ }
30
+ }, [handleMenuClose, isRunboxRunning]);
31
+ //
32
+ //
33
+ //
34
+ return React.createElement(Menu, {
35
+ open: Boolean(menuAnchorEl),
36
+ anchorEl: menuAnchorEl,
37
+ anchorOrigin: {
38
+ vertical: 'bottom',
39
+ horizontal: 'right'
40
+ },
41
+ transformOrigin: {
42
+ vertical: 'top',
43
+ horizontal: 'right'
44
+ },
45
+ onClose: handleMenuClose
46
+ }, React.createElement(MaterialRunboxActionShare, {
47
+ handleMenuClose: handleMenuClose
48
+ }), React.createElement(MaterialRunboxActionRestart, {
49
+ runbox: runbox,
50
+ runtime: runtime,
51
+ courseId: courseId,
52
+ refetch: refetch,
53
+ handleMenuClose: handleMenuClose
54
+ }), React.createElement(MaterialRunboxActionReset, {
55
+ runtime: runtime,
56
+ courseId: courseId,
57
+ handleMenuClose: handleMenuClose
58
+ }));
59
+ };
60
+
61
+ export { MaterialRunboxActionMenu as default };
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { RuntimeProps } from '../runtime/Runtime';
3
- type MaterialRunboxActionResetProps = Pick<RuntimeProps, 'runtime' | 'courseId'>;
3
+ type MaterialRunboxActionResetProps = Pick<RuntimeProps, 'runtime' | 'courseId'> & {
4
+ handleMenuClose: () => void;
5
+ };
4
6
  declare const MaterialRunboxActionReset: React.FC<MaterialRunboxActionResetProps>;
5
7
  export default MaterialRunboxActionReset;
@@ -1,11 +1,11 @@
1
- import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import React from 'react';
3
2
  import { useIntl, FormattedMessage } from 'react-intl';
3
+ import { EliceIcon } from '@elice/mui-elements';
4
+ import { useSnackbar } from '@elice/mui-x-snackbar';
4
5
  import { CommandType } from '@elice/openapi-client-material-runbox';
5
- import { useEliceRunboxRunning } from '@elice/runbox-client';
6
+ import { faRefresh } from '@fortawesome/pro-solid-svg-icons';
6
7
  import { LoadingButton } from '@mui/lab';
7
- import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material';
8
- import { useSnackbar } from 'notistack';
8
+ import { MenuItem, ListItemIcon, ListItemText, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material';
9
9
  import { useMaterialRunboxApiContext } from '../contexts/MaterialRunboxApiContext.js';
10
10
  import { useMaterialRunboxCommandContext } from '../contexts/MaterialRunboxCommandContext.js';
11
11
  import '../contexts/MaterialRunboxContext.js';
@@ -13,114 +13,81 @@ import '../contexts/MaterialRunboxContext.js';
13
13
  //
14
14
  //
15
15
  //
16
- var MaterialRunboxActionReset = function MaterialRunboxActionReset(_ref) {
17
- var runtime = _ref.runtime,
18
- courseId = _ref.courseId;
19
- var _useSnackbar = useSnackbar(),
20
- enqueueSnackbar = _useSnackbar.enqueueSnackbar;
21
- var intl = useIntl();
22
- var materialRunboxApi = useMaterialRunboxApiContext();
23
- var _useMaterialRunboxCom = useMaterialRunboxCommandContext(),
24
- isLastCommandRunning = _useMaterialRunboxCom.isLastCommandRunning,
25
- lastCommand = _useMaterialRunboxCom.lastCommand,
26
- setCommandIdToPing = _useMaterialRunboxCom.setCommandIdToPing;
27
- var _useEliceRunboxRunnin = useEliceRunboxRunning(),
28
- status = _useEliceRunboxRunnin.status;
29
- var isRunboxRunning = status === 'running';
30
- var _React$useState = React.useState(false),
31
- _React$useState2 = _slicedToArray(_React$useState, 2),
32
- isConfirmDialogOpen = _React$useState2[0],
33
- setConfirmDialogOpen = _React$useState2[1];
34
- var _React$useState3 = React.useState(false),
35
- _React$useState4 = _slicedToArray(_React$useState3, 2),
36
- isActionLoading = _React$useState4[0],
37
- setActionLoading = _React$useState4[1];
16
+ const MaterialRunboxActionReset = ({
17
+ runtime,
18
+ courseId,
19
+ handleMenuClose
20
+ }) => {
21
+ const intl = useIntl();
22
+ const {
23
+ enqueueSnackbar
24
+ } = useSnackbar();
25
+ const materialRunboxApi = useMaterialRunboxApiContext();
26
+ const [isLoading, setLoading] = React.useState(false);
27
+ const [isDialogOpened, setDialogOpened] = React.useState(false);
28
+ const {
29
+ isLastCommandRunning,
30
+ setCommandIdToPing
31
+ } = useMaterialRunboxCommandContext();
38
32
  /**
39
33
  *
40
34
  */
41
- var handleConfirmDialogOpen = function handleConfirmDialogOpen() {
42
- setConfirmDialogOpen(true);
35
+ const handleDialogClose = () => {
36
+ setDialogOpened(false);
43
37
  };
44
38
  /**
45
39
  *
46
40
  */
47
- var handleConfirmDialogClose = function handleConfirmDialogClose() {
48
- setConfirmDialogOpen(false);
49
- };
50
- /**
51
- *
52
- */
53
- var handleAction = /*#__PURE__*/function () {
54
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
55
- var runtimeId, _yield$materialRunbox, commentId;
56
- return _regeneratorRuntime().wrap(function _callee$(_context) {
57
- while (1) switch (_context.prev = _context.next) {
58
- case 0:
59
- setActionLoading(true);
60
- _context.prev = 1;
61
- runtimeId = runtime === null || runtime === void 0 ? void 0 : runtime.id;
62
- _context.next = 5;
63
- return materialRunboxApi.runtime.runtimeRuntimeIdCommandPost({
64
- runtimeId: runtimeId,
65
- eliceCourseId: courseId,
66
- runboxCommandPostRequest: {
67
- commandType: CommandType.ProjectFileReset
68
- }
69
- });
70
- case 5:
71
- _yield$materialRunbox = _context.sent;
72
- commentId = _yield$materialRunbox.id;
73
- setCommandIdToPing(commentId);
74
- handleConfirmDialogClose();
75
- _context.next = 14;
76
- break;
77
- case 11:
78
- _context.prev = 11;
79
- _context.t0 = _context["catch"](1);
80
- enqueueSnackbar(intl.formatMessage({
81
- id: 'runbox.action.reset.noti.error'
82
- }), {
83
- variant: 'error'
84
- });
85
- case 14:
86
- _context.prev = 14;
87
- setActionLoading(false);
88
- return _context.finish(14);
89
- case 17:
90
- case "end":
91
- return _context.stop();
41
+ const handleReset = async () => {
42
+ setLoading(true);
43
+ try {
44
+ const runtimeId = runtime === null || runtime === void 0 ? void 0 : runtime.id;
45
+ const {
46
+ id: commentId
47
+ } = await materialRunboxApi.runtime.runtimeRuntimeIdCommandPost({
48
+ runtimeId,
49
+ eliceCourseId: courseId,
50
+ runboxCommandPostRequest: {
51
+ commandType: CommandType.ProjectFileReset
92
52
  }
93
- }, _callee, null, [[1, 11, 14, 17]]);
94
- }));
95
- return function handleAction() {
96
- return _ref2.apply(this, arguments);
97
- };
98
- }();
53
+ });
54
+ setCommandIdToPing(commentId);
55
+ handleDialogClose();
56
+ } catch (err) {
57
+ enqueueSnackbar(intl.formatMessage({
58
+ id: 'runbox.action.reset.noti.error'
59
+ }), {
60
+ variant: 'error'
61
+ });
62
+ } finally {
63
+ setLoading(false);
64
+ }
65
+ };
99
66
  /**
100
67
  *
101
68
  */
102
- var renderActionButton = function renderActionButton() {
103
- var isResetType = (lastCommand === null || lastCommand === void 0 ? void 0 : lastCommand.commandType) === CommandType.ProjectFileReset;
104
- return React.createElement(LoadingButton, {
105
- variant: "contained",
106
- color: "inherit",
107
- loading: isActionLoading || isLastCommandRunning && isResetType,
108
- disabled: !isRunboxRunning || isLastCommandRunning,
109
- size: "small",
110
- onClick: handleConfirmDialogOpen
111
- }, React.createElement(FormattedMessage, {
69
+ const renderResetMenuItem = () => {
70
+ return React.createElement(MenuItem, {
71
+ onClick: () => setDialogOpened(true),
72
+ disabled: isLastCommandRunning
73
+ }, React.createElement(ListItemIcon, null, React.createElement(EliceIcon, {
74
+ icon: faRefresh
75
+ })), React.createElement(ListItemText, null, React.createElement(FormattedMessage, {
112
76
  id: "runbox.action.reset.title"
113
- }));
77
+ })));
114
78
  };
115
79
  /**
116
80
  *
117
81
  */
118
- var renderActionConfirmDialog = function renderActionConfirmDialog() {
82
+ const renderConfirmDialog = () => {
83
+ if (!isDialogOpened) {
84
+ return null;
85
+ }
119
86
  return React.createElement(Dialog, {
120
- open: isConfirmDialogOpen,
87
+ open: true,
121
88
  maxWidth: "xs",
122
89
  fullWidth: true,
123
- onClose: handleConfirmDialogClose
90
+ onClose: handleDialogClose
124
91
  }, React.createElement(DialogTitle, null, React.createElement(FormattedMessage, {
125
92
  id: "runbox.action.reset.title"
126
93
  })), React.createElement(DialogContent, null, React.createElement(DialogContentText, {
@@ -131,15 +98,15 @@ var MaterialRunboxActionReset = function MaterialRunboxActionReset(_ref) {
131
98
  id: "runbox.action.reset.dialog.description"
132
99
  }))), React.createElement(DialogActions, null, React.createElement(Button, {
133
100
  color: "inherit",
134
- disabled: isActionLoading,
135
- onClick: handleConfirmDialogClose
101
+ disabled: isLoading,
102
+ onClick: handleDialogClose
136
103
  }, React.createElement(FormattedMessage, {
137
104
  id: "runbox.common.close"
138
105
  })), React.createElement(LoadingButton, {
139
106
  variant: "contained",
140
107
  color: "warning",
141
- loading: isActionLoading,
142
- onClick: handleAction
108
+ loading: isLoading || isLastCommandRunning,
109
+ onClick: handleReset
143
110
  }, React.createElement(FormattedMessage, {
144
111
  id: "runbox.action.reset.dialog.actions.confirm"
145
112
  }))));
@@ -147,7 +114,7 @@ var MaterialRunboxActionReset = function MaterialRunboxActionReset(_ref) {
147
114
  //
148
115
  //
149
116
  //
150
- return React.createElement(React.Fragment, null, renderActionButton(), renderActionConfirmDialog());
117
+ return React.createElement(React.Fragment, null, renderResetMenuItem(), renderConfirmDialog());
151
118
  };
152
119
 
153
120
  export { MaterialRunboxActionReset as default };
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { RuntimeProps } from '../runtime/Runtime';
3
- type MaterialRunboxActionRestartProps = Pick<RuntimeProps, 'runbox' | 'courseId' | 'refetch'>;
3
+ type MaterialRunboxActionRestartProps = Pick<RuntimeProps, 'runbox' | 'runtime' | 'courseId' | 'refetch'> & {
4
+ handleMenuClose: () => void;
5
+ };
4
6
  declare const MaterialRunboxActionRestart: React.FC<MaterialRunboxActionRestartProps>;
5
7
  export default MaterialRunboxActionRestart;
@@ -1,83 +1,71 @@
1
- import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import React from 'react';
3
- import { useIntl, FormattedMessage } from 'react-intl';
4
- import { useEliceRunboxRunning } from '@elice/runbox-client';
5
- import { RestartAlt } from '@mui/icons-material';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import { EliceIcon } from '@elice/mui-elements';
4
+ import { faRotateRight } from '@fortawesome/pro-solid-svg-icons';
6
5
  import { LoadingButton } from '@mui/lab';
7
- import { Tooltip, IconButton, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material';
6
+ import { MenuItem, ListItemIcon, ListItemText, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material';
8
7
  import { useRunboxControl } from '../hooks/useRunboxControl.js';
9
8
 
10
9
  //
11
10
  //
12
11
  //
13
- var MaterialRunboxActionRestart = function MaterialRunboxActionRestart(_ref) {
14
- var runbox = _ref.runbox,
15
- courseId = _ref.courseId,
16
- refetch = _ref.refetch;
17
- var intl = useIntl();
18
- var _useEliceRunboxRunnin = useEliceRunboxRunning(),
19
- status = _useEliceRunboxRunnin.status;
20
- var _useRunboxControl = useRunboxControl({
21
- runbox: runbox,
22
- courseId: courseId,
23
- refetch: refetch
24
- }),
25
- start = _useRunboxControl.start;
26
- var isRunboxRunning = status === 'running';
27
- var _React$useState = React.useState(false),
28
- _React$useState2 = _slicedToArray(_React$useState, 2),
29
- isConfirmDialogOpen = _React$useState2[0],
30
- setConfirmDialogOpen = _React$useState2[1];
31
- var _React$useState3 = React.useState(false),
32
- _React$useState4 = _slicedToArray(_React$useState3, 2),
33
- isActionLoading = _React$useState4[0],
34
- setActionLoading = _React$useState4[1];
12
+ const MaterialRunboxActionRestart = ({
13
+ runbox,
14
+ courseId,
15
+ refetch,
16
+ handleMenuClose
17
+ }) => {
18
+ const [isLoading, setIsLoading] = React.useState(false);
19
+ const [isDialogOpened, setDialogOpened] = React.useState(false);
20
+ // restart
21
+ const {
22
+ start
23
+ } = useRunboxControl({
24
+ runbox,
25
+ courseId,
26
+ refetch
27
+ });
35
28
  /**
36
29
  *
37
30
  */
38
- var handleConfirmDialogOpen = function handleConfirmDialogOpen() {
39
- setConfirmDialogOpen(true);
31
+ const handleDialogClose = () => {
32
+ setDialogOpened(false);
40
33
  };
41
34
  /**
42
35
  *
43
36
  */
44
- var handleConfirmDialogClose = function handleConfirmDialogClose() {
45
- setConfirmDialogOpen(false);
46
- };
47
- /**
48
- *
49
- */
50
- var handleAction = function handleAction() {
51
- setActionLoading(true);
52
- start(true).catch(function () {
53
- return void 0;
54
- }).finally(function () {
55
- setActionLoading(false);
56
- handleConfirmDialogClose();
37
+ const handleRestartAction = () => {
38
+ setIsLoading(true);
39
+ start(true).catch(() => void 0).finally(() => {
40
+ handleDialogClose();
41
+ handleMenuClose();
42
+ setIsLoading(false);
57
43
  });
58
44
  };
59
45
  /**
60
46
  *
61
47
  */
62
- var renderActionButton = function renderActionButton() {
63
- return React.createElement(Tooltip, {
64
- title: intl.formatMessage({
65
- id: 'runbox.action.restart.title'
66
- })
67
- }, React.createElement(IconButton, {
68
- disabled: !isRunboxRunning,
69
- onClick: handleConfirmDialogOpen
70
- }, React.createElement(RestartAlt, null)));
48
+ const renderRestartMenuItem = () => {
49
+ return React.createElement(MenuItem, {
50
+ onClick: () => setDialogOpened(true)
51
+ }, React.createElement(ListItemIcon, null, React.createElement(EliceIcon, {
52
+ icon: faRotateRight
53
+ })), React.createElement(ListItemText, null, React.createElement(FormattedMessage, {
54
+ id: "runbox.action.restart.title"
55
+ })));
71
56
  };
72
57
  /**
73
58
  *
74
59
  */
75
- var renderActionConfirmDialog = function renderActionConfirmDialog() {
60
+ const renderConfirmDialog = () => {
61
+ if (!isDialogOpened) {
62
+ return null;
63
+ }
76
64
  return React.createElement(Dialog, {
77
- open: isConfirmDialogOpen,
78
65
  maxWidth: "xs",
66
+ open: true,
79
67
  fullWidth: true,
80
- onClose: handleConfirmDialogClose
68
+ onClose: handleDialogClose
81
69
  }, React.createElement(DialogTitle, null, React.createElement(FormattedMessage, {
82
70
  id: "runbox.action.restart.title"
83
71
  })), React.createElement(DialogContent, null, React.createElement(DialogContentText, {
@@ -88,15 +76,15 @@ var MaterialRunboxActionRestart = function MaterialRunboxActionRestart(_ref) {
88
76
  id: "runbox.action.restart.dialog.description"
89
77
  }))), React.createElement(DialogActions, null, React.createElement(Button, {
90
78
  color: "inherit",
91
- disabled: isActionLoading,
92
- onClick: handleConfirmDialogClose
79
+ disabled: isLoading,
80
+ onClick: handleDialogClose
93
81
  }, React.createElement(FormattedMessage, {
94
82
  id: "runbox.common.close"
95
83
  })), React.createElement(LoadingButton, {
96
84
  variant: "contained",
97
85
  color: "warning",
98
- loading: isActionLoading,
99
- onClick: handleAction
86
+ loading: isLoading,
87
+ onClick: handleRestartAction
100
88
  }, React.createElement(FormattedMessage, {
101
89
  id: "runbox.action.restart.dialog.actions.confirm"
102
90
  }))));
@@ -104,7 +92,7 @@ var MaterialRunboxActionRestart = function MaterialRunboxActionRestart(_ref) {
104
92
  //
105
93
  //
106
94
  //
107
- return React.createElement(React.Fragment, null, renderActionButton(), renderActionConfirmDialog());
95
+ return React.createElement(React.Fragment, null, renderRestartMenuItem(), renderConfirmDialog());
108
96
  };
109
97
 
110
98
  export { MaterialRunboxActionRestart as default };
@@ -1,3 +1,6 @@
1
1
  import React from 'react';
2
- declare const MaterialRunboxActionShare: React.FC;
2
+ interface MaterialRunboxActionShareProps {
3
+ handleMenuClose: () => void;
4
+ }
5
+ declare const MaterialRunboxActionShare: React.FC<MaterialRunboxActionShareProps>;
3
6
  export default MaterialRunboxActionShare;
@@ -1,61 +1,91 @@
1
- import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import React from 'react';
3
- import { useIntl } from 'react-intl';
2
+ import { useIntl, FormattedMessage } from 'react-intl';
4
3
  import { useCopyToClipboard } from 'react-use';
4
+ import { EliceIcon } from '@elice/mui-elements';
5
+ import { useSnackbar } from '@elice/mui-x-snackbar';
5
6
  import { useEliceRunboxRunning } from '@elice/runbox-client';
6
- import { Check, Link } from '@mui/icons-material';
7
- import { Tooltip, IconButton } from '@mui/material';
7
+ import { faLinkSimple } from '@fortawesome/pro-solid-svg-icons';
8
+ import { MenuItem, ListItemIcon, ListItemText } from '@mui/material';
9
+ import '../contexts/MaterialRunboxApiContext.js';
10
+ import '../contexts/MaterialRunboxCommandContext.js';
11
+ import { useMaterialRunboxContext } from '../contexts/MaterialRunboxContext.js';
8
12
 
9
13
  //
10
14
  //
11
15
  //
12
- var MaterialRunboxActionShare = function MaterialRunboxActionShare() {
13
- var intl = useIntl();
14
- var _useEliceRunboxRunnin = useEliceRunboxRunning(),
15
- status = _useEliceRunboxRunnin.status,
16
- url = _useEliceRunboxRunnin.url;
17
- var _React$useState = React.useState(false),
18
- _React$useState2 = _slicedToArray(_React$useState, 2),
19
- isClipboardCopied = _React$useState2[0],
20
- setClipboardCopied = _React$useState2[1];
21
- var _useCopyToClipboard = useCopyToClipboard(),
22
- _useCopyToClipboard2 = _slicedToArray(_useCopyToClipboard, 2),
23
- clipboardValue = _useCopyToClipboard2[0].value,
24
- copy = _useCopyToClipboard2[1];
25
- var isRunboxRunning = status === 'running';
16
+ const MaterialRunboxActionShare = ({
17
+ handleMenuClose
18
+ }) => {
19
+ const intl = useIntl();
20
+ const {
21
+ enqueueSnackbar
22
+ } = useSnackbar();
23
+ const {
24
+ enableUrlShare
25
+ } = useMaterialRunboxContext();
26
+ const {
27
+ url
28
+ } = useEliceRunboxRunning();
29
+ const [{
30
+ value: clipboardValue,
31
+ error
32
+ }, copy] = useCopyToClipboard();
33
+ const [isClipboardCopied, setClipboardCopied] = React.useState(false);
26
34
  /**
27
35
  *
28
36
  */
29
- var handleAction = function handleAction() {
37
+ const renderShareMenuItem = () => {
38
+ if (!enableUrlShare) {
39
+ return null;
40
+ }
41
+ return React.createElement(MenuItem, {
42
+ disabled: !url,
43
+ onClick: handleShareAction
44
+ }, React.createElement(ListItemIcon, null, React.createElement(EliceIcon, {
45
+ icon: faLinkSimple
46
+ })), React.createElement(ListItemText, null, React.createElement(FormattedMessage, {
47
+ id: "runbox.action.share.title"
48
+ })));
49
+ };
50
+ /**
51
+ *
52
+ */
53
+ const handleShareAction = () => {
30
54
  if (url) {
31
55
  copy(url);
56
+ if (!error) {
57
+ handleMenuClose();
58
+ setClipboardCopied(true);
59
+ }
32
60
  }
33
61
  };
34
62
  //
35
63
  //
36
64
  //
37
- React.useEffect(function () {
38
- setClipboardCopied(Boolean(clipboardValue));
39
- var timeoutId = setTimeout(function () {
40
- return setClipboardCopied(false);
41
- }, 2000);
42
- return function () {
43
- clearTimeout(timeoutId);
44
- };
45
- }, [clipboardValue]);
65
+ React.useEffect(() => {
66
+ if (!isClipboardCopied) {
67
+ return;
68
+ }
69
+ if (clipboardValue && !error) {
70
+ enqueueSnackbar(intl.formatMessage({
71
+ id: 'runbox.action.share.snackbar.copied.success'
72
+ }), {
73
+ variant: 'success'
74
+ });
75
+ } else {
76
+ enqueueSnackbar(intl.formatMessage({
77
+ id: 'runbox.action.share.snackbar.copied.fail'
78
+ }), {
79
+ variant: 'error'
80
+ });
81
+ }
82
+ setClipboardCopied(false);
83
+ // eslint-disable-next-line react-hooks/exhaustive-deps
84
+ }, [isClipboardCopied]);
46
85
  //
47
86
  //
48
87
  //
49
- return React.createElement(Tooltip, {
50
- title: isClipboardCopied ? intl.formatMessage({
51
- id: 'runbox.action.share.tooltip.copied'
52
- }) : intl.formatMessage({
53
- id: 'runbox.action.share.title'
54
- })
55
- }, React.createElement(IconButton, {
56
- disabled: !isRunboxRunning || !url,
57
- onClick: handleAction
58
- }, isClipboardCopied ? React.createElement(Check, null) : React.createElement(Link, null)));
88
+ return renderShareMenuItem();
59
89
  };
60
90
 
61
91
  export { MaterialRunboxActionShare as default };
@@ -1,40 +1,33 @@
1
- import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
1
  import React from 'react';
3
2
  import { RunboxApi, RuntimeApi, RuntimeTemplateApi } from '@elice/openapi-client-material-runbox';
4
3
 
5
4
  //
6
5
  //
7
6
  //
8
- var MaterialRunboxApiContext = React.createContext({});
9
- var useMaterialRunboxApiContext = function useMaterialRunboxApiContext() {
7
+ const MaterialRunboxApiContext = React.createContext({});
8
+ const useMaterialRunboxApiContext = () => {
10
9
  return React.useContext(MaterialRunboxApiContext);
11
10
  };
12
11
  //
13
12
  //
14
13
  //
15
- var MaterialRunboxApiContextProvider = function MaterialRunboxApiContextProvider(_ref) {
16
- var children = _ref.children,
17
- eliceMaterialRunboxApiConfiguration = _ref.eliceMaterialRunboxApiConfiguration;
18
- var createMaterialRunboxApi = function createMaterialRunboxApi() {
19
- return Object.freeze({
20
- runbox: new RunboxApi(eliceMaterialRunboxApiConfiguration),
21
- runtime: new RuntimeApi(eliceMaterialRunboxApiConfiguration),
22
- runtimeTemplate: new RuntimeTemplateApi(eliceMaterialRunboxApiConfiguration)
23
- });
24
- };
14
+ const MaterialRunboxApiContextProvider = ({
15
+ children,
16
+ eliceMaterialRunboxApiConfiguration
17
+ }) => {
18
+ const createMaterialRunboxApi = () => Object.freeze({
19
+ runbox: new RunboxApi(eliceMaterialRunboxApiConfiguration),
20
+ runtime: new RuntimeApi(eliceMaterialRunboxApiConfiguration),
21
+ runtimeTemplate: new RuntimeTemplateApi(eliceMaterialRunboxApiConfiguration)
22
+ });
25
23
  //
26
24
  //
27
25
  //
28
- var _React$useState = React.useState(createMaterialRunboxApi),
29
- _React$useState2 = _slicedToArray(_React$useState, 2),
30
- materialRunboxApi = _React$useState2[0],
31
- setMaterialRunboxApi = _React$useState2[1];
26
+ const [materialRunboxApi, setMaterialRunboxApi] = React.useState(createMaterialRunboxApi);
32
27
  //
33
28
  //
34
29
  //
35
- React.useEffect(function () {
36
- return setMaterialRunboxApi(createMaterialRunboxApi);
37
- },
30
+ React.useEffect(() => setMaterialRunboxApi(createMaterialRunboxApi),
38
31
  // eslint-disable-next-line react-hooks/exhaustive-deps
39
32
  [eliceMaterialRunboxApiConfiguration]);
40
33
  //