diff --git a/app/helpers/ems_container_helper.rb b/app/helpers/ems_container_helper.rb index cfe4ed58e96a..2b51c233505b 100644 --- a/app/helpers/ems_container_helper.rb +++ b/app/helpers/ems_container_helper.rb @@ -2,4 +2,8 @@ module EmsContainerHelper include ContainerSummaryHelper include_concern 'TextualSummary' include_concern 'ComplianceSummaryHelper' + + def edit_redirect_path(lastaction, ems) + lastaction == 'show_list' ? ems_containers_path : ems_container_path(ems) + end end diff --git a/app/javascript/components/provider-form/detect-button.jsx b/app/javascript/components/provider-form/detect-button.jsx new file mode 100644 index 000000000000..59a373bb2b3a --- /dev/null +++ b/app/javascript/components/provider-form/detect-button.jsx @@ -0,0 +1,17 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import fieldsMapper from '../../forms/mappers/formFieldsMapper'; +import { componentTypes } from '@@ddf'; + +const Component = fieldsMapper[componentTypes.BUTTON]; + +const DetectButton = ({ formOptions, ...props }) => { + const onClick = () => { + // TODO: api('detect endpoint data').then('store in form using formOptions'); + }; + + return ; +}; + +export default DetectButton; diff --git a/app/javascript/components/provider-form/index.jsx b/app/javascript/components/provider-form/index.jsx index b6b967d7b05d..48b20a449c89 100644 --- a/app/javascript/components/provider-form/index.jsx +++ b/app/javascript/components/provider-form/index.jsx @@ -11,6 +11,7 @@ import ProtocolSelector from './protocol-selector'; import ProviderSelectField from './provider-select-field'; import ProviderCredentials from './provider-credentials'; import ValidateProviderCredentials from './validate-provider-credentials'; +import DetectButton from './detect-button'; const findSkipSubmits = (schema, items) => { const found = schema.skipSubmit && items.includes(schema.name) ? [schema.name] : []; @@ -146,6 +147,7 @@ const ProviderForm = ({ providerId, kind, title, redirect }) => { 'provider-select-field': ProviderSelectField, 'provider-credentials': ProviderCredentials, 'validate-provider-credentials': ValidateProviderCredentials, + 'detect-button': DetectButton, }; return ( diff --git a/app/views/ems_container/edit.html.haml b/app/views/ems_container/edit.html.haml index 36e27a613edd..b72fc89f7d26 100644 --- a/app/views/ems_container/edit.html.haml +++ b/app/views/ems_container/edit.html.haml @@ -1,18 +1 @@ -= form_for(@ems, - :url => "/#{controller_name}/#{@ems.id}", - :method => :patch, - :html => {"ng-controller" => "emsCommonFormController", - "name" => "angularForm", - "ng-show" => "afterGet", - "update-url" => "/#{controller_name}/#{@ems.id}", - "form-fields-url" => "/#{controller_name}/ems_container_form_fields/", - "novalidate" => true}) do |f| - %input{:type => 'hidden', :id => "form_id", :value => "##{f.options[:html][:id]}"} - %input{:type => 'hidden', :id => "button_name", :name => "button", :value => "save"} - %input{:type => 'hidden', :id => "cred_type", :name => "cred_type", :value => "default"} - - = render :partial => "form" - -:javascript - ManageIQ.angular.app.value('emsCommonFormId', '#{@ems.id || "new"}'); - miq_bootstrap($('#form_id').val()); += react('ProviderForm', :providerId => @ems.id.to_s, :redirect => edit_redirect_path(@lastaction, @ems), :kind => 'container', :title => ui_lookup(:model => 'ManageIQ::Providers::ContainerManager')) \ No newline at end of file diff --git a/app/views/ems_container/new.html.haml b/app/views/ems_container/new.html.haml index e832877c14c5..31363b4ae386 100644 --- a/app/views/ems_container/new.html.haml +++ b/app/views/ems_container/new.html.haml @@ -1,19 +1 @@ -- url = @ems.persisted? ? ems_containers_path(@ems) : ems_containers_path -= form_for(@ems, - :url => url, - :method => :post, - :html => {"ng-controller" => "emsCommonFormController", - "name" => "angularForm", - "ng-show" => "afterGet", - "create-url" => url, - "form-fields-url" => "/#{controller_name}/ems_container_form_fields/", - "novalidate" => true}) do |f| - %input{:type => 'hidden', :id => "form_id", :value => "##{f.options[:html][:id]}"} - %input{:type => 'hidden', :id => "button_name", :name => "button", :value => "add"} - %input{:type => 'hidden', :id => "cred_type", :name => "cred_type", :value => "default"} - - = render :partial => "form" - -:javascript - ManageIQ.angular.app.value('emsCommonFormId', '#{@ems.id || "new"}'); - miq_bootstrap($('#form_id').val()); += react('ProviderForm', :redirect => ems_containers_path, :kind => 'container', :title => ui_lookup(:model => 'ManageIQ::Providers::ContainerManager'))