/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import React, { Component } from "react"; import { ArgsWithError, ArgsWithQuery, EuiFlexGroup, EuiFlexItem, EuiSearchBar, EuiSwitch } from "@elastic/eui"; import { DataStream } from "../../../../../server/models/interfaces"; interface IndexControlsProps { search: string; showDataStreams: boolean; onSearchChange: (args: ArgsWithQuery | ArgsWithError) => void; onRefresh: () => Promise; getDataStreams: () => Promise; toggleShowDataStreams: () => void; } interface IndexControlsState { refreshInterval: number; isPaused: boolean; } export default class IndexControls extends Component { state: IndexControlsState = { refreshInterval: 0, isPaused: true, }; onRefreshChange = ({ refreshInterval, isPaused }: IndexControlsState): void => { this.setState({ isPaused, refreshInterval }); }; getDataStreams = async () => { return (await this.props.getDataStreams()).map((ds) => ({ value: ds.name })); }; render() { const { search, onSearchChange, showDataStreams, toggleShowDataStreams } = this.props; const schema = { strict: true, fields: { indices: { type: "string", }, data_streams: { type: "string", }, }, }; const filters = showDataStreams ? [ { type: "field_value_selection", field: "data_streams", name: "Data streams", noOptionsMessage: "No data streams found", multiSelect: "or", cache: 60000, options: () => this.getDataStreams(), }, ] : undefined; return ( ); } }