UNPKG

@stolostron/multicluster-sdk

Version:

Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.

50 lines 3.36 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FleetResourceLink = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); /* Copyright Contributors to the Open Cluster Management project */ const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk"); const classnames_1 = __importDefault(require("classnames")); const react_router_dom_v5_compat_1 = require("react-router-dom-v5-compat"); const searchPaths_1 = require("./utils/searchPaths"); const FleetResourceLink = (_a) => { var { cluster } = _a, resourceLinkProps = __rest(_a, ["cluster"]); if (cluster) { const { className, displayName, inline = false, groupVersionKind, name, nameSuffix, namespace, hideIcon, title, children, dataTest, onClick, truncate, } = resourceLinkProps; const value = displayName ? displayName : name; const classes = (0, classnames_1.default)('co-resource-item', className || '', { 'co-resource-item--inline': inline, 'co-resource-item--truncate': truncate, }); const path = (groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind) === 'VirtualMachine' ? `/multicloud/infrastructure/virtualmachines/${cluster}/${namespace}/${name}` : (0, searchPaths_1.getURLSearchParam)({ cluster, kind: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind, apigroup: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.group, apiversion: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.version, name, namespace, }); return ((0, jsx_runtime_1.jsxs)("span", { className: classes, children: [!hideIcon && (0, jsx_runtime_1.jsx)(dynamic_plugin_sdk_1.ResourceIcon, { groupVersionKind: groupVersionKind }), path ? ((0, jsx_runtime_1.jsxs)(react_router_dom_v5_compat_1.Link, { to: path, title: title, className: "co-resource-item__resource-name", "data-test-id": value, "data-test": dataTest !== null && dataTest !== void 0 ? dataTest : value, onClick: onClick, children: [value, nameSuffix] })) : ((0, jsx_runtime_1.jsxs)("span", { className: "co-resource-item__resource-name", "data-test-id": value, "data-test": dataTest !== null && dataTest !== void 0 ? dataTest : value, children: [value, nameSuffix] })), children] })); } else { return (0, jsx_runtime_1.jsx)(dynamic_plugin_sdk_1.ResourceLink, Object.assign({}, resourceLinkProps)); } }; exports.FleetResourceLink = FleetResourceLink; //# sourceMappingURL=FleetResourceLink.js.map