cdd-cli 3.1.7 → 3.2.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 (136) hide show
  1. package/.eslintrc.json +1 -1
  2. package/.github/workflows/ci.yml +3 -0
  3. package/.github/workflows/docs.yml +8 -1
  4. package/CHANGELOG.md +40 -0
  5. package/CONTRIBUTING.md +28 -15
  6. package/README.md +56 -88
  7. package/babel.config.cjs +18 -1
  8. package/coverage/clover.xml +604 -0
  9. package/coverage/coverage-final.json +17 -0
  10. package/coverage/lcov-report/base.css +224 -0
  11. package/coverage/lcov-report/block-navigation.js +87 -0
  12. package/coverage/lcov-report/favicon.png +0 -0
  13. package/coverage/lcov-report/helpers/constants.js.html +235 -0
  14. package/coverage/lcov-report/helpers/containerOptionsBuilder.js.html +211 -0
  15. package/coverage/lcov-report/helpers/dockerService/serviceComponents/containerActions.js.html +853 -0
  16. package/coverage/lcov-report/helpers/dockerService/serviceComponents/containerList.js.html +289 -0
  17. package/coverage/lcov-report/helpers/dockerService/serviceComponents/index.html +131 -0
  18. package/coverage/lcov-report/helpers/index.html +176 -0
  19. package/coverage/lcov-report/helpers/logger.js.html +424 -0
  20. package/coverage/lcov-report/helpers/safeCall.js.html +139 -0
  21. package/coverage/lcov-report/helpers/validationHelpers.js.html +394 -0
  22. package/coverage/lcov-report/hooks/creation/index.html +146 -0
  23. package/coverage/lcov-report/hooks/creation/useContainerActions.js.html +292 -0
  24. package/coverage/lcov-report/hooks/creation/useContainerCreation.js.html +478 -0
  25. package/coverage/lcov-report/hooks/creation/useLogsViewer.js.html +238 -0
  26. package/coverage/lcov-report/hooks/debug/index.html +116 -0
  27. package/coverage/lcov-report/hooks/debug/useDebugLogs.js.html +172 -0
  28. package/coverage/lcov-report/hooks/index.html +161 -0
  29. package/coverage/lcov-report/hooks/navigation/index.html +116 -0
  30. package/coverage/lcov-report/hooks/navigation/useContainerSelection.js.html +160 -0
  31. package/coverage/lcov-report/hooks/useContainerCommandRouter.js.html +415 -0
  32. package/coverage/lcov-report/hooks/useControls.js.html +685 -0
  33. package/coverage/lcov-report/hooks/useEraseConfirmation.js.html +202 -0
  34. package/coverage/lcov-report/hooks/useExitHandler.js.html +283 -0
  35. package/coverage/lcov-report/index.html +191 -0
  36. package/coverage/lcov-report/prettify.css +1 -0
  37. package/coverage/lcov-report/prettify.js +2 -0
  38. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  39. package/coverage/lcov-report/sorter.js +210 -0
  40. package/coverage/lcov.info +1216 -0
  41. package/dist/components/ContainerRow.js +5 -78
  42. package/dist/components/LogViewer.js +4 -9
  43. package/dist/helpers/containerOptionsBuilder.js +58 -0
  44. package/dist/hooks/creation/useContainerCreation.js +16 -1
  45. package/dist/hooks/debug/useDebugLogs.js +46 -0
  46. package/dist/hooks/navigation/useContainerSelection.js +36 -0
  47. package/dist/hooks/useContainerCommandRouter.js +151 -0
  48. package/dist/{helpers/actionHelpers.js → hooks/useContainerStats.js} +76 -78
  49. package/dist/hooks/useControls.js +83 -342
  50. package/dist/hooks/useEraseConfirmation.js +47 -0
  51. package/dist/hooks/useExitHandler.js +68 -0
  52. package/jest.config.cjs +1 -1
  53. package/package.json +2 -3
  54. package/src/components/ContainerRow.jsx +3 -38
  55. package/src/components/LogViewer.jsx +4 -10
  56. package/src/helpers/constants.js +20 -0
  57. package/src/helpers/containerOptionsBuilder.js +42 -0
  58. package/src/helpers/dockerService/serviceComponents/containerActions.js +55 -8
  59. package/src/helpers/validationHelpers.js +75 -18
  60. package/src/hooks/creation/useContainerCreation.js +34 -4
  61. package/src/hooks/debug/useDebugLogs.js +29 -0
  62. package/src/hooks/navigation/useContainerSelection.js +25 -0
  63. package/src/hooks/useContainerCommandRouter.js +110 -0
  64. package/src/hooks/useContainerStats.js +44 -0
  65. package/src/hooks/useControls.js +75 -274
  66. package/src/hooks/useEraseConfirmation.js +39 -0
  67. package/src/hooks/useExitHandler.js +66 -0
  68. package/test/containerActions.test.js +104 -13
  69. package/test/containerOptionsBuilder.test.js +36 -0
  70. package/test/useContainerCreation.dom.test.js +46 -2
  71. package/test/useControls.dom.test.js +117 -0
  72. package/test/validationHelpers.test.js +51 -0
  73. package/.babelrc +0 -6
  74. package/FIXES_APPLIED.md +0 -419
  75. package/SECURITY.md +0 -5
  76. package/dist/hooks/useLogsStream.js +0 -41
  77. package/docs/_config.yml +0 -13
  78. package/docs/components_ContainerCreationPrompt.jsx.html +0 -114
  79. package/docs/components_ContainerRow.jsx.html +0 -151
  80. package/docs/components_ContainerSection.jsx.html +0 -75
  81. package/docs/components_Footer.jsx.html +0 -66
  82. package/docs/components_Header.jsx.html +0 -84
  83. package/docs/components_LogViewer.jsx.html +0 -91
  84. package/docs/components_MessageFeedback.jsx.html +0 -76
  85. package/docs/components_PromptField.jsx.html +0 -99
  86. package/docs/components_StatsBar.jsx.html +0 -105
  87. package/docs/components_UsageMenu.jsx.html +0 -73
  88. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  89. package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
  90. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  91. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  92. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  93. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  94. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  95. package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
  96. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  97. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  98. package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
  99. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  100. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  101. package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  102. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  103. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  104. package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
  105. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  106. package/docs/global.html +0 -6145
  107. package/docs/helpers_actionHelpers.js.html +0 -94
  108. package/docs/helpers_constants.js.html +0 -81
  109. package/docs/helpers_dockerService_dockerService.js.html +0 -79
  110. package/docs/helpers_dockerService_serviceComponents_containerActions.js.html +0 -153
  111. package/docs/helpers_dockerService_serviceComponents_containerList.js.html +0 -81
  112. package/docs/helpers_dockerService_serviceComponents_containerLogs.js.html +0 -85
  113. package/docs/helpers_dockerService_serviceComponents_containerStats.js.html +0 -107
  114. package/docs/helpers_dockerService_serviceComponents_imageUtils.js.html +0 -82
  115. package/docs/helpers_exitWithMessage.js.html +0 -77
  116. package/docs/helpers_safeCall.js.html +0 -68
  117. package/docs/helpers_validationHelpers.js.html +0 -96
  118. package/docs/hooks_creation_useContainerActions.js.html +0 -120
  119. package/docs/hooks_creation_useContainerCreation.js.html +0 -152
  120. package/docs/hooks_creation_useLogsViewer.js.html +0 -102
  121. package/docs/hooks_useControls.js.html +0 -298
  122. package/docs/hooks_useLogsStream.js.html +0 -82
  123. package/docs/index.html +0 -65
  124. package/docs/index.js.html +0 -65
  125. package/docs/module-index.html +0 -171
  126. package/docs/scripts/linenumber.js +0 -25
  127. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  128. package/docs/scripts/prettify/lang-css.js +0 -2
  129. package/docs/scripts/prettify/prettify.js +0 -28
  130. package/docs/styles/jsdoc-default.css +0 -358
  131. package/docs/styles/prettify-jsdoc.css +0 -111
  132. package/docs/styles/prettify-tomorrow.css +0 -132
  133. package/esbuild.config.cjs +0 -11
  134. package/src/helpers/actionHelpers.js +0 -52
  135. package/src/hooks/useLogsStream.js +0 -31
  136. package/test/actionHelpers.test.js +0 -106
@@ -1,19 +1,8 @@
1
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
2
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
8
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
9
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
- import React, { useState, useEffect } from "react";
1
+ import React from "react";
12
2
  import { Box, Text } from "ink";
13
- import { getStats } from "../helpers/dockerService/serviceComponents/containerStats.js";
14
- import { REFRESH_INTERVALS } from "../helpers/constants.js";
15
3
  import StatsBar from "./StatsBar.js";
16
4
  import PropTypes from 'prop-types';
5
+ import { useContainerStats } from '../hooks/useContainerStats.js';
17
6
  var stateText = function stateText(state) {
18
7
  if (state === "running") return {
19
8
  text: "🟢 RUNNING",
@@ -48,17 +37,9 @@ export default function ContainerRow(_ref) {
48
37
  name = container.name,
49
38
  image = container.image,
50
39
  state = container.state;
51
- var _useState = useState({
52
- cpuPercent: 0,
53
- memPercent: 0,
54
- netIO: {
55
- rx: 0,
56
- tx: 0
57
- }
58
- }),
59
- _useState2 = _slicedToArray(_useState, 2),
60
- stats = _useState2[0],
61
- setStats = _useState2[1];
40
+ var _useContainerStats = useContainerStats(id, state),
41
+ stats = _useContainerStats.stats,
42
+ statsError = _useContainerStats.statsError;
62
43
 
63
44
  // Format ports for display (no leading space to avoid layout shifts)
64
45
  var formatPorts = function formatPorts(ports) {
@@ -77,60 +58,6 @@ export default function ContainerRow(_ref) {
77
58
  if (!s) return "";
78
59
  return s.length > max ? s.slice(0, max - 1) + "…" : s;
79
60
  };
80
- var _useState3 = useState(""),
81
- _useState4 = _slicedToArray(_useState3, 2),
82
- statsError = _useState4[0],
83
- setStatsError = _useState4[1];
84
- useEffect(function () {
85
- if (state !== "running") return;
86
- var isMounted = true;
87
- var fetchStats = /*#__PURE__*/function () {
88
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
89
- var s, _t;
90
- return _regenerator().w(function (_context) {
91
- while (1) switch (_context.p = _context.n) {
92
- case 0:
93
- _context.p = 0;
94
- _context.n = 1;
95
- return getStats(id);
96
- case 1:
97
- s = _context.v;
98
- if (isMounted) {
99
- setStats(s);
100
- setStatsError("");
101
- }
102
- _context.n = 3;
103
- break;
104
- case 2:
105
- _context.p = 2;
106
- _t = _context.v;
107
- if (isMounted) {
108
- setStats({
109
- cpuPercent: 0,
110
- memPercent: 0,
111
- netIO: {
112
- rx: 0,
113
- tx: 0
114
- }
115
- });
116
- setStatsError("Error fetching stats");
117
- }
118
- case 3:
119
- return _context.a(2);
120
- }
121
- }, _callee, null, [[0, 2]]);
122
- }));
123
- return function fetchStats() {
124
- return _ref2.apply(this, arguments);
125
- };
126
- }();
127
- fetchStats();
128
- var timer = setInterval(fetchStats, REFRESH_INTERVALS.CONTAINER_STATS);
129
- return function () {
130
- isMounted = false;
131
- clearInterval(timer);
132
- };
133
- }, [id, state]);
134
61
  var stateInfo = stateText(state);
135
62
  return /*#__PURE__*/React.createElement(Box, {
136
63
  flexDirection: "column",
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
- import { Text, useInput } from "ink";
3
- import { safeCall } from "../helpers/safeCall.js";
2
+ import { Text } from "ink";
4
3
  import PropTypes from 'prop-types';
5
4
 
6
5
  /**
7
- * Log viewer overlay component. Shows the most recent lines and closes on ESC.
6
+ * Log viewer overlay component. Shows the most recent lines.
7
+ * Purely presentational — keyboard handling is centralized in useControls.
8
8
  *
9
9
  * @param {Object} props
10
10
  * @param {Array<string>} props.logs - Array of log lines
@@ -15,13 +15,8 @@ import PropTypes from 'prop-types';
15
15
  export default function LogViewer(_ref) {
16
16
  var _container$name;
17
17
  var logs = _ref.logs,
18
- onExit = _ref.onExit,
18
+ _onExit = _ref.onExit,
19
19
  container = _ref.container;
20
- useInput(function (input, key) {
21
- if (key.escape) {
22
- safeCall(onExit);
23
- }
24
- });
25
20
  var visibleLogs = logs.slice(-15);
26
21
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
27
22
  color: "green"
@@ -0,0 +1,58 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ /**
8
+ * Builds Docker container creation options from raw user inputs.
9
+ *
10
+ * This is a pure function — it has no side effects and calls no services.
11
+ * It mirrors exactly the option-building logic in useControls.js onCreate callback.
12
+ *
13
+ * @param {object} params
14
+ * @param {string} params.imageName - Docker image name (e.g. "nginx:alpine")
15
+ * @param {string} [params.containerName] - Optional container name
16
+ * @param {string} [params.portInput] - Comma-separated host:container port pairs
17
+ * (e.g. "8080:80,3000:3000")
18
+ * @param {string} [params.envInput] - Comma-separated KEY=VALUE pairs
19
+ * (e.g. "NODE_ENV=production,PORT=3000")
20
+ * @returns {object} Docker container options ready to pass to createContainer
21
+ */
22
+ export function buildContainerOptions(_ref) {
23
+ var _imageName = _ref.imageName,
24
+ containerName = _ref.containerName,
25
+ portInput = _ref.portInput,
26
+ envInput = _ref.envInput;
27
+ var env = (envInput || "").split(",").map(function (s) {
28
+ return s.trim();
29
+ }).filter(Boolean);
30
+ var ports = (portInput || "").split(",").map(function (s) {
31
+ return s.trim();
32
+ }).filter(Boolean);
33
+ var ExposedPorts = {};
34
+ var PortBindings = {};
35
+ ports.forEach(function (pair) {
36
+ var _pair$split = pair.split(":"),
37
+ _pair$split2 = _slicedToArray(_pair$split, 2),
38
+ host = _pair$split2[0],
39
+ cont = _pair$split2[1];
40
+ if (!host || !cont) return;
41
+ var key = "".concat(cont, "/tcp");
42
+ ExposedPorts[key] = {};
43
+ PortBindings[key] = PortBindings[key] || [];
44
+ PortBindings[key].push({
45
+ HostPort: "".concat(host)
46
+ });
47
+ });
48
+ var options = {
49
+ Tty: true
50
+ };
51
+ if (Object.keys(ExposedPorts).length) options.ExposedPorts = ExposedPorts;
52
+ if (Object.keys(PortBindings).length) options.HostConfig = {
53
+ PortBindings: PortBindings
54
+ };
55
+ if (env.length) options.Env = env;
56
+ if (containerName) options.name = containerName;
57
+ return options;
58
+ }
@@ -117,6 +117,20 @@ export function useContainerCreation(_ref) {
117
117
  setMessageColor("yellow");
118
118
  safeCall(onCancel);
119
119
  }
120
+
121
+ /**
122
+ * Resets all creation state to initial values without triggering onCancel.
123
+ * Used by the command router when the user presses 'c' to open the creation wizard.
124
+ */
125
+ function resetCreation() {
126
+ setStep(0);
127
+ setImageName("");
128
+ setContainerName("");
129
+ setPortInput("");
130
+ setEnvInput("");
131
+ setMessage("Insert the name of the image to create: ");
132
+ setMessageColor("yellow");
133
+ }
120
134
  return {
121
135
  step: step,
122
136
  setStep: setStep,
@@ -133,6 +147,7 @@ export function useContainerCreation(_ref) {
133
147
  messageColor: messageColor,
134
148
  setMessageColor: setMessageColor,
135
149
  nextStep: nextStep,
136
- cancelCreation: cancelCreation
150
+ cancelCreation: cancelCreation,
151
+ resetCreation: resetCreation
137
152
  };
138
153
  }
@@ -0,0 +1,46 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
4
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
8
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
+ import { useState, useEffect } from 'react';
12
+ import { logger } from '../../helpers/logger.js';
13
+ export function useDebugLogs() {
14
+ var _useState = useState(false),
15
+ _useState2 = _slicedToArray(_useState, 2),
16
+ showDebugLogs = _useState2[0],
17
+ setShowDebugLogs = _useState2[1];
18
+ var _useState3 = useState([]),
19
+ _useState4 = _slicedToArray(_useState3, 2),
20
+ debugLogs = _useState4[0],
21
+ setDebugLogs = _useState4[1];
22
+ useEffect(function () {
23
+ var unsubscribe = logger.subscribe(function (entry) {
24
+ setDebugLogs(function (prev) {
25
+ var extras = (entry.args || []).map(function (arg) {
26
+ if (typeof arg === "string") return arg;
27
+ if (typeof arg === "number" || typeof arg === "boolean") return String(arg);
28
+ try {
29
+ return JSON.stringify(arg);
30
+ } catch (err) {
31
+ return "[unserializable]";
32
+ }
33
+ }).filter(Boolean);
34
+ var line = extras.length ? "".concat(entry.formatted, " ").concat(extras.join(" ")) : entry.formatted;
35
+ var next = [].concat(_toConsumableArray(prev), [line]);
36
+ return next.slice(-200);
37
+ });
38
+ });
39
+ return unsubscribe;
40
+ }, []);
41
+ return {
42
+ showDebugLogs: showDebugLogs,
43
+ setShowDebugLogs: setShowDebugLogs,
44
+ debugLogs: debugLogs
45
+ };
46
+ }
@@ -0,0 +1,36 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import { useState, useCallback } from 'react';
8
+ export function useContainerSelection(total) {
9
+ var _useState = useState(0),
10
+ _useState2 = _slicedToArray(_useState, 2),
11
+ selected = _useState2[0],
12
+ setSelected = _useState2[1];
13
+ var handleNavigation = useCallback(function (input, key) {
14
+ if (total === 0) {
15
+ return false;
16
+ }
17
+ if (key.upArrow) {
18
+ setSelected(function (i) {
19
+ return i === 0 ? total - 1 : i - 1;
20
+ });
21
+ return true;
22
+ }
23
+ if (key.downArrow) {
24
+ setSelected(function (i) {
25
+ return i === total - 1 ? 0 : i + 1;
26
+ });
27
+ return true;
28
+ }
29
+ return false;
30
+ }, [total]);
31
+ return {
32
+ selected: selected,
33
+ setSelected: setSelected,
34
+ handleNavigation: handleNavigation
35
+ };
36
+ }
@@ -0,0 +1,151 @@
1
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
2
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ import { useCallback } from "react";
6
+
7
+ /**
8
+ * Hook responsible solely for routing Docker action keystrokes to the correct handler.
9
+ * Has no domain state of its own — it delegates every side-effect to its dependencies.
10
+ *
11
+ * Handled keys:
12
+ * i — start container
13
+ * p — stop container
14
+ * r — restart container
15
+ * e — request erase confirmation
16
+ * l — open logs viewer and start log stream
17
+ * c — open container creation wizard (reset + activate)
18
+ * d — toggle debug log panel
19
+ *
20
+ * @param {Object} params
21
+ * @param {Object} params.actions - API from useContainerActions
22
+ * @param {Array<Object>} params.containers - Current list of Docker containers
23
+ * @param {number} params.selected - Index of the currently selected container
24
+ * @param {Object} params.creation - API from useContainerCreation (must expose resetCreation)
25
+ * @param {Object} params.logsViewer - API from useLogsViewer
26
+ * @param {Function} params.startLogsStream - Starts the log stream for a container id
27
+ * @param {Function} params.onStartErase - Callback: activates confirmErase state
28
+ * @param {Function} params.onToggleDebug - Callback: toggles showDebugLogs state
29
+ * @param {Function} params.onStartCreate - Callback: sets creatingContainer = true
30
+ * @returns {{ handleDockerCommands: Function }}
31
+ */
32
+ export function useContainerCommandRouter(_ref) {
33
+ var actions = _ref.actions,
34
+ containers = _ref.containers,
35
+ selected = _ref.selected,
36
+ creation = _ref.creation,
37
+ logsViewer = _ref.logsViewer,
38
+ startLogsStream = _ref.startLogsStream,
39
+ onStartErase = _ref.onStartErase,
40
+ onToggleDebug = _ref.onToggleDebug,
41
+ onStartCreate = _ref.onStartCreate;
42
+ var handleDockerCommands = useCallback(function (input) {
43
+ var container = containers[selected];
44
+ if (input === "i") {
45
+ actions.handleAction({
46
+ actionFn: function () {
47
+ var _actionFn = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(id) {
48
+ return _regenerator().w(function (_context) {
49
+ while (1) switch (_context.n) {
50
+ case 0:
51
+ _context.n = 1;
52
+ return actions.startContainer(id);
53
+ case 1:
54
+ return _context.a(2, _context.v);
55
+ }
56
+ }, _callee);
57
+ }));
58
+ function actionFn(_x) {
59
+ return _actionFn.apply(this, arguments);
60
+ }
61
+ return actionFn;
62
+ }(),
63
+ actionLabel: "Starting",
64
+ selected: selected,
65
+ stateCheck: function stateCheck(c) {
66
+ return (c.state === "running" || c.status === "running") && "Container is already running.";
67
+ }
68
+ });
69
+ return true;
70
+ }
71
+ if (input === "p") {
72
+ actions.handleAction({
73
+ actionFn: function () {
74
+ var _actionFn2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(id) {
75
+ return _regenerator().w(function (_context2) {
76
+ while (1) switch (_context2.n) {
77
+ case 0:
78
+ _context2.n = 1;
79
+ return actions.stopContainer(id);
80
+ case 1:
81
+ return _context2.a(2, _context2.v);
82
+ }
83
+ }, _callee2);
84
+ }));
85
+ function actionFn(_x2) {
86
+ return _actionFn2.apply(this, arguments);
87
+ }
88
+ return actionFn;
89
+ }(),
90
+ actionLabel: "Stopping",
91
+ selected: selected,
92
+ stateCheck: function stateCheck(c) {
93
+ return (c.state === "exited" || c.status === "exited" || c.state === "stopped" || c.status === "stopped") && "Container is already stopped.";
94
+ }
95
+ });
96
+ return true;
97
+ }
98
+ if (input === "r") {
99
+ actions.handleAction({
100
+ actionFn: function () {
101
+ var _actionFn3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(id) {
102
+ return _regenerator().w(function (_context3) {
103
+ while (1) switch (_context3.n) {
104
+ case 0:
105
+ _context3.n = 1;
106
+ return actions.restartContainer(id);
107
+ case 1:
108
+ return _context3.a(2, _context3.v);
109
+ }
110
+ }, _callee3);
111
+ }));
112
+ function actionFn(_x3) {
113
+ return _actionFn3.apply(this, arguments);
114
+ }
115
+ return actionFn;
116
+ }(),
117
+ actionLabel: "Restarting",
118
+ selected: selected
119
+ });
120
+ return true;
121
+ }
122
+ if (input === "e") {
123
+ if (!container) {
124
+ return true;
125
+ }
126
+ onStartErase();
127
+ return true;
128
+ }
129
+ if (input === "l") {
130
+ if (!container) {
131
+ return true;
132
+ }
133
+ logsViewer.openLogs();
134
+ startLogsStream(container.id);
135
+ return true;
136
+ }
137
+ if (input === "c") {
138
+ onStartCreate();
139
+ creation.resetCreation();
140
+ return true;
141
+ }
142
+ if (input === "d") {
143
+ onToggleDebug();
144
+ return true;
145
+ }
146
+ return false;
147
+ }, [actions, containers, creation, logsViewer, onStartCreate, onStartErase, onToggleDebug, selected, startLogsStream]);
148
+ return {
149
+ handleDockerCommands: handleDockerCommands
150
+ };
151
+ }
@@ -2,83 +2,81 @@ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present,
2
2
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
3
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
4
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
- import { MESSAGE_TIMEOUTS } from "../helpers/constants.js";
6
- import { logger } from "./logger.js";
7
- /**
8
- * Generic helper to perform a container action with user feedback.
9
- *
10
- * @param {Object} params
11
- * @param {Array} params.containers - Array of container objects
12
- * @param {number} params.selected - Index of the selected container
13
- * @param {Function} params.actionFn - Async function that performs the action (receives container id)
14
- * @param {string} params.actionLabel - Label used in feedback messages (e.g. 'Starting')
15
- * @param {Function} params.setMessage - Setter for feedback message
16
- * @param {Function} params.setMessageColor - Setter for feedback color
17
- * @param {Function} [params.stateCheck] - Optional function that validates container state before action
18
- * @returns {Promise<void>}
19
- */
20
- export function handleAction(_x) {
21
- return _handleAction.apply(this, arguments);
22
- }
23
- function _handleAction() {
24
- _handleAction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
25
- var containers, selected, actionFn, actionLabel, setMessage, setMessageColor, stateCheck, c, failureReason, _t;
26
- return _regenerator().w(function (_context) {
27
- while (1) switch (_context.p = _context.n) {
28
- case 0:
29
- containers = _ref.containers, selected = _ref.selected, actionFn = _ref.actionFn, actionLabel = _ref.actionLabel, setMessage = _ref.setMessage, setMessageColor = _ref.setMessageColor, stateCheck = _ref.stateCheck;
30
- c = containers[selected];
31
- if (c) {
32
- _context.n = 1;
33
- break;
5
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
8
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
+ import { useState, useEffect } from 'react';
12
+ import { getStats } from '../helpers/dockerService/serviceComponents/containerStats.js';
13
+ import { REFRESH_INTERVALS } from '../helpers/constants.js';
14
+ var DEFAULT_STATS = {
15
+ cpuPercent: 0,
16
+ memPercent: 0,
17
+ netIO: {
18
+ rx: 0,
19
+ tx: 0
20
+ }
21
+ };
22
+ export function useContainerStats(id, state) {
23
+ var _useState = useState(DEFAULT_STATS),
24
+ _useState2 = _slicedToArray(_useState, 2),
25
+ stats = _useState2[0],
26
+ setStats = _useState2[1];
27
+ var _useState3 = useState(''),
28
+ _useState4 = _slicedToArray(_useState3, 2),
29
+ statsError = _useState4[0],
30
+ setStatsError = _useState4[1];
31
+ useEffect(function () {
32
+ if (state !== 'running') {
33
+ setStats(DEFAULT_STATS);
34
+ setStatsError('');
35
+ return;
36
+ }
37
+ var isMounted = true;
38
+ var fetchStats = /*#__PURE__*/function () {
39
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
40
+ var s, _t;
41
+ return _regenerator().w(function (_context) {
42
+ while (1) switch (_context.p = _context.n) {
43
+ case 0:
44
+ _context.p = 0;
45
+ _context.n = 1;
46
+ return getStats(id);
47
+ case 1:
48
+ s = _context.v;
49
+ if (isMounted) {
50
+ setStats(s);
51
+ setStatsError('');
52
+ }
53
+ _context.n = 3;
54
+ break;
55
+ case 2:
56
+ _context.p = 2;
57
+ _t = _context.v;
58
+ if (isMounted) {
59
+ setStats(DEFAULT_STATS);
60
+ setStatsError('Error fetching stats');
61
+ }
62
+ case 3:
63
+ return _context.a(2);
34
64
  }
35
- return _context.a(2);
36
- case 1:
37
- if (!stateCheck) {
38
- _context.n = 2;
39
- break;
40
- }
41
- failureReason = stateCheck(c);
42
- if (!failureReason) {
43
- _context.n = 2;
44
- break;
45
- }
46
- logger.warn("Action %s blocked for container %s: %s", actionLabel, c.id, failureReason);
47
- setMessage(failureReason);
48
- setMessageColor("red");
49
- setTimeout(function () {
50
- return setMessage("");
51
- }, MESSAGE_TIMEOUTS.SHORT);
52
- return _context.a(2);
53
- case 2:
54
- setMessage("".concat(actionLabel, " container..."));
55
- setMessageColor("green");
56
- logger.info("Action %s requested for container %s", actionLabel, c.id);
57
- _context.p = 3;
58
- _context.n = 4;
59
- return actionFn(c.id);
60
- case 4:
61
- setMessage("".concat(actionLabel, " container completed successfully"));
62
- setMessageColor("green");
63
- setTimeout(function () {
64
- return setMessage("");
65
- }, MESSAGE_TIMEOUTS.DEFAULT);
66
- logger.info("Action %s completed for container %s", actionLabel, c.id);
67
- _context.n = 6;
68
- break;
69
- case 5:
70
- _context.p = 5;
71
- _t = _context.v;
72
- setMessage("Failed to ".concat(actionLabel.toLowerCase(), " container."));
73
- setMessageColor("red");
74
- setTimeout(function () {
75
- return setMessage("");
76
- }, MESSAGE_TIMEOUTS.DEFAULT);
77
- logger.error("Action %s failed for container %s", actionLabel, c.id, _t);
78
- case 6:
79
- return _context.a(2);
80
- }
81
- }, _callee, null, [[3, 5]]);
82
- }));
83
- return _handleAction.apply(this, arguments);
65
+ }, _callee, null, [[0, 2]]);
66
+ }));
67
+ return function fetchStats() {
68
+ return _ref.apply(this, arguments);
69
+ };
70
+ }();
71
+ fetchStats();
72
+ var timer = setInterval(fetchStats, REFRESH_INTERVALS.CONTAINER_STATS);
73
+ return function () {
74
+ isMounted = false;
75
+ clearInterval(timer);
76
+ };
77
+ }, [id, state]);
78
+ return {
79
+ stats: stats,
80
+ statsError: statsError
81
+ };
84
82
  }