import React from 'react';
import ReactDOM from 'react-dom';
import app from 'hadron-app';
import AppRegistry from 'hadron-app-registry';
import { AppContainer } from 'react-hot-loader';
import {{pascalcase name}}Plugin, { activate } from 'plugin';

// Import global less file. Note: these styles WILL NOT be used in compass, as compass provides its own set
// of global styles. If you are wishing to style a given component, you should be writing a less file per
// component as per the CSS Modules ICSS spec. @see src/components/toggle-button for an example.
import 'bootstrap/less/bootstrap.less';
import 'less/index.less';

const appRegistry = new AppRegistry();

global.hadronApp = app;
global.hadronApp.appRegistry = appRegistry;

// Activate our plugin with the Hadron App Registry
activate(appRegistry);
appRegistry.onActivated();

// Since we are using HtmlWebpackPlugin WITHOUT a template,
// we should create our own root node in the body element before rendering into it.
const root = document.createElement('div');
root.id = 'root';
document.body.appendChild(root);

// Create a HMR enabled render function
const render = Component => {
  ReactDOM.render(
    <AppContainer>
      <Component />
    </AppContainer>,
    document.getElementById('root')
  );
};

// For initialization events to happen in isolation, uncomment the
// following lines as needed in the same places they are commented out.
//
// // Application was initialized.
// appRegistry.emit('application-initialized', '1.11.0-dev');

// Render our plugin - don't remove the following line.
render({{pascalcase name}}Plugin);

// // Data service initialization and connection.
// import Connection from 'mongodb-connection-model';
// import DataService from 'mongodb-data-service';
//
// const connection = new Connection({
//   hostname: '127.0.0.1',
//   port: 27017,
//   ns: 'databaseName',
//   mongodb_database_name: 'admin',
//   mongodb_username: '<user>',
//   mongodb_password: '<password>'
// });
// const dataService = new DataService(connection);
//
// appRegistry.emit('data-service-initialized', dataService);
// dataService.connect((error, ds) => {
//    appRegistry.emit('data-service-connected', error, ds);
// });

// For automatic switching to specific namespaces, uncomment below as needed.
// appRegistry.emit('collection-changed', 'database.collection');
// appRegistry.emit('database-changed', 'database');

// For plugins based on query execution, comment out below:
// const query = {
//   filter: { name: 'testing' },
//   project: { name: 1 },
//   sort: { name: -1 },
//   skip: 0,
//   limit: 20,
//   ns: 'database.collection'
// }
// appRegistry.emit('query-applied', query);

if (module.hot) {
  /**
   * Warning from React Router, caused by react-hot-loader.
   * The warning can be safely ignored, so filter it from the console.
   * Otherwise you'll see it every time something changes.
   * See https://github.com/gaearon/react-hot-loader/issues/298
   */
  const orgError = console.error; // eslint-disable-line no-console
  console.error = (message) => { // eslint-disable-line no-console
    if (message && message.indexOf('You cannot change <Router routes>;') === -1) {
      // Log the error as normally
      orgError.apply(console, [message]);
    }
  };

  module.hot.accept('plugin', () => {
    // Because Webpack 2 has built-in support for ES2015 modules,
    // you won't need to re-require your app root in module.hot.accept
    render({{pascalcase name}}Plugin);
  });
}

@@ -2205,15 +2205,10 @@
 %0A// 
-%7D);%0A%0A//
+  
  For
@@ -2277,24 +2277,27 @@
 s needed.%0A//
+   
  appRegistry
@@ -2350,16 +2350,19 @@
 on');%0A//
+   
  appRegi
@@ -2403,24 +2403,27 @@
 abase');%0A%0A//
+   
  For plugins
@@ -2470,16 +2470,19 @@
 elow:%0A//
+   
  const q
@@ -2492,16 +2492,19 @@
 y = %7B%0A//
+   
    filte
@@ -2532,16 +2532,19 @@
 %7D,%0A//   
+  
+ 
 project:
@@ -2555,24 +2555,27 @@
 ame: 1 %7D,%0A//
+   
    sort: %7B n
@@ -2587,16 +2587,19 @@
 -1 %7D,%0A//
+   
    skip:
@@ -2604,16 +2604,19 @@
 p: 0,%0A//
+   
    limit
@@ -2619,24 +2619,27 @@
 imit: 20,%0A//
+   
    ns: 'data
@@ -2661,13 +2661,19 @@
 '%0A//
+   
  %7D%0A//
+   
  app
@@ -2710,16 +2710,23 @@
  query);
+%0A// %7D);
 %0A%0Aif (mo

Fix renderer setup