import React, {
	Component
} from 'react';
import {
	observer
} from 'mobx-react';
import {
	WeaNewScroll,
	WeaRightMenu,
	WeaDialog,
	WeaAlertPage
} from 'ecCom';
import {
	Row,
	Col
} from 'antd';
import MatrixCard from './MatrixCard';
import {
	Link
} from 'react-router';
import classnames from 'classnames';
import {
	i18n
} from '../../public/i18n';
import MatrixMaintenance from './maintenance/MatrixMaintenance';

@observer
export default class Dashboard extends Component {
	constructor(props) {
		super(props);
	}

	render() {
		const {
			store,
			rightMenu
		} = this.props;
		const {
			createable,
			matrixList,
			dialogParams,
			getDialogOpButtons,
			authorizationInfo,
			editorDialogRightMenu
		} = store;
		const dProps = {
			...dialogParams,
			scalable: dialogParams.opType == 'dataMaintenance' ? true : false,
			onChangeHeight: height => store.dialogHeight = height,
			hasScroll: false,
			buttons: getDialogOpButtons(),
			moreBtn: {
				datas: editorDialogRightMenu
			},
			className: "hrmDialog"
		}

		const classes = classnames({
			['tabPane']: true
		});

		return (
			<div className={classes}>
				<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@dxdmac`} datas={rightMenu}>
					<WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@l231b6`} height={'100%'}>
						<div className='dashboard'>
								{
									createable && 
									<MatrixCard ecId={`${this && this.props && this.props.ecId || ''}_MatrixCard@wwaf4t`} store={store} />
								}
		              			{
									matrixList.map((matrixGroup, i) => {
										let childrens = [];
										matrixGroup.map((matrix, j) => {
											childrens.push(
												(
													<MatrixCard ecId={`${this && this.props && this.props.ecId || ''}_MatrixCard@fbiarn@${i}`} store={store} matrix={matrix} />
												)
											)
										})
										return childrens;
									})
		              			}
						</div>
					</WeaNewScroll>
				</WeaRightMenu>
				<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@x4ig0k`} {...dProps}>
                	{dProps.coms}
                </WeaDialog>
				<MatrixMaintenance ecId={`${this && this.props && this.props.ecId || ''}_MatrixMaintenance@cbe9os`} store={store.stores.matrixMaintenanceStore}/>
			</div>
		)
	}
}