export function AllIngestionEvents()

in frontend/src/js/components/IngestionEvents/AllIngestionEvents.tsx [27:90]


export function AllIngestionEvents(
    {getCollections, updateCurrentCollection, updateCurrentIngestion, collections, workspacesMetadata, currentCollection, currentIngestion = "all"}: {
        getCollections: (dispatch: any) => any,
        updateCurrentCollection: (dispatch: any) => any,
        updateCurrentIngestion: (dispatch: any) => any,
        collections: Collection[],
        workspacesMetadata: WorkspaceMetadata[],
        currentCollection?: string,
        currentIngestion?: string
    }) {

    const [ingestOptions, setIngestOptions] = useState<EuiSelectOption[]>([])
    const [toggleIdSelected, setToggleIdSelected] = useState<FilterState>(FilterState.All);

    useEffect(() => {
        getCollections({})
    }, [getCollections])

    const collectionOptions: EuiSelectOption[] = _.sortBy(
        collections,
        (c) => c.display
    ).map((collection: Collection) => ({
        value: collection.uri,
        text: collection.display,
    }))

    useEffect(() => {
        if (currentCollection) {
            const sc = getCollection(currentCollection, collections)
            sc && setIngestOptions(
                [{value: "all", text: "All ingestions"}].concat(
                    _.sortBy(sc.ingestions, (i) => i.display).map((ingestion: Ingestion) => ({
                        value: ingestion.path,
                        text: ingestion.display
                    }))
            ))
            if (sc?.ingestions && sc?.ingestions.find((i) => i.display === currentIngestion) === undefined){
                updateCurrentIngestion(undefined)
            }
        }
    }, [currentCollection, collections, currentIngestion, updateCurrentIngestion])

    const toggleFilterButtons = [
        { id: FilterState.All, label: 'all' },
        { id: FilterState.ErrorsOnly, label: 'errors only' },
      ];

    return (
        <div className='app__main-content'>
            <h1 className='page-title'>All ingestion events</h1>
            <EuiProvider globalStyles={false} colorMode="light">
                <EuiFlexGroup wrap alignItems={"flexStart"} >
                    {collections.length > 0 && <EuiFlexItem grow={false}>
                        <EuiFormControlLayout className={styles.dropdown} prepend={<EuiFormLabel htmlFor={"collection-picker"}>Collection</EuiFormLabel>}>
                            <EuiSelect
                                hasNoInitialSelection={true}
                                value={currentCollection}
                                onChange={(e) => updateCurrentCollection(e.target.value)}
                                options={collectionOptions}>
                                id={"collection-picker"}
                            </EuiSelect>
                        </EuiFormControlLayout>
                    </EuiFlexItem>
                    }