/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import React, { Component } from "react"; import { Switch, Route, Redirect, RouteComponentProps } from "react-router-dom"; // @ts-ignore import { EuiSideNav, EuiPage, EuiPageBody, EuiPageSideBar } from "@elastic/eui"; import { CoreStart } from "opensearch-dashboards/public"; import Policies from "../Policies"; import ManagedIndices from "../ManagedIndices"; import Indices from "../Indices"; import CreatePolicy from "../CreatePolicy"; import VisualCreatePolicy from "../VisualCreatePolicy"; import ChangePolicy from "../ChangePolicy"; import PolicyDetails from "../PolicyDetails/containers/PolicyDetails"; import Rollups from "../Rollups"; import { ModalProvider, ModalRoot } from "../../components/Modal"; import { ServicesConsumer } from "../../services"; import { BrowserServices } from "../../models/interfaces"; import { ROUTES } from "../../utils/constants"; import { CoreServicesConsumer } from "../../components/core_services"; import CreateRollupForm from "../CreateRollup/containers/CreateRollupForm"; import CreateTransformForm from "../CreateTransform/containers/CreateTransformForm"; import EditRollup from "../EditRollup/containers"; import RollupDetails from "../RollupDetails/containers/RollupDetails"; import { EditTransform, Transforms } from "../Transforms"; import TransformDetails from "../Transforms/containers/Transforms/TransformDetails"; import queryString from "query-string"; import CreateSnapshotPolicy from "../CreateSnapshotPolicy"; import Repositories from "../Repositories"; import SnapshotPolicies from "../SnapshotPolicies"; import SnapshotPolicyDetails from "../SnapshotPolicyDetails"; import Snapshots from "../Snapshots"; import CreateIndex from "../CreateIndex"; import Reindex from "../Reindex/container/Reindex"; import Aliases from "../Aliases"; import Templates from "../Templates"; import CreateIndexTemplate from "../CreateIndexTemplate"; import SplitIndex from "../SplitIndex"; import IndexDetail from "../IndexDetail"; import ShrinkIndex from "../ShrinkIndex/container/ShrinkIndex"; import Rollover from "../Rollover"; import DataStreams from "../DataStreams"; import CreateDataStream from "../CreateDataStream"; import ForceMerge from "../ForceMerge"; import Notifications from "../Notifications"; import ComposableTemplates from "../ComposableTemplates"; import CreateComposableTemplate from "../CreateComposableTemplate"; enum Navigation { IndexManagement = "Index Management", IndexPolicies = "State management policies", ManagedIndices = "Policy managed indices", Indices = "Indices", Rollups = "Rollup jobs", Transforms = "Transform jobs", SnapshotManagement = "Snapshot Management", Snapshots = "Snapshots", SnapshotPolicies = "Snapshot policies", Repositories = "Repositories", Aliases = "Aliases", Templates = "Templates", DataStreams = "Data streams", CreateDataStream = "Create data stream", Notifications = "Notification settings", ComposableTemplates = "Component templates", } enum Pathname { IndexPolicies = "/index-policies", ManagedIndices = "/managed-indices", Indices = "/indices", Rollups = "/rollups", Transforms = "/transforms", Snapshots = "/snapshots", SnapshotPolicies = "/snapshot-policies", Repositories = "/repositories", } const HIDDEN_NAV_ROUTES = [ ROUTES.CREATE_ROLLUP, ROUTES.EDIT_ROLLUP, ROUTES.ROLLUP_DETAILS, ROUTES.CREATE_TRANSFORM, ROUTES.EDIT_TRANSFORM, ROUTES.TRANSFORM_DETAILS, ROUTES.CREATE_POLICY, ROUTES.EDIT_POLICY, ROUTES.POLICY_DETAILS, ROUTES.CHANGE_POLICY, ROUTES.SNAPSHOT_POLICY_DETAILS, ROUTES.CREATE_SNAPSHOT_POLICY, ROUTES.EDIT_SNAPSHOT_POLICY, ROUTES.REINDEX, ROUTES.CREATE_INDEX, ROUTES.CREATE_TEMPLATE, ROUTES.SPLIT_INDEX, ROUTES.SHRINK_INDEX, ROUTES.FORCE_MERGE, ROUTES.CREATE_DATA_STREAM, ]; const HIDDEN_NAV_STARTS_WITH_ROUTE = [ ROUTES.CREATE_TEMPLATE, ROUTES.INDEX_DETAIL, ROUTES.ROLLOVER, ROUTES.CREATE_DATA_STREAM, ROUTES.FORCE_MERGE, ROUTES.CREATE_COMPOSABLE_TEMPLATE, ]; interface MainProps extends RouteComponentProps { landingPage: string; } export default class Main extends Component { render() { const { location: { pathname }, } = this.props; const sideNav = [ { name: Navigation.IndexManagement, id: 0, href: `#${Pathname.IndexPolicies}`, items: [ { name: Navigation.IndexPolicies, id: 1, href: `#${Pathname.IndexPolicies}`, isSelected: pathname === Pathname.IndexPolicies, }, { name: Navigation.ManagedIndices, id: 2, href: `#${Pathname.ManagedIndices}`, isSelected: pathname === Pathname.ManagedIndices, }, { name: Navigation.Indices, id: 3, href: `#${Pathname.Indices}`, isSelected: [Pathname.Indices, ROUTES.CREATE_INDEX].includes(pathname as Pathname), }, { name: Navigation.DataStreams, id: 8, href: `#${ROUTES.DATA_STREAMS}`, isSelected: ROUTES.DATA_STREAMS === pathname, }, { name: Navigation.Templates, id: 7, href: `#${ROUTES.TEMPLATES}`, isSelected: ROUTES.TEMPLATES === pathname, items: [ { name: Navigation.ComposableTemplates, id: 9, href: `#${ROUTES.COMPOSABLE_TEMPLATES}`, isSelected: ROUTES.COMPOSABLE_TEMPLATES === pathname, }, ], }, { name: Navigation.Aliases, id: 6, href: `#${ROUTES.ALIASES}`, isSelected: ROUTES.ALIASES === pathname, }, { name: Navigation.Rollups, id: 4, href: `#${Pathname.Rollups}`, isSelected: pathname === Pathname.Rollups, }, { name: Navigation.Transforms, id: 5, href: `#${Pathname.Transforms}`, isSelected: pathname === Pathname.Transforms, }, { name: Navigation.Notifications, id: 10, href: `#${ROUTES.NOTIFICATIONS}`, isSelected: pathname === ROUTES.NOTIFICATIONS, }, ], }, { name: Navigation.SnapshotManagement, id: 1, href: `#${Pathname.SnapshotPolicies}`, items: [ { name: Navigation.SnapshotPolicies, id: 1, href: `#${Pathname.SnapshotPolicies}`, isSelected: pathname === Pathname.SnapshotPolicies, }, { name: Navigation.Snapshots, id: 2, href: `#${Pathname.Snapshots}`, isSelected: pathname === Pathname.Snapshots, }, { name: Navigation.Repositories, id: 3, href: `#${Pathname.Repositories}`, isSelected: pathname === Pathname.Repositories, }, ], }, ]; const { landingPage } = this.props; const ROUTE_STYLE = { padding: "25px 25px" }; return ( {(core: CoreStart | null) => core && ( {(services: BrowserServices | null) => services && ( {/*Hide side navigation bar when creating or editing rollup job*/} {!HIDDEN_NAV_ROUTES.includes(pathname) && !HIDDEN_NAV_STARTS_WITH_ROUTE.some((item) => pathname.startsWith(item)) ? ( ) : null} (
)} /> (
)} /> (
)} /> ( )} /> ( )} /> ( )} /> ( )} /> queryString.parse(this.props.location.search).type == "visual" ? ( ) : ( ) } /> queryString.parse(this.props.location.search).type == "visual" ? ( ) : ( ) } /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} /> (
)} />
) }
) }
); } }