/* global window */ import jQuery from 'jquery'; import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; import { provideInjector } from 'lib/Injector'; import FormBuilderLoader from 'containers/FormBuilderLoader/FormBuilderLoader'; const sectionConfigKey = 'TestReactFormBuilder'; const InjectedFormBuilderLoader = provideInjector(FormBuilderLoader); jQuery.entwine('ss', ($) => { /** * Kick off Test React FormBuilder admin section. * Uses React to rebuild the list of fields from FrameworkTest's TestPages. */ $('.js-injector-boot .TestReactFormBuilder').entwine({ onmatch() { this._renderForm(); }, onunmatch() { this._clearForm(); }, container() { let container = this.find('.frameworktest-react-container'); if (!container.length) { container = $('
'); this.append(container); } container.siblings('form').hide(); return container[0]; }, _renderForm() { const store = window.ss.store; const sectionConfig = store.getState() .config.sections.find((section) => section.name === sectionConfigKey); const schemaUrl = sectionConfig.form.TestEditForm.schemaUrl; ReactDOM.render(