diff --git a/app/javascript/components/automate-method-form/ansibleTowerJobTemplateSchema.js b/app/javascript/components/automate-method-form/ansibleTowerJobTemplateSchema.js deleted file mode 100644 index c11030897af..00000000000 --- a/app/javascript/components/automate-method-form/ansibleTowerJobTemplateSchema.js +++ /dev/null @@ -1,68 +0,0 @@ -import { componentTypes } from '@@ddf'; - -const baseSchema = (options, selectedOption) => { - const commonFields = [ - { - component: componentTypes.TEXTAREA, - name: 'specify-details', - label: __('Specify details'), - condition: { - and: [{ when: 'hostValue', is: 'specify' }], - }, - }, - { - component: componentTypes.TEXT_FIELD, - id: 'maxttl', - name: 'maxttl', - label: __('Max TTL(mins)'), - }, - { - component: componentTypes.SELECT, - id: 'loggingOutput', - name: 'loggingOutput', - label: __('Logging Output'), - }, - ]; - - return { - fields: [ - { - component: componentTypes.SELECT, - id: 'provider', - name: 'provider', - label: __('Provider'), - options: options, - }, - { - component: componentTypes.SELECT, - id: 'workflowTemplate', - name: 'workflowTemplate', - label: __('Workflow Template'), - options: options, - }, - ...(selectedOption && selectedOption.id === 'Ansible Tower Workflow Template' - ? [] - : [ - { - component: componentTypes.RADIO, - id: 'hostValue', - name: 'hostValue', - label: __('Hosts'), - options: [ - { value: 'localhost', label: 'Localhost' }, - { value: 'specify', label: 'Specify host values' }, - ], - }, - ]), - ...commonFields, - ], - }; -}; - -const ansibleTowerJobTemplateSchema = (options, selectedOption) => { - let schema = baseSchema(options, selectedOption); - - return schema; -}; - -export default ansibleTowerJobTemplateSchema; diff --git a/app/javascript/components/automate-method-form/automateModal.jsx b/app/javascript/components/automate-method-form/automateModal.jsx new file mode 100644 index 00000000000..00063a46a4d --- /dev/null +++ b/app/javascript/components/automate-method-form/automateModal.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Modal } from 'carbon-components-react'; +import MiqFormRenderer from '@@ddf'; + +const AutomateModal = ({ isOpen, onClose, modalLabel, schema }) => { + + return ( + + + + ); +}; + +export default AutomateModal; diff --git a/app/javascript/components/automate-method-form/codeMirror.js b/app/javascript/components/automate-method-form/codeMirror.js new file mode 100644 index 00000000000..17d0aaeff89 --- /dev/null +++ b/app/javascript/components/automate-method-form/codeMirror.js @@ -0,0 +1,35 @@ +import React, { useRef, useEffect } from 'react'; +import CodeMirror from 'codemirror'; +import 'codemirror/lib/codemirror.css'; +import 'codemirror/mode/javascript/javascript'; + +const ReactCodeMirror = ({ code, onChange }) => { + const codeMirrorRef = useRef(null); + + useEffect(() => { + const editor = CodeMirror.fromTextArea(codeMirrorRef.current, { + mode: 'javascript', + theme: 'material', + lineNumbers: true, + }); + + editor.on('change', (instance) => { + if (onChange) { + onChange(instance.getValue()); + } + }); + editor.setValue(code); + + return () => { + editor.toTextArea(); + }; + }, [code, onChange]); + + return ( +
+