import React, { useEffect } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { Form, Button, Field, Checkbox, LinkButton, HorizontalGroup, Alert } from '@grafana/ui'; import { Page } from 'app/core/components/Page/Page'; import { StoreState } from 'app/types'; import { loadSupportBundleCollectors, createSupportBundle } from './state/actions'; const subTitle = ( Choose the components for the support bundle. The support bundle will be available for 3 days after creation. ); const mapStateToProps = (state: StoreState) => { return { collectors: state.supportBundles.supportBundleCollectors, isLoading: state.supportBundles.createBundlePageLoading, loadCollectorsError: state.supportBundles.loadBundlesError, createBundleError: state.supportBundles.createBundleError, }; }; const mapDispatchToProps = { loadSupportBundleCollectors, createSupportBundle, }; const connector = connect(mapStateToProps, mapDispatchToProps); type Props = ConnectedProps; export const SupportBundlesCreateUnconnected = ({ collectors, isLoading, loadCollectorsError, createBundleError, loadSupportBundleCollectors, createSupportBundle, }: Props): JSX.Element => { const onSubmit = (data: Record) => { const selectedLabelsArray = Object.keys(data).filter((key) => data[key]); createSupportBundle({ collectors: selectedLabelsArray }); }; useEffect(() => { loadSupportBundleCollectors(); }, [loadSupportBundleCollectors]); // turn components into a uuid -> enabled map const values: Record = collectors.reduce((acc, curr) => { return { ...acc, [curr.uid]: curr.default }; }, {}); return (

Create support bundle

{loadCollectorsError && } {createBundleError && } {!!collectors.length && (
{({ register, errors }) => { return ( <> {[...collectors] .sort((a, b) => a.displayName.localeCompare(b.displayName)) .map((component) => { return ( ); })} Cancel ); }}
)}
); }; export default connector(SupportBundlesCreateUnconnected);