@hawtio/react
Version:
A Hawtio reimplementation based on TypeScript + React.
710 lines (610 loc) • 85.2 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunkUB6QWSAJjs = require('./chunk-UB6QWSAJ.js');
var _chunkBLJGIIMVjs = require('./chunk-BLJGIIMV.js');
var _chunkBJ6TSPQKjs = require('./chunk-BJ6TSPQK.js');
var _chunkBHIEXRGKjs = require('./chunk-BHIEXRGK.js');
// src/plugins/connect/Connect.tsx
var _reactcore = require('@patternfly/react-core');
var _outlinedquestioncircleicon = require('@patternfly/react-icons/dist/esm/icons/outlined-question-circle-icon');
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var _reactrouterdom = require('react-router-dom');
// src/plugins/connect/context.ts
function useConnections() {
const [connections, dispatch] = _react.useReducer.call(void 0, _chunkBLJGIIMVjs.reducer, _chunkBJ6TSPQKjs.connectService.loadConnections());
_react.useEffect.call(void 0, () => {
_chunkBJ6TSPQKjs.connectService.saveConnections(connections);
}, [connections]);
return { connections, dispatch };
}
var ConnectContext = _react.createContext.call(void 0, {
connections: {},
dispatch: () => {
}
});
// src/plugins/connect/discover/Discover.tsx
// src/plugins/connect/img/camel-logo.svg
var camel_logo_default = 'data:image/svg+xml,<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">%0A<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->%0A<svg width="64px" height="64px" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid" fill="%23000000">%0A%0D<g id="SVGRepo_bgCarrier" stroke-width="0"/>%0A%0D<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>%0A%0D<g id="SVGRepo_iconCarrier"> <defs> <circle id="path-1" cx="128" cy="128.00015" r="128"> </circle> <linearGradient x1="-12.5638445%" y1="108.214456%" x2="101.304079%" y2="-1.96418442%" id="linearGradient-3"> <stop stop-color="%23F69923" offset="0%"> </stop> <stop stop-color="%23F79A23" offset="10.996%"> </stop> <stop stop-color="%23E97826" offset="94.502%"> </stop> </linearGradient> <linearGradient x1="-12.5638445%" y1="108.214456%" x2="101.304079%" y2="-1.96418442%" id="linearGradient-4"> <stop stop-color="%23F69923" offset="0%"> </stop> <stop stop-color="%23F79A23" offset="8.0478%"> </stop> <stop stop-color="%23E97826" offset="41.874%"> </stop> </linearGradient> <linearGradient x1="74.7241541%" y1="-3.0591512%" x2="6.6528419%" y2="100.065517%" id="linearGradient-5"> <stop stop-color="%23F6E423" offset="0%"> </stop> <stop stop-color="%23F79A23" offset="41.191%"> </stop> <stop stop-color="%23E97826" offset="73.271%"> </stop> </linearGradient> </defs> <g> <mask id="mask-2" fill="white"> <use xlink:href="%23path-1"> </use> </mask> <g> </g> <circle fill="url(%23linearGradient-3)" fill-rule="nonzero" mask="url(%23mask-2)" cx="127.99429" cy="127.994289" r="123.110531"> </circle> <path d="M128,256 C57.307552,256 0,198.692448 0,128 C0,57.307552 57.307552,0 128,0 C198.692448,0 256,57.307552 256,128 C256,198.692448 198.692448,256 128,256 Z M128,246.232047 C193.297756,246.232047 246.232047,193.297757 246.232047,128 C246.232047,62.7022434 193.297756,9.76795285 128,9.76795285 C62.7022433,9.76795285 9.76795287,62.7022434 9.76795287,128 C9.76795287,193.297757 62.7022433,246.232047 128,246.232047 Z" fill="url(%23linearGradient-4)" fill-rule="nonzero" mask="url(%23mask-2)"> </path> <path d="M98.0436948,75.5167519 C96.2930127,75.5147828 94.5195279,75.5265976 92.7516355,75.578189 C90.6964457,75.6388385 87.9353199,76.2913715 84.7520108,77.3627207 C138.52721,118.196743 157.860212,191.86024 124.627063,255.876929 C125.755714,255.906269 126.875819,256 128.011618,256 C188.747721,256 239.504232,213.677309 252.620663,156.92871 C214.078718,111.750768 161.80794,75.6151104 98.043301,75.5166535 L98.0436948,75.5167519 Z" fill="url(%23linearGradient-5)" fill-rule="nonzero" opacity="0.75" mask="url(%23mask-2)"> </path> <path d="M84.7520108,77.3677419 C66.8954703,83.3771585 32.8297703,104.545789 0.0790609054,132.810802 C2.56627958,200.145488 57.1072772,254.12351 124.627063,255.88195 C157.860212,191.865262 138.527998,118.201764 84.7520108,77.3677419 L84.7520108,77.3677419 Z" fill="%2328170B" fill-rule="nonzero" opacity="0.75" mask="url(%23mask-2)"> </path> <path d="M128.747194,54.0045284 C117.762336,59.4999 128.747194,81.4705963 128.747194,81.4705963 C95.774179,108.954321 102.779988,155.899717 64.3117981,155.899717 C43.3414552,155.899717 22.069572,131.822923 0.0790609054,117.071683 C-0.204035781,120.550653 -0.706298828,124.044146 -0.706298828,127.596097 C-0.706298828,175.691144 25.5565753,217.52046 64.7133789,239.493314 C75.666062,238.113713 87.5520153,235.378866 95.7643696,229.900759 C138.909639,201.135938 149.621405,146.409798 167.250697,119.975669 C178.229669,103.483669 229.684993,104.914651 233.157489,97.9655396 C238.658746,86.9747963 222.166942,70.4994717 216.665685,70.4994717 L172.708205,70.4994717 C169.63691,70.4994717 164.811122,65.0431411 161.733941,65.0431411 L145.242137,65.0431411 C145.242137,65.0431411 137.935182,53.9580322 131.447893,53.5172018 C130.51799,53.4510871 129.61726,53.5697797 128.747194,54.0045284 Z" fill="%23FFFFFF" fill-rule="nonzero" mask="url(%23mask-2)"> </path> </g> </g>%0A%0D</svg>';
// src/plugins/connect/img/java-logo.svg
var java_logo_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 32 32"><path d="M11.622 24.74s-1.23.748.855.962c2.51.32 3.847.267 6.625-.267a10.02 10.02 0 0 0 1.763.855c-6.25 2.672-14.16-.16-9.244-1.55zm-.8-3.473s-1.336 1.015.748 1.23c2.725.267 4.862.32 8.55-.427a3.26 3.26 0 0 0 1.282.801c-7.534 2.244-15.976.214-10.58-1.603zm14.747 6.09s.908.748-1.015 1.336c-3.58 1.07-15.014 1.39-18.22 0-1.122-.48 1.015-1.175 1.7-1.282.695-.16 1.07-.16 1.07-.16-1.23-.855-8.175 1.763-3.526 2.51 12.77 2.084 23.296-.908 19.983-2.404zM12.2 17.633s-5.824 1.39-2.084 1.87c1.603.214 4.755.16 7.694-.053 2.404-.214 4.81-.64 4.81-.64s-.855.374-1.443.748c-5.93 1.55-17.312.855-14.052-.748 2.778-1.336 5.076-1.175 5.076-1.175zm10.42 5.824c5.984-3.1 3.206-6.09 1.282-5.717-.48.107-.695.214-.695.214s.16-.32.534-.427c3.794-1.336 6.786 4.007-1.23 6.09 0 0 .053-.053.107-.16zm-9.83 8.442c5.77.374 14.587-.214 14.8-2.94 0 0-.427 1.07-4.755 1.87-4.916.908-11.007.8-14.587.214 0 0 .748.64 4.542.855z" fill="%234e7896"/><path d="M18.996.001s3.313 3.366-3.152 8.442c-5.183 4.114-1.175 6.465 0 9.137-3.046-2.725-5.236-5.13-3.74-7.373C14.294 6.893 20.332 5.3 18.996.001zm-1.7 15.335c1.55 1.763-.427 3.366-.427 3.366s3.954-2.03 2.137-4.542c-1.656-2.404-2.94-3.58 4.007-7.587 0 0-10.953 2.725-5.717 8.763z" fill="%23f58219"/></svg>%0A';
// src/plugins/connect/img/jetty-logo.svg
var jetty_logo_default = 'data:image/svg+xml,<?xml version="1.0" encoding="UTF-8" standalone="no"?>%0A<!-- Created with Inkscape (http://www.inkscape.org/) -->%0A%0A<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns%23" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns%23" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="400" height="400" id="svg2" sodipodi:version="0.32" inkscape:version="0.48.5 r10040" version="1.0" sodipodi:docname="jetty-avatar.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape" inkscape:export-filename="jetty-avatar.png" inkscape:export-xdpi="28.799999" inkscape:export-ydpi="28.799999">%0A <defs id="defs4">%0A <inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective10" />%0A <inkscape:perspective id="perspective2390" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 526.18109 : 1" sodipodi:type="inkscape:persp3d" />%0A <filter inkscape:collect="always" id="filter3853"%0A x="-0.15826963"%0A width="1.3165393"%0A y="-0.20584013"%0A height="1.4116803">%0A <feGaussianBlur%0A inkscape:collect="always"%0A stdDeviation="26.292865"%0A id="feGaussianBlur3855" />%0A </filter>%0A </defs>%0A <sodipodi:namedview%0A id="base"%0A pagecolor="%23525252"%0A bordercolor="%23666666"%0A borderopacity="1.0"%0A gridtolerance="10000"%0A guidetolerance="10"%0A objecttolerance="10"%0A inkscape:pageopacity="0"%0A inkscape:pageshadow="2"%0A inkscape:zoom="0.87428571"%0A inkscape:cx="171.56863"%0A inkscape:cy="200"%0A inkscape:document-units="px"%0A inkscape:current-layer="layer2"%0A showgrid="false"%0A inkscape:window-width="1920"%0A inkscape:window-height="1026"%0A inkscape:window-x="0"%0A inkscape:window-y="0"%0A showguides="true"%0A inkscape:guide-bbox="true"%0A showborder="true"%0A inkscape:window-maximized="1" />%0A <metadata%0A id="metadata7">%0A <rdf:RDF>%0A <cc:Work%0A rdf:about="">%0A <dc:format>image/svg+xml</dc:format>%0A <dc:type%0A rdf:resource="http://purl.org/dc/dcmitype/StillImage" />%0A <dc:title />%0A </cc:Work>%0A </rdf:RDF>%0A </metadata>%0A <g%0A inkscape:groupmode="layer"%0A id="layer2"%0A inkscape:label="Jetty"%0A style="display:inline"%0A transform="translate(-1.845606,-221.31978)">%0A <g%0A id="g3857"%0A transform="matrix(0.88669095,0,0,0.88669095,25.158515,48.38446)">%0A <path%0A inkscape:connector-curvature="0"%0A id="path3004"%0A d="m 84.37204,268.03851 a 12.50125,12.50125 0 0 0 -12.1875,9.6875 l -10.3125,44.75 a 12.50125,12.50125 0 0 0 0.71875,7.75 12.50125,12.50125 0 0 0 -4.0625,6.6875 L 18.68454,509.44476 c -0.93999,0.0793 -1.75306,0.16127 -3.21875,0.21875 a 12.50125,12.50125 0 0 0 -12,12.1875 l -0.96875,39.9375 a 12.50125,12.50125 0 0 0 12.53125,12.8125 l 67.40625,-0.25 a 12.50125,12.50125 0 0 0 0.625,0 c 8.74629,-0.48292 17.66461,-3.77402 24.21875,-10.15625 6.55414,-6.38223 10.64721,-14.90394 13.6875,-25.25 a 12.50125,12.50125 0 0 0 0.1875,-0.6875 l 5.625,-24.3125 3.75,0 -4.0625,8.6875 a 12.50125,12.50125 0 0 0 11.34375,17.78125 l 42.15625,0 a 12.50125,12.50125 0 0 0 11.34375,-7.21875 l 115.34375,-247.375 a 12.50125,12.50125 0 0 0 -11.3125,-17.78125 l -42.1875,0 a 12.50125,12.50125 0 0 0 -11.3125,7.21875 l -24.59375,52.75 a 12.50125,12.50125 0 0 0 -4.375,-0.78125 l -43.03125,0 10.15625,-43.875 a 12.50125,12.50125 0 0 0 -12.1875,-15.3125 l -83.4375,0 z m 262.15625,0 a 12.50125,12.50125 0 0 0 -11.3125,7.21875 l -115.375,247.375 a 12.50125,12.50125 0 0 0 11.34375,17.78125 l 42.15625,0 a 12.50125,12.50125 0 0 0 11.34375,-7.21875 l 115.34375,-247.375 a 12.50125,12.50125 0 0 0 -11.3125,-17.78125 l -42.1875,0 z m -196.75,146.28125 27.21875,0 -5.84375,12.53125 -24.28125,0 2.90625,-12.53125 z"%0A style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:%23000000;fill:%23ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:25;marker:none;visibility:visible;display:inline;overflow:visible;filter:url(%23filter3853);enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" />%0A <g%0A id="g3058">%0A <g%0A id="g3032"%0A transform="translate(-33.169935,0)">%0A <path%0A id="path2996"%0A d="M 106.32205,339.73892 65.825288,515.14967 c -2.406515,7.05911 -6.072322,6.68223 -14.254473,7.0031 l -0.962606,39.94815 67.382421,-0.24066 c 13.0754,-0.72195 21.22428,-8.13437 26.59883,-26.42388 l 45.18031,-195.69746 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:%23000000;stroke-width:28.19471741;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path2994"%0A d="m 119.98951,280.53864 -10.33393,44.76119 83.44772,0 10.33393,-44.76119 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:%23000000;stroke-width:28.19471741;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path3020"%0A d="M 106.32205,339.73892 65.825288,515.14967 c -2.406515,7.05911 -6.072322,6.68223 -14.254473,7.0031 l -0.962606,39.94815 67.382421,-0.24066 c 13.0754,-0.72195 21.22428,-8.13437 26.59883,-26.42388 l 45.18031,-195.69746 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path3018"%0A d="m 119.98951,280.53864 -10.33393,44.76119 83.44772,0 10.33393,-44.76119 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:none"%0A inkscape:connector-curvature="0" />%0A </g>%0A <g%0A id="g3046"%0A transform="translate(-287.0915,0)">%0A <path%0A id="path2988"%0A d="m 542.7018,280.53864 -115.3597,247.38976 42.1718,0 115.3597,-247.38976 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:%23000000;stroke-width:28.19471741;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path3193"%0A d="m 636.0746,280.53864 -115.3597,247.38976 42.1718,0 115.3597,-247.38976 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:%23000000;stroke-width:28.19471741;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path3012"%0A d="m 542.7018,280.53864 -115.3597,247.38976 42.1718,0 115.3597,-247.38976 z"%0A style="fill:%23fc592e;fill-opacity:1;fill-rule:evenodd;stroke:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path3316"%0A d="m 636.0746,280.53864 -115.3597,247.38976 42.1718,0 115.3597,-247.38976 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:none"%0A inkscape:connector-curvature="0" />%0A </g>%0A <g%0A id="g3052"%0A transform="translate(-239.05228,0)">%0A <path%0A id="path2992"%0A d="m 370.6225,339.73892 -14.3342,62.08809 83.7467,0 14.3342,-62.08809 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:%23000000;stroke-width:28.19471741;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path2990"%0A d="m 347.6212,439.36864 -14.3342,62.08809 83.7466,0 14.3342,-62.08809 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:%23000000;stroke-width:28.19471741;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path3016"%0A d="m 370.6225,339.73892 -14.3342,62.08809 83.7467,0 14.3342,-62.08809 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:none"%0A inkscape:connector-curvature="0" />%0A <path%0A id="path3014"%0A d="m 347.6212,439.36864 -14.3342,62.08809 83.7466,0 14.3342,-62.08809 z"%0A style="fill:%23fc390e;fill-opacity:1;fill-rule:evenodd;stroke:none"%0A inkscape:connector-curvature="0" />%0A </g>%0A </g>%0A </g>%0A </g>%0A</svg>%0A';
// src/plugins/connect/img/tomcat-logo.svg
var tomcat_logo_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="595.279" height="424" viewBox="0 209.445 595.279 424" xmlns:v="https://vecta.io/nano"><path fill="%23d1a41a" d="M531.64 594.445L437.037 493.74l-10.896 7.205c-52.431-30.908-91.661-75.49-111.786-142.345-71.662 17.629-155.214 62.845-209.047 124.013.01.012.021.023.03.037-53.459 57.869-87.91 112.324-97.033 132.129l52.169.334c-2.015-23.424 4.09-42.951 20-64.668 72.167-98.5 343.167 15 450.167 76.5l57-.5c-.001 0-8.501-37.5-56.001-32h0z"/><path fill="%23ffdc76" d="M428.14 500.945c-110.127-54.949-140-189-113-281 0 0 20.5 9.5 40 55.5 44.646-12.799 96.667-14.001 142-1.5 0 0 5.5-36 38.5-53 4.992 21.339 38 191-107.5 280z"/><path d="M229.617 394.569L261.671 379l18.317 49.455-50.371-33.886zm-35.945 18.088l19.919-11.906 18.316 32.284-38.235-20.378zm-38.693 24.956l17.399-11.447 8.7 29.764-26.099-18.317zm308.172 82.424l-11.448-11.447-16.026 25.184 27.474-13.737zm22.896 27.474l-9.158-9.158-27.476 18.316 36.634-9.158zM315.64 346.862l-1.311-18.231 32.055 16.256-30.744 1.975zm10.139 26.644l-6.389-13.561 22.415 9.211-16.026 4.35zm210.638-19.233l4.578-13.736-25.185 10.531 20.607 3.205zm-9.158 27.933l2.289-11.219-18.316 5.495 16.027 5.724zm-222.086 35.488h59.985v7.419h-59.985v-7.419zm0-17.859h59.985v7.418h-59.985v-7.418zm183.163 17.859h59.985v7.419h-59.985v-7.419zm0-17.859h59.985v7.418h-59.985v-7.418z"/><path d="M547.277 286.323l-.1-.151c-.042-11.562-3.627-60.43-10.2-73.884-17.838 6.819-50.32 28.961-57.572 51.537-35.134-5.291-74.799-4.652-109.706 1.388-5.802-24.4-34.905-42.871-56.892-53.361-9.271 15.758-13.396 52.22-12.331 78.217-.039.027-.083.053-.122.083 4.08 108.774 57.119 176.502 126.478 217.549 71.4-41.047 122.399-121.09 120.358-221.427.029.017.061.031.087.049zM427.816 493.599c-109.027-54.727-129.652-193.147-111.064-266.803 5.168 28.505 14.552 46.291 34.905 54.957 18.88-5.445 40.823-8.739 63.263-9.765l16.179 37.412 11.968-37.497c20.707.828 40.93 3.638 58.645 8.554 18.698-13.683 26.066-34.662 29.919-52.906 4.94 21.254 4.375 67.272 4.397 67.272l.138-.755C538 384.597 492.189 456.66 427.817 493.601l-.001-.002z"/><path d="M583.444 607.021c-11.197-12.611-33.094-18.563-51.453-18.129-13.011-15.576-88.398-95.549-88.398-95.549l-5.235 6.613 91.12 98.51 3.943-.34c24.707-2.129 38.759 11.357 42.613 15.553 2.721 3.08 4.374 5.883 5.282 8.074h-50.093c-114.693-60.201-215.56-102.617-321.865-111.966.235-14.98 2.878-31.924 7.978-50.852l-9.838-2.691c-5.234 19.43-7.978 36.943-8.296 52.678a506.01 506.01 0 0 0-33.772-1.129c-9.61 0-18.361.898-26.294 2.463-10.403-10.467-19.266-20.434-26.746-29.873 49.64-51.994 131.692-99.197 202.865-116.527l-2.313-10.034c-76.612 18.585-160.479 69.095-207.171 118.124-21.669-29.418-30.373-53.59-32.866-71.833-3.218-23.032 2.26-44.239 15.866-61.343 21.307-26.68 51.453-28.505 82.731-23.26-.607 4.948.039 9.669 2.006 12.587 8.229 12.223 52.359 16.534 78.881 4.675-19.493-27.364-58.934-40.818-69.813-35.574-3.627 1.779-6.347 5.04-8.229 8.87-10.767-1.936-21.442-3.375-29.24-3.329-27.427.202-48.507 9.851-64.146 29.417-15.413 19.269-21.646 43.099-18.02 69.096 3.444 24.627 15.549 50.852 35.812 77.989l-9.768 10.764c-49.413 55.641-85.68 115.617-85.68 125.42v5.131h65.279l-1.144-6.088c-3.695-19.611 3.672-44.24 18.767-62.482 9.475-11.492 25.16-24.629 49.866-30.785 21.896 21.504 49.866 44.24 80.92 66.359h48.506v-5.131c0-5.793-2.855-10.855-8.023-14.275-7.662-5.039-19.493-5.746-30.373-2.012-10.358-11.605-16.185-27.137-17.431-46.291 105.398 9.395 206.038 52.221 319.597 111.967h62.559l-.002-4.063c-.997-12-8.38-20.736-8.38-20.736l-.002.002zM77.981 545.906c-15.458 18.768-23.573 43.557-21.76 64.764H14.968c8.273-17.992 41.254-70.008 89.759-122.686 6.71 8.348 14.167 16.762 22.372 25.313-23.801 7.229-39.666 20.66-49.413 32.609h.295zm288.822-221.515l-.003-.001-.002.005.005-.004z"/><path d="M507.276 325.238v-6.687c-24.772 0-39.609 9.799-46.707 30.68h-53.575c3.746-16.713 4.388-33.106-1.131-42.585-3.113-5.334-8.014-8.173-14.172-8.173-22.071 0-30.781 22.621-31.138 23.582l6.247 2.334c.249-.827 7.556-19.204 24.954-19.204 3.801 0 6.471 1.534 8.402 4.854 4.52 7.784 3.786 23.078.031 39.151h-30.451v6.686l28.959.027c-3.091 10.967-7.418 21.796-12.294 30.451l-1.578 2.771 38.235 24.04-21.477 14.15 3.687 5.586 24.041-15.821 25.871 16.895 3.549-5.652-24.04-14.86 37.777-24.499c-.013-.015-.02-.029-.029-.042l-.13-.076.043-.007c-7.92-11.674-10.417-21.655-7.123-32.962l31.219.041.067-6.64h-29.077c5.496-12.661 13.052-24.04 39.84-24.04h0zm-78.24 83.779l-28.16-17.744 55.178.014-27.018 17.73h0zm29.395-53.114c-2.381 7.555-1.419 18.935 4.419 28.619h-67.999c4.144-8.288 7.968-18.385 10.761-28.619h52.819z"/></svg>';
// src/plugins/connect/discover/discover-service.ts
var PRODUCT_LOGO = {
camel: camel_logo_default,
jetty: jetty_logo_default,
tomcat: tomcat_logo_default,
generic: java_logo_default
};
var DiscoverService = class {
hasDiscoveryMBean() {
return _chunkBJ6TSPQKjs.workspace.treeContainsDomainAndProperties("jolokia", { type: "Discovery" });
}
hasLocalMBean() {
return _chunkBJ6TSPQKjs.workspace.treeContainsDomainAndProperties("hawtio", { type: "JVMList" });
}
async discoverAgents() {
const discoveryMBean = (await _chunkBJ6TSPQKjs.workspace.findMBeans("jolokia", { type: "Discovery" }))[0];
if (!_optionalChain([discoveryMBean, 'optionalAccess', _2 => _2.objectName])) {
return [];
}
const agents = await _chunkBJ6TSPQKjs.jolokiaService.execute(discoveryMBean.objectName, "lookupAgentsWithTimeout(int)", [
10 * 1e3
]);
await this.fetchMoreJvmDetails(agents);
return agents;
}
async listJvms() {
const jvmListMBean = (await _chunkBJ6TSPQKjs.workspace.findMBeans("hawtio", { type: "JVMList" }))[0];
if (!_optionalChain([jvmListMBean, 'optionalAccess', _3 => _3.objectName])) {
return [];
}
return await _chunkBJ6TSPQKjs.jolokiaService.execute(jvmListMBean.objectName, "listLocalJVMs()");
}
async fetchMoreJvmDetails(agents) {
for (const agent of agents) {
if (!agent.url || agent.secured) {
continue;
}
const jolokia = _chunkBJ6TSPQKjs.connectService.createJolokia(this.agentToConnection(agent));
agent.startTime = await jolokia.getAttribute("java.lang:type=Runtime", "StartTime");
if (!this.hasName(agent)) {
agent.command = await jolokia.getAttribute(
"java.lang:type=Runtime",
"SystemProperties",
"sun.java.command"
);
}
}
}
hasName(agent) {
return [agent.server_vendor, agent.server_product, agent.server_version].every((s) => !_chunkBHIEXRGKjs.isBlank.call(void 0, s));
}
productLogo(agent) {
if (_optionalChain([agent, 'access', _4 => _4.command, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("main.CamelJBang")])) {
return PRODUCT_LOGO.camel;
}
return _nullishCoalesce(PRODUCT_LOGO[_nullishCoalesce(_optionalChain([agent, 'access', _7 => _7.server_product, 'optionalAccess', _8 => _8.toLowerCase, 'call', _9 => _9()]), () => ( "generic"))], () => ( PRODUCT_LOGO.generic));
}
productLogoJvm(jvm) {
if (jvm.displayName.startsWith("main.CamelJBang")) {
return PRODUCT_LOGO.camel;
}
return PRODUCT_LOGO.generic;
}
agentToConnection(agent) {
const conn = {
..._chunkBJ6TSPQKjs.INITIAL_CONNECTION,
id: agent.agent_id ? `discover-${agent.agent_id}` : "",
name: _nullishCoalesce(agent.agent_description, () => ( `discover-${agent.agent_id}`))
};
if (!agent.url) {
_chunkBJ6TSPQKjs.log2.warn("No URL available to connect to agent:", agent);
return conn;
}
const url = new URL(agent.url);
conn.scheme = this.schemeFromUrl(url);
conn.host = url.hostname;
conn.port = parseInt(url.port);
conn.path = url.pathname;
_chunkBJ6TSPQKjs.log2.debug("Discover - connection from agent:", conn);
return conn;
}
schemeFromUrl(url) {
const scheme = url.protocol.substring(0, url.protocol.length - 1);
return scheme === "http" || scheme === "https" ? scheme : "http";
}
jvmToConnection(jvm) {
const conn = { ..._chunkBJ6TSPQKjs.INITIAL_CONNECTION, name: `local-${jvm.port}` };
if (!jvm.scheme || !jvm.hostname || jvm.port === 0 || !jvm.path) {
_chunkBJ6TSPQKjs.log2.warn("Lack of information to connect to JVM:", jvm);
return conn;
}
conn.scheme = jvm.scheme === "http" || jvm.scheme === "https" ? jvm.scheme : "http";
conn.host = jvm.hostname;
conn.port = jvm.port;
conn.path = jvm.path;
_chunkBJ6TSPQKjs.log2.debug("Discover - connection from JVM:", conn);
return conn;
}
isConnectable(jvm) {
return [jvm.scheme, jvm.hostname, jvm.path].every((s) => s && !_chunkBHIEXRGKjs.isBlank.call(void 0, s)) && jvm.port !== 0;
}
async stopAgent(pid) {
const jvmListMBean = (await _chunkBJ6TSPQKjs.workspace.findMBeans("hawtio", { type: "JVMList" }))[0];
if (!_optionalChain([jvmListMBean, 'optionalAccess', _10 => _10.objectName])) {
return;
}
_chunkBJ6TSPQKjs.log2.debug("Discover - stop JVM agent:", jvmListMBean, pid);
await _chunkBJ6TSPQKjs.jolokiaService.execute(jvmListMBean.objectName, "stopAgent(java.lang.String)", [pid]);
}
async startAgent(pid) {
const jvmListMBean = (await _chunkBJ6TSPQKjs.workspace.findMBeans("hawtio", { type: "JVMList" }))[0];
if (!_optionalChain([jvmListMBean, 'optionalAccess', _11 => _11.objectName])) {
return;
}
_chunkBJ6TSPQKjs.log2.debug("Discover - start JVM agent:", jvmListMBean, pid);
await _chunkBJ6TSPQKjs.jolokiaService.execute(jvmListMBean.objectName, "startAgent(java.lang.String)", [pid]);
}
};
var discoverService = new DiscoverService();
// src/plugins/connect/discover/Discover.tsx
var _jsxruntime = require('react/jsx-runtime');
var Discover = () => {
const { connections, dispatch } = _react.useContext.call(void 0, ConnectContext);
const [agentDiscoverable, setAgentDiscoverable] = _react.useState.call(void 0, false);
const [jvmListable, setJvmListable] = _react.useState.call(void 0, false);
const [discovering, setDiscovering] = _react.useState.call(void 0, true);
const [agents, setAgents] = _react.useState.call(void 0, []);
const [jvms, setJvms] = _react.useState.call(void 0, []);
const [filter, setFilter] = _react.useState.call(void 0, "");
const [label, setLabel] = _react.useState.call(void 0, "Agent");
const [isSelectLabelOpen, setIsSelectLabelOpen] = _react.useState.call(void 0, false);
const [filteredAgents, setFilteredAgents] = _react.useState.call(void 0, []);
const [filteredJvms, setFilteredJvms] = _react.useState.call(void 0, []);
_react.useEffect.call(void 0, () => {
const isDiscoverable = async () => {
const discoverable = await discoverService.hasDiscoveryMBean();
setAgentDiscoverable(discoverable);
const listable = await discoverService.hasLocalMBean();
setJvmListable(listable);
if (!discoverable && listable) {
setLabel("JVM");
}
if (!discoverable && !listable) {
setDiscovering(false);
}
};
isDiscoverable();
}, []);
_react.useEffect.call(void 0, () => {
if (!discovering) {
return;
}
const discover = async () => {
const agents2 = await discoverService.discoverAgents();
_chunkBJ6TSPQKjs.log2.debug("Discover - agents:", agents2);
setAgents(agents2);
setFilteredAgents(agents2);
const jvms2 = await discoverService.listJvms();
_chunkBJ6TSPQKjs.log2.debug("Discover - JVMs:", jvms2);
setJvms(jvms2);
setFilteredJvms(jvms2);
setDiscovering(false);
};
discover();
}, [discovering]);
if (!agentDiscoverable && !jvmListable) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkBJ6TSPQKjs.HawtioEmptyCard, { message: "Agent discovery is not available" });
}
if (discovering) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkBJ6TSPQKjs.HawtioLoadingCard, { message: "Please wait, discovering agents..." });
}
const selectLabel = (event, value) => {
setLabel(value);
setIsSelectLabelOpen(!isSelectLabelOpen);
};
const applyFilter = () => {
const matchesIgnoringCase = (value) => typeof value === "string" && value.toLowerCase().includes(filter.toLowerCase());
const filteredAgents2 = agents.filter((agent) => Object.values(agent).some(matchesIgnoringCase));
setFilteredAgents(filteredAgents2);
const filteredJvms2 = jvms.filter((jvm) => Object.values(jvm).some(matchesIgnoringCase));
setFilteredJvms(filteredJvms2);
_chunkBJ6TSPQKjs.log2.debug("Discover - apply filter:", filter, "agents:", filteredAgents2, "JVMs:", filteredJvms2);
};
const clearFilter = () => {
setFilter("");
setFilteredAgents(agents);
setFilteredJvms(jvms);
};
const reset = () => {
setAgents([]);
setFilteredAgents([]);
setJvms([]);
setFilteredJvms([]);
};
const refresh = (delay = false) => {
reset();
if (delay) {
setTimeout(() => setDiscovering(true), 100);
} else {
setDiscovering(true);
}
};
const connect = (conn) => {
_chunkBJ6TSPQKjs.log2.debug("Discover - connect to:", conn);
if (connections[conn.id]) {
dispatch({ type: _chunkBLJGIIMVjs.UPDATE, id: conn.id, connection: conn });
} else {
dispatch({ type: _chunkBLJGIIMVjs.ADD, connection: conn });
}
_chunkBJ6TSPQKjs.connectService.connect(conn);
};
const toolbar = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Toolbar, { id: "connect-discover-toolbar", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.ToolbarContent, { children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.ToolbarGroup, { id: "connect-discover-toolbar-filters", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { id: "connect-discover-toolbar-label", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Select,
{
id: "connect-discover-toolbar-label-select",
"aria-label": "Filter Label",
selected: label,
isOpen: isSelectLabelOpen,
onOpenChange: setIsSelectLabelOpen,
toggle: (toggleRef) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.MenuToggle, { ref: toggleRef, onClick: () => setIsSelectLabelOpen(!isSelectLabelOpen), children: label }),
onSelect: selectLabel,
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.SelectList, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.SelectOption, { value: "Agent", isDisabled: !agentDiscoverable, children: "Agent" }, "agent"),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.SelectOption, { value: "JVM", isDisabled: !jvmListable, children: "JVM" }, "jvm")
] })
}
) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { id: "connect-discover-toolbar-filter", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.SearchInput,
{
id: "connect-discover-toolbar-filter-input",
"aria-label": "Filter Agents",
placeholder: "Filter by text...",
value: filter,
onChange: (_, value) => setFilter(value),
onSearch: applyFilter,
onClear: clearFilter
}
) })
] }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { variant: "separator" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "secondary", onClick: () => refresh(true), size: "sm", children: "Refresh" }) })
] }) });
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react2.default.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Card, { style: { marginBottom: "1rem" }, children: toolbar }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Gallery, { hasGutter: true, minWidths: { default: "400px" }, children: [
label === "Agent" && filteredAgents.map((agent, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AgentCard, { agent, connect }, `agent-${index}-${agent.agent_id}`)),
label === "JVM" && filteredJvms.map((jvm, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, JvmCard, { jvm, connect, refresh }, `jvm-${index}-${jvm.id}`))
] })
] });
};
var AgentCard = ({ agent, connect }) => {
const title = discoverService.hasName(agent) ? `${agent.server_vendor} ${agent.server_product} ${agent.server_version}` : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Content, { component: "pre", children: agent.command });
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Card, { isCompact: true, id: `connect-discover-agent-card-${agent.agent_id}`, children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
_reactcore.CardHeader,
{
actions: {
actions: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Label, { color: "blue", children: "Agent" }),
hasNoOffset: false
},
children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"img",
{
src: discoverService.productLogo(agent),
alt: agent.server_product,
style: { maxWidth: "30px", paddingRight: "0.5rem" }
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardTitle, { style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: title })
]
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardBody, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionList, { isCompact: true, isHorizontal: true, children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "Agent ID" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: agent.agent_id })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "Agent Version" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: agent.agent_version })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "Agent Description" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: agent.agent_description })
] }),
agent.startTime && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "JVM Started" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: _chunkBLJGIIMVjs.formatTimestamp.call(void 0, new Date(agent.startTime)) })
] }),
agent.url && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "Agent URL" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Content, { component: "a", href: agent.url, target: "_blank", children: agent.url }) })
] }),
!window.isSecureContext && agent.secured ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Alert,
{
variant: "danger",
isInline: true,
isPlain: true,
title: "Can't connect to secured agent in non-secure browsing context"
}
) : ""
] }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Button,
{
variant: "primary",
onClick: () => connect(discoverService.agentToConnection(agent)),
size: "sm",
isDisabled: !window.isSecureContext && agent.secured,
children: "Connect"
}
) })
] });
};
var JvmCard = ({ jvm, connect, refresh }) => {
const stopAgent = () => {
discoverService.stopAgent(jvm.id);
refresh();
};
const startAgent = () => {
discoverService.startAgent(jvm.id);
refresh();
};
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Card, { isCompact: true, id: `connect-discover-jvm-card-${jvm.id}`, children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
_reactcore.CardHeader,
{
actions: {
actions: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Label, { color: "green", children: "JVM" }),
hasNoOffset: false
},
children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"img",
{
src: discoverService.productLogoJvm(jvm),
alt: jvm.alias,
style: { maxWidth: "30px", paddingRight: "0.5rem" }
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardTitle, { style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: jvm.alias })
]
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardBody, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionList, { isCompact: true, isHorizontal: true, children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "PID" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: jvm.id })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "Name" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: jvm.displayName })
] }),
jvm.agentUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: "Agent URL" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListDescription, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Content, { component: "a", href: jvm.agentUrl, target: "_blank", children: jvm.agentUrl }) })
] })
] }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardFooter, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.ActionList, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ActionListItem, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Button,
{
variant: "primary",
onClick: () => connect(discoverService.jvmToConnection(jvm)),
size: "sm",
isDisabled: !discoverService.isConnectable(jvm),
children: "Connect"
}
) }),
jvm.agentUrl && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react2.default.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ActionListItem, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "secondary", onClick: startAgent, size: "sm", children: "Start agent" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ActionListItem, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "danger", onClick: stopAgent, size: "sm", children: "Stop agent" }) })
] })
] }) })
] });
};
// src/plugins/connect/login/ConnectLogin.tsx
var _deprecated = require('@patternfly/react-core/deprecated');
var ConnectLogin = () => {
const [isOpen, setIsOpen] = _react.useState.call(void 0, true);
const [username, setUsername] = _react.useState.call(void 0, "");
const [password, setPassword] = _react.useState.call(void 0, "");
const [loginFailed, setLoginFailed] = _react.useState.call(void 0, false);
const [loginFailedMessage, setLoginFailedMessage] = _react.useState.call(void 0, "");
const [isEnabled, setIsEnabled] = _react.useState.call(void 0, true);
const connectionName = _chunkBJ6TSPQKjs.connectService.getCurrentConnectionName();
if (!connectionName) {
return null;
}
const reset = () => {
setLoginFailed(false);
setLoginFailedMessage("");
setIsEnabled(true);
};
const handleLogin = () => {
const login = async () => {
const result = await _chunkBJ6TSPQKjs.connectService.login(username, password);
switch (result.type) {
case "success":
sessionStorage.removeItem("connect-login-redirect");
setLoginFailed(false);
_chunkBJ6TSPQKjs.connectService.redirect();
break;
case "failure":
setLoginFailed(true);
setLoginFailedMessage("Incorrect username or password");
break;
case "session-expired":
setLoginFailed(true);
setLoginFailedMessage("Session expired. Re-login in main window.");
break;
case "throttled": {
const { retryAfter } = result;
setLoginFailed(true);
setLoginFailedMessage(`Login attempt blocked. Retry after ${_chunkBLJGIIMVjs.humanizeSeconds.call(void 0, retryAfter)}`);
setIsEnabled(false);
setTimeout(reset, retryAfter * 1e3);
break;
}
}
};
login();
};
const handleClose = () => {
setIsOpen(false);
window.close();
};
const actions = [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "primary", onClick: handleLogin, isDisabled: !isEnabled, children: "Log in" }, "login"),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "link", onClick: handleClose, children: "Cancel" }, "cancel")
];
const title = `Log in to ${connectionName}`;
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _deprecated.Modal, { variant: "small", title, isOpen, onClose: handleClose, actions, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Form, { id: "connect-login-form", isHorizontal: true, onKeyUp: (e) => e.key === "Enter" && handleLogin(), children: [
loginFailed && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.FormAlert, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Alert, { variant: "danger", title: loginFailedMessage, isInline: true }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.FormGroup, { label: "Username", isRequired: true, fieldId: "connect-login-form-username", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.TextInput,
{
isRequired: true,
id: "connect-login-form-username",
name: "connect-login-form-username",
value: username,
onChange: (_event, value) => setUsername(value),
autoFocus: true
}
) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.FormGroup, { label: "Password", isRequired: true, fieldId: "connect-login-form-password", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.TextInput,
{
isRequired: true,
id: "connect-login-form-password",
name: "connect-login-form-password",
type: "password",
value: password,
onChange: (_event, value) => setPassword(value)
}
) })
] }) });
};
// src/plugins/connect/remote/Remote.tsx
var _ellipsisvicon = require('@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon');
var _pluggedicon = require('@patternfly/react-icons/dist/esm/icons/plugged-icon');
var _plusicon = require('@patternfly/react-icons/dist/esm/icons/plus-icon');
var _unpluggedicon = require('@patternfly/react-icons/dist/esm/icons/unplugged-icon');
// src/plugins/connect/remote/ConnectionModal.tsx
var _exclamationcircleicon = require('@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon');
var emptyResult = {
name: { text: "", validated: "default" },
host: { text: "", validated: "default" },
port: { text: "", validated: "default" },
test: null
};
var ValidatedHelperText = ({ validated, errorText }) => {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.FormHelperText, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.HelperText, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.HelperTextItem, { variant: validated, ...validated === "error" && { icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _exclamationcircleicon.ExclamationCircleIcon, {}) }, children: validated === "error" && errorText }) }) });
};
var ConnectionModal = ({ mode, isOpen, onClose, input }) => {
const { connections, dispatch } = _react.useContext.call(void 0, ConnectContext);
const [connection, setConnection] = _react.useState.call(void 0, input);
const [validations, setValidations] = _react.useState.call(void 0, emptyResult);
const test = async () => {
if (!validate()) {
return;
}
try {
const result = await _chunkBJ6TSPQKjs.connectService.testConnection(connection);
setValidations({ ...emptyResult, test: result });
} catch (error) {
setValidations({ ...emptyResult, test: { status: "not-reachable", message: "" + error } });
}
};
const validate = () => {
const result = { ...emptyResult };
const { id: cid, name, host, port } = connection;
let valid = true;
if (_chunkBHIEXRGKjs.isBlank.call(void 0, name)) {
result.name = {
text: "Please fill out this field",
validated: "error"
};
valid = false;
} else if (name !== input.name) {
for (const id in connections) {
if (id !== cid && _optionalChain([connections, 'access', _12 => _12[id], 'optionalAccess', _13 => _13.name]) === name) {
result.name = {
text: `Connection name '${connection.name.trim()}' is already in use`,
validated: "error"
};
valid = false;
break;
}
}
}
if (_chunkBHIEXRGKjs.isBlank.call(void 0, host)) {
result.host = {
text: "Please fill out this field",
validated: "error"
};
valid = false;
} else if (host.indexOf(":") !== -1) {
result.host = {
// TODO: IPv6
text: "Invalid character ':'",
validated: "error"
};
valid = false;
}
if (port === null || port < 0 || port > 65535) {
result.port = {
text: "Please enter a number from 0 to 65535",
validated: "error"
};
valid = false;
}
if (!valid) {
setValidations(result);
}
return valid;
};
const save = () => {
if (!validate()) {
return;
}
switch (mode) {
case "add":
dispatch({ type: _chunkBLJGIIMVjs.ADD, connection });
setConnection(input);
break;
case "edit":
dispatch({ type: _chunkBLJGIIMVjs.UPDATE, id: input.id, connection });
setConnection(connection);
break;
}
setValidations(emptyResult);
onClose();
};
const clear = () => {
setConnection(input);
setValidations(emptyResult);
onClose();
};
const modalTitle = (mode === "add" ? "Add" : "Edit") + " Connection";
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_deprecated.Modal,
{
variant: _deprecated.ModalVariant.medium,
title: modalTitle,
isOpen,
onClose: clear,
actions: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: _reactcore.ButtonVariant.primary, form: "connection-form", onClick: save, children: mode === "add" ? "Add" : "Save" }, "save"),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: _reactcore.ButtonVariant.link, onClick: clear, children: "Cancel" }, "cancel")
],
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Form, { id: "connection-form", isHorizontal: true, children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.FormGroup, { label: "Name", isRequired: