foreman_templates 7.0.7 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/template_controller.rb +6 -1
- data/app/controllers/concerns/foreman/controller/parameters/template_params.rb +22 -2
- data/app/models/setting/template_sync.rb +12 -2
- data/app/services/foreman_templates/template_exporter.rb +2 -2
- data/app/services/foreman_templates/template_importer.rb +20 -4
- data/app/views/template_syncs/index.html.erb +2 -6
- data/db/migrate/20180627134929_change_lock_setting.rb +5 -0
- data/lib/foreman_templates/engine.rb +6 -0
- data/lib/foreman_templates/version.rb +1 -1
- data/package.json +15 -21
- data/webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js +2 -0
- data/webpack/components/NewTemplateSync/__fixtures__/templateSyncSettings.fixtures.js +4 -4
- data/webpack/components/NewTemplateSync/__tests__/__snapshots__/NewTemplateSync.test.js.snap +2 -2
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncForm.js +68 -71
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncFormSelectors.js +10 -13
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/NewTemplateSyncFormSelectors.test.js +1 -19
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/__snapshots__/NewTemplateSyncFormSelectors.test.js.snap +7 -36
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/index.js +3 -20
- data/webpack/components/NewTemplateSync/components/SyncSettingField.js +5 -11
- data/webpack/components/NewTemplateSync/components/SyncSettingFields.js +8 -25
- data/webpack/components/NewTemplateSync/components/TextButtonField/index.js +27 -20
- data/webpack/components/NewTemplateSync/components/__tests__/SyncSettingField.test.js +2 -1
- data/webpack/components/NewTemplateSync/components/__tests__/SyncSettingFields.test.js +1 -0
- data/webpack/components/NewTemplateSync/components/__tests__/TextButtonField.test.js +4 -4
- data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/SyncSettingField.test.js.snap +18 -27
- data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/SyncSettingFields.test.js.snap +5 -3
- data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/TextButtonField.test.js.snap +8 -91
- data/webpack/components/TemplateSyncResult/__fixtures__/templateSyncResult.fixtures.js +2 -2
- data/webpack/components/TemplateSyncResult/__tests__/__snapshots__/TemplateSyncResult.test.js.snap +3 -1
- data/webpack/components/TemplateSyncResult/__tests__/__snapshots__/TemplateSyncResultReducer.test.js.snap +3 -1
- data/webpack/components/TemplateSyncResult/components/SyncedTemplate/helpers.js +19 -9
- data/webpack/components/TemplateSyncResult/components/__tests__/__snapshots__/SyncResultList.test.js.snap +3 -1
- data/webpack/components/TemplateSyncResult/components/__tests__/__snapshots__/SyncedTemplate.test.js.snap +39 -15
- data/webpack/testSetup.js +2 -1
- metadata +4 -7
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutSelectors.js +0 -4
- data/webpack/__mocks__/foremanReact/components/common/forms/Form.js +0 -2
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncFormConstants.js +0 -1
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/NewTemplateSyncForm.test.js +0 -42
- data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/__snapshots__/NewTemplateSyncForm.test.js.snap +0 -186
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0dbc6a618a7c30af0547757f78e6548ae69c5b61112d14ae51dcdad8195d3ae
|
4
|
+
data.tar.gz: 8660614fbc2a7ba17f5f778bf9e6f65a2f3ce5fe3a01bbb83212762d6c07afa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f7dabefd106226e7a11fa7bcf0d7314945c7955b50476c466d7cd21fdb5d562f2b4eff1977cb418d0f0e2a86c10889a4c2df81aedd8919b948558ad080aef1
|
7
|
+
data.tar.gz: 0bdb20444ed985d3862de5785d14a542cd294fe2365d137f9c4030be725db6642aee70f4e0c60df091bcb37599a2c956bf828e85f431994d4169c37d9a325729
|
@@ -3,6 +3,10 @@ module Api
|
|
3
3
|
class TemplateController < ::Api::V2::BaseController
|
4
4
|
include ::Foreman::Controller::Parameters::TemplateParams
|
5
5
|
|
6
|
+
resource_description do
|
7
|
+
resource_id 'templates'
|
8
|
+
end
|
9
|
+
|
6
10
|
def_param_group :foreman_template_sync_params do
|
7
11
|
param :branch, String, :required => false, :desc => N_("Branch in Git repo.")
|
8
12
|
param :repo, String, :required => false, :desc => N_("Override the default repo from settings.")
|
@@ -15,7 +19,7 @@ module Api
|
|
15
19
|
param :prefix, String, :required => false, :desc => N_("The string all imported templates should begin with.")
|
16
20
|
param :associate, Setting::TemplateSync.associate_types.keys, :required => false, :desc => N_("Associate to OS's, Locations & Organizations. Options are: always, new or never.")
|
17
21
|
param :force, :bool, :required => false, :desc => N_("Update templates that are locked")
|
18
|
-
param :lock,
|
22
|
+
param :lock, Setting::TemplateSync.lock_types.keys + ["true", "false", "0", "1"], :required => false, :desc => N_("Lock imported templates")
|
19
23
|
param :verbose, :bool, :required => false, :desc => N_("Show template diff in response")
|
20
24
|
param_group :foreman_template_sync_params
|
21
25
|
param_group :taxonomies, ::Api::V2::BaseController
|
@@ -29,6 +33,7 @@ module Api
|
|
29
33
|
|
30
34
|
api :POST, "/templates/export", N_("Initiate Export")
|
31
35
|
param :metadata_export_mode, Setting::TemplateSync.metadata_export_mode_types.keys, :required => false, :desc => N_("Specify how to handle metadata")
|
36
|
+
param :commit_msg, String, :desc => N_("Custom commit message for templates export")
|
32
37
|
param_group :foreman_template_sync_params
|
33
38
|
param_group :taxonomies, ::Api::V2::BaseController
|
34
39
|
def export
|
@@ -15,7 +15,7 @@ module Foreman
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def extra_export_params
|
18
|
-
|
18
|
+
%i(metadata_export_mode commit_msg)
|
19
19
|
end
|
20
20
|
|
21
21
|
def template_params_filter(extra_params = [])
|
@@ -34,7 +34,27 @@ module Foreman
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def template_import_params
|
37
|
-
add_taxonomy_params(base_import_params(:none))
|
37
|
+
transform_lock_param add_taxonomy_params(base_import_params(:none))
|
38
|
+
end
|
39
|
+
|
40
|
+
def transform_lock_param(params)
|
41
|
+
lock = params[:lock]
|
42
|
+
return params if lock.nil?
|
43
|
+
|
44
|
+
if lock == "true" || lock.is_a?(TrueClass) || lock.to_s == "1"
|
45
|
+
log_deprecated_param(lock)
|
46
|
+
params[:lock] = "lock"
|
47
|
+
end
|
48
|
+
|
49
|
+
if lock == "false" || lock.is_a?(FalseClass) || lock.to_s == "0"
|
50
|
+
log_deprecated_param(lock)
|
51
|
+
params[:lock] = "unlock"
|
52
|
+
end
|
53
|
+
params
|
54
|
+
end
|
55
|
+
|
56
|
+
def log_deprecated_param(value)
|
57
|
+
Logging.logger('app').warn "Using '#{value}' as a value for lock when syncing templates is deprecated and will be removed in the future."
|
38
58
|
end
|
39
59
|
|
40
60
|
def template_export_params
|
@@ -11,7 +11,7 @@ class Setting
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.export_stripped_names
|
14
|
-
%w(metadata_export_mode)
|
14
|
+
%w(metadata_export_mode commit_msg)
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.import_setting_names(except = [])
|
@@ -38,6 +38,15 @@ class Setting
|
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
|
+
def self.lock_types
|
42
|
+
{
|
43
|
+
'lock' => _('Lock'),
|
44
|
+
'keep_lock_new' => _('Keep, lock new'),
|
45
|
+
'keep' => _('Keep, do not lock new'),
|
46
|
+
'unlock' => _('Unlock')
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
41
50
|
def self.metadata_export_mode_types
|
42
51
|
{
|
43
52
|
'refresh' => _('Refresh'),
|
@@ -75,7 +84,8 @@ class Setting
|
|
75
84
|
self.set('template_sync_branch', N_('Default branch in Git repo'), '', N_('Branch')),
|
76
85
|
self.set('template_sync_metadata_export_mode', N_('Default metadata export mode, refresh re-renders metadata, keep will keep existing metadata, remove exports template without metadata'), 'refresh', N_('Metadata export mode'), nil, { :collection => Proc.new { self.metadata_export_mode_types } }),
|
77
86
|
self.set('template_sync_force', N_('Should importing overwrite locked templates?'), false, N_('Force import')),
|
78
|
-
self.set('template_sync_lock', N_('
|
87
|
+
self.set('template_sync_lock', N_('How to handle lock for imported templates?'), 'keep', N_('Lock templates'), nil, { :collection => Proc.new { self.lock_types } }),
|
88
|
+
self.set('template_sync_commit_msg', N_('Custom commit message for templates export'), 'Templates export made by a Foreman user', N_('Commit message'))
|
79
89
|
].compact.each { |s| self.create! s.update(:category => "Setting::TemplateSync") }
|
80
90
|
end
|
81
91
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ForemanTemplates
|
2
2
|
class TemplateExporter < Action
|
3
3
|
def self.setting_overrides
|
4
|
-
super + %i(metadata_export_mode)
|
4
|
+
super + %i(metadata_export_mode commit_msg)
|
5
5
|
end
|
6
6
|
|
7
7
|
def initialize(args = {})
|
@@ -42,7 +42,7 @@ module ForemanTemplates
|
|
42
42
|
new_repo = true
|
43
43
|
end
|
44
44
|
if new_repo || status.added.any? || status.changed.any? || status.deleted.any? || status.untracked.any?
|
45
|
-
git_repo.commit
|
45
|
+
git_repo.commit commit_msg
|
46
46
|
git_repo.push 'origin', branch
|
47
47
|
else
|
48
48
|
@warning = 'No change detected, skipping the commit and push'
|
@@ -10,7 +10,6 @@ module ForemanTemplates
|
|
10
10
|
super args
|
11
11
|
@verbose = parse_bool(@verbose)
|
12
12
|
@force = parse_bool(@force)
|
13
|
-
@lock = parse_bool(@lock)
|
14
13
|
@result_lines = []
|
15
14
|
end
|
16
15
|
|
@@ -79,11 +78,28 @@ module ForemanTemplates
|
|
79
78
|
end
|
80
79
|
|
81
80
|
def import_options
|
82
|
-
|
81
|
+
lock_predicate = lambda do |template|
|
82
|
+
case @lock
|
83
|
+
when 'lock'
|
84
|
+
return true
|
85
|
+
when 'unlock'
|
86
|
+
return false
|
87
|
+
when 'keep'
|
88
|
+
return template.new_record? ? false : template.locked
|
89
|
+
when 'keep_lock_new'
|
90
|
+
return template.new_record? ? true : template.locked
|
91
|
+
else
|
92
|
+
raise ::Foreman::Exception.new("Unknown lock option type, expected one of #{::Setting::TemplateSync.lock_types.keys}, got #{@lock}")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
{
|
97
|
+
:force => @force,
|
83
98
|
:associate => @associate,
|
84
|
-
:lock =>
|
99
|
+
:lock => lock_predicate,
|
85
100
|
:organization_params => @taxonomies[:organizations],
|
86
|
-
:location_params => @taxonomies[:locations]
|
101
|
+
:location_params => @taxonomies[:locations]
|
102
|
+
}
|
87
103
|
end
|
88
104
|
|
89
105
|
def template_model(metadata, parse_result)
|
@@ -1,9 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<% end %>
|
4
|
-
<% content_for(:stylesheets) do %>
|
5
|
-
<%= webpacked_plugins_css_for :foreman_templates %>
|
6
|
-
<% end %>
|
1
|
+
<%= webpacked_plugins_js_for :foreman_templates %>
|
2
|
+
<%= webpacked_plugins_css_for :foreman_templates %>
|
7
3
|
|
8
4
|
<div id="foreman-templates"/>
|
9
5
|
|
@@ -20,6 +20,12 @@ module ForemanTemplates
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
initializer "foreman_templates.load_app_instance_data" do |app|
|
24
|
+
ForemanTemplates::Engine.paths['db/migrate'].existent.each do |path|
|
25
|
+
app.config.paths['db/migrate'] << path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
23
29
|
initializer 'foreman_templates.register_plugin', :before => :finisher_hook do
|
24
30
|
Foreman::Plugin.register :foreman_templates do
|
25
31
|
requires_foreman '>= 1.24'
|
data/package.json
CHANGED
@@ -20,33 +20,24 @@
|
|
20
20
|
"url": "https://projects.theforeman.org"
|
21
21
|
},
|
22
22
|
"homepage": "https://github.com/theforeman/foreman_templates",
|
23
|
-
"
|
24
|
-
"@theforeman/vendor": "
|
23
|
+
"peerDependencies": {
|
24
|
+
"@theforeman/vendor": ">= 3.3.2"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
|
-
"@
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"babel-
|
32
|
-
"babel-
|
33
|
-
"babel-plugin-transform-object-assign": "^6.22.0",
|
34
|
-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
35
|
-
"babel-preset-env": "^1.6.0",
|
36
|
-
"babel-preset-react": "^6.24.1",
|
27
|
+
"@babel/core": "^7.7.0",
|
28
|
+
"@theforeman/env": "^3.3.2",
|
29
|
+
"@theforeman/builder": "^4.0.2",
|
30
|
+
"@theforeman/vendor-dev": "^3.3.2",
|
31
|
+
"babel-eslint": "^10.0.0",
|
32
|
+
"babel-jest": "^24.9.0",
|
37
33
|
"enzyme": "^3.7.0",
|
38
34
|
"enzyme-adapter-react-16": "^1.7.0",
|
39
35
|
"enzyme-to-json": "^3.3.5",
|
40
|
-
"eslint": "^
|
41
|
-
"eslint-
|
42
|
-
"eslint-plugin-import": "^2.8.0",
|
43
|
-
"eslint-plugin-jest": "^21.2.0",
|
44
|
-
"eslint-plugin-jsx-a11y": "^6.0.2",
|
45
|
-
"eslint-plugin-patternfly-react": "^0.2.1",
|
46
|
-
"eslint-plugin-react": "^7.4.0",
|
36
|
+
"eslint": "^6.8.0",
|
37
|
+
"eslint-plugin-patternfly-react": "^0.3.0",
|
47
38
|
"identity-obj-proxy": "^3.0.0",
|
48
|
-
"jest": "^
|
49
|
-
"prettier": "^1.
|
39
|
+
"jest": "^24.9.0",
|
40
|
+
"prettier": "^1.19.1",
|
50
41
|
"react-redux-test-utils": "^0.1.1"
|
51
42
|
},
|
52
43
|
"jest": {
|
@@ -56,6 +47,9 @@
|
|
56
47
|
"node_modules",
|
57
48
|
"webpack"
|
58
49
|
],
|
50
|
+
"transform": {
|
51
|
+
"^.+\\.js$": "babel-jest"
|
52
|
+
},
|
59
53
|
"setupFiles": [
|
60
54
|
"raf/polyfill",
|
61
55
|
"./webpack/testSetup.js"
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import Immutable from 'seamless-immutable';
|
2
2
|
|
3
|
+
import { transformInitialValues } from '../components/NewTemplateSyncForm/NewTemplateSyncFormSelectors';
|
4
|
+
|
3
5
|
export const associateSetting = Immutable({
|
4
6
|
id: 45,
|
5
7
|
value: 'new',
|
@@ -65,10 +67,8 @@ export const registeredExportSettings = {
|
|
65
67
|
};
|
66
68
|
|
67
69
|
export const initialValues = {
|
68
|
-
|
69
|
-
|
70
|
-
return memo;
|
71
|
-
}, {}),
|
70
|
+
import: transformInitialValues(importSettings),
|
71
|
+
export: transformInitialValues(exportSettings),
|
72
72
|
};
|
73
73
|
|
74
74
|
export const stateFactory = obj => ({
|
data/webpack/components/NewTemplateSync/__tests__/__snapshots__/NewTemplateSync.test.js.snap
CHANGED
@@ -12,7 +12,7 @@ exports[`NewTemplateSync should render when loaded 1`] = `
|
|
12
12
|
header="Import or Export Templates"
|
13
13
|
searchable={false}
|
14
14
|
>
|
15
|
-
<Connect(
|
15
|
+
<Connect(NewTemplateSyncForm)
|
16
16
|
history={Object {}}
|
17
17
|
userPermissions={
|
18
18
|
Object {
|
@@ -38,7 +38,7 @@ exports[`NewTemplateSync should render when loading 1`] = `
|
|
38
38
|
header="Import or Export Templates"
|
39
39
|
searchable={false}
|
40
40
|
>
|
41
|
-
<Connect(
|
41
|
+
<Connect(NewTemplateSyncForm)
|
42
42
|
history={Object {}}
|
43
43
|
userPermissions={
|
44
44
|
Object {
|
data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncForm.js
CHANGED
@@ -1,58 +1,53 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { change } from 'redux-form';
|
3
2
|
import PropTypes from 'prop-types';
|
4
3
|
|
5
|
-
import
|
6
|
-
|
4
|
+
import ForemanForm from 'foremanReact/components/common/forms/ForemanForm';
|
5
|
+
import * as Yup from 'yup';
|
7
6
|
import SyncSettingsFields from '../SyncSettingFields';
|
8
7
|
import SyncTypeRadios from '../SyncTypeRadios';
|
9
|
-
import { NEW_TEMPLATE_SYNC_FORM_NAME } from './NewTemplateSyncFormConstants';
|
10
8
|
|
11
|
-
const
|
12
|
-
|
13
|
-
|
9
|
+
const redirectToResult = history => () =>
|
10
|
+
history.push({ pathname: '/template_syncs/result' });
|
11
|
+
|
12
|
+
const repoFormat = formatAry => value => {
|
13
|
+
if (value === undefined) {
|
14
|
+
return true;
|
14
15
|
}
|
15
|
-
|
16
|
+
|
17
|
+
const valid = formatAry
|
18
|
+
.map(item => value.startsWith(item))
|
19
|
+
.reduce((memo, item) => item || memo, false);
|
20
|
+
|
21
|
+
return value && valid;
|
16
22
|
};
|
17
23
|
|
18
|
-
const
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
memo
|
36
|
-
}
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
return
|
41
|
-
|
42
|
-
values: addOrgParams(
|
43
|
-
addLocParams(postValues, currentLocation),
|
44
|
-
currentOrganization
|
45
|
-
),
|
46
|
-
message: `Templates were ${syncType}ed.`,
|
47
|
-
item: 'TemplateSync',
|
48
|
-
}).then(args => {
|
49
|
-
history.replace({ pathname: '/template_syncs/result' });
|
24
|
+
const syncFormSchema = (syncType, settingsObj, validationData) => {
|
25
|
+
const schema = (settingsObj[syncType].asMutable() || []).reduce(
|
26
|
+
(memo, setting) => {
|
27
|
+
if (setting.name === 'repo') {
|
28
|
+
return {
|
29
|
+
...memo,
|
30
|
+
repo: Yup.string()
|
31
|
+
.test(
|
32
|
+
'repo-format',
|
33
|
+
`Invalid repo format, must start with one of: ${validationData.repo.join(
|
34
|
+
', '
|
35
|
+
)}`,
|
36
|
+
repoFormat(validationData.repo)
|
37
|
+
)
|
38
|
+
.required("can't be blank"),
|
39
|
+
};
|
40
|
+
}
|
41
|
+
return memo;
|
42
|
+
},
|
43
|
+
{}
|
44
|
+
);
|
45
|
+
|
46
|
+
return Yup.object().shape({
|
47
|
+
[syncType]: Yup.object().shape(schema),
|
50
48
|
});
|
51
49
|
};
|
52
50
|
|
53
|
-
const redirectToResult = history => () =>
|
54
|
-
history.push({ pathname: '/template_syncs/result' });
|
55
|
-
|
56
51
|
class NewTemplateSyncForm extends React.Component {
|
57
52
|
allowedSyncType = (userPermissions, radioAttrs) =>
|
58
53
|
this.props.userPermissions[radioAttrs.permission];
|
@@ -92,50 +87,54 @@ class NewTemplateSyncForm extends React.Component {
|
|
92
87
|
|
93
88
|
render() {
|
94
89
|
const {
|
95
|
-
submitting,
|
96
90
|
error,
|
97
|
-
|
91
|
+
submitForm,
|
98
92
|
importSettings,
|
99
93
|
exportSettings,
|
100
|
-
dispatch,
|
101
94
|
history,
|
102
95
|
validationData,
|
103
|
-
|
96
|
+
importUrl,
|
97
|
+
exportUrl,
|
98
|
+
initialValues,
|
104
99
|
} = this.props;
|
105
100
|
|
106
|
-
const resetToDefault = (
|
107
|
-
fieldName,
|
108
|
-
value
|
109
|
-
) => {
|
110
|
-
dispatchFn(changeFn(nameOfForm, fieldName, value));
|
111
|
-
})(dispatch, change, NEW_TEMPLATE_SYNC_FORM_NAME);
|
101
|
+
const resetToDefault = (fieldName, fieldValue) => resetFn =>
|
102
|
+
resetFn(fieldName, fieldValue);
|
112
103
|
|
113
104
|
return (
|
114
|
-
<
|
115
|
-
onSubmit={
|
116
|
-
|
117
|
-
|
118
|
-
|
105
|
+
<ForemanForm
|
106
|
+
onSubmit={(values, actions) => {
|
107
|
+
const url = this.state.syncType === 'import' ? importUrl : exportUrl;
|
108
|
+
return submitForm({
|
109
|
+
url,
|
110
|
+
values: values[this.state.syncType],
|
111
|
+
message: `Templates were ${this.state.syncType}ed.`,
|
112
|
+
item: 'TemplateSync',
|
113
|
+
}).then(args => {
|
114
|
+
history.replace({ pathname: '/template_syncs/result' });
|
115
|
+
});
|
116
|
+
}}
|
117
|
+
initialValues={initialValues}
|
118
|
+
validationSchema={syncFormSchema(
|
119
|
+
this.state.syncType,
|
120
|
+
{ import: importSettings, export: exportSettings },
|
121
|
+
validationData
|
122
|
+
)}
|
119
123
|
onCancel={redirectToResult(history)}
|
120
|
-
|
121
|
-
error && error.severity === 'danger' ? __('Error! ') : __('Warning! ')
|
122
|
-
}
|
124
|
+
error={error}
|
123
125
|
>
|
124
126
|
<SyncTypeRadios
|
125
127
|
name="syncType"
|
126
128
|
controlLabel="Action type"
|
127
129
|
radios={this.initRadioButtons(this.state.syncType)}
|
128
|
-
disabled={submitting}
|
129
130
|
/>
|
130
131
|
<SyncSettingsFields
|
131
132
|
importSettings={importSettings}
|
132
133
|
exportSettings={exportSettings}
|
133
134
|
syncType={this.state.syncType}
|
134
135
|
resetField={resetToDefault}
|
135
|
-
disabled={submitting}
|
136
|
-
validationData={validationData}
|
137
136
|
/>
|
138
|
-
</
|
137
|
+
</ForemanForm>
|
139
138
|
);
|
140
139
|
}
|
141
140
|
}
|
@@ -144,13 +143,13 @@ NewTemplateSyncForm.propTypes = {
|
|
144
143
|
importSettings: PropTypes.array,
|
145
144
|
exportSettings: PropTypes.array,
|
146
145
|
userPermissions: PropTypes.object.isRequired,
|
147
|
-
submitting: PropTypes.bool,
|
148
146
|
error: PropTypes.object,
|
149
|
-
handleSubmit: PropTypes.func.isRequired,
|
150
|
-
dispatch: PropTypes.func,
|
151
147
|
history: PropTypes.object,
|
152
148
|
validationData: PropTypes.object,
|
153
|
-
|
149
|
+
initialValues: PropTypes.object.isRequired,
|
150
|
+
exportUrl: PropTypes.string.isRequired,
|
151
|
+
importUrl: PropTypes.string.isRequired,
|
152
|
+
submitForm: PropTypes.func.isRequired,
|
154
153
|
};
|
155
154
|
|
156
155
|
NewTemplateSyncForm.defaultProps = {
|
@@ -158,8 +157,6 @@ NewTemplateSyncForm.defaultProps = {
|
|
158
157
|
exportSettings: [],
|
159
158
|
validationData: {},
|
160
159
|
error: undefined,
|
161
|
-
dispatch: () => {},
|
162
|
-
submitting: false,
|
163
160
|
history: {},
|
164
161
|
};
|
165
162
|
|