import React from 'react' ; import { EuiSelectableOption } from '@elastic/eui' ; import { orderDataStreamsAndIndices } from '../../../../../lib' ; import { DataStreamBadge } from '../../../../../data_stream_badge' ; export const mapSelectionToIndicesOptions = ( { allSelected , selection , dataStreams , indices , } ) : EuiSelectableOption [ ] => { return orderDataStreamsAndIndices < EuiSelectableOption > ( { dataStreams : dataStreams . map ( ( dataStream ) : EuiSelectableOption => { return { label : dataStream , append : < DataStreamBadge />, checked : allSelected || selection . includes ( dataStream ) ? 'on' : undefined , } ; } ) , indices : indices . map ( ( index ) : EuiSelectableOption => { return { label : index , checked : allSelected || selection . includes ( index ) ? 'on' : undefined , } ; } ) , } ) ; } ; remark export const determineListMode = ( { configuredIndices , indices , dataStreams , } ) : 'custom' | 'list' => { const indicesAndDataStreams = indices . concat ( dataStreams ) ; return typeof configuredIndices === 'string' || indicesAndDataStreams . length > 100 || ( Array . isArray ( configuredIndices ) && ! configuredIndices . every ( ( c ) => indicesAndDataStreams . some ( ( i ) => i === c ) ) ) ? 'custom' : 'list' ; } ;