diff options
author | Ariel Kenan <Ariel.Kenan@amdocs.com> | 2019-04-07 12:16:37 +0300 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2019-04-14 08:38:08 +0000 |
commit | 1dc6361b5b1d10b30fdd6f93454e67861ed1db35 (patch) | |
tree | 36a955a3257ee651f57d40c4692f1597036e212e | |
parent | 7e18b05f01c7e92d7b6d48790770f49689e08508 (diff) |
fix artifact not updating with versioning1.4.0
Change-Id: Id343b73f600154eff7b52b643be3aeca3bdf23c9
Issue-ID: SDC-2223
Signed-off-by: Ariel Kenan <Ariel.Kenan@amdocs.com>
8 files changed, 217 insertions, 121 deletions
diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/CompositionUpdate.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/CompositionUpdate.js new file mode 100644 index 00000000..e5756eb5 --- /dev/null +++ b/workflow-designer-ui/src/main/frontend/src/features/version/composition/CompositionUpdate.js @@ -0,0 +1,131 @@ +/* +* Copyright © 2018 European Support Limited +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +*http://www.apache.org/licenses/LICENSE-2.0 +* + * Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { I18n } from 'react-redux-i18n'; + +import CustomModeler from 'features/version/composition/custom-modeler'; +import camundaModuleDescriptor from 'features/version/composition/custom-properties-provider/descriptors/camunda'; +import { setElementInputsOutputs } from 'features/version/composition/bpmnUtils.js'; + +import { connect } from 'react-redux'; +import { updateComposition } from 'features/version/composition/compositionActions'; +import { showErrorModalAction } from 'shared/modal/modalWrapperActions'; +import { getComposition } from 'features/version/composition/compositionSelectors'; +import { getWorkflowName } from 'features/workflow/workflowSelectors'; +import { activitiesSelector } from 'features/activities/activitiesSelectors'; +import { getInputOutputForComposition } from 'features/version/inputOutput/inputOutputSelectors'; + +class CompositionUpdate extends Component { + static propTypes = { + compositionUpdate: PropTypes.func, + showErrorModal: PropTypes.func, + composition: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), + inputOutput: PropTypes.object, + activities: PropTypes.object, + certifyBack: PropTypes.func + }; + + constructor(props) { + super(props); + this.generatedId = 'bpmn-container' + Date.now(); + this.fileInput = React.createRef(); + this.bpmnContainer = React.createRef(); + } + + componentDidMount() { + const { composition, activities, inputOutput } = this.props; + + this.modeler = new CustomModeler({ + moddleExtensions: { + camunda: camundaModuleDescriptor + }, + workflow: { + activities: activities, + workflowInputOutput: inputOutput + } + }); + + this.setDiagramToBPMN(composition); + } + + setDiagramToBPMN = diagram => { + let modeler = this.modeler; + this.modeler.importXML(diagram, err => { + if (err) { + return this.props.showErrorModal( + I18n.t('workflow.composition.importErrorMsg') + ); + } + const canvas = modeler.get('canvas'); + const { businessObject } = canvas._rootElement; + + setElementInputsOutputs( + businessObject, + this.props.inputOutput, + this.modeler.get('moddle') + ); + + this.exportDiagramToStore(); + }); + }; + + exportDiagramToStore = () => { + this.modeler.saveXML({ format: true }, (err, xml) => { + if (err) { + return this.props.showErrorModal( + I18n.t('workflow.composition.saveErrorMsg') + ); + } + this.props.compositionUpdate(xml); + this.props.certifyBack(); + }); + }; + + render() { + return <div />; + } +} + +function mapStateToProps(state) { + return { + composition: getComposition(state), + name: getWorkflowName(state), + activities: activitiesSelector(state), + inputOutput: getInputOutputForComposition(state) + }; +} + +function mapDispatchToProps(dispatch) { + return { + compositionUpdate: composition => + dispatch(updateComposition(composition)), + showErrorModal: msg => + dispatch( + showErrorModalAction({ + title: I18n.t('workflow.composition.bpmnError'), + body: msg, + withButtons: true, + closeButtonText: I18n.t('buttons.okBtn') + }) + ) + }; +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(CompositionUpdate); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionConstants.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionConstants.js index 8c2b4225..5b945a02 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionConstants.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionConstants.js @@ -20,6 +20,8 @@ export const FETCH_REQUESTED = 'workflow/version/FETCH_REQUESTED'; export const DETAILS_CHANGED = 'workflow/version/DETAILS_CHANGED'; export const FETCH_REQUESTED_FAILED = 'workflow/version/FETCH_REQUESTED_FAILED'; export const VERSION_STATE_CHANGED = 'workflow/version/VERSION_STATE_CHANGED'; +export const TOGGLE_COMPOSITION_UPDATE = + 'workflow/version/TOGGLE_COMPOSITION_UPDATE'; export const SET_OPERRATION_MODE = 'workflow/version/SET_OPERRATION_MODE'; export const workflowVersionFetchRequestedAction = createAction( @@ -41,8 +43,16 @@ export const versionStateChangedAction = createAction( payload => payload ); +export const toggleCompositionUpdate = createAction( + TOGGLE_COMPOSITION_UPDATE, + payload => ({ isCompositionUpdating: payload }) +); + export const setOperationModeAction = createAction(SET_OPERRATION_MODE); +export const getIsCompositionUpdating = state => + state.currentVersion.general.isCompositionUpdating; + export const versionState = { DRAFT: 'draft', CERTIFIED: 'certified' diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js index 7f8769cc..8c37a0e3 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js @@ -21,8 +21,8 @@ import { getVersions, getSortedVersions } from 'features/workflow/overview/overviewSelectors'; -import { isWorkflowArchive } from 'features/workflow/workflowSelectors'; import { + isWorkflowArchive, getWorkflowId, getWorkflowName } from 'features/workflow/workflowSelectors'; @@ -30,11 +30,16 @@ import { saveParamsAction, certifyVersionAction } from 'features/version/versionController/versionControllerConstants'; -import { workflowVersionFetchRequestedAction } from '../versionConstants'; +import { + workflowVersionFetchRequestedAction, + toggleCompositionUpdate, + getIsCompositionUpdating +} from 'features/version/versionConstants'; import { getIsCertified } from 'features/version/general/generalSelectors'; import { getIOErrors } from 'features/version/inputOutput/inputOutputSelectors'; import { getCompositionHasErrors } from 'features/version/composition/compositionSelectors'; import { pluginContextSelector } from 'wfapp/pluginContext/pluginContextSelector'; + function mapStateToProps(state) { return { workflowName: getWorkflowName(state), @@ -45,7 +50,8 @@ function mapStateToProps(state) { isCertifyDisable: getIsCertified(state), isArchive: isWorkflowArchive(state), currentWorkflowVersion: state.currentVersion.general, - pluginContext: pluginContextSelector(state) + pluginContext: pluginContextSelector(state), + isCompositionUpdating: getIsCompositionUpdating(state) }; } @@ -55,7 +61,9 @@ function mapDispatchToProps(dispatch) { saveParamsToServer: params => dispatch(saveParamsAction(params)), certifyVersion: payload => dispatch(certifyVersionAction(payload)), changeVersion: payload => - dispatch(workflowVersionFetchRequestedAction(payload)) + dispatch(workflowVersionFetchRequestedAction(payload)), + toggleCompositionUpdate: payload => + dispatch(toggleCompositionUpdate(payload)) }; } diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx index ef5e1168..730d92fb 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx @@ -45,7 +45,9 @@ export default class VersionControllerView extends Component { hasErrors: PropTypes.bool, isArchive: PropTypes.bool, operationMode: PropTypes.bool, - pluginContext: PropTypes.object + pluginContext: PropTypes.object, + isCompositionUpdating: PropTypes.bool, + toggleCompositionUpdate: PropTypes.func }; constructor(props) { @@ -118,7 +120,9 @@ export default class VersionControllerView extends Component { hasErrors, isCertifyDisable, isArchive, - operationMode + operationMode, + isCompositionUpdating, + toggleCompositionUpdate } = this.props; const isReadonly = isCertifyDisable || hasErrors || isArchive; return ( @@ -147,11 +151,13 @@ export default class VersionControllerView extends Component { )} {!operationMode && ( <ActionButtons + isCompositionUpdating={isCompositionUpdating} saveDisabled={isReadonly} onSaveClick={this.sendSaveParamsToServer} certifyDisabled={isReadonly} onCertifyClick={this.certifyVersion} onUndoClick={this.undoClickCallback} + toggleCompositionUpdate={toggleCompositionUpdate} /> )} </div> diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/VersionControllerView_snapshot-test.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/VersionControllerView_snapshot-test.js index 5dfb5737..2bcfa300 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/VersionControllerView_snapshot-test.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/VersionControllerView_snapshot-test.js @@ -16,7 +16,7 @@ import React from 'react'; import renderer from 'react-test-renderer'; -import VersionControllerView from 'features/version/versionController/VersionControllerView'; +import VersionsContainer from 'features/version/versionController/views/VersionsContainer'; describe('Version Controller View Snapshot', () => { it('renders correctly', () => { @@ -27,6 +27,7 @@ describe('Version Controller View Snapshot', () => { description: 'Initial version, bug fix for previous version that fixed an exception when the port was occupied', status: 'Draft', + state: 'Draft', creationTime: 1530687330460, modificationTime: 1530687330575, archivedStatus: 'ACTIVE' @@ -37,6 +38,7 @@ describe('Version Controller View Snapshot', () => { description: 'Test version, bug fix for previous version that fixed an exception when the port was occupied', status: 'Draft', + state: 'Draft', creationTime: 1530687330461, modificationTime: 1530687330576, archivedStatus: 'ACTIVE', @@ -45,7 +47,7 @@ describe('Version Controller View Snapshot', () => { ]; const tree = renderer .create( - <VersionControllerView + <VersionsContainer viewableVersions={versionList} currentWorkflowVersion={versionList[0]} /> diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/__snapshots__/VersionControllerView_snapshot-test.js.snap b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/__snapshots__/VersionControllerView_snapshot-test.js.snap index 1c8ffba3..ea135fce 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/__snapshots__/VersionControllerView_snapshot-test.js.snap +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/__snapshots__/VersionControllerView_snapshot-test.js.snap @@ -2,122 +2,38 @@ exports[`Version Controller View Snapshot renders correctly 1`] = ` <div - className="version-controller-bar" + className="version-section-wrapper" > <div - className="version-section-wrapper" + className="version-status-container" > - <div - className="group-name-wrapper" + version + <select + className="version-selector" + data-test-id="vc-versions-select-box" + onChange={[Function]} + value="7b5f6b086613470985082df2c0f6c713" > - <div - className="group-name" + <option + data-test-id="vc-version-option" + value="7b5f6b086613470985082df2c0f6c713" > - - </div> - </div> - </div> - <div - className="vc-container " - > - <div - className="version-section-wrapper" - > - <div - className="version-status-container" + 1.0 DRAFT + </option> + <option + data-test-id="vc-version-option" + value="7b5f6b086613470985082df2c0f6c666" > - version - <select - className="version-selector" - data-test-id="vc-versions-select-box" - onChange={[Function]} - value="7b5f6b086613470985082df2c0f6c713" - /> - <span - className="version-selector-more-versions" - data-test-id="vc-versions-page-link" - onClick={[Function]} - > - viewOverview - </span> - </div> - </div> - <div - className="save-submit-cancel-container" + 2.0 Draft + </option> + </select> + <span + className="version-selector-more-versions" + data-test-id="vc-versions-page-link" + onClick={undefined} > - <div - className="action-buttons" - > - <div - className="select-action-buttons" - > - <div - className="separator vc-separator" - /> - <div - className="action-button-wrapper clickable" - onClick={[Function]} - > - <div - className="action-buttons-svg" - > - <div - className="svg-icon-wrapper bottom" - data-test-id="vc-save-btn" - disabled={undefined} - onClick={undefined} - > - <test-file-stub - className="svg-icon __version-controller-save" - /> - <span - className="svg-icon-label action-button-label" - > - saveBtn - </span> - </div> - </div> - </div> - <div - className="separator vc-separator" - /> - <div - className="action-button-wrapper clickable" - onClick={[Function]} - > - <div - className="action-buttons-svg" - > - <div - className="svg-icon-wrapper bottom" - data-test-id="vc-undo-btn" - disabled={undefined} - onClick={undefined} - > - <test-file-stub - className="svg-icon __version-controller-undo" - /> - <span - className="svg-icon-label action-button-label" - > - undoBtn - </span> - </div> - </div> - </div> - <div - className="separator vc-separator" - /> - <button - className="sdc-button sdc-button__primary certifyBtn " - disabled={false} - onClick={[Function]} - > - certifyBtn - </button> - </div> - </div> - </div> + viewOverview + </span> </div> </div> `; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js index e2a7dc54..472b3a0b 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js @@ -19,12 +19,15 @@ import { I18n } from 'react-redux-i18n'; import { Button } from 'sdc-ui/lib/react'; import PropTypes from 'prop-types'; import SvgButton from 'features/version/versionController/views/SvgButton'; +import CompositionUpdate from 'features/version/composition/CompositionUpdate'; const ActionButtons = props => { const { onSaveClick, certifyDisabled, onCertifyClick, + isCompositionUpdating, + toggleCompositionUpdate, onUndoClick, saveDisabled } = props; @@ -58,9 +61,18 @@ const ActionButtons = props => { className="certifyBtn" btnType="primary" disabled={certifyDisabled} - onClick={onCertifyClick}> + onClick={() => toggleCompositionUpdate(true)}> {I18n.t('buttons.certifyBtn')} </Button> + + {isCompositionUpdating && ( + <CompositionUpdate + certifyBack={() => { + toggleCompositionUpdate(false); + onCertifyClick(); + }} + /> + )} </div> </div> </div> @@ -72,7 +84,9 @@ ActionButtons.propTypes = { certifyDisabled: PropTypes.bool, onCertifyClick: PropTypes.func, onUndoClick: PropTypes.func, - saveDisabled: PropTypes.bool + saveDisabled: PropTypes.bool, + isCompositionUpdating: PropTypes.bool, + toggleCompositionUpdate: PropTypes.func }; export default ActionButtons; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionReducer.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionReducer.js index c7fccd22..d05af2d7 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionReducer.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionReducer.js @@ -16,9 +16,13 @@ import { SET_CURRENT_VERSION, DETAILS_CHANGED, - VERSION_STATE_CHANGED + VERSION_STATE_CHANGED, + TOGGLE_COMPOSITION_UPDATE } from 'features/version/versionConstants'; -const initialState = {}; + +const initialState = { + isCompositionUpdating: false +}; function versionReducer(state = initialState, action) { switch (action.type) { @@ -34,6 +38,11 @@ function versionReducer(state = initialState, action) { ...state, ...action.payload }; + case TOGGLE_COMPOSITION_UPDATE: + return { + ...state, + isCompositionUpdating: action.payload.isCompositionUpdating + }; default: return state; } |