import React, { PureComponent } from 'react'; import { dateTime } from '@grafana/data'; import { Forms } from '@grafana/ui'; import { connect, MapDispatchToProps, MapStateToProps } from 'react-redux'; import { ImportDashboardForm } from './ImportDashboardForm'; import { resetDashboard, saveDashboard } 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; folderId: number; } interface DispatchProps { resetDashboard: typeof resetDashboard; saveDashboard: typeof saveDashboard; } type Props = OwnProps & ConnectedProps & DispatchProps; interface State { uidReset: boolean; } class ImportDashboardOverviewUnConnected extends PureComponent { state: State = { uidReset: false, }; onSubmit = (form: ImportDashboardDTO) => { this.props.saveDashboard(form); }; onCancel = () => { this.props.resetDashboard(); }; onUidReset = () => { this.setState({ uidReset: true }); }; render() { const { dashboard, inputs, meta, source, folderId } = this.props; const { uidReset } = this.state; return ( <> {source === DashboardSource.Gcom && (
Importing Dashboard from{' '} Grafana.com
Published by {meta.orgName}
Updated on {dateTime(meta.updatedAt).format('YYYY-MM-DD HH:mm:ss')}
)} {({ register, errors, control, getValues }) => ( )} ); } } const mapStateToProps: MapStateToProps = (state: StoreState) => ({ dashboard: state.importDashboard.dashboard, meta: state.importDashboard.meta, source: state.importDashboard.source, inputs: state.importDashboard.inputs, folderId: state.location.routeParams.folderId ? Number(state.location.routeParams.folderId) : 0, }); const mapDispatchToProps: MapDispatchToProps = { resetDashboard, saveDashboard, }; export const ImportDashboardOverview = connect(mapStateToProps, mapDispatchToProps)(ImportDashboardOverviewUnConnected); ImportDashboardOverview.displayName = 'ImportDashboardOverview';