foreman_acd 0.4.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +84 -84
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +103 -11
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +21 -3
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +9 -1
- data/app/controllers/foreman_acd/app_definitions_controller.rb +117 -15
- data/app/controllers/foreman_acd/app_instances_controller.rb +104 -30
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +36 -23
- data/app/controllers/ui_acd_controller.rb +46 -0
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +45 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +39 -0
- data/app/models/foreman_acd/acd_provider.rb +36 -0
- data/app/models/foreman_acd/ansible_playbook.rb +32 -14
- data/app/models/foreman_acd/app_definition.rb +24 -1
- data/app/models/foreman_acd/app_instance.rb +85 -5
- data/app/models/foreman_acd/foreman_host.rb +31 -0
- data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
- data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +64 -36
- data/app/services/foreman_acd/app_deployer.rb +83 -48
- data/app/services/foreman_acd/inventory_creator.rb +36 -25
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +50 -7
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +9 -1
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
- data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
- data/app/views/foreman_acd/app_definitions/index.html.erb +5 -8
- data/app/views/foreman_acd/app_instances/_form.html.erb +4 -4
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +93 -14
- data/app/views/foreman_acd/app_instances/report.html.erb +12 -4
- data/app/views/templates/job/run_acd_ansible_playbook.erb +28 -15
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/host_report.json.rabl +4 -0
- data/app/views/ui_acd/report_data.json.rabl +10 -0
- data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
- data/config/routes.rb +12 -3
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -0
- data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
- data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
- data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
- data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
- data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
- data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
- data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
- data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
- data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
- data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
- data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +6 -1
- data/lib/foreman_acd/engine.rb +40 -3
- data/lib/foreman_acd/plugin.rb +60 -45
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/foreman_acd.rb +30 -0
- data/lib/tasks/foreman_acd_tasks.rake +0 -12
- data/locale/en/foreman_acd.edit.po +326 -0
- data/locale/en/foreman_acd.po +232 -2
- data/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +8 -8
- data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
- data/test/controllers/app_instances_controller_test.rb +8 -3
- data/test/controllers/ui_acd_controller_test.rb +22 -6
- data/test/factories/foreman_acd_factories.rb +18 -4
- data/test/models/acd_provider_test.rb +37 -0
- data/test/models/ansible_playbook_test.rb +11 -0
- data/test/models/app_definition_test.rb +1 -1
- data/test/models/app_instance_test.rb +2 -0
- data/test/models/concerns/host_extensions_test.rb +26 -0
- data/test/models/foreman_host_test.rb +12 -0
- data/webpack/__mocks__/foremanReact/API.js +2 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
- data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
- data/webpack/__snapshots__/helper.test.js.snap +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +55 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +2 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +48 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +26 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +225 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +2 -1
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
- data/webpack/components/ApplicationDefinition/index.js +8 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
- data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +153 -45
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +120 -6
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +77 -22
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +299 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
- data/webpack/components/ApplicationInstance/components/Service.js +1 -1
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
- data/webpack/components/ApplicationInstance/helper.js +0 -0
- data/webpack/components/ApplicationInstance/index.js +8 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +128 -60
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +40 -50
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +5 -4
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -14
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -1
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +7 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
- data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
- data/webpack/components/ApplicationInstanceReport/index.js +8 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
- data/webpack/components/ExistingHostSelection/index.js +26 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +138 -15
- data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +52 -9
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +3 -0
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +62 -25
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +33 -25
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1488 -872
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
- data/webpack/components/ParameterSelection/index.js +2 -1
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
- data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +31 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +47 -0
- data/webpack/components/SyncGitRepo/index.js +28 -0
- data/webpack/components/common/DeleteTableEntry.js +18 -4
- data/webpack/components/common/EditTableEntry.js +50 -0
- data/webpack/components/common/ExtTextInput.js +43 -0
- data/webpack/components/common/LockTableEntry.js +60 -0
- data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
- data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +40 -2
- data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
- data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
- data/webpack/helper.js +20 -1
- data/webpack/helper.test.js +37 -0
- data/webpack/index.js +7 -0
- data/webpack/js-yaml.js +3874 -0
- data/webpack/reducer.js +16 -1
- metadata +182 -11
- data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
- data/webpack/components/common/EasyHeaderFormatter.js +0 -18
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -0,0 +1,80 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
|
3
|
+
import {
|
4
|
+
SYNC_GIT_REPO_INIT,
|
5
|
+
SYNC_GIT_REPO_LOAD_SCM_TYPE,
|
6
|
+
SYNC_GIT_REPO_LOAD_PATH,
|
7
|
+
SYNC_GIT_REPO_LOAD_GIT_COMMIT,
|
8
|
+
SYNC_GIT_REPO_LOAD_GIT_URL,
|
9
|
+
SYNC_GIT_REPO_FAILURE,
|
10
|
+
SYNC_GIT_REPO_REQUEST,
|
11
|
+
SYNC_GIT_REPO_SUCCESS,
|
12
|
+
} from './SyncGitRepoConstants';
|
13
|
+
|
14
|
+
export const initialState = Immutable({
|
15
|
+
loading: false,
|
16
|
+
});
|
17
|
+
|
18
|
+
const syncGitRepoConf = (state = initialState, action) => {
|
19
|
+
const { payload } = action;
|
20
|
+
|
21
|
+
switch (action.type) {
|
22
|
+
case SYNC_GIT_REPO_INIT: {
|
23
|
+
return state.merge(payload);
|
24
|
+
}
|
25
|
+
case SYNC_GIT_REPO_LOAD_SCM_TYPE: {
|
26
|
+
let newState = {};
|
27
|
+
const scmType = action.scmType;
|
28
|
+
|
29
|
+
newState = {
|
30
|
+
scmType: scmType,
|
31
|
+
};
|
32
|
+
|
33
|
+
return state.merge(newState);
|
34
|
+
}
|
35
|
+
case SYNC_GIT_REPO_LOAD_PATH: {
|
36
|
+
let newState = {};
|
37
|
+
const path = action.path;
|
38
|
+
|
39
|
+
newState = {
|
40
|
+
path: path,
|
41
|
+
};
|
42
|
+
|
43
|
+
return state.merge(newState);
|
44
|
+
}
|
45
|
+
case SYNC_GIT_REPO_LOAD_GIT_COMMIT: {
|
46
|
+
let newState = {};
|
47
|
+
const gitCommit = action.gitCommit;
|
48
|
+
|
49
|
+
newState = {
|
50
|
+
gitCommit: gitCommit,
|
51
|
+
};
|
52
|
+
|
53
|
+
return state.merge(newState);
|
54
|
+
}
|
55
|
+
case SYNC_GIT_REPO_LOAD_GIT_URL: {
|
56
|
+
let newState = {};
|
57
|
+
const gitUrl = action.gitUrl;
|
58
|
+
|
59
|
+
newState = {
|
60
|
+
gitUrl: gitUrl,
|
61
|
+
};
|
62
|
+
|
63
|
+
return state.merge(newState);
|
64
|
+
}
|
65
|
+
case SYNC_GIT_REPO_FAILURE: {
|
66
|
+
return state.merge({ error: payload.error, loading: false });
|
67
|
+
}
|
68
|
+
case SYNC_GIT_REPO_REQUEST: {
|
69
|
+
return state.set('loading', true);
|
70
|
+
}
|
71
|
+
case SYNC_GIT_REPO_SUCCESS: {
|
72
|
+
let newState = {};
|
73
|
+
return state.merge(newState);
|
74
|
+
}
|
75
|
+
default:
|
76
|
+
return state;
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
export default syncGitRepoConf;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
const syncGitRepoConf = state => state.foremanAcd.syncGitRepoConf;
|
2
|
+
|
3
|
+
export const selectScmType = state => syncGitRepoConf(state).scmType;
|
4
|
+
export const selectPath = state => syncGitRepoConf(state).path;
|
5
|
+
export const selectGitCommit = state => syncGitRepoConf(state).gitCommit;
|
6
|
+
export const selectGitUrl = state => syncGitRepoConf(state).gitUrl;
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import {
|
3
|
+
cloneDeep,
|
4
|
+
findIndex,
|
5
|
+
findLastIndex,
|
6
|
+
} from 'lodash';
|
7
|
+
|
8
|
+
import {
|
9
|
+
syncGitRepoConfData_1,
|
10
|
+
} from '../__fixtures__/syncGitRepoConfData_1.fixtures';
|
11
|
+
|
12
|
+
export const successState = Immutable(syncGitRepoConfData_1);
|
13
|
+
|
14
|
+
// Payload Data
|
15
|
+
export const initSyncGitRepoPayload = syncGitRepoConfData_1;
|
16
|
+
|
17
|
+
export const loadPathPayload = {
|
18
|
+
path: 'https://example.com'
|
19
|
+
};
|
20
|
+
|
21
|
+
export const loadGitCommitPayload = {
|
22
|
+
gitCommit: 'master'
|
23
|
+
};
|
24
|
+
|
25
|
+
export const loadGitUrlPayload = {
|
26
|
+
gitUrl: 'https://github.com/alpha.git'
|
27
|
+
};
|
28
|
+
|
29
|
+
export const loadScmTypePayload = {
|
30
|
+
scmType: {
|
31
|
+
git: "git",
|
32
|
+
}
|
33
|
+
};
|
34
|
+
|
35
|
+
export const handleGitRepoSyncRequestPayload = {
|
36
|
+
clearRows: false,
|
37
|
+
};
|
38
|
+
|
39
|
+
export const handleGitRepoSyncSuccessPayload = {
|
40
|
+
};
|
41
|
+
|
42
|
+
export const handleGitRepoSyncFailurePayload = {
|
43
|
+
error: "Something really bad happend",
|
44
|
+
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import SyncGitRepo from '../SyncGitRepo';
|
4
|
+
|
5
|
+
const noop = () => {};
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'should render ansible playbook': {
|
9
|
+
data: {
|
10
|
+
scmType: "",
|
11
|
+
path: "",
|
12
|
+
gitCommit: "",
|
13
|
+
appDefinitions: "",
|
14
|
+
gitUrl: "",
|
15
|
+
scmTypes: {},
|
16
|
+
},
|
17
|
+
initSyncGitRepo: noop,
|
18
|
+
loadScmType: noop,
|
19
|
+
loadPath: noop,
|
20
|
+
loadGitCommit: noop,
|
21
|
+
loadGitUrl: noop,
|
22
|
+
handleGitRepoSync: noop,
|
23
|
+
},
|
24
|
+
};
|
25
|
+
|
26
|
+
describe('SyncGitRepo', () =>
|
27
|
+
testComponentSnapshotsWithFixtures(SyncGitRepo, fixtures));
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import reducer, { initialState } from '../SyncGitRepoReducer';
|
3
|
+
|
4
|
+
import {
|
5
|
+
successState,
|
6
|
+
initSyncGitRepoPayload,
|
7
|
+
loadPathPayload,
|
8
|
+
loadGitCommitPayload,
|
9
|
+
loadScmTypePayload,
|
10
|
+
loadGitUrlPayload,
|
11
|
+
handleGitRepoSyncRequestPayload,
|
12
|
+
handleGitRepoSyncSuccessPayload,
|
13
|
+
handleGitRepoSyncFailurePayload,
|
14
|
+
} from '../__fixtures__/syncGitRepoReducer.fixtures';
|
15
|
+
|
16
|
+
import {
|
17
|
+
SYNC_GIT_REPO_INIT,
|
18
|
+
SYNC_GIT_REPO_LOAD_SCM_TYPE,
|
19
|
+
SYNC_GIT_REPO_LOAD_PATH,
|
20
|
+
SYNC_GIT_REPO_LOAD_GIT_COMMIT,
|
21
|
+
SYNC_GIT_REPO_LOAD_GIT_URL,
|
22
|
+
SYNC_GIT_REPO_REQUEST,
|
23
|
+
SYNC_GIT_REPO_FAILURE,
|
24
|
+
SYNC_GIT_REPO_SUCCESS,
|
25
|
+
} from '../SyncGitRepoConstants';
|
26
|
+
|
27
|
+
const fixtures = {
|
28
|
+
'should return initial state': {
|
29
|
+
state: initialState,
|
30
|
+
action: {
|
31
|
+
type: undefined,
|
32
|
+
payload: {},
|
33
|
+
},
|
34
|
+
},
|
35
|
+
|
36
|
+
'should initialize component': {
|
37
|
+
state: initialState,
|
38
|
+
action: {
|
39
|
+
type: SYNC_GIT_REPO_INIT,
|
40
|
+
payload: initSyncGitRepoPayload,
|
41
|
+
},
|
42
|
+
},
|
43
|
+
'should load path': {
|
44
|
+
state: successState,
|
45
|
+
action: {
|
46
|
+
type: SYNC_GIT_REPO_LOAD_PATH,
|
47
|
+
path: loadPathPayload,
|
48
|
+
},
|
49
|
+
},
|
50
|
+
'should load git commit': {
|
51
|
+
state: successState,
|
52
|
+
action: {
|
53
|
+
type: SYNC_GIT_REPO_LOAD_GIT_COMMIT,
|
54
|
+
gitCommit: loadGitCommitPayload,
|
55
|
+
},
|
56
|
+
},
|
57
|
+
'should load git url': {
|
58
|
+
state: successState,
|
59
|
+
action: {
|
60
|
+
type: SYNC_GIT_REPO_LOAD_GIT_URL,
|
61
|
+
gitCommit: loadGitUrlPayload,
|
62
|
+
},
|
63
|
+
},
|
64
|
+
'should load scm_type': {
|
65
|
+
state: successState,
|
66
|
+
action: {
|
67
|
+
type: SYNC_GIT_REPO_LOAD_SCM_TYPE,
|
68
|
+
scmType: loadScmTypePayload,
|
69
|
+
},
|
70
|
+
},
|
71
|
+
'should request handle git repo sync': {
|
72
|
+
state: successState,
|
73
|
+
action: {
|
74
|
+
type: SYNC_GIT_REPO_REQUEST,
|
75
|
+
payload: handleGitRepoSyncRequestPayload,
|
76
|
+
},
|
77
|
+
},
|
78
|
+
'should handle git repo sync be successful': {
|
79
|
+
state: successState,
|
80
|
+
action: {
|
81
|
+
type: SYNC_GIT_REPO_SUCCESS,
|
82
|
+
payload: handleGitRepoSyncSuccessPayload,
|
83
|
+
},
|
84
|
+
},
|
85
|
+
'should handle git repo sync be erroneous': {
|
86
|
+
state: successState,
|
87
|
+
action: {
|
88
|
+
type: SYNC_GIT_REPO_FAILURE,
|
89
|
+
payload: handleGitRepoSyncFailurePayload,
|
90
|
+
},
|
91
|
+
},
|
92
|
+
};
|
93
|
+
|
94
|
+
describe('SyncGitRepoReducer', () =>
|
95
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import {
|
4
|
+
selectScmType,
|
5
|
+
selectPath,
|
6
|
+
selectGitCommit,
|
7
|
+
selectGitUrl,
|
8
|
+
} from '../SyncGitRepoSelectors';
|
9
|
+
|
10
|
+
import {
|
11
|
+
syncGitRepoConfData_1,
|
12
|
+
} from '../__fixtures__/syncGitRepoConfData_1.fixtures';
|
13
|
+
|
14
|
+
const stateFactory = obj => ({
|
15
|
+
foremanAcd: {
|
16
|
+
syncGitRepoConf: obj,
|
17
|
+
},
|
18
|
+
});
|
19
|
+
|
20
|
+
const fixtures = {
|
21
|
+
'should return scmType from syncGitRepoConfData_1 fixtures': () =>
|
22
|
+
selectScmType(stateFactory(syncGitRepoConfData_1)),
|
23
|
+
'should return path from syncGitRepoConfData_1 fixtures': () =>
|
24
|
+
selectPath(stateFactory(syncGitRepoConfData_1)),
|
25
|
+
'should return gitCommit from syncGitRepoConfData_1 fixtures': () =>
|
26
|
+
selectGitCommit(stateFactory(syncGitRepoConfData_1)),
|
27
|
+
'should return gitUrl from syncGitRepoConfData_1 fixtures': () =>
|
28
|
+
selectGitUrl(stateFactory(syncGitRepoConfData_1)),
|
29
|
+
};
|
30
|
+
|
31
|
+
describe('SyncGitRepoSelectors', () =>
|
32
|
+
testSelectorsSnapshotWithFixtures(fixtures));
|
@@ -0,0 +1,31 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`SyncGitRepo should render ansible playbook 1`] = `
|
4
|
+
<span>
|
5
|
+
<div>
|
6
|
+
<ScmTypeSelector
|
7
|
+
editable={true}
|
8
|
+
hidden={false}
|
9
|
+
label="SCM Type *"
|
10
|
+
onChange={[Function]}
|
11
|
+
options={Object {}}
|
12
|
+
selectValue=""
|
13
|
+
/>
|
14
|
+
<div />
|
15
|
+
<div
|
16
|
+
className="form-group"
|
17
|
+
>
|
18
|
+
<div
|
19
|
+
className="col-md-2"
|
20
|
+
/>
|
21
|
+
<div
|
22
|
+
className="col-md-4"
|
23
|
+
>
|
24
|
+
<pre>
|
25
|
+
SCM Type cannot be blank
|
26
|
+
</pre>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</span>
|
31
|
+
`;
|
@@ -0,0 +1,137 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`SyncGitRepoReducer should handle git repo sync be erroneous 1`] = `
|
4
|
+
Object {
|
5
|
+
"error": "Something really bad happend",
|
6
|
+
"gitCommit": "master",
|
7
|
+
"gitUrl": "https://github.com/alpha.git",
|
8
|
+
"loading": false,
|
9
|
+
"path": "https://example.com",
|
10
|
+
"scmType": Object {
|
11
|
+
"git": "git",
|
12
|
+
},
|
13
|
+
"scmTypes": Object {
|
14
|
+
"directory": "directory",
|
15
|
+
"git": "git",
|
16
|
+
},
|
17
|
+
}
|
18
|
+
`;
|
19
|
+
|
20
|
+
exports[`SyncGitRepoReducer should handle git repo sync be successful 1`] = `
|
21
|
+
Object {
|
22
|
+
"gitCommit": "master",
|
23
|
+
"gitUrl": "https://github.com/alpha.git",
|
24
|
+
"path": "https://example.com",
|
25
|
+
"scmType": Object {
|
26
|
+
"git": "git",
|
27
|
+
},
|
28
|
+
"scmTypes": Object {
|
29
|
+
"directory": "directory",
|
30
|
+
"git": "git",
|
31
|
+
},
|
32
|
+
}
|
33
|
+
`;
|
34
|
+
|
35
|
+
exports[`SyncGitRepoReducer should initialize component 1`] = `
|
36
|
+
Object {
|
37
|
+
"gitCommit": "master",
|
38
|
+
"gitUrl": "https://github.com/alpha.git",
|
39
|
+
"loading": false,
|
40
|
+
"path": "https://example.com",
|
41
|
+
"scmType": Object {
|
42
|
+
"git": "git",
|
43
|
+
},
|
44
|
+
"scmTypes": Object {
|
45
|
+
"directory": "directory",
|
46
|
+
"git": "git",
|
47
|
+
},
|
48
|
+
}
|
49
|
+
`;
|
50
|
+
|
51
|
+
exports[`SyncGitRepoReducer should load git commit 1`] = `
|
52
|
+
Object {
|
53
|
+
"gitCommit": Object {
|
54
|
+
"gitCommit": "master",
|
55
|
+
},
|
56
|
+
"gitUrl": "https://github.com/alpha.git",
|
57
|
+
"path": "https://example.com",
|
58
|
+
"scmType": Object {
|
59
|
+
"git": "git",
|
60
|
+
},
|
61
|
+
"scmTypes": Object {
|
62
|
+
"directory": "directory",
|
63
|
+
"git": "git",
|
64
|
+
},
|
65
|
+
}
|
66
|
+
`;
|
67
|
+
|
68
|
+
exports[`SyncGitRepoReducer should load git url 1`] = `
|
69
|
+
Object {
|
70
|
+
"gitCommit": "master",
|
71
|
+
"gitUrl": undefined,
|
72
|
+
"path": "https://example.com",
|
73
|
+
"scmType": Object {
|
74
|
+
"git": "git",
|
75
|
+
},
|
76
|
+
"scmTypes": Object {
|
77
|
+
"directory": "directory",
|
78
|
+
"git": "git",
|
79
|
+
},
|
80
|
+
}
|
81
|
+
`;
|
82
|
+
|
83
|
+
exports[`SyncGitRepoReducer should load path 1`] = `
|
84
|
+
Object {
|
85
|
+
"gitCommit": "master",
|
86
|
+
"gitUrl": "https://github.com/alpha.git",
|
87
|
+
"path": Object {
|
88
|
+
"path": "https://example.com",
|
89
|
+
},
|
90
|
+
"scmType": Object {
|
91
|
+
"git": "git",
|
92
|
+
},
|
93
|
+
"scmTypes": Object {
|
94
|
+
"directory": "directory",
|
95
|
+
"git": "git",
|
96
|
+
},
|
97
|
+
}
|
98
|
+
`;
|
99
|
+
|
100
|
+
exports[`SyncGitRepoReducer should load scm_type 1`] = `
|
101
|
+
Object {
|
102
|
+
"gitCommit": "master",
|
103
|
+
"gitUrl": "https://github.com/alpha.git",
|
104
|
+
"path": "https://example.com",
|
105
|
+
"scmType": Object {
|
106
|
+
"scmType": Object {
|
107
|
+
"git": "git",
|
108
|
+
},
|
109
|
+
},
|
110
|
+
"scmTypes": Object {
|
111
|
+
"directory": "directory",
|
112
|
+
"git": "git",
|
113
|
+
},
|
114
|
+
}
|
115
|
+
`;
|
116
|
+
|
117
|
+
exports[`SyncGitRepoReducer should request handle git repo sync 1`] = `
|
118
|
+
Object {
|
119
|
+
"gitCommit": "master",
|
120
|
+
"gitUrl": "https://github.com/alpha.git",
|
121
|
+
"loading": true,
|
122
|
+
"path": "https://example.com",
|
123
|
+
"scmType": Object {
|
124
|
+
"git": "git",
|
125
|
+
},
|
126
|
+
"scmTypes": Object {
|
127
|
+
"directory": "directory",
|
128
|
+
"git": "git",
|
129
|
+
},
|
130
|
+
}
|
131
|
+
`;
|
132
|
+
|
133
|
+
exports[`SyncGitRepoReducer should return initial state 1`] = `
|
134
|
+
Object {
|
135
|
+
"loading": false,
|
136
|
+
}
|
137
|
+
`;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`SyncGitRepoSelectors should return gitCommit from syncGitRepoConfData_1 fixtures 1`] = `"master"`;
|
4
|
+
|
5
|
+
exports[`SyncGitRepoSelectors should return gitUrl from syncGitRepoConfData_1 fixtures 1`] = `"https://github.com/alpha.git"`;
|
6
|
+
|
7
|
+
exports[`SyncGitRepoSelectors should return path from syncGitRepoConfData_1 fixtures 1`] = `"https://example.com"`;
|
8
|
+
|
9
|
+
exports[`SyncGitRepoSelectors should return scmType from syncGitRepoConfData_1 fixtures 1`] = `
|
10
|
+
Object {
|
11
|
+
"git": "git",
|
12
|
+
}
|
13
|
+
`;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import ExtTextInput from '../../common/ExtTextInput';
|
4
|
+
import RailsData from '../../common/RailsData'
|
5
|
+
|
6
|
+
const FormTextInput= ({
|
7
|
+
label,
|
8
|
+
hidden,
|
9
|
+
editable,
|
10
|
+
viewText,
|
11
|
+
onChange,
|
12
|
+
parameter,
|
13
|
+
}) =>{
|
14
|
+
return (
|
15
|
+
<div >
|
16
|
+
<div >
|
17
|
+
<ExtTextInput
|
18
|
+
label={label}
|
19
|
+
editable={editable}
|
20
|
+
viewText={viewText}
|
21
|
+
onChange={onChange}
|
22
|
+
/>
|
23
|
+
<RailsData
|
24
|
+
key='ansible_playbook_form_data'
|
25
|
+
view='ansible_playbook'
|
26
|
+
parameter={parameter}
|
27
|
+
value={viewText}
|
28
|
+
/>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
);
|
32
|
+
};
|
33
|
+
|
34
|
+
FormTextInput.propTypes = {
|
35
|
+
label: PropTypes.string.isRequired,
|
36
|
+
editable: PropTypes.bool.isRequired,
|
37
|
+
viewText: PropTypes.string,
|
38
|
+
onChange: PropTypes.func.isRequired,
|
39
|
+
parameter: PropTypes.string,
|
40
|
+
};
|
41
|
+
|
42
|
+
export default FormTextInput;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import ExtSelect from '../../common/ExtSelect';
|
4
|
+
import RailsData from '../../common/RailsData'
|
5
|
+
|
6
|
+
const ScmTypeSelector= ({
|
7
|
+
label,
|
8
|
+
hidden,
|
9
|
+
editable,
|
10
|
+
viewText,
|
11
|
+
selectValue,
|
12
|
+
onChange,
|
13
|
+
options,
|
14
|
+
}) =>{
|
15
|
+
return (
|
16
|
+
<div className="form-group">
|
17
|
+
<label className="col-md-2 control-label">{label}</label>
|
18
|
+
<div className="col-md-4">
|
19
|
+
<ExtSelect
|
20
|
+
hidden={hidden}
|
21
|
+
editable={editable}
|
22
|
+
viewText={viewText}
|
23
|
+
selectValue={selectValue}
|
24
|
+
onChange={onChange}
|
25
|
+
options={options}
|
26
|
+
/>
|
27
|
+
<RailsData
|
28
|
+
key='ansible_playbook_scm_data'
|
29
|
+
view='ansible_playbook'
|
30
|
+
parameter='scm_type'
|
31
|
+
value={selectValue}
|
32
|
+
/>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
);
|
36
|
+
};
|
37
|
+
|
38
|
+
ScmTypeSelector.propTypes = {
|
39
|
+
label: PropTypes.string.isRequired,
|
40
|
+
editable: PropTypes.bool.isRequired,
|
41
|
+
viewText: PropTypes.string,
|
42
|
+
selectValue: PropTypes.string,
|
43
|
+
onChange: PropTypes.func.isRequired,
|
44
|
+
options: PropTypes.object,
|
45
|
+
};
|
46
|
+
|
47
|
+
export default ScmTypeSelector;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { bindActionCreators } from 'redux';
|
2
|
+
import { connect } from 'react-redux';
|
3
|
+
|
4
|
+
import './SyncGitRepo.scss';
|
5
|
+
import SyncGitRepo from './SyncGitRepo';
|
6
|
+
import * as SyncGitRepoActions from './SyncGitRepoActions';
|
7
|
+
|
8
|
+
import {
|
9
|
+
selectScmType,
|
10
|
+
selectPath,
|
11
|
+
selectGitCommit,
|
12
|
+
selectGitUrl,
|
13
|
+
} from './SyncGitRepoSelectors';
|
14
|
+
|
15
|
+
const mapStateToProps = state => ({
|
16
|
+
scmType: selectScmType(state),
|
17
|
+
gitCommit: selectGitCommit(state),
|
18
|
+
path: selectPath(state),
|
19
|
+
gitUrl: selectGitUrl(state)
|
20
|
+
});
|
21
|
+
|
22
|
+
const mapDispatchToProps = dispatch =>
|
23
|
+
bindActionCreators(SyncGitRepoActions, dispatch);
|
24
|
+
|
25
|
+
export default connect(
|
26
|
+
mapStateToProps,
|
27
|
+
mapDispatchToProps
|
28
|
+
)(SyncGitRepo);
|
@@ -1,9 +1,11 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { useState } from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import {
|
4
4
|
Icon,
|
5
5
|
Button,
|
6
|
+
MessageDialog,
|
6
7
|
} from 'patternfly-react';
|
8
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
7
9
|
|
8
10
|
const DeleteTableEntry = ({
|
9
11
|
hidden,
|
@@ -15,15 +17,27 @@ const DeleteTableEntry = ({
|
|
15
17
|
return null;
|
16
18
|
}
|
17
19
|
|
20
|
+
const [showModal, setShowModal] = useState(false);
|
21
|
+
const toggleModal = () => setShowModal(!showModal);
|
22
|
+
|
18
23
|
return (
|
19
24
|
<span>
|
20
|
-
|
25
|
+
<MessageDialog
|
26
|
+
show={showModal}
|
27
|
+
onHide={toggleModal}
|
28
|
+
primaryAction={() => onDeleteTableEntry(additionalData)}
|
29
|
+
secondaryAction={toggleModal}
|
30
|
+
primaryActionButtonContent={__('Confirm')}
|
31
|
+
secondaryActionButtonContent={__('Cancel')}
|
32
|
+
title={__('Confirm action')}
|
33
|
+
primaryContent={__('Are you sure you wish to delete this item?')}
|
34
|
+
/>
|
21
35
|
<Button
|
22
36
|
bsStyle="default"
|
23
37
|
disabled={disabled}
|
24
|
-
onClick={
|
38
|
+
onClick={toggleModal}
|
25
39
|
>
|
26
|
-
<Icon type="pf" name="delete" title="
|
40
|
+
<Icon type="pf" name="delete" title={__("Delete entry")} />
|
27
41
|
</Button>
|
28
42
|
</span>
|
29
43
|
);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import {
|
4
|
+
Icon,
|
5
|
+
Button,
|
6
|
+
} from 'patternfly-react';
|
7
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
8
|
+
|
9
|
+
const EditTableEntry = ({
|
10
|
+
hidden,
|
11
|
+
disabled,
|
12
|
+
handleLocking,
|
13
|
+
onEditTableEntry,
|
14
|
+
additionalData,
|
15
|
+
}) =>{
|
16
|
+
if (hidden) {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
|
20
|
+
let title = 'edit this entry'
|
21
|
+
|
22
|
+
if (handleLocking === true) {
|
23
|
+
if (additionalData.rowData.locked === true) {
|
24
|
+
disabled = true;
|
25
|
+
title = 'This entry is locked and can not be changed.';
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
return (
|
30
|
+
<span>
|
31
|
+
<Button
|
32
|
+
bsStyle="default"
|
33
|
+
disabled={disabled}
|
34
|
+
onClick={() => onEditTableEntry(additionalData) }
|
35
|
+
>
|
36
|
+
<Icon type="pf" name="edit" title={__(title)} />
|
37
|
+
</Button>
|
38
|
+
</span>
|
39
|
+
);
|
40
|
+
};
|
41
|
+
|
42
|
+
EditTableEntry.propTypes = {
|
43
|
+
hidden: PropTypes.bool,
|
44
|
+
disabled: PropTypes.bool.isRequired,
|
45
|
+
handleLocking: PropTypes.bool.isRequired,
|
46
|
+
onEditTableEntry: PropTypes.func.isRequired,
|
47
|
+
additionalData: PropTypes.object.isRequired,
|
48
|
+
};
|
49
|
+
|
50
|
+
export default EditTableEntry;
|