import React from 'react';
import {MountService} from 'foundation-ui';

import ConfigurationMap from '../../../../../src/js/components/ConfigurationMap';
import ServiceConfigGeneralSectionDisplay from './ServiceConfigGeneralSectionDisplay';
import ServiceConfigNetworkingSectionDisplay from './ServiceConfigNetworkingSectionDisplay';
import ServiceConfigStorageSectionDisplay from './ServiceConfigStorageSectionDisplay';
import ServiceConfigEnvironmentVariablesSectionDisplay from './ServiceConfigEnvironmentVariablesSectionDisplay';
import ServiceConfigLabelsSectionDisplay from './ServiceConfigLabelsSectionDisplay';
import ServiceConfigHealthChecksSectionDisplay from './ServiceConfigHealthChecksSectionDisplay';

const serviceConfigDisplayList = [
  ServiceConfigGeneralSectionDisplay,
  ServiceConfigNetworkingSectionDisplay,
  ServiceConfigStorageSectionDisplay,
  ServiceConfigEnvironmentVariablesSectionDisplay,
  ServiceConfigLabelsSectionDisplay,
  ServiceConfigHealthChecksSectionDisplay
].reverse(); // MountService sorts by priority but DESC ¯\_(ツ)_/¯

class ServiceConfigDisplay extends React.Component {
  componentWillMount() {
    serviceConfigDisplayList.forEach((component, index) => {
      MountService.MountService.registerComponent(
        component,
        'CreateService:ServiceConfigDisplay',
        100 * index // pad priorities, so we can add components in between
      );
    });
  }

  render() {
    return (
      <div className="flex-item-grow-1">
        <div className="container">
          <ConfigurationMap>
            <MountService.Mount
              type="CreateService:ServiceConfigDisplay"
              appConfig={this.props.appConfig} />
          </ConfigurationMap>
        </div>
      </div>
    );
  };
}

ServiceConfigDisplay.propTypes = {
  appConfig: React.PropTypes.object.isRequired
};

module.exports = ServiceConfigDisplay;

@@ -714,38 +714,135 @@
 ';%0A%0A
-const serviceConfigDisplayList
+// To pad priorities, so we can add components in between%0Aconst PRIORITIES_PAD_NUMBER = 100;%0A%0Aconst SERVICE_CONFIG_DISPLAY_LIST
  = %5B
@@ -1242,32 +1242,35 @@
     
-serviceConfigDisplayList
+SERVICE_CONFIG_DISPLAY_LIST
 .for
@@ -1426,74 +1426,37 @@
     
-100 * index // pad priorities, so we can add components in between
+PRIORITIES_PAD_NUMBER * index
 %0A   

extract constant