"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTrailingBreadcrumbs = void 0; var _redirect_to_detection_engine = require("../../../../common/components/link_to/redirect_to_detection_engine"); var i18nRules = _interopRequireWildcard(require("./translations")); var _types = require("../../../../app/types"); var _constants = require("../../../../../common/constants"); var _rule_details = require("../../../../detection_engine/rule_details_ui/pages/rule_details"); var _translations2 = require("../../../../detection_engine/rule_details_ui/pages/rule_details/translations"); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ const getRuleDetailsTabName = tabName => { var _RULE_DETAILS_TAB_NAM; return (_RULE_DETAILS_TAB_NAM = _rule_details.RULE_DETAILS_TAB_NAME[tabName]) !== null && _RULE_DETAILS_TAB_NAM !== void 0 ? _RULE_DETAILS_TAB_NAM : _rule_details.RULE_DETAILS_TAB_NAME[_rule_details.RuleDetailTabs.alerts]; }; const isRuleCreatePage = pathname => pathname.includes(_constants.RULES_PATH) && pathname.includes('/create'); const isRuleEditPage = pathname => pathname.includes(_constants.RULES_PATH) && pathname.includes('/edit'); /** * This module should only export this function. * All the `getTrailingBreadcrumbs` functions in Security are loaded into the main bundle. * We should be careful to not import unnecessary modules in this file to avoid increasing the main app bundle size. */ const getTrailingBreadcrumbs = (params, getSecuritySolutionUrl) => { var _params$state, _params$state2, _params$state3; let breadcrumb = []; if (params.detailName && (_params$state = params.state) !== null && _params$state !== void 0 && _params$state.ruleName) { breadcrumb = [...breadcrumb, { text: params.state.ruleName, href: getSecuritySolutionUrl({ deepLinkId: _types.SecurityPageName.rules, path: (0, _redirect_to_detection_engine.getRuleDetailsUrl)(params.detailName, '') }) }]; } if (params.detailName && (_params$state2 = params.state) !== null && _params$state2 !== void 0 && _params$state2.ruleName && params.tabName) { breadcrumb = [...breadcrumb, { text: getRuleDetailsTabName(params.tabName), href: getSecuritySolutionUrl({ deepLinkId: _types.SecurityPageName.rules, path: (0, _redirect_to_detection_engine.getRuleDetailsTabUrl)(params.detailName, params.tabName, '') }) }]; } if (isRuleCreatePage(params.pathName)) { breadcrumb = [...breadcrumb, { text: i18nRules.ADD_PAGE_TITLE, href: '' }]; } if (isRuleEditPage(params.pathName) && params.detailName && (_params$state3 = params.state) !== null && _params$state3 !== void 0 && _params$state3.ruleName) { breadcrumb = [...breadcrumb, { text: i18nRules.EDIT_PAGE_TITLE, href: '' }]; } if (!isRuleEditPage(params.pathName) && params.state && !params.state.isExistingRule) { breadcrumb = [...breadcrumb, { text: _translations2.DELETED_RULE, href: '' }]; } return breadcrumb; }; exports.getTrailingBreadcrumbs = getTrailingBreadcrumbs;