/* * 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. */ // @ts-ignore import { euiColorAccent } from '@elastic/eui/dist/eui_theme_light.json'; import React, { Component, Fragment } from 'react'; import { EuiBadge, EuiButton, EuiContextMenuItem, EuiContextMenuPanel, EuiDescriptionList, EuiDescriptionListDescription, EuiDescriptionListTitle, EuiPopover, } from '@elastic/eui'; import { FormattedMessage } from '@osd/i18n/react'; interface State { isPopoverOpen: boolean; } interface Props { options: Array<{ text: string; description?: string; testSubj?: string; isBeta?: boolean; onClick: () => void; }>; } export class CreateButton extends Component { public state = { isPopoverOpen: false, }; public render() { const { options, children } = this.props; const { isPopoverOpen } = this.state; if (!options || !options.length) { return null; } if (options.length === 1) { return ( {children} ); } const button = ( {children} ); if (options.length > 1) { return ( { return ( {option.text} {option.isBeta ? {this.renderBetaBadge()} : null} {option.description} ); })} /> ); } } private togglePopover = () => { this.setState({ isPopoverOpen: !this.state.isPopoverOpen, }); }; private closePopover = () => { this.setState({ isPopoverOpen: false, }); }; private renderBetaBadge = () => { return ( ); }; }