"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DefaultLayout = void 0;
var _react = _interopRequireDefault(require("react"));
var _i18nReact = require("@kbn/i18n-react");
var _hooks = require("../../hooks");
var _layouts = require("../../../../layouts");
var _services = require("../../services");
var _default_page_title = require("./default_page_title");
/*
 * 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 DefaultLayout = ({
  section,
  children,
  rightColumn
}) => {
  const {
    getHref
  } = (0, _hooks.useLink)();
  const {
    agents
  } = (0, _hooks.useConfig)();
  const {
    agentTamperProtectionEnabled
  } = _services.ExperimentalFeaturesService.get();
  const tabs = [{
    name: /*#__PURE__*/_react.default.createElement(_i18nReact.FormattedMessage, {
      id: "xpack.fleet.appNavigation.agentsLinkText",
      defaultMessage: "Agents"
    }),
    isSelected: section === 'agents',
    href: getHref('agent_list'),
    disabled: !(agents !== null && agents !== void 0 && agents.enabled),
    'data-test-subj': 'fleet-agents-tab'
  }, {
    name: /*#__PURE__*/_react.default.createElement(_i18nReact.FormattedMessage, {
      id: "xpack.fleet.appNavigation.policiesLinkText",
      defaultMessage: "Agent policies"
    }),
    isSelected: section === 'agent_policies',
    href: getHref('policies_list'),
    'data-test-subj': 'fleet-agent-policies-tab'
  }, {
    name: /*#__PURE__*/_react.default.createElement(_i18nReact.FormattedMessage, {
      id: "xpack.fleet.appNavigation.enrollmentTokensText",
      defaultMessage: "Enrollment tokens"
    }),
    isSelected: section === 'enrollment_tokens',
    href: getHref('enrollment_tokens'),
    'data-test-subj': 'fleet-enrollment-tokens-tab'
  }, {
    name: /*#__PURE__*/_react.default.createElement(_i18nReact.FormattedMessage, {
      id: "xpack.fleet.appNavigation.uninstallTokensText",
      defaultMessage: "Uninstall tokens"
    }),
    isSelected: section === 'uninstall_tokens',
    href: getHref('uninstall_tokens'),
    'data-test-subj': 'fleet-uninstall-tokens-tab',
    isHidden: !agentTamperProtectionEnabled // needed only for agentTamperProtectionEnabled feature flag
  }, {
    name: /*#__PURE__*/_react.default.createElement(_i18nReact.FormattedMessage, {
      id: "xpack.fleet.appNavigation.dataStreamsLinkText",
      defaultMessage: "Data streams"
    }),
    isSelected: section === 'data_streams',
    href: getHref('data_streams'),
    'data-test-subj': 'fleet-datastreams-tab'
  }, {
    name: /*#__PURE__*/_react.default.createElement(_i18nReact.FormattedMessage, {
      id: "xpack.fleet.appNavigation.settingsLinkText",
      defaultMessage: "Settings"
    }),
    isSelected: section === 'settings',
    href: getHref('settings'),
    'data-test-subj': 'fleet-settings-tab'
  }
  // the filtering below is needed only for agentTamperProtectionEnabled feature flag
  ].filter(({
    isHidden
  }) => !isHidden);
  return /*#__PURE__*/_react.default.createElement(_layouts.WithHeaderLayout, {
    leftColumn: /*#__PURE__*/_react.default.createElement(_default_page_title.DefaultPageTitle, null),
    rightColumn: rightColumn,
    tabs: tabs
  }, children);
};
exports.DefaultLayout = DefaultLayout;