Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidResende0 committed Feb 10, 2021
1 parent 3b07d31 commit 6dbd063
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/javascript/components/code-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
// editor modes
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/yaml/yaml';
import 'codemirror/mode/xml/xml';
import 'codemirror/mode/shell/shell';
// editor help
import 'codemirror/addon/edit/matchbrackets';
import 'codemirror/addon/edit/closebrackets';
Expand Down Expand Up @@ -76,7 +78,7 @@ const CodeEditor = ({
};

CodeEditor.propTypes = {
mode: PropTypes.oneOf(['json', 'yaml']),
mode: PropTypes.oneOf(['json', 'yaml', 'xml', 'shell']),
modes: PropTypes.arrayOf(PropTypes.string),
onChange: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const PxeCustomizationTemplateForm = ({ recordId }) => {

return !isLoading && (
<MiqFormRenderer
schema={createSchema()}
schema={createSchema( initialValues )}
initialValues={initialValues}
canReset={!!recordId}
onSubmit={onSubmit}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { componentTypes } from '@@ddf';

const createSchema = () => {
const setFormat = (values) => {
return typeof values.type !== 'undefined' && values.type == "CustomizationTemplateKickstart" ? "shell" : "xml";
};

const createSchema = ( initialValues = {}, loadSchema ) => {
return ({
fields: [
{
Expand Down Expand Up @@ -50,6 +54,17 @@ const createSchema = () => {
],
isRequired: true,
},
{
component: 'code-editor',
id: 'script',
name: 'script',
label: __('Script'),
mode: setFormat(initialValues),
validateOnMount: true,
// validate: [{
// type: validatorTypes.REQUIRED,
// }, value => validateCopyContent(value, initialValues, isCopying)],
},
],
});
};
Expand Down
3 changes: 2 additions & 1 deletion app/views/pxe/_template_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
:javascript
miqSelectPickerEvent("typ", "#{url}")
%hr
= react 'PxeCustomizationTemplateForm', :recordId => @pxe_image_type.try(:id).try(:to_s)
%h3= _('Script')
= render :partial => "template_script_data"

= react 'PxeCustomizationTemplateForm', :recordId => @ct.try(:id).try(:to_s)

0 comments on commit 6dbd063

Please sign in to comment.