import React, { PureComponent } from 'react'; import { dateTimeFormat } from '@grafana/data'; import { Legend, Form } from '@grafana/ui'; import { connect, MapDispatchToProps, MapStateToProps } from 'react-redux'; import { ImportDashboardForm } from './ImportDashboardForm'; import { clearLoadedDashboard, importDashboard } from '../state/actions'; import { DashboardInputs, DashboardSource, ImportDashboardDTO } from '../state/reducers'; import { StoreState } from 'app/types'; interface OwnProps {} interface ConnectedProps { dashboard: ImportDashboardDTO; inputs: DashboardInputs; source: DashboardSource; meta?: any; folder: { id: number; title?: string }; } interface DispatchProps { clearLoadedDashboard: typeof clearLoadedDashboard; importDashboard: typeof importDashboard; } type Props = OwnProps & ConnectedProps & DispatchProps; interface State { uidReset: boolean; } class ImportDashboardOverviewUnConnected extends PureComponent { state: State = { uidReset: false, }; onSubmit = (form: ImportDashboardDTO) => { this.props.importDashboard(form); }; onCancel = () => { this.props.clearLoadedDashboard(); }; onUidReset = () => { this.setState({ uidReset: true }); }; render() { const { dashboard, inputs, meta, source, folder } = this.props; const { uidReset } = this.state; return ( <> {source === DashboardSource.Gcom && (
Importing Dashboard from{' '} Grafana.com
Published by {meta.orgName}
Updated on {dateTimeFormat(meta.updatedAt)}
)}
{({ register, errors, control, watch, getValues }) => ( )} ); } } const mapStateToProps: MapStateToProps = (state: StoreState) => ({ dashboard: state.importDashboard.dashboard, meta: state.importDashboard.meta, source: state.importDashboard.source, inputs: state.importDashboard.inputs, folder: state.location.routeParams.folderId ? { id: Number(state.location.routeParams.folderId) } : { id: 0 }, }); const mapDispatchToProps: MapDispatchToProps = { clearLoadedDashboard, importDashboard, }; export const ImportDashboardOverview = connect(mapStateToProps, mapDispatchToProps)(ImportDashboardOverviewUnConnected); ImportDashboardOverview.displayName = 'ImportDashboardOverview';