import Route from "react-router/lib/Route";
import {
    IndexRedirect
} from "react-router";
import {
    Provider
} from 'mobx-react';
import {
    WeaLocaleProvider
} from 'ecCom';

import Home from "./components/Home.js";
import Schedule from "./components/schedule/index.js";
import DataSource from "./components/dataSource/index.js";
import WorkflowFlow from './components/workflowflow/index';
import WorkflowTrigger from './components/workflowtrigger/index';
import WorkflowArchive from './components/workflowarchive/index';
import DataShow from './components/datashow/index';
import AuthenticationCenter from './components/authenticationcenter/index';
import AuthenticationSource from './components/authenticationsource/index';
import AuthenticationToken from './components/authenticationToken';
import AuthenticationOAuth2 from './components/authenticationOAuth2';
import AuthenticationSPNEGO from './components/authenticationSPNEGO';
import AuthenticationDelegate from './components/authenticationDelegate';
import AppCenter from './components/authenticationApp';
import HelpCenter from './components/authenticationHelp';
import DelegateClient from './components/delegateClient';
import OAuth2 from './components/oauth2/index';
import WhiteList from './components/whitelist/index';
import Saml from './components/saml/index';
import TodoCenter from './components/todocenter/index';
import TodoClient from './components/todoclient/index';
import Imrtx from './components/imrtx/index';
import Cas from './components/cas/index';
import Webseal from './components/webseal/index';
import Webservice from './components/Webservice/index';
import HrSync from './components/hrsync/index';
import TencentMail from './components/tencentmail/index';
import Mail from './components/email';
import HomePage from './components/homepage/index';
import Ldap from "./components/ldap/index.js";
import coremail from "./components/coremail/index";
import CoremailPortal from "./components/CoremailPortal";
import NC from './components/productlist/NC';
import EAS from './components/productlist/EAS';
import U8 from './components/productlist/U8';
import K3 from './components/productlist/K3';
import AccountSetting from './components/accountSetting';
import Login from './components/login/index'; //新版集成登录
import WorkflowflowTestDialog from './components/workflowflow/TestDialog';
import Docx from './components/docx';
import RegisterDML from "./components/workflowflow/RegisterDML";
import RegisterWebservice from "./components/workflowflow/RegisterWebservice";
import RegisterCustom from "./components/workflowflow/RegisterCustom";
import RegisterCustomOnline from "./components/workflowflow/RegisterCustomOnline";
import RegisterESB from './components/workflowflow/RegisterESB';
import CreateOrEditTask from './components/dataSource/createAndEdit';
import LDAPInit from './components/LDAPInit';
import Exchange from './components/Exchange';
import UserLoginURL from "./components/Exchange/UserLoginURL";

import stores from "./stores/index";
import "./style/index";

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'integration');
const {
    getLocaleLabelByCode
} = WeaLocaleProvider;
const Routers = (
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@18tf43`} name="integration" onEnter={getLocaleLabel} breadcrumbName="集成中心" path="integration" component={Home}>
        <IndexRedirect ecId={`${this && this.props && this.props.ecId || ''}_IndexRedirect@zh7mi5`} to='index'/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@y0yl5v`} name="index" breadcrumbName="集成首页" path="index" component={HomePage}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@p1oy2w`} name="schedule" breadcrumbName="计划任务" path="schedule" component={Schedule}/>
        {/* <Route name="scheduleCreateModal" breadcrumbName="计划任务-新建" path="scheduleCreateModal" component={ScheduleCreateModal} /> */}

        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@vxjezt`} name="workflowflow" breadcrumbName="流程流转集成" path="workflowflow" component={WorkflowFlow}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@xxgh38`} name="workflowtrigger" breadcrumbName="流程触发集成" path="workflowtrigger" component={WorkflowTrigger}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@7779eh`} name="workflowarchive" breadcrumbName="流程归档集成" path="workflowarchive" component={WorkflowArchive}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@tpv9yy`} name="datashow" breadcrumbName="数据展现集成" path="datashow" component={DataShow}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@epw7qc`} name="authenticationcenter" breadcrumbName="CAS认证" path="authenticationcenter" component={AuthenticationCenter}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@9ur6w2`} name="authenticationsource" breadcrumbName="认证源" path="authentication_source" component={AuthenticationSource}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@1mjrym`} name="token" breadcrumbName="Token认证" path="token" component={AuthenticationToken}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@xv2kxv`} name="oauth2" breadcrumbName="OAuth2认证" path="oauth2_server" component={AuthenticationOAuth2}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@ex3pf2`} name="spnego" breadcrumbName="SPNEGO认证" path="spnego" component={AuthenticationSPNEGO}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@zz950f`} name="delegate" breadcrumbName="Delegate认证" path="delegate_server" component={AuthenticationDelegate}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@g8zpbr`} name="appcenter" breadcrumbName="应用管理" path="appcenter" component={AppCenter}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@zz8g71`} name="helpcenter" breadcrumbName="帮助中心" path="helpcenter" component={HelpCenter}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@fl32z8`} name="todocenter" breadcrumbName="统一待办中心" path="todocenter" component={TodoCenter}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@lnovu4`} name="todoclient" breadcrumbName="统一待办推送设置" path="todoclient" component={TodoClient}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@x8kk7n`} name="tencentmail" breadcrumbName="腾讯企业邮箱" path="tencentmail" component={TencentMail}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@64shyh`} name="mail" breadcrumbName="邮箱" path="mail" component={Mail}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@iw7n6x`} name="Imrtx" breadcrumbName="IM集成设置" path="imrtx" component={Imrtx}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@3hn6en`} name="Cas" breadcrumbName="CAS集成" path="cas" component={Cas}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@0591du`} name="ldap" breadcrumbName="LDAP集成" path="ldap" component={Ldap}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@wig62m`} name="Webseal" breadcrumbName="Webseal集成" path="webseal" component={Webseal}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@e9en5q`} name="WebService注册" breadcrumbName="WebService注册" path="webservice" component={Webservice}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@zzdvec`} name="coremail" breadcrumbName="coremail" path="coremail" component={coremail}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@5bei9z`} name="coremailportal" breadcrumbName="coremailportal" path="coremailportal" component={CoremailPortal}/>
        {/*切换至旧版集成登录方式：component={Login} => component={Outter}*/}
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@4c406s`} name="Outter" breadcrumbName="集成登录" path="outter" component={Login}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@qpktb7`} name="DataSource" breadcrumbName="数据源设置" path="dataSource" component={DataSource}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@31tqn4`} name="HR同步" breadcrumbName="HR同步" path="hrsync" component={HrSync}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@prpc4f`} name="NC集成" breadcrumbName="NC集成" path="NC" component={NC} />
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@42mem1`} name="EAS集成" breadcrumbName="EAS集成" path="EAS" component={EAS} />
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@1k4yl8`} name="U8集成" breadcrumbName="U8集成" path="U8" component={U8} />
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@zash5p`} name="K3集成" breadcrumbName="K3集成" path="K3" component={K3} />
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@k4f8fj`} name="账号设置" breadcrumbName="账号设置" path="accountSetting" component={AccountSetting} />
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@hompey`} name="账号设置" breadcrumbName="账号设置" path="accountSetting/:id" component={AccountSetting} />
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@1gwcv9`} name="开发需求文档" breadcrumbName="开发需求文档" path="docx" component={Docx}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@k0xpq5`} name="LDAP初始化" breadcrumbName="LDAP初始化" path="LDAPInit" component={LDAPInit}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@od8lyg`} name="delegate_client" breadcrumbName="delegate_client" path="delegate_client" component={DelegateClient}/>
		<Route ecId={`${this && this.props && this.props.ecId || ''}_Route@5u0yix`} name="OAuth2" breadcrumbName="OAuth2" path="oauth2" component={OAuth2}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@1078sv`} name="Saml" breadcrumbName="Saml" path="saml" component={Saml}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@hsg2zk`} name="Exchange" breadcrumbName="Exchange" path="Exchange" component={Exchange}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@q36arr`} name="UserLoginURL" breadcrumbName="UserLoginURL" path="UserLoginURL" component={UserLoginURL}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@7irds0`} name="统一白名单配置" breadcrumbName="WhiteList" path="whitelist" component={WhiteList}/>
    </Route>
);

class RegisterESBDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@g7idxa`} {...stores}>
            <RegisterESB ecId={`${this && this.props && this.props.ecId || ''}_RegisterESB@y1r5k4`} {...this.props} />
        </Provider>
    )
}

class RegisterDMLDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@c8adg7`} {...stores}>
            <RegisterDML ecId={`${this && this.props && this.props.ecId || ''}_RegisterDML@cpfr3l`} {...this.props} />
        </Provider>
    )
}

class WorkflowTestDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@c8adg7`} {...stores}>
            <WorkflowflowTestDialog ecId={`${this && this.props && this.props.ecId || ''}_RegisterDML@testdialog`} {...this.props} />
        </Provider>
    )
}


class RegisterWebServiceDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@2mpy8i`} {...stores}>
            <RegisterWebservice ecId={`${this && this.props && this.props.ecId || ''}_RegisterWebservice@kxnrxe`} {...this.props} />
        </Provider>
    )
}

class RegisterCustomDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@y2yb5t`} {...stores}>
            <RegisterCustom ecId={`${this && this.props && this.props.ecId || ''}_RegisterCustom@gb0i0q`} {...this.props} />
        </Provider>
    )
}

class RegisterCustomOnlineDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@3qt8jg`} {...stores}>
            <RegisterCustomOnline ecId={`${this && this.props && this.props.ecId || ''}_RegisterCustomOnline@sbnol6`} {...this.props} />
        </Provider>
    )
}

class CoremailForPortal extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@2q51a4`} {...stores}>
            <CoremailPortal ecId={`${this && this.props && this.props.ecId || ''}_CoremailPortal@gf8sfm`} {...this.props} from="portal"/>
        </Provider>
    )
}

class DataSourceDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            reRender: false,
        };
    }

    componentDidMount() {
        // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
        getLocaleLabelByCode('integration').then(() => this.setState({
            reRender: true
        }));
    }

    render = () => (
        <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@51d823`} {...stores}>
      <CreateOrEditTask ecId={`${this && this.props && this.props.ecId || ''}_CreateOrEditTask@1zo6jf`} {...this.props} />
    </Provider>
    )
}

module.exports = {
    Route: Routers,
    store: stores,
    com: {
        WorkflowTestDialog,
        RegisterESBDialog,
        RegisterDMLDialog,
        RegisterWebServiceDialog,
        RegisterCustomDialog,
        RegisterCustomOnlineDialog,
        CoremailForPortal,
        DataSourceDialog
    }
};