/* * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * * Any modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import { EuiHeader, EuiHeaderProps, EuiHeaderSection, EuiHeaderSectionItem, EuiHeaderSectionItemButton, EuiHideFor, EuiIcon, EuiShowFor, htmlIdGenerator, } from '@elastic/eui'; import { i18n } from '@osd/i18n'; import classnames from 'classnames'; import React, { createRef, useState } from 'react'; import useObservable from 'react-use/lib/useObservable'; import { Observable } from 'rxjs'; import { LoadingIndicator } from '../'; import { ChromeBadge, ChromeBreadcrumb, ChromeNavControl, ChromeNavLink, ChromeRecentlyAccessedHistoryItem, } from '../..'; import { InternalApplicationStart } from '../../../application/types'; import { HttpStart } from '../../../http'; import { ChromeHelpExtension, ChromeBranding } from '../../chrome_service'; import { OnIsLockedUpdate } from './'; import { CollapsibleNav } from './collapsible_nav'; import { HeaderBadge } from './header_badge'; import { HeaderBreadcrumbs } from './header_breadcrumbs'; import { HeaderHelpMenu } from './header_help_menu'; import { HomeLoader } from './home_loader'; import { HeaderNavControls } from './header_nav_controls'; import { HeaderActionMenu } from './header_action_menu'; import { HeaderLogo } from './header_logo'; export interface HeaderProps { opensearchDashboardsVersion: string; application: InternalApplicationStart; appTitle$: Observable; badge$: Observable; breadcrumbs$: Observable; customNavLink$: Observable; homeHref: string; isVisible$: Observable; opensearchDashboardsDocLink: string; navLinks$: Observable; recentlyAccessed$: Observable; forceAppSwitcherNavigation$: Observable; helpExtension$: Observable; helpSupportUrl$: Observable; navControlsLeft$: Observable; navControlsCenter$: Observable; navControlsRight$: Observable; navControlsExpandedCenter$: Observable; navControlsExpandedRight$: Observable; basePath: HttpStart['basePath']; isLocked$: Observable; loadingCount$: ReturnType; onIsLockedUpdate: OnIsLockedUpdate; branding: ChromeBranding; survey: string | undefined; } export function Header({ opensearchDashboardsVersion, opensearchDashboardsDocLink, application, basePath, onIsLockedUpdate, homeHref, branding, survey, ...observables }: HeaderProps) { const isVisible = useObservable(observables.isVisible$, false); const isLocked = useObservable(observables.isLocked$, false); const [isNavOpen, setIsNavOpen] = useState(false); if (!isVisible) { return ; } const toggleCollapsibleNavRef = createRef void }>(); const navId = htmlIdGenerator()(); const className = classnames('hide-for-sharing', 'headerGlobalNav'); const { useExpandedHeader = true } = branding; const headerTheme: EuiHeaderProps['theme'] = 'dark'; return ( <>
{useExpandedHeader && ( , ], borders: 'none', }, { items: [ , ], borders: 'none', }, { items: [ , , ], borders: 'none', }, ]} /> )} setIsNavOpen(!isNavOpen)} aria-expanded={isNavOpen} aria-pressed={isNavOpen} aria-controls={navId} ref={toggleCollapsibleNavRef} >
{ setIsNavOpen(false); if (toggleCollapsibleNavRef.current) { toggleCollapsibleNavRef.current.focus(); } }} customNavLink$={observables.customNavLink$} branding={branding} />
); }