diff options
Diffstat (limited to 'workflow-designer-ui/src/main/frontend/src/features/version')
80 files changed, 0 insertions, 8070 deletions
diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/Version.js b/workflow-designer-ui/src/main/frontend/src/features/version/Version.js deleted file mode 100644 index 5df68759..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/Version.js +++ /dev/null @@ -1,19 +0,0 @@ -import { connect } from 'react-redux'; -import VersionView from 'features/version/VersionView'; -import { workflowVersionFetchRequestedAction } from 'features/version/versionConstants'; - -const mapStateToProps = ({ currentVersion: { operationMode } }) => { - return { - operationMode - }; -}; - -const mapDispatchToProps = dispatch => ({ - loadSelectedVersion: payload => - dispatch(workflowVersionFetchRequestedAction(payload)) -}); - -export default connect( - mapStateToProps, - mapDispatchToProps -)(VersionView); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/VersionView.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/VersionView.jsx deleted file mode 100644 index 48c671e2..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/VersionView.jsx +++ /dev/null @@ -1,127 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import { Route, matchPath } from 'react-router-dom'; -import { I18n } from 'react-redux-i18n'; - -import NavigationSideBar from 'shared/navigationSideBar/index'; -import VersionController from 'features/version/versionController/VersionController'; - -class VersionView extends React.Component { - componentDidMount() { - const { loadSelectedVersion, match } = this.props; - const workflowId = match.params.workflowId; - const versionId = match.params.versionId; - loadSelectedVersion({ workflowId, versionId }); - } - - onSelect = item => { - const { history, match } = this.props; - - if (!item.disabled) { - history.push( - item.path === '/' ? match.url : `${match.url}${item.path}` - ); - } - }; - - getGroups = () => { - const { routes } = this.props; - - const items = routes.map(route => { - return route.i18nName - ? { - ...route, - name: I18n.t(route.i18nName) - } - : route; - }); - - return [ - { - id: 'WORKFLOW', - items - } - ]; - }; - - getActiveItemIdProps = () => { - const { location, routes, match } = this.props; - - const activeItem = routes.find(route => - matchPath(location.pathname, { - path: `${match.path}${route.path}`, - exact: true, - strict: false - }) - ); - - return activeItem && activeItem.id; - }; - - render() { - const { match, routes, history, operationMode } = this.props; - - const groups = this.getGroups(); - const activeItemId = this.getActiveItemIdProps(); - - return ( - <div className="version-wrapper"> - <VersionController - operationMode={operationMode} - history={history} - match={match} - key="versionControllerView" - /> - - <div - className={`${operationMode ? '' : 'workflow-view'}`} - key="workflowView"> - {!operationMode && ( - <div className="workflow-navigation-side-bar"> - <NavigationSideBar - groups={groups} - activeItemId={activeItemId} - onSelect={this.onSelect} - /> - </div> - )} - {routes.map((route, i) => ( - <Route - key={`Version.route.${i}`} - exact={route.exact} - path={`${match.url}${route.path}`} - component={route.component} - /> - ))} - </div> - </div> - ); - } -} - -VersionView.propTypes = { - history: PropTypes.object, - location: PropTypes.object, - match: PropTypes.object, - routes: PropTypes.array, - loadSelectedVersion: PropTypes.func, - operationMode: PropTypes.bool -}; - -export default VersionView; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/Composition.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/Composition.js deleted file mode 100644 index 97697c70..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/Composition.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -* 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 { connect } from 'react-redux'; -import { I18n } from 'react-redux-i18n'; -import { updateComposition, updateValidation } from './compositionActions'; -import CompositionView from './CompositionView'; -import { showErrorModalAction } from '../../../shared/modal/modalWrapperActions'; -import { getComposition, getErrors } from './compositionSelectors'; -import { getWorkflowName } from '../../workflow/workflowSelectors'; -import { activitiesSelector } from 'features/activities/activitiesSelectors'; -import { getInputOutputForComposition } from 'features/version/inputOutput/inputOutputSelectors'; -import { getVersionInfo } from 'features/version/general/generalSelectors'; -import { getIsCertified } from 'features/version/general/generalSelectors'; -import { isWorkflowArchive } from 'features/workflow/workflowSelectors'; - -function mapStateToProps(state) { - return { - composition: getComposition(state), - name: getWorkflowName(state), - versionName: getVersionInfo(state).name, - activities: activitiesSelector(state), - inputOutput: getInputOutputForComposition(state), - errors: getErrors(state), - isReadOnly: getIsCertified(state) || isWorkflowArchive(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') - }) - ), - validationUpdate: (element, isValid) => - dispatch(updateValidation({ element, isValid })) - }; -} - -export default connect( - mapStateToProps, - mapDispatchToProps -)(CompositionView); 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 deleted file mode 100644 index e5756eb5..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/CompositionUpdate.js +++ /dev/null @@ -1,131 +0,0 @@ -/* -* 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/composition/CompositionView.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/CompositionView.js deleted file mode 100644 index e444d98c..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/CompositionView.js +++ /dev/null @@ -1,284 +0,0 @@ -/* -* 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 fileSaver from 'file-saver'; -import isEqual from 'lodash.isequal'; -import PropTypes from 'prop-types'; -import propertiesPanelModule from 'bpmn-js-properties-panel'; -import { I18n } from 'react-redux-i18n'; - -import CustomModeler from './custom-modeler'; -import propertiesProviderModule from './custom-properties-provider/provider/camunda'; -import camundaModuleDescriptor from './custom-properties-provider/descriptors/camunda'; -import newDiagramXML from './newDiagram.bpmn'; -import CompositionButtons from './components/CompositionButtonsPanel'; -import { setElementInputsOutputs } from './bpmnUtils.js'; -import { - PROCESS_DEFAULT_ID, - COMPOSITION_ERROR_COLOR, - COMPOSITION_VALID_COLOR, - CAMUNDA_PANEL_INPUTS_NAMES -} from './compositionConstants'; -import readOnly from './readOnly'; - -function setStatusToElement(type, status, parent) { - let elements = parent.getElementsByTagName(type); - for (let item of elements) { - if (item.name !== 'selectedExtensionElement') { - item.readOnly = status; - item.disabled = status; - } - } -} - -function disablePanelInputs(status) { - let panel = document.getElementById('js-properties-panel'); - - if (panel) { - setStatusToElement('input', status, panel); - setStatusToElement('button', status, panel); - setStatusToElement('select', status, panel); - - //distinguish editable and clickable fields using attr and style - CAMUNDA_PANEL_INPUTS_NAMES.map(name => { - const div = document.getElementById(name); - if (div) { - div.setAttribute('editable-readonly', !status); - } - }); - } -} -class CompositionView extends Component { - static propTypes = { - compositionUpdate: PropTypes.func, - showErrorModal: PropTypes.func, - composition: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), - name: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), - versionName: PropTypes.string, - inputOutput: PropTypes.object, - activities: PropTypes.array, - validationUpdate: PropTypes.func, - errors: PropTypes.array, - isReadOnly: PropTypes.bool - }; - - constructor(props) { - super(props); - this.generatedId = 'bpmn-container' + Date.now(); - this.fileInput = React.createRef(); - this.bpmnContainer = React.createRef(); - this.versionChanged = false; - } - componentDidUpdate(prevProps) { - const { errors, isReadOnly, versionName, composition } = this.props; - if (!isEqual(prevProps.errors, errors)) { - errors.map(item => { - this.modeling.setColor([item.element], { - fill: item.isValid - ? COMPOSITION_VALID_COLOR - : COMPOSITION_ERROR_COLOR - }); - }); - } - if (prevProps.isReadOnly !== isReadOnly) { - this.modeler.get('readOnly').readOnly(isReadOnly); - disablePanelInputs(isReadOnly); - } - - if (prevProps.versionName !== versionName) { - this.versionChanged = true; - } - if ( - !isEqual(prevProps.composition, composition) && - this.versionChanged - ) { - this.setDiagramToBPMN(composition); - this.versionChanged = false; - } - } - componentDidMount() { - const { - composition, - activities, - inputOutput, - validationUpdate, - isReadOnly - } = this.props; - - const readOnlyModule = { - __init__: ['readOnly'], - readOnly: ['type', readOnly] - }; - this.modeler = new CustomModeler({ - propertiesPanel: { - parent: '#js-properties-panel' - }, - additionalModules: [ - propertiesPanelModule, - propertiesProviderModule, - readOnlyModule - ], - moddleExtensions: { - camunda: camundaModuleDescriptor - }, - workflow: { - activities: activities, - getActivityInputsOutputs: this.getActivityInputsOutputs, - workflowInputOutput: inputOutput, - validationUpdate: validationUpdate - } - }); - - this.modeler.attachTo('#' + this.generatedId); - this.setDiagramToBPMN(composition); - this.modeler.on('element.out', () => this.exportDiagramToStore()); - this.modeler.on('element.click', this.handleCompositionStatus); - this.modeler.on( - 'propertiesPanel.changed', - this.handleCompositionStatus - ); - this.modeling = this.modeler.get('modeling'); - this.modeler.get('readOnly').readOnly(isReadOnly); - } - handleCompositionStatus = () => { - disablePanelInputs(this.props.isReadOnly); - }; - getActivityInputsOutputs = selectedValue => { - const selectedActivity = this.props.activities.find( - el => el.name === selectedValue - ); - - if (selectedActivity) { - const inputsOutputs = { - inputs: selectedActivity.inputs, - outputs: selectedActivity.outputs - }; - return inputsOutputs; - } else return { inputs: [], outputs: [] }; - }; - - 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'); - canvas.zoom('fit-viewport'); - const { businessObject } = canvas._rootElement; - - this.setDefaultIdAndName(businessObject); - setElementInputsOutputs( - businessObject, - this.props.inputOutput, - this.modeler.get('moddle') - ); - disablePanelInputs(this.props.isReadOnly); - }); - }; - setDefaultIdAndName = businessObject => { - const { name = '' } = this.props; - if (!businessObject.name) { - businessObject.name = name; - } - - if (businessObject.id === PROCESS_DEFAULT_ID || !businessObject.id) { - businessObject.id = name.toLowerCase().replace(/\s/g, '_'); - } - }; - exportDiagramToStore = () => { - this.modeler.saveXML({ format: true }, (err, xml) => { - if (err) { - return this.props.showErrorModal( - I18n.t('workflow.composition.saveErrorMsg') - ); - } - return this.props.compositionUpdate(xml); - }); - }; - - exportDiagram = () => { - const { name, showErrorModal, versionName } = this.props; - this.modeler.saveXML({ format: true }, (err, xml) => { - if (err) { - return showErrorModal( - I18n.t('workflow.composition.exportErrorMsg') - ); - } - const blob = new Blob([xml], { type: 'text/html;charset=utf-8' }); - fileSaver.saveAs( - blob, - `${name.replace(/\s/g, '').toLowerCase()}-${versionName}.bpmn` - ); - }); - }; - - loadNewDiagram = () => { - this.setDiagramToBPMN(newDiagramXML); - }; - - uploadDiagram = () => { - this.fileInput.current.click(); - }; - - handleFileInputChange = filesList => { - const file = filesList[0]; - const reader = new FileReader(); - reader.onloadend = event => { - var xml = event.target.result; - this.setDiagramToBPMN(xml); - this.fileInput.value = ''; - }; - reader.readAsText(file); - }; - - render() { - return ( - <div className="composition-view content"> - <input - ref={this.fileInput} - onChange={e => this.handleFileInputChange(e.target.files)} - id="file-input" - accept=".bpmn, .xml" - type="file" - name="file-input" - style={{ display: 'none' }} - /> - <div - ref={this.bpmnContainer} - className="bpmn-container" - id={this.generatedId} - /> - <div className="bpmn-sidebar"> - <div - className="properties-panel" - id="js-properties-panel" - /> - <CompositionButtons - isReadOnly={this.props.isReadOnly} - onClean={this.loadNewDiagram} - onDownload={this.exportDiagram} - onUpload={this.uploadDiagram} - /> - </div> - </div> - ); - } -} - -export default CompositionView; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/bpmnUtils.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/bpmnUtils.js deleted file mode 100644 index ada2bdc4..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/bpmnUtils.js +++ /dev/null @@ -1,93 +0,0 @@ -/* -* 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 { bpmnElementsTypes } from './compositionConstants'; -function getExtension(element, type) { - if (!element.extensionElements || !element.extensionElements.values) { - return null; - } - - return element.extensionElements.values.filter(function(e) { - return e.$instanceOf(type); - })[0]; -} - -export function updatedData(moddle, inputData, existingArray, type, parent) { - return inputData.map(item => { - const existingInput = existingArray.find(el => el.name === item.name); - const updatedElement = moddle.create( - type, - existingInput ? { ...item, value: existingInput.value } : item - ); - updatedElement.$parent = parent; - return updatedElement; - }); -} - -export function setElementInputsOutputs( - businessObject, - inputOutput, - moddle, - cleanInputsOutpus -) { - const { inputs = [], outputs = [] } = inputOutput; - - if (!businessObject.extensionElements) { - businessObject.extensionElements = moddle.create( - bpmnElementsTypes.EXTENSION_ElEMENTS - ); - businessObject.extensionElements.$parent = businessObject.id; - } - - const existingInputOutput = getExtension( - businessObject, - bpmnElementsTypes.INPUT_OUTPUT - ); - - const processInputs = updatedData( - moddle, - inputs, - cleanInputsOutpus - ? [] - : (existingInputOutput && existingInputOutput.inputParameters) || - [], - bpmnElementsTypes.INPUT_PARAMETER, - businessObject.id - ); - - const processOutputs = updatedData( - moddle, - outputs, - cleanInputsOutpus - ? [] - : (existingInputOutput && existingInputOutput.outputParameters) || - [], - bpmnElementsTypes.OUTPUT_PARAMETER, - businessObject.id - ); - - const processInputOutput = moddle.create(bpmnElementsTypes.INPUT_OUTPUT); - processInputOutput.$parent = businessObject.id; - processInputOutput.inputParameters = [...processInputs]; - processInputOutput.outputParameters = [...processOutputs]; - - const extensionElements = businessObject.extensionElements.get('values'); - businessObject.extensionElements.set( - 'values', - extensionElements - .filter(item => item.$type !== bpmnElementsTypes.INPUT_OUTPUT) - .concat(processInputOutput) - ); -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/components/CompositionButton.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/components/CompositionButton.js deleted file mode 100644 index 62500d25..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/components/CompositionButton.js +++ /dev/null @@ -1,36 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import { SVGIcon } from 'onap-ui-react'; - -const CompositionButton = ({ onClick, name, title, disabled }) => ( - <div - onClick={disabled ? () => {} : onClick} - className={`diagram-btn ${disabled ? 'disabled' : ''}`}> - <SVGIcon title={title} name={name} /> - </div> -); - -CompositionButton.propTypes = { - onClick: PropTypes.func, - className: PropTypes.string, - name: PropTypes.string, - title: PropTypes.string, - disabled: PropTypes.bool -}; - -export default CompositionButton; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/components/CompositionButtonsPanel.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/components/CompositionButtonsPanel.js deleted file mode 100644 index 0292fd4e..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/components/CompositionButtonsPanel.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import CompositionButton from './CompositionButton'; - -const Divider = () => <div className="divider" />; - -const CompositionButtons = ({ onClean, onUpload, onDownload, isReadOnly }) => ( - <div className="composition-buttons"> - <CompositionButton - disabled={isReadOnly} - data-test-id="composition-clear-btn" - onClick={onClean} - name="trashO" - title="clear" - /> - - <Divider /> - <CompositionButton - data-test-id="composition-download-btn" - onClick={onDownload} - name="download" - title="download" - /> - <Divider /> - <CompositionButton - disabled={isReadOnly} - data-test-id="composition-download-upload" - onClick={onUpload} - name="upload" - title="upload" - /> - </div> -); - -CompositionButtons.propTypes = { - onClean: PropTypes.func, - onUpload: PropTypes.func, - onDownload: PropTypes.func, - isReadOnly: PropTypes.bool -}; -export default CompositionButtons; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionActions.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionActions.js deleted file mode 100644 index fe74ba0d..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionActions.js +++ /dev/null @@ -1,34 +0,0 @@ -/* -* 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 { - SET_COMPOSITION, - UPDATE_ERRORS, - DELETE_COMPOSITION -} from './compositionConstants'; - -export const updateComposition = payload => ({ - type: SET_COMPOSITION, - payload -}); - -export const deleteCompositionArtifact = () => ({ - type: DELETE_COMPOSITION -}); - -export const updateValidation = payload => ({ - type: UPDATE_ERRORS, - payload -}); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionConstants.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionConstants.js deleted file mode 100644 index 1db40210..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionConstants.js +++ /dev/null @@ -1,38 +0,0 @@ -/* -* 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. -*/ -export const SET_COMPOSITION = 'composition/SET_COMPOSITION'; -export const DELETE_COMPOSITION = 'composition/DELETE_COMPOSITION'; -export const UPDATE_ERRORS = 'composition/UPDATE_ERRORS'; - -export const bpmnElementsTypes = { - EXTENSION_ElEMENTS: 'bpmn:ExtensionElements', - INPUT_OUTPUT: 'camunda:InputOutput', - INPUT_PARAMETER: 'camunda:InputParameter', - OUTPUT_PARAMETER: 'camunda:OutputParameter' -}; - -export const PROCESS_DEFAULT_ID = 'Process_1'; - -export const COMPOSITION_ERROR_COLOR = '#f0c2c2'; -export const COMPOSITION_VALID_COLOR = 'white'; - -//list of field ids (contenteditable) that has separate treatment -export const CAMUNDA_PANEL_INPUTS_NAMES = [ - 'camunda-parameterType-text', - 'camunda-documentation', - 'camunda-name', - 'camunda-listener-field-value' -]; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionReducer.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionReducer.js deleted file mode 100644 index 9deb9cbd..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionReducer.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -* 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 { SET_COMPOSITION, DELETE_COMPOSITION } from './compositionConstants'; -import { UPDATE_ERRORS } from './compositionConstants'; -import newDiagramXML from './newDiagram.bpmn'; - -export default (state = { diagram: newDiagramXML, errors: [] }, action) => { - switch (action.type) { - case SET_COMPOSITION: - return { - ...state, - diagram: action.payload - }; - case DELETE_COMPOSITION: - return { - ...state, - diagram: newDiagramXML - }; - case UPDATE_ERRORS: { - const filteredErrors = state.errors.filter( - item => item.element.id !== action.payload.element.id - ); - return { - ...state, - errors: [...filteredErrors, action.payload] - }; - } - default: - return state; - } -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionSelectors.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionSelectors.js deleted file mode 100644 index e6b51f1a..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/compositionSelectors.js +++ /dev/null @@ -1,32 +0,0 @@ -/* -* 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. -*/ -export const getComposition = state => - state && state.currentVersion && state.currentVersion.composition.diagram; - -export const getCompositionHasErrors = state => - state && - state.currentVersion && - state.currentVersion.composition && - state.currentVersion.composition.errors && - Boolean( - state.currentVersion.composition.errors.find(item => !item.isValid) - ); - -export const getErrors = state => - state && - state.currentVersion && - state.currentVersion.composition && - state.currentVersion.composition.errors; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomContextPadProvider.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomContextPadProvider.js deleted file mode 100644 index 0f2ba528..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomContextPadProvider.js +++ /dev/null @@ -1,43 +0,0 @@ -import inherits from 'inherits';
-
-import ContextPadProvider from 'bpmn-js/lib/features/context-pad/ContextPadProvider';
-
-import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil';
-
-import { assign, bind } from 'min-dash';
-
-export default function CustomContextPadProvider(injector, connect, translate) {
- injector.invoke(ContextPadProvider, this);
-
- var cached = bind(this.getContextPadEntries, this);
-
- this.getContextPadEntries = function(element) {
- var actions = cached(element);
-
- var businessObject = element.businessObject;
-
- function startConnect(event, element, autoActivate) {
- connect.start(event, element, autoActivate);
- }
-
- if (isAny(businessObject, ['custom:triangle', 'custom:circle'])) {
- assign(actions, {
- connect: {
- group: 'connect',
- className: 'bpmn-icon-connection-multi',
- title: translate('Connect using custom connection'),
- action: {
- click: startConnect,
- dragstart: startConnect
- }
- }
- });
- }
-
- return actions;
- };
-}
-
-inherits(CustomContextPadProvider, ContextPadProvider);
-
-CustomContextPadProvider.$inject = ['injector', 'connect', 'translate'];
diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomElementFactory.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomElementFactory.js deleted file mode 100644 index 01d4d278..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomElementFactory.js +++ /dev/null @@ -1,101 +0,0 @@ -import { assign } from 'min-dash'; - -import inherits from 'inherits'; - -import BpmnElementFactory from 'bpmn-js/lib/features/modeling/ElementFactory'; -import { DEFAULT_LABEL_SIZE } from 'bpmn-js/lib/util/LabelUtil'; - -/** - * A custom factory that knows how to create BPMN _and_ custom elements. - */ -export default function CustomElementFactory(bpmnFactory, moddle) { - BpmnElementFactory.call(this, bpmnFactory, moddle); - - var self = this; - - /** - * Create a diagram-js element with the given type (any of shape, connection, label). - * - * @param {String} elementType - * @param {Object} attrs - * - * @return {djs.model.Base} - */ - this.create = function(elementType, attrs) { - var type = attrs.type; - - if (elementType === 'label') { - return self.baseCreate( - elementType, - assign({ type: 'label' }, DEFAULT_LABEL_SIZE, attrs) - ); - } - - // add type to businessObject if custom - if (/^custom:/.test(type)) { - if (!attrs.businessObject) { - attrs.businessObject = { - type: type - }; - - if (attrs.id) { - assign(attrs.businessObject, { - id: attrs.id - }); - } - } - - // add width and height if shape - if (!/:connection$/.test(type)) { - assign(attrs, self._getCustomElementSize(type)); - } - - if (!('$instanceOf' in attrs.businessObject)) { - // ensure we can use ModelUtil#is for type checks - Object.defineProperty(attrs.businessObject, '$instanceOf', { - value: function(type) { - return this.type === type; - } - }); - } - - return self.baseCreate(elementType, attrs); - } - - return self.createBpmnElement(elementType, attrs); - }; -} - -inherits(CustomElementFactory, BpmnElementFactory); - -CustomElementFactory.$inject = ['bpmnFactory', 'moddle']; - -/** - * Returns the default size of custom shapes. - * - * The following example shows an interface on how - * to setup the custom shapes's dimensions. - * - * @example - * - * var shapes = { - * triangle: { width: 40, height: 40 }, - * rectangle: { width: 100, height: 20 } - * }; - * - * return shapes[type]; - * - * - * @param {String} type - * - * @return {Dimensions} a {width, height} object representing the size of the element - */ -CustomElementFactory.prototype._getCustomElementSize = function(type) { - var shapes = { - __default: { width: 100, height: 80 }, - 'custom:triangle': { width: 40, height: 40 }, - 'custom:circle': { width: 140, height: 140 } - }; - - return shapes[type] || shapes.__default; -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomPalette.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomPalette.js deleted file mode 100644 index a8adb2fd..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomPalette.js +++ /dev/null @@ -1,151 +0,0 @@ -import { assign } from 'min-dash'; - -/** - * A palette that allows you to create BPMN _and_ custom elements. - */ -export default function PaletteProvider( - palette, - create, - elementFactory, - spaceTool, - lassoTool, - handTool, - globalConnect, - translate -) { - this._create = create; - this._elementFactory = elementFactory; - this._spaceTool = spaceTool; - this._lassoTool = lassoTool; - this._handTool = handTool; - this._globalConnect = globalConnect; - this._translate = translate; - - palette.registerProvider(this); -} - -PaletteProvider.$inject = [ - 'palette', - 'create', - 'elementFactory', - 'spaceTool', - 'lassoTool', - 'handTool', - 'globalConnect', - 'translate' -]; - -PaletteProvider.prototype.getPaletteEntries = function() { - var actions = {}, - create = this._create, - elementFactory = this._elementFactory, - spaceTool = this._spaceTool, - lassoTool = this._lassoTool, - handTool = this._handTool, - globalConnect = this._globalConnect, - translate = this._translate; - - function createAction(type, group, className, title, options) { - function createListener(event) { - var shape = elementFactory.createShape( - assign({ type: type }, options) - ); - - if (options) { - shape.businessObject.di.isExpanded = options.isExpanded; - } - - create.start(event, shape); - } - - var shortType = type.replace(/^bpmn:/, ''); - - return { - group: group, - className: className, - title: title || 'Create ' + shortType, - action: { - dragstart: createListener, - click: createListener - } - }; - } - - assign(actions, { - 'hand-tool': { - group: 'tools', - className: 'bpmn-icon-hand-tool', - title: translate('Activate the hand tool'), - action: { - click: function(event) { - handTool.activateHand(event); - } - } - }, - 'lasso-tool': { - group: 'tools', - className: 'bpmn-icon-lasso-tool', - title: translate('Activate the lasso tool'), - action: { - click: function(event) { - lassoTool.activateSelection(event); - } - } - }, - 'space-tool': { - group: 'tools', - className: 'bpmn-icon-space-tool', - title: translate('Activate the create/remove space tool'), - action: { - click: function(event) { - spaceTool.activateSelection(event); - } - } - }, - 'global-connect-tool': { - group: 'tools', - className: 'bpmn-icon-connection-multi', - title: translate('Activate the global connect tool'), - action: { - click: function(event) { - globalConnect.toggle(event); - } - } - }, - 'tool-separator': { - group: 'tools', - separator: true - }, - 'create.start-event': createAction( - 'bpmn:StartEvent', - 'event', - 'bpmn-icon-start-event-none' - ), - 'create.intermediate-event': createAction( - 'bpmn:IntermediateThrowEvent', - 'event', - 'bpmn-icon-intermediate-event-none', - translate('Create Intermediate/Boundary Event') - ), - 'create.end-event': createAction( - 'bpmn:EndEvent', - 'event', - 'bpmn-icon-end-event-none' - ), - 'create.exclusive-gateway': createAction( - 'bpmn:ExclusiveGateway', - 'gateway', - 'bpmn-icon-gateway-none', - translate('Create Gateway') - ), - 'create.task': createAction('bpmn:Task', 'activity', 'bpmn-icon-task'), - 'create.subprocess-expanded': createAction( - 'bpmn:SubProcess', - 'activity', - 'bpmn-icon-subprocess-expanded', - translate('Create expanded SubProcess'), - { isExpanded: true } - ) - }); - return actions; -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomRenderer.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomRenderer.js deleted file mode 100644 index f397fed9..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomRenderer.js +++ /dev/null @@ -1,176 +0,0 @@ -import inherits from 'inherits'; - -import BaseRenderer from 'diagram-js/lib/draw/BaseRenderer'; - -import { componentsToPath, createLine } from 'diagram-js/lib/util/RenderUtil'; - -import { - append as svgAppend, - attr as svgAttr, - create as svgCreate -} from 'tiny-svg'; - -/** - * A renderer that knows how to render custom elements. - */ -export default function CustomRenderer(eventBus, styles) { - BaseRenderer.call(this, eventBus, 2000); - - var computeStyle = styles.computeStyle; - - this.drawTriangle = function(p, side) { - var halfSide = side / 2, - points, - attrs; - - points = [halfSide, 0, side, side, 0, side]; - - attrs = computeStyle(attrs, { - stroke: '#3CAA82', - strokeWidth: 2, - fill: '#3CAA82' - }); - - var polygon = svgCreate('polygon'); - - svgAttr(polygon, { - points: points - }); - - svgAttr(polygon, attrs); - - svgAppend(p, polygon); - - return polygon; - }; - - this.getTrianglePath = function(element) { - var x = element.x, - y = element.y, - width = element.width, - height = element.height; - - var trianglePath = [ - ['M', x + width / 2, y], - ['l', width / 2, height], - ['l', -width, 0], - ['z'] - ]; - - return componentsToPath(trianglePath); - }; - - this.drawCircle = function(p, width, height) { - var cx = width / 2, - cy = height / 2; - - var attrs = computeStyle(attrs, { - stroke: '#4488aa', - strokeWidth: 4, - fill: 'white' - }); - - var circle = svgCreate('circle'); - - svgAttr(circle, { - cx: cx, - cy: cy, - r: Math.round((width + height) / 4) - }); - - svgAttr(circle, attrs); - - svgAppend(p, circle); - - return circle; - }; - - this.getCirclePath = function(shape) { - var cx = shape.x + shape.width / 2, - cy = shape.y + shape.height / 2, - radius = shape.width / 2; - - var circlePath = [ - ['M', cx, cy], - ['m', 0, -radius], - ['a', radius, radius, 0, 1, 1, 0, 2 * radius], - ['a', radius, radius, 0, 1, 1, 0, -2 * radius], - ['z'] - ]; - - return componentsToPath(circlePath); - }; - - this.drawCustomConnection = function(p, element) { - var attrs = computeStyle(attrs, { - stroke: '#ff471a', - strokeWidth: 2 - }); - - return svgAppend(p, createLine(element.waypoints, attrs)); - }; - - this.getCustomConnectionPath = function(connection) { - var waypoints = connection.waypoints.map(function(p) { - return p.original || p; - }); - - var connectionPath = [['M', waypoints[0].x, waypoints[0].y]]; - - waypoints.forEach(function(waypoint, index) { - if (index !== 0) { - connectionPath.push(['L', waypoint.x, waypoint.y]); - } - }); - - return componentsToPath(connectionPath); - }; -} - -inherits(CustomRenderer, BaseRenderer); - -CustomRenderer.$inject = ['eventBus', 'styles']; - -CustomRenderer.prototype.canRender = function(element) { - return /^custom:/.test(element.type); -}; - -CustomRenderer.prototype.drawShape = function(p, element) { - var type = element.type; - - if (type === 'custom:triangle') { - return this.drawTriangle(p, element.width); - } - - if (type === 'custom:circle') { - return this.drawCircle(p, element.width, element.height); - } -}; - -CustomRenderer.prototype.getShapePath = function(shape) { - var type = shape.type; - - if (type === 'custom:triangle') { - return this.getTrianglePath(shape); - } - - if (type === 'custom:circle') { - return this.getCirclePath(shape); - } -}; - -CustomRenderer.prototype.drawConnection = function(p, element) { - var type = element.type; - - if (type === 'custom:connection') { - return this.drawCustomConnection(p, element); - } -}; - -CustomRenderer.prototype.getConnectionPath = function(connection) { - var type = connection.type; - - if (type === 'custom:connection') { - return this.getCustomConnectionPath(connection); - } -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomRules.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomRules.js deleted file mode 100644 index 1dce143d..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomRules.js +++ /dev/null @@ -1,136 +0,0 @@ -import { reduce } from 'min-dash'; - -import inherits from 'inherits'; - -import { is } from 'bpmn-js/lib/util/ModelUtil'; - -import RuleProvider from 'diagram-js/lib/features/rules/RuleProvider'; - -var HIGH_PRIORITY = 1500; - -function isCustom(element) { - return element && /^custom:/.test(element.type); -} - -/** - * Specific rules for custom elements - */ -export default function CustomRules(eventBus) { - RuleProvider.call(this, eventBus); -} - -inherits(CustomRules, RuleProvider); - -CustomRules.$inject = ['eventBus']; - -CustomRules.prototype.init = function() { - /** - * Can shape be created on target container? - */ - function canCreate(shape, target) { - // only judge about custom elements - if (!isCustom(shape)) { - return; - } - - // allow creation on processes - return ( - is(target, 'bpmn:Process') || - is(target, 'bpmn:Participant') || - is(target, 'bpmn:Collaboration') - ); - } - - /** - * Can source and target be connected? - */ - function canConnect(source, target) { - // only judge about custom elements - if (!isCustom(source) && !isCustom(target)) { - return; - } - - // allow connection between custom shape and task - if (isCustom(source)) { - if (is(target, 'bpmn:Task')) { - return { type: 'custom:connection' }; - } else { - return false; - } - } else if (isCustom(target)) { - if (is(source, 'bpmn:Task')) { - return { type: 'custom:connection' }; - } else { - return false; - } - } - } - - this.addRule('elements.move', HIGH_PRIORITY, function(context) { - var target = context.target, - shapes = context.shapes; - - var type; - - // do not allow mixed movements of custom / BPMN shapes - // if any shape cannot be moved, the group cannot be moved, too - var allowed = reduce( - shapes, - function(result, s) { - if (type === undefined) { - type = isCustom(s); - } - - if (type !== isCustom(s) || result === false) { - return false; - } - - return canCreate(s, target); - }, - undefined - ); - - // reject, if we have at least one - // custom element that cannot be moved - return allowed; - }); - - this.addRule('shape.create', HIGH_PRIORITY, function(context) { - var target = context.target, - shape = context.shape; - - return canCreate(shape, target); - }); - - this.addRule('shape.resize', HIGH_PRIORITY, function(context) { - var shape = context.shape; - - if (isCustom(shape)) { - // cannot resize custom elements - return false; - } - }); - - this.addRule('connection.create', HIGH_PRIORITY, function(context) { - var source = context.source, - target = context.target; - - return canConnect(source, target); - }); - - this.addRule('connection.reconnectStart', HIGH_PRIORITY, function(context) { - var connection = context.connection, - source = context.hover || context.source, - target = connection.target; - - return canConnect(source, target, connection); - }); - - this.addRule('connection.reconnectEnd', HIGH_PRIORITY, function(context) { - var connection = context.connection, - source = connection.source, - target = context.hover || context.target; - - return canConnect(source, target, connection); - }); -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomUpdater.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomUpdater.js deleted file mode 100644 index 532c24f3..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/CustomUpdater.js +++ /dev/null @@ -1,136 +0,0 @@ -import inherits from 'inherits'; - -import { pick, assign } from 'min-dash'; - -import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; - -import { - add as collectionAdd, - remove as collectionRemove -} from 'diagram-js/lib/util/Collections'; - -/** - * A handler responsible for updating the custom element's businessObject - * once changes on the diagram happen. - */ -export default function CustomUpdater(eventBus, bpmnjs) { - CommandInterceptor.call(this, eventBus); - - function updateCustomElement(e) { - var context = e.context, - shape = context.shape, - businessObject = shape.businessObject; - - if (!isCustom(shape)) { - return; - } - - var parent = shape.parent; - - var customElements = bpmnjs._customElements; - - // make sure element is added / removed from bpmnjs.customElements - if (!parent) { - collectionRemove(customElements, businessObject); - } else { - collectionAdd(customElements, businessObject); - } - - // save custom element position - assign(businessObject, pick(shape, ['x', 'y'])); - } - - function updateCustomConnection(e) { - var context = e.context, - connection = context.connection, - source = connection.source, - target = connection.target, - businessObject = connection.businessObject; - - var parent = connection.parent; - - var customElements = bpmnjs._customElements; - - // make sure element is added / removed from bpmnjs.customElements - if (!parent) { - collectionRemove(customElements, businessObject); - } else { - collectionAdd(customElements, businessObject); - } - - // update waypoints - assign(businessObject, { - waypoints: copyWaypoints(connection) - }); - - if (source && target) { - assign(businessObject, { - source: source.id, - target: target.id - }); - } - } - - this.executed( - ['shape.create', 'shape.move', 'shape.delete'], - ifCustomElement(updateCustomElement) - ); - - this.reverted( - ['shape.create', 'shape.move', 'shape.delete'], - ifCustomElement(updateCustomElement) - ); - - this.executed( - [ - 'connection.create', - 'connection.reconnectStart', - 'connection.reconnectEnd', - 'connection.updateWaypoints', - 'connection.delete', - 'connection.layout', - 'connection.move' - ], - ifCustomElement(updateCustomConnection) - ); - - this.reverted( - [ - 'connection.create', - 'connection.reconnectStart', - 'connection.reconnectEnd', - 'connection.updateWaypoints', - 'connection.delete', - 'connection.layout', - 'connection.move' - ], - ifCustomElement(updateCustomConnection) - ); -} - -inherits(CustomUpdater, CommandInterceptor); - -CustomUpdater.$inject = ['eventBus', 'bpmnjs']; - -/////// helpers /////////////////////////////////// - -function copyWaypoints(connection) { - return connection.waypoints.map(function(p) { - return { x: p.x, y: p.y }; - }); -} - -function isCustom(element) { - return element && /custom:/.test(element.type); -} - -function ifCustomElement(fn) { - return function(event) { - var context = event.context, - element = context.shape || context.connection; - - if (isCustom(element)) { - fn(event); - } - }; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/index.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/index.js deleted file mode 100644 index f1085390..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/custom/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import CustomElementFactory from './CustomElementFactory'; -import CustomRenderer from './CustomRenderer'; -import CustomPalette from './CustomPalette'; -import CustomRules from './CustomRules'; -import CustomUpdater from './CustomUpdater'; -import CustomContextPadProvider from './CustomContextPadProvider'; - -export default { - __init__: [ - 'customRenderer', - 'paletteProvider', - 'customRules', - 'customUpdater', - 'contextPadProvider' - ], - elementFactory: ['type', CustomElementFactory], - customRenderer: ['type', CustomRenderer], - paletteProvider: ['type', CustomPalette], - customRules: ['type', CustomRules], - customUpdater: ['type', CustomUpdater], - contextPadProvider: ['type', CustomContextPadProvider] -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/index.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/index.js deleted file mode 100644 index 86fbff6a..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-modeler/index.js +++ /dev/null @@ -1,99 +0,0 @@ -import Modeler from 'bpmn-js/lib/Modeler'; - -import { assign, isArray } from 'min-dash'; - -import inherits from 'inherits'; - -import CustomModule from './custom'; - -export default function CustomModeler(options) { - Modeler.call(this, options); - - this._customElements = []; -} - -inherits(CustomModeler, Modeler); - -CustomModeler.prototype._modules = [].concat(CustomModeler.prototype._modules, [ - CustomModule -]); - -/** - * Add a single custom element to the underlying diagram - * - * @param {Object} customElement - */ -CustomModeler.prototype._addCustomShape = function(customElement) { - this._customElements.push(customElement); - - var canvas = this.get('canvas'), - elementFactory = this.get('elementFactory'); - - var customAttrs = assign({ businessObject: customElement }, customElement); - - var customShape = elementFactory.create('shape', customAttrs); - - return canvas.addShape(customShape); -}; - -CustomModeler.prototype._addCustomConnection = function(customElement) { - this._customElements.push(customElement); - - var canvas = this.get('canvas'), - elementFactory = this.get('elementFactory'), - elementRegistry = this.get('elementRegistry'); - - var customAttrs = assign({ businessObject: customElement }, customElement); - - var connection = elementFactory.create( - 'connection', - assign(customAttrs, { - source: elementRegistry.get(customElement.source), - target: elementRegistry.get(customElement.target) - }), - elementRegistry.get(customElement.source).parent - ); - - return canvas.addConnection(connection); -}; - -/** - * Add a number of custom elements and connections to the underlying diagram. - * - * @param {Array<Object>} customElements - */ -CustomModeler.prototype.addCustomElements = function(customElements) { - if (!isArray(customElements)) { - throw new Error('argument must be an array'); - } - - var shapes = [], - connections = []; - - customElements.forEach(function(customElement) { - if (isCustomConnection(customElement)) { - connections.push(customElement); - } else { - shapes.push(customElement); - } - }); - - // add shapes before connections so that connections - // can already rely on the shapes being part of the diagram - shapes.forEach(this._addCustomShape, this); - - connections.forEach(this._addCustomConnection, this); -}; - -/** - * Get custom elements with their current status. - * - * @return {Array<Object>} custom elements on the diagram - */ -CustomModeler.prototype.getCustomElements = function() { - return this._customElements; -}; - -function isCustomConnection(element) { - return element.type === 'custom:connection'; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/descriptors/camunda.json b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/descriptors/camunda.json deleted file mode 100644 index 6613c4bf..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/descriptors/camunda.json +++ /dev/null @@ -1,1025 +0,0 @@ -{ - "name": "Camunda", - "uri": "http://camunda.org/schema/1.0/bpmn", - "prefix": "camunda", - "xml": { - "tagAlias": "lowerCase" - }, - "associations": [], - "types": [ - { - "name": "InOutBinding", - "superClass": ["Element"], - "isAbstract": true, - "properties": [ - { - "name": "source", - "isAttr": true, - "type": "String" - }, - { - "name": "sourceExpression", - "isAttr": true, - "type": "String" - }, - { - "name": "target", - "isAttr": true, - "type": "String" - }, - { - "name": "businessKey", - "isAttr": true, - "type": "String" - }, - { - "name": "local", - "isAttr": true, - "type": "Boolean", - "default": false - }, - { - "name": "variables", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "In", - "superClass": ["InOutBinding"], - "meta": { - "allowedIn": ["bpmn:CallActivity"] - } - }, - { - "name": "Out", - "superClass": ["InOutBinding"], - "meta": { - "allowedIn": ["bpmn:CallActivity"] - } - }, - { - "name": "AsyncCapable", - "isAbstract": true, - "extends": ["bpmn:Activity", "bpmn:Gateway", "bpmn:Event"], - "properties": [ - { - "name": "async", - "isAttr": true, - "type": "Boolean", - "default": false - }, - { - "name": "asyncBefore", - "isAttr": true, - "type": "Boolean", - "default": false - }, - { - "name": "asyncAfter", - "isAttr": true, - "type": "Boolean", - "default": false - }, - { - "name": "exclusive", - "isAttr": true, - "type": "Boolean", - "default": true - } - ] - }, - { - "name": "JobPriorized", - "isAbstract": true, - "extends": ["bpmn:Process", "camunda:AsyncCapable"], - "properties": [ - { - "name": "jobPriority", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "SignalEventDefinition", - "isAbstract": true, - "extends": ["bpmn:SignalEventDefinition"], - "properties": [ - { - "name": "async", - "isAttr": true, - "type": "Boolean", - "default": false - } - ] - }, - { - "name": "ErrorEventDefinition", - "isAbstract": true, - "extends": ["bpmn:ErrorEventDefinition"], - "properties": [ - { - "name": "errorCodeVariable", - "isAttr": true, - "type": "String" - }, - { - "name": "errorMessageVariable", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "PotentialStarter", - "superClass": ["Element"], - "properties": [ - { - "name": "resourceAssignmentExpression", - "type": "bpmn:ResourceAssignmentExpression" - } - ] - }, - { - "name": "FormSupported", - "isAbstract": true, - "extends": ["bpmn:StartEvent", "bpmn:UserTask"], - "properties": [ - { - "name": "formHandlerClass", - "isAttr": true, - "type": "String" - }, - { - "name": "formKey", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "TemplateSupported", - "isAbstract": true, - "extends": ["bpmn:Process", "bpmn:FlowElement"], - "properties": [ - { - "name": "modelerTemplate", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "Initiator", - "isAbstract": true, - "extends": ["bpmn:StartEvent"], - "properties": [ - { - "name": "initiator", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "ScriptTask", - "isAbstract": true, - "extends": ["bpmn:ScriptTask"], - "properties": [ - { - "name": "resultVariable", - "isAttr": true, - "type": "String" - }, - { - "name": "resource", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "Process", - "isAbstract": true, - "extends": ["bpmn:Process"], - "properties": [ - { - "name": "candidateStarterGroups", - "isAttr": true, - "type": "String" - }, - { - "name": "candidateStarterUsers", - "isAttr": true, - "type": "String" - }, - { - "name": "versionTag", - "isAttr": true, - "type": "String" - }, - { - "name": "historyTimeToLive", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "EscalationEventDefinition", - "isAbstract": true, - "extends": ["bpmn:EscalationEventDefinition"], - "properties": [ - { - "name": "escalationCodeVariable", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "FormalExpression", - "isAbstract": true, - "extends": ["bpmn:FormalExpression"], - "properties": [ - { - "name": "resource", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "Assignable", - "extends": ["bpmn:UserTask"], - "properties": [ - { - "name": "assignee", - "isAttr": true, - "type": "String" - }, - { - "name": "candidateUsers", - "isAttr": true, - "type": "String" - }, - { - "name": "candidateGroups", - "isAttr": true, - "type": "String" - }, - { - "name": "dueDate", - "isAttr": true, - "type": "String" - }, - { - "name": "followUpDate", - "isAttr": true, - "type": "String" - }, - { - "name": "priority", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "CallActivity", - "extends": ["bpmn:CallActivity"], - "properties": [ - { - "name": "calledElementBinding", - "isAttr": true, - "type": "String", - "default": "latest" - }, - { - "name": "calledElementVersion", - "isAttr": true, - "type": "String" - }, - { - "name": "calledElementTenantId", - "isAttr": true, - "type": "String" - }, - { - "name": "caseRef", - "isAttr": true, - "type": "String" - }, - { - "name": "caseBinding", - "isAttr": true, - "type": "String", - "default": "latest" - }, - { - "name": "caseVersion", - "isAttr": true, - "type": "String" - }, - { - "name": "caseTenantId", - "isAttr": true, - "type": "String" - }, - { - "name": "variableMappingClass", - "isAttr": true, - "type": "String" - }, - { - "name": "variableMappingDelegateExpression", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "ServiceTaskLike", - "extends": [ - "bpmn:ServiceTask", - "bpmn:BusinessRuleTask", - "bpmn:SendTask", - "bpmn:MessageEventDefinition" - ], - "properties": [ - { - "name": "expression", - "isAttr": true, - "type": "String" - }, - { - "name": "class", - "isAttr": true, - "type": "String" - }, - { - "name": "delegateExpression", - "isAttr": true, - "type": "String" - }, - { - "name": "resultVariable", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "DmnCapable", - "extends": ["bpmn:BusinessRuleTask"], - "properties": [ - { - "name": "decisionRef", - "isAttr": true, - "type": "String" - }, - { - "name": "decisionRefBinding", - "isAttr": true, - "type": "String", - "default": "latest" - }, - { - "name": "decisionRefVersion", - "isAttr": true, - "type": "String" - }, - { - "name": "mapDecisionResult", - "isAttr": true, - "type": "String", - "default": "resultList" - }, - { - "name": "decisionRefTenantId", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "ExternalCapable", - "extends": ["camunda:ServiceTaskLike"], - "properties": [ - { - "name": "type", - "isAttr": true, - "type": "String" - }, - { - "name": "topic", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "TaskPriorized", - "extends": ["bpmn:Process", "camunda:ExternalCapable"], - "properties": [ - { - "name": "taskPriority", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "Properties", - "superClass": ["Element"], - "meta": { - "allowedIn": ["*"] - }, - "properties": [ - { - "name": "values", - "type": "Property", - "isMany": true - } - ] - }, - { - "name": "Property", - "superClass": ["Element"], - "properties": [ - { - "name": "id", - "type": "String", - "isAttr": true - }, - { - "name": "name", - "type": "String", - "isAttr": true - }, - { - "name": "value", - "type": "String", - "isAttr": true - } - ] - }, - { - "name": "Connector", - "superClass": ["Element"], - "meta": { - "allowedIn": [ - "bpmn:ServiceTask", - "bpmn:BusinessRuleTask", - "bpmn:SendTask" - ] - }, - "properties": [ - { - "name": "inputOutput", - "type": "InputOutput" - }, - { - "name": "connectorId", - "type": "String" - } - ] - }, - { - "name": "WorkflowActivity", - "superClass": ["Element"], - "meta": { - "allowedIn": [ - "bpmn:ServiceTask", - "bpmn:BusinessRuleTask", - "bpmn:SendTask" - ] - }, - "properties": [ - { - "name": "activityId", - "type": "String" - } - ] - }, - { - "name": "InputOutput", - "superClass": ["Element"], - "meta": { - "allowedIn": [ - "bpmn:Task", - "bpmn:UserTask", - "bpmn:ServiceTask", - "bpmn:SendTask", - "bpmn:BusinessRuleTask", - "bpmn:ReceiveTask", - "bpmn:ScriptTask", - "bpmn:ManualTask", - "bpmn:GlobalUserTask", - "bpmn:GlobalScriptTask", - "bpmn:GlobalBusinessRuleTask", - "bpmn:GlobalTask", - "bpmn:GlobalManualTask", - "bpmn:SubProcess", - "bpmn:Transaction", - "bpmn:IntermediateCatchEvent", - "bpmn:IntermediateThrowEvent", - "bpmn:EndEvent", - "bpmn:ThrowEvent", - "bpmn:CatchEvent", - "bpmn:ImplicitThrowEvent", - "bpmn:CallActivity" - ] - }, - "properties": [ - { - "name": "inputOutput", - "type": "InputOutput" - }, - { - "name": "connectorId", - "type": "String" - }, - { - "name": "inputParameters", - "isMany": true, - "type": "InputParameter" - }, - { - "name": "outputParameters", - "isMany": true, - "type": "OutputParameter" - } - ] - }, - { - "name": "InputOutputParameter", - "properties": [ - { - "name": "name", - "isAttr": true, - "type": "String" - }, - { - "name": "workflowSource", - "isAttr": true, - "type": "String" - }, - { - "name": "workflowTarget", - "isAttr": true, - "type": "String" - }, - { - "name": "value", - "isBody": true, - "type": "String" - }, - { - "name": "definition", - "type": "InputOutputParameterDefinition" - } - ] - }, - { - "name": "InputOutputParameterDefinition", - "isAbstract": true - }, - { - "name": "List", - "superClass": ["InputOutputParameterDefinition"], - "properties": [ - { - "name": "items", - "isMany": true, - "type": "InputOutputParameterDefinition" - } - ] - }, - { - "name": "Map", - "superClass": ["InputOutputParameterDefinition"], - "properties": [ - { - "name": "entries", - "isMany": true, - "type": "Entry" - } - ] - }, - { - "name": "Entry", - "properties": [ - { - "name": "key", - "isAttr": true, - "type": "String" - }, - { - "name": "value", - "isBody": true, - "type": "String" - }, - { - "name": "definition", - "type": "InputOutputParameterDefinition" - } - ] - }, - { - "name": "Value", - "superClass": ["InputOutputParameterDefinition"], - "properties": [ - { - "name": "id", - "isAttr": true, - "type": "String" - }, - { - "name": "name", - "isAttr": true, - "type": "String" - }, - { - "name": "value", - "isBody": true, - "type": "String" - } - ] - }, - { - "name": "Script", - "superClass": ["InputOutputParameterDefinition"], - "properties": [ - { - "name": "scriptFormat", - "isAttr": true, - "type": "String" - }, - { - "name": "resource", - "isAttr": true, - "type": "String" - }, - { - "name": "value", - "isBody": true, - "type": "String" - } - ] - }, - { - "name": "Field", - "superClass": ["Element"], - "meta": { - "allowedIn": [ - "bpmn:ServiceTask", - "bpmn:BusinessRuleTask", - "bpmn:SendTask" - ] - }, - "properties": [ - { - "name": "name", - "isAttr": true, - "type": "String" - }, - { - "name": "expression", - "type": "String" - }, - { - "name": "stringValue", - "isAttr": true, - "type": "String" - }, - { - "name": "string", - "type": "String" - } - ] - }, - { - "name": "InputParameter", - "superClass": ["InputOutputParameter"] - }, - { - "name": "OutputParameter", - "superClass": ["InputOutputParameter"] - }, - { - "name": "Collectable", - "isAbstract": true, - "extends": ["bpmn:MultiInstanceLoopCharacteristics"], - "superClass": ["camunda:AsyncCapable"], - "properties": [ - { - "name": "collection", - "isAttr": true, - "type": "String" - }, - { - "name": "elementVariable", - "isAttr": true, - "type": "String" - } - ] - }, - { - "name": "FailedJobRetryTimeCycle", - "superClass": ["Element"], - "meta": { - "allowedIn": [ - "bpmn:Task", - "bpmn:ServiceTask", - "bpmn:SendTask", - "bpmn:UserTask", - "bpmn:BusinessRuleTask", - "bpmn:ScriptTask", - "bpmn:ReceiveTask", - "bpmn:CallActivity", - "bpmn:TimerEventDefinition", - "bpmn:SignalEventDefinition", - "bpmn:MultiInstanceLoopCharacteristics" - ] - }, - "properties": [ - { - "name": "body", - "isBody": true, - "type": "String" - } - ] - }, - { - "name": "ExecutionListener", - "superClass": ["Element"], - "meta": { - "allowedIn": [ - "bpmn:Task", - "bpmn:ServiceTask", - "bpmn:UserTask", - "bpmn:BusinessRuleTask", - "bpmn:ScriptTask", - "bpmn:ReceiveTask", - "bpmn:ManualTask", - "bpmn:ExclusiveGateway", - "bpmn:SequenceFlow", - "bpmn:ParallelGateway", - "bpmn:InclusiveGateway", - "bpmn:EventBasedGateway", - "bpmn:StartEvent", - "bpmn:IntermediateCatchEvent", - "bpmn:IntermediateThrowEvent", - "bpmn:EndEvent", - "bpmn:BoundaryEvent", - "bpmn:CallActivity", - "bpmn:SubProcess" - ] - }, - "properties": [ - { - "name": "expression", - "isAttr": true, - "type": "String" - }, - { - "name": "class", - "isAttr": true, - "type": "String" - }, - { - "name": "delegateExpression", - "isAttr": true, - "type": "String" - }, - { - "name": "event", - "isAttr": true, - "type": "String" - }, - { - "name": "script", - "type": "Script" - }, - { - "name": "fields", - "type": "Field", - "isMany": true - } - ] - }, - { - "name": "TaskListener", - "superClass": ["Element"], - "meta": { - "allowedIn": ["bpmn:UserTask"] - }, - "properties": [ - { - "name": "expression", - "isAttr": true, - "type": "String" - }, - { - "name": "class", - "isAttr": true, - "type": "String" - }, - { - "name": "delegateExpression", - "isAttr": true, - "type": "String" - }, - { - "name": "event", - "isAttr": true, - "type": "String" - }, - { - "name": "script", - "type": "Script" - }, - { - "name": "fields", - "type": "Field", - "isMany": true - } - ] - }, - { - "name": "FormProperty", - "superClass": ["Element"], - "meta": { - "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] - }, - "properties": [ - { - "name": "id", - "type": "String", - "isAttr": true - }, - { - "name": "name", - "type": "String", - "isAttr": true - }, - { - "name": "type", - "type": "String", - "isAttr": true - }, - { - "name": "required", - "type": "String", - "isAttr": true - }, - { - "name": "readable", - "type": "String", - "isAttr": true - }, - { - "name": "writable", - "type": "String", - "isAttr": true - }, - { - "name": "variable", - "type": "String", - "isAttr": true - }, - { - "name": "expression", - "type": "String", - "isAttr": true - }, - { - "name": "datePattern", - "type": "String", - "isAttr": true - }, - { - "name": "default", - "type": "String", - "isAttr": true - }, - { - "name": "values", - "type": "Value", - "isMany": true - } - ] - }, - { - "name": "FormData", - "superClass": ["Element"], - "meta": { - "allowedIn": ["bpmn:StartEvent", "bpmn:UserTask"] - }, - "properties": [ - { - "name": "fields", - "type": "FormField", - "isMany": true - }, - { - "name": "businessKey", - "type": "String", - "isAttr": true - } - ] - }, - { - "name": "FormField", - "superClass": ["Element"], - "properties": [ - { - "name": "id", - "type": "String", - "isAttr": true - }, - { - "name": "label", - "type": "String", - "isAttr": true - }, - { - "name": "type", - "type": "String", - "isAttr": true - }, - { - "name": "datePattern", - "type": "String", - "isAttr": true - }, - { - "name": "defaultValue", - "type": "String", - "isAttr": true - }, - { - "name": "properties", - "type": "Properties" - }, - { - "name": "validation", - "type": "Validation" - }, - { - "name": "values", - "type": "Value", - "isMany": true - } - ] - }, - { - "name": "Validation", - "superClass": ["Element"], - "properties": [ - { - "name": "constraints", - "type": "Constraint", - "isMany": true - } - ] - }, - { - "name": "Constraint", - "superClass": ["Element"], - "properties": [ - { - "name": "name", - "type": "String", - "isAttr": true - }, - { - "name": "config", - "type": "String", - "isAttr": true - } - ] - }, - { - "name": "ConditionalEventDefinition", - "isAbstract": true, - "extends": ["bpmn:ConditionalEventDefinition"], - "properties": [ - { - "name": "variableName", - "isAttr": true, - "type": "String" - }, - { - "name": "variableEvent", - "isAttr": true, - "type": "String" - } - ] - } - ], - "emumerations": [] -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/WorkflowPropertiesProvider.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/WorkflowPropertiesProvider.js deleted file mode 100644 index d6b3b274..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/WorkflowPropertiesProvider.js +++ /dev/null @@ -1,300 +0,0 @@ -import inherits from 'inherits'; -import CamundaPropertiesProvider from 'bpmn-js-properties-panel/lib/provider/camunda/CamundaPropertiesProvider'; - -import { is, getBusinessObject } from 'bpmn-js/lib/util/ModelUtil'; - -import asyncCapableHelper from 'bpmn-js-properties-panel/lib/helper/AsyncCapableHelper'; -import eventDefinitionHelper from 'bpmn-js-properties-panel/lib/helper/EventDefinitionHelper'; -import implementationTypeHelper from 'bpmn-js-properties-panel/lib/helper/ImplementationTypeHelper'; - -import idProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/IdProps'; -import nameProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/NameProps'; -import processProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/ProcessProps'; -import linkProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/LinkProps'; -import eventProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/EventProps'; -import documentationProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/DocumentationProps'; - -import elementTemplateChooserProps from 'bpmn-js-properties-panel/lib/provider/camunda/element-templates/parts/ChooserProps'; -import elementTemplateCustomProps from 'bpmn-js-properties-panel/lib/provider/camunda/element-templates/parts/CustomProps'; - -import versionTag from 'bpmn-js-properties-panel/lib/provider/camunda/parts/VersionTagProps'; -import userTaskProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/UserTaskProps'; -import scriptProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/ScriptTaskProps'; -import callActivityProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/CallActivityProps'; -import conditionalProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/ConditionalProps'; -import startEventInitiator from 'bpmn-js-properties-panel/lib/provider/camunda/parts/StartEventInitiator'; -import multiInstanceProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/MultiInstanceLoopProps'; -import asynchronousContinuationProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/AsynchronousContinuationProps'; -import jobConfiguration from 'bpmn-js-properties-panel/lib/provider/camunda/parts/JobConfigurationProps'; -import externalTaskConfiguration from 'bpmn-js-properties-panel/lib/provider/camunda/parts/ExternalTaskConfigurationProps'; -import candidateStarter from 'bpmn-js-properties-panel/lib/provider/camunda/parts/CandidateStarterProps'; -import historyTimeToLive from 'bpmn-js-properties-panel/lib/provider/camunda/parts/HistoryTimeToLiveProps'; - -import createInputOutputTabGroups from './parts/createInputOutputTabGroups'; -import workflowServiceTaskDelegateProps from './parts/WorkflowServiceTaskDelegateProps'; - -const PROCESS_KEY_HINT = 'This maps to the process definition key.'; - -const isExternalTaskPriorityEnabled = function(element) { - const businessObject = getBusinessObject(element); - - // show only if element is a process, a participant ... - if ( - is(element, 'bpmn:Process') || - (is(element, 'bpmn:Participant') && businessObject.get('processRef')) - ) { - return true; - } - - const externalBo = implementationTypeHelper.getServiceTaskLikeBusinessObject( - element - ), - isExternalTask = - implementationTypeHelper.getImplementationType(externalBo) === - 'external'; - - // ... or an external task with selected external implementation type - return ( - !!implementationTypeHelper.isExternalCapable(externalBo) && - isExternalTask - ); -}; - -const isJobConfigEnabled = element => { - const businessObject = getBusinessObject(element); - - if ( - is(element, 'bpmn:Process') || - (is(element, 'bpmn:Participant') && businessObject.get('processRef')) - ) { - return true; - } - - // async behavior - const bo = getBusinessObject(element); - if ( - asyncCapableHelper.isAsyncBefore(bo) || - asyncCapableHelper.isAsyncAfter(bo) - ) { - return true; - } - - // timer definition - if (is(element, 'bpmn:Event')) { - return !!eventDefinitionHelper.getTimerEventDefinition(element); - } - - return false; -}; - -function createGeneralTabGroups( - element, - config, - bpmnFactory, - elementRegistry, - elementTemplates, - translate -) { - // refer to target element for external labels - element = element.labelTarget || element; - - const generalGroup = { - id: 'general', - label: translate('General'), - entries: [] - }; - - let idOptions; - let processOptions; - - if (is(element, 'bpmn:Process')) { - idOptions = { description: PROCESS_KEY_HINT }; - } - - if (is(element, 'bpmn:Participant')) { - processOptions = { processIdDescription: PROCESS_KEY_HINT }; - } - - idProps(generalGroup, element, translate, idOptions); - nameProps(generalGroup, element, translate); - processProps(generalGroup, element, translate, processOptions); - versionTag(generalGroup, element, translate); - elementTemplateChooserProps( - generalGroup, - element, - elementTemplates, - translate - ); - - const customFieldsGroups = elementTemplateCustomProps( - element, - elementTemplates, - bpmnFactory, - translate - ); - - const detailsGroup = { - id: 'details', - label: translate('Details'), - entries: [] - }; - workflowServiceTaskDelegateProps( - detailsGroup, - element, - config, - bpmnFactory, - translate - ); - userTaskProps(detailsGroup, element, translate); - scriptProps(detailsGroup, element, bpmnFactory, translate); - linkProps(detailsGroup, element, translate); - callActivityProps(detailsGroup, element, bpmnFactory, translate); - eventProps(detailsGroup, element, bpmnFactory, elementRegistry, translate); - conditionalProps(detailsGroup, element, bpmnFactory, translate); - startEventInitiator(detailsGroup, element, translate); // this must be the last element of the details group! - - const multiInstanceGroup = { - id: 'multiInstance', - label: translate('Multi Instance'), - entries: [] - }; - multiInstanceProps(multiInstanceGroup, element, bpmnFactory, translate); - - const asyncGroup = { - id: 'async', - label: translate('Asynchronous Continuations'), - entries: [] - }; - asynchronousContinuationProps(asyncGroup, element, bpmnFactory, translate); - - const jobConfigurationGroup = { - id: 'jobConfiguration', - label: translate('Job Configuration'), - entries: [], - enabled: isJobConfigEnabled - }; - jobConfiguration(jobConfigurationGroup, element, bpmnFactory, translate); - - const externalTaskGroup = { - id: 'externalTaskConfiguration', - label: translate('External Task Configuration'), - entries: [], - enabled: isExternalTaskPriorityEnabled - }; - externalTaskConfiguration( - externalTaskGroup, - element, - bpmnFactory, - translate - ); - - const candidateStarterGroup = { - id: 'candidateStarterConfiguration', - label: translate('Candidate Starter Configuration'), - entries: [] - }; - candidateStarter(candidateStarterGroup, element, bpmnFactory, translate); - - const historyTimeToLiveGroup = { - id: 'historyConfiguration', - label: translate('History Configuration'), - entries: [] - }; - historyTimeToLive(historyTimeToLiveGroup, element, bpmnFactory, translate); - - const documentationGroup = { - id: 'documentation', - label: translate('Documentation'), - entries: [] - }; - documentationProps(documentationGroup, element, bpmnFactory, translate); - - const groups = []; - groups.push(generalGroup); - customFieldsGroups.forEach(function(group) { - groups.push(group); - }); - groups.push(detailsGroup); - groups.push(externalTaskGroup); - groups.push(multiInstanceGroup); - groups.push(asyncGroup); - groups.push(jobConfigurationGroup); - groups.push(candidateStarterGroup); - groups.push(historyTimeToLiveGroup); - groups.push(documentationGroup); - - return groups; -} - -function WorkflowPropertiesProvider( - config, - eventBus, - bpmnFactory, - elementRegistry, - elementTemplates, - translate -) { - CamundaPropertiesProvider.call( - this, - eventBus, - bpmnFactory, - elementRegistry, - elementTemplates, - translate - ); - - this.getTabs = function(element) { - const camundaPropertiesProvider = new CamundaPropertiesProvider( - eventBus, - bpmnFactory, - elementRegistry, - elementTemplates, - translate - ); - - const tabs = camundaPropertiesProvider - .getTabs(element) - .filter(tab => tab.id !== 'general' && tab.id !== 'input-output'); - - const generalTab = { - id: 'general', - label: translate('General'), - groups: createGeneralTabGroups( - element, - config, - bpmnFactory, - elementRegistry, - elementTemplates, - translate - ) - }; - - const inputOutputTab = { - id: 'input-output', - label: translate('Input/Output'), - groups: createInputOutputTabGroups( - element, - bpmnFactory, - elementRegistry, - translate, - config - ) - }; - tabs.unshift(inputOutputTab); - tabs.unshift(generalTab); - return tabs; - }; -} - -WorkflowPropertiesProvider.$inject = [ - 'config.workflow', - 'eventBus', - 'bpmnFactory', - 'elementRegistry', - 'elementTemplates', - 'translate' -]; - -inherits(WorkflowPropertiesProvider, CamundaPropertiesProvider); - -export default WorkflowPropertiesProvider; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/index.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/index.js deleted file mode 100644 index bc60c581..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import ElementTemplates from 'bpmn-js-properties-panel/lib/provider/camunda/element-templates'; -import Translate from 'diagram-js/lib/i18n/translate'; - -import WorkflowPropertiesProvider from './WorkflowPropertiesProvider'; - -export default { - __depends__: [ElementTemplates, Translate], - __init__: ['propertiesProvider'], - propertiesProvider: ['type', WorkflowPropertiesProvider] -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/InputOutputParameterProps.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/InputOutputParameterProps.js deleted file mode 100644 index d221c6e3..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/InputOutputParameterProps.js +++ /dev/null @@ -1,21 +0,0 @@ -import inputOutputParameter from './implementation/InputOutputParameter'; -import assign from 'lodash.assign'; - -export default function( - group, - element, - bpmnFactory, - options, - translate, - config -) { - group.entries = group.entries.concat( - inputOutputParameter( - element, - bpmnFactory, - assign({}, options), - translate, - config - ) - ); -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/InputOutputProps.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/InputOutputProps.js deleted file mode 100644 index bdcbab46..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/InputOutputProps.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -import inputOutput from './implementation/InputOutput'; - -export default function(group, element, bpmnFactory, translate) { - const inputOutputEntry = inputOutput(element, bpmnFactory, {}, translate); - - group.entries = group.entries.concat(inputOutputEntry.entries); - - return { - getSelectedParameter: inputOutputEntry.getSelectedParameter - }; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/WorkflowServiceTaskDelegateProps.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/WorkflowServiceTaskDelegateProps.js deleted file mode 100644 index bc871357..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/WorkflowServiceTaskDelegateProps.js +++ /dev/null @@ -1,123 +0,0 @@ -import inherits from 'inherits'; - -import ImplementationTypeHelper from 'bpmn-js-properties-panel/lib/helper/ImplementationTypeHelper'; -import ServiceTaskDelegateProps from 'bpmn-js-properties-panel/lib/provider/camunda/parts/ServiceTaskDelegateProps'; -import workflowImplementationType from './implementation/WorkflowImplementationType'; -import workflowActivity from './implementation/WorkflowActivity'; -import { - implementationType as implementationTypeConst, - serviceTaskEntries -} from './implementation/implementationConstants'; -import Delegate from './implementation/Delegate'; -import ResultVariable from './implementation/ResultVariable'; - -const getImplementationType = element => { - let implementationType = ImplementationTypeHelper.getImplementationType( - element - ); - - if (!implementationType || implementationType === 'expression') { - const bo = getBusinessObject(element); - if (bo) { - if ( - typeof bo.get(implementationTypeConst.ACTIVITY) !== 'undefined' - ) { - return 'workflowActivity'; - } - } - } - - return implementationType; -}; - -const hideResultVariable = element => { - return getImplementationType(element) !== 'expression'; -}; - -const getBusinessObject = element => - ImplementationTypeHelper.getServiceTaskLikeBusinessObject(element); - -const isDmnCapable = element => ImplementationTypeHelper.isDmnCapable(element); - -const isExternalCapable = element => - ImplementationTypeHelper.isExternalCapable(element); - -const isServiceTaskLike = element => - ImplementationTypeHelper.isServiceTaskLike(element); - -function WorkflowServiceTaskDelegateProps( - group, - element, - config, - bpmnFactory, - translate -) { - ServiceTaskDelegateProps.call(this, group, element, bpmnFactory, translate); - - if (isServiceTaskLike(getBusinessObject(element))) { - group.entries = group.entries.filter( - entry => - entry.id !== serviceTaskEntries.IMPLEMENTATION && - entry.id !== serviceTaskEntries.DELEGATE && - entry.id !== serviceTaskEntries.RESULT_VARIABLE - ); - - group.entries = group.entries.concat( - workflowActivity( - element, - config, - bpmnFactory, - { - getBusinessObject: getBusinessObject, - getImplementationType: getImplementationType - }, - translate - ) - ); - - group.entries = group.entries.concat( - Delegate( - element, - bpmnFactory, - { - getBusinessObject: getBusinessObject, - getImplementationType: getImplementationType - }, - translate - ) - ); - - group.entries = group.entries.concat( - ResultVariable( - element, - bpmnFactory, - { - getBusinessObject: getBusinessObject, - getImplementationType: getImplementationType, - hideResultVariable: hideResultVariable - }, - translate - ) - ); - group.entries = group.entries.concat( - workflowImplementationType( - element, - bpmnFactory, - { - getBusinessObject: getBusinessObject, - getImplementationType: getImplementationType, - hasDmnSupport: isDmnCapable(element), - hasExternalSupport: isExternalCapable( - getBusinessObject(element) - ), - hasServiceTaskLikeSupport: true - }, - translate - ) - ); - } -} - -inherits(WorkflowServiceTaskDelegateProps, ServiceTaskDelegateProps); - -export default WorkflowServiceTaskDelegateProps; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/createInputOutputTabGroups.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/createInputOutputTabGroups.js deleted file mode 100644 index 3dede1a9..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/createInputOutputTabGroups.js +++ /dev/null @@ -1,58 +0,0 @@ -import inputOutputParameter from './InputOutputParameterProps'; -import inputOutput from './InputOutputProps'; -const is = require('bpmn-js/lib/util/ModelUtil').is; - -var getInputOutputParameterLabel = function(param, translate) { - if (is(param, 'camunda:InputParameter')) { - return translate('Input Parameter'); - } - - if (is(param, 'camunda:OutputParameter')) { - return translate('Output Parameter'); - } - - return ''; -}; - -export default function createInputOutputTabGroups( - element, - bpmnFactory, - elementRegistry, - translate, - config -) { - var inputOutputGroup = { - id: 'input-output', - label: translate('Parameters'), - entries: [] - }; - - var options = inputOutput( - inputOutputGroup, - element, - bpmnFactory, - translate - ); - var inputOutputParameterGroup = { - id: 'input-output-parameter', - entries: [], - enabled: function(element, node) { - return options.getSelectedParameter(element, node); - }, - label: function(element, node) { - var param = options.getSelectedParameter(element, node); - return getInputOutputParameterLabel(param, translate); - } - }; - - inputOutputParameter( - inputOutputParameterGroup, - element, - bpmnFactory, - options, - translate, - config - ); - - return [inputOutputGroup, inputOutputParameterGroup]; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/Delegate.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/Delegate.js deleted file mode 100644 index f6a0b247..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/Delegate.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -import entryFactory from 'bpmn-js-properties-panel/lib/factory/EntryFactory'; -import cmdHelper from 'bpmn-js-properties-panel/lib/helper/CmdHelper'; - -const DELEGATE_TYPES = ['class', 'expression', 'delegateExpression']; - -const PROPERTIES = { - class: 'camunda:class', - expression: 'camunda:expression', - delegateExpression: 'camunda:delegateExpression' -}; - -function isDelegate(type) { - return DELEGATE_TYPES.indexOf(type) !== -1; -} - -function getAttribute(type) { - return PROPERTIES[type]; -} - -export default function(element, bpmnFactory, options, translate) { - var getImplementationType = options.getImplementationType, - getBusinessObject = options.getBusinessObject; - - function getDelegationLabel(type) { - switch (type) { - case 'class': - return translate('Java Class'); - case 'expression': - return translate('Expression'); - case 'delegateExpression': - return translate('Delegate Expression'); - default: - return ''; - } - } - - var delegateEntry = entryFactory.textField({ - id: 'delegate', - label: translate('Value'), - dataValueLabel: 'delegationLabel', - modelProperty: 'delegate', - - get: function(element) { - var bo = getBusinessObject(element); - var type = getImplementationType(element); - var attr = getAttribute(type); - var label = getDelegationLabel(type); - return { - delegate: bo.get(attr), - delegationLabel: label - }; - }, - - set: function(element, values) { - var bo = getBusinessObject(element); - var type = getImplementationType(element); - var attr = getAttribute(type); - var prop = {}; - prop[attr] = values.delegate || ''; - return cmdHelper.updateBusinessObject(element, bo, prop); - }, - - validate: function(element, values) { - return isDelegate(getImplementationType(element)) && - !values.delegate - ? { delegate: 'Must provide a value' } - : {}; - }, - - hidden: function(element) { - return !isDelegate(getImplementationType(element)); - } - }); - - return [delegateEntry]; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutput.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutput.js deleted file mode 100644 index 2bbef4f2..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutput.js +++ /dev/null @@ -1,289 +0,0 @@ -import inputOutputHelper from './InputOutputHelper'; -var getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject; - -var elementHelper = require('bpmn-js-properties-panel/lib/helper/ElementHelper'), - extensionElementsHelper = require('bpmn-js-properties-panel/lib/helper/ExtensionElementsHelper'), - cmdHelper = require('bpmn-js-properties-panel/lib/helper/CmdHelper'); - -var extensionElementsEntry = require('bpmn-js-properties-panel/lib/provider/camunda/parts/implementation//ExtensionElements'); - -function getInputOutput(element, insideConnector) { - return inputOutputHelper.getInputOutput(element, insideConnector); -} - -function getConnector(element) { - return inputOutputHelper.getConnector(element); -} - -function getInputParameters(element, insideConnector) { - return inputOutputHelper.getInputParameters(element, insideConnector); -} - -function getOutputParameters(element, insideConnector) { - return inputOutputHelper.getOutputParameters(element, insideConnector); -} - -function getInputParameter(element, insideConnector, idx) { - return inputOutputHelper.getInputParameter(element, insideConnector, idx); -} - -function getOutputParameter(element, insideConnector, idx) { - return inputOutputHelper.getOutputParameter(element, insideConnector, idx); -} - -export function createElement(type, parent, factory, properties) { - const el = elementHelper.createElement(type, properties, parent, factory); - return el; -} - -export function createInputOutput(parent, bpmnFactory, properties) { - return createElement( - 'camunda:InputOutput', - parent, - bpmnFactory, - properties - ); -} - -function createParameter(type, parent, bpmnFactory, properties) { - return createElement(type, parent, bpmnFactory, properties); -} - -function ensureInputOutputSupported(element, insideConnector) { - return inputOutputHelper.isInputOutputSupported(element, insideConnector); -} - -function ensureOutparameterSupported(element, insideConnector) { - return inputOutputHelper.areOutputParametersSupported( - element, - insideConnector - ); -} - -export default function(element, bpmnFactory, options, translate) { - var TYPE_LABEL = { - 'camunda:Map': translate('Map'), - 'camunda:List': translate('List'), - 'camunda:Script': translate('Script') - }; - - options = options || {}; - - var insideConnector = !!options.insideConnector, - idPrefix = options.idPrefix || ''; - - var getSelected = function(element, node) { - var selection = (inputEntry && - inputEntry.getSelected(element, node)) || { idx: -1 }; - - var parameter = getInputParameter( - element, - insideConnector, - selection.idx - ); - if (!parameter && outputEntry) { - selection = outputEntry.getSelected(element, node); - parameter = getOutputParameter( - element, - insideConnector, - selection.idx - ); - } - return parameter; - }; - - var result = { - getSelectedParameter: getSelected - }; - - var entries = (result.entries = []); - - if (!ensureInputOutputSupported(element)) { - return result; - } - - var newElement = function(type, prop, elementData) { - return function(element, extensionElements, value) { - var commands = []; - - var inputOutput = getInputOutput(element, insideConnector); - if (!inputOutput) { - var parent = !insideConnector - ? extensionElements - : getConnector(element); - - inputOutput = createInputOutput(parent, bpmnFactory, { - inputParameters: [], - outputParameters: [] - }); - - if (!insideConnector) { - commands.push( - cmdHelper.addAndRemoveElementsFromList( - element, - extensionElements, - 'values', - 'extensionElements', - [inputOutput], - [] - ) - ); - } else { - commands.push( - cmdHelper.updateBusinessObject(element, parent, { - inputOutput: inputOutput - }) - ); - } - } - - var newElem = elementData - ? createParameter(type, inputOutput, bpmnFactory, elementData) - : createParameter(type, inputOutput, bpmnFactory, { - name: value - }); - - commands.push( - cmdHelper.addElementsTolist(element, inputOutput, prop, [ - newElem - ]) - ); - - return commands; - }; - }; - - var removeElement = function(getter, prop, otherProp) { - return function(element, extensionElements, value, idx) { - var inputOutput = getInputOutput(element, insideConnector); - var parameter = getter(element, insideConnector, idx); - - var commands = []; - commands.push( - cmdHelper.removeElementsFromList( - element, - inputOutput, - prop, - null, - [parameter] - ) - ); - - var firstLength = inputOutput.get(prop).length - 1; - var secondLength = (inputOutput.get(otherProp) || []).length; - - if (!firstLength && !secondLength) { - if (!insideConnector) { - commands.push( - extensionElementsHelper.removeEntry( - getBusinessObject(element), - element, - inputOutput - ) - ); - } else { - var connector = getConnector(element); - commands.push( - cmdHelper.updateBusinessObject(element, connector, { - inputOutput: undefined - }) - ); - } - } - - return commands; - }; - }; - - var setOptionLabelValue = function(getter) { - return function(element, node, option, property, value, idx) { - var parameter = getter(element, insideConnector, idx); - - var suffix = 'Text'; - - var definition = parameter.get('definition'); - if (typeof definition !== 'undefined') { - var type = definition.$type; - suffix = TYPE_LABEL[type]; - } - - option.text = (value || '') + ' : ' + suffix; - }; - }; - - // input parameters /////////////////////////////////////////////////////////////// - - var inputEntry = extensionElementsEntry(element, bpmnFactory, { - id: idPrefix + 'inputs', - label: translate('Input Parameters'), - modelProperty: 'name', - prefix: 'Input', - resizable: true, - - createExtensionElement: inputOutputHelper.isCreateDeleteSupported( - element - ) - ? newElement('camunda:InputParameter', 'inputParameters') - : undefined, - removeExtensionElement: inputOutputHelper.isCreateDeleteSupported( - element - ) - ? removeElement( - getInputParameter, - 'inputParameters', - 'outputParameters' - ) - : undefined, - - getExtensionElements: function(element) { - return getInputParameters(element, insideConnector); - }, - - onSelectionChange: function(element, node) { - outputEntry && outputEntry.deselect(element, node); - }, - - setOptionLabelValue: setOptionLabelValue(getInputParameter) - }); - entries.push(inputEntry); - - // output parameters /////////////////////////////////////////////////////// - - if (ensureOutparameterSupported(element, insideConnector)) { - var outputEntry = extensionElementsEntry(element, bpmnFactory, { - id: idPrefix + 'outputs', - label: translate('Output Parameters'), - modelProperty: 'name', - prefix: 'Output', - resizable: true, - - createExtensionElement: inputOutputHelper.isCreateDeleteSupported( - element - ) - ? newElement('camunda:OutputParameter', 'outputParameters') - : undefined, - removeExtensionElement: inputOutputHelper.isCreateDeleteSupported( - element - ) - ? removeElement( - getOutputParameter, - 'outputParameters', - 'inputParameters' - ) - : inputOutputHelper.isCreateDeleteSupported(element), - - getExtensionElements: function(element) { - return getOutputParameters(element, insideConnector); - }, - - onSelectionChange: function(element, node) { - inputEntry.deselect(element, node); - }, - - setOptionLabelValue: setOptionLabelValue(getOutputParameter) - }); - entries.push(outputEntry); - } - - return result; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputHelper.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputHelper.js deleted file mode 100644 index 595ab799..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputHelper.js +++ /dev/null @@ -1,173 +0,0 @@ -var ModelUtil = require('bpmn-js/lib/util/ModelUtil'), - is = ModelUtil.is, - getBusinessObject = ModelUtil.getBusinessObject; - -var extensionElementsHelper = require('bpmn-js-properties-panel/lib/helper/ExtensionElementsHelper'), - implementationTypeHelper = require('bpmn-js-properties-panel/lib/helper/ImplementationTypeHelper'); -import { implementationType } from './implementationConstants'; - -var InputOutputHelper = {}; - -function getElements(bo, type, prop) { - var elems = extensionElementsHelper.getExtensionElements(bo, type) || []; - return !prop ? elems : (elems[0] || {})[prop] || []; -} - -function getParameters(element, prop, insideConnector) { - var inputOutput = InputOutputHelper.getInputOutput( - element, - insideConnector - ); - return (inputOutput && inputOutput.get(prop)) || []; -} - -/** - * Get a inputOutput from the business object - * - * @param {djs.model.Base} element - * @param {boolean} insideConnector - * - * @return {ModdleElement} the inputOutput object - */ -InputOutputHelper.getInputOutput = function(element, insideConnector) { - if (!insideConnector) { - var bo = getBusinessObject(element); - return (getElements(bo, 'camunda:InputOutput') || [])[0]; - } - var connector = this.getConnector(element); - - return connector && connector.get('inputOutput'); -}; - -/** - * Get a connector from the business object - * - * @param {djs.model.Base} element - * - * @return {ModdleElement} the connector object - */ -InputOutputHelper.getConnector = function(element) { - var bo = implementationTypeHelper.getServiceTaskLikeBusinessObject(element); - return bo && (getElements(bo, 'camunda:Connector') || [])[0]; -}; - -/** - * Return all input parameters existing in the business object, and - * an empty array if none exist. - * - * @param {djs.model.Base} element - * @param {boolean} insideConnector - * - * @return {Array} a list of input parameter objects - */ -InputOutputHelper.getInputParameters = function(element, insideConnector) { - return getParameters.apply(this, [ - element, - 'inputParameters', - insideConnector - ]); -}; - -/** - * Return all output parameters existing in the business object, and - * an empty array if none exist. - * - * @param {djs.model.Base} element - * @param {boolean} insideConnector - * - * @return {Array} a list of output parameter objects - */ -InputOutputHelper.getOutputParameters = function(element, insideConnector) { - return getParameters.apply(this, [ - element, - 'outputParameters', - insideConnector - ]); -}; - -/** - * Get a input parameter from the business object at given index - * - * @param {djs.model.Base} element - * @param {boolean} insideConnector - * @param {number} idx - * - * @return {ModdleElement} input parameter - */ -InputOutputHelper.getInputParameter = function(element, insideConnector, idx) { - return this.getInputParameters(element, insideConnector)[idx]; -}; - -/** - * Get a output parameter from the business object at given index - * - * @param {djs.model.Base} element - * @param {boolean} insideConnector - * @param {number} idx - * - * @return {ModdleElement} output parameter - */ -InputOutputHelper.getOutputParameter = function(element, insideConnector, idx) { - return this.getOutputParameters(element, insideConnector)[idx]; -}; - -/** - * Returns 'true' if the given element supports inputOutput - * - * @param {djs.model.Base} element - * @param {boolean} insideConnector - * - * @return {boolean} a boolean value - */ -InputOutputHelper.isInputOutputSupported = function(element, insideConnector) { - var bo = getBusinessObject(element); - return ( - insideConnector || - is(bo, 'bpmn:Process') || - (is(bo, 'bpmn:FlowNode') && - !is(bo, 'bpmn:StartEvent') && - !is(bo, 'bpmn:BoundaryEvent') && - !(is(bo, 'bpmn:SubProcess') && bo.get('triggeredByEvent'))) - ); -}; - -/** - * Returns 'true' if the given element supports output parameters - * - * @param {djs.model.Base} element - * @param {boolean} insideConnector - * - * @return {boolean} a boolean value - */ -InputOutputHelper.areOutputParametersSupported = function( - element, - insideConnector -) { - var bo = getBusinessObject(element); - return ( - insideConnector || (!is(bo, 'bpmn:EndEvent') && !bo.loopCharacteristics) - ); -}; - -InputOutputHelper.isCreateDeleteSupported = function(element) { - const bo = getBusinessObject(element); - return ( - (element.type !== 'bpmn:ServiceTask' || - !bo[implementationType.ACTIVITY]) && - element.type !== 'bpmn:Process' - ); -}; - -InputOutputHelper.isWorkflowTargetSupported = function(element, selected) { - const bo = getBusinessObject(element); - return ( - is(bo, 'bpmn:ServiceTask') && is(selected, 'camunda:OutputParameter') - ); -}; - -InputOutputHelper.isWorkflowSourceSupported = function(element, selected) { - const bo = getBusinessObject(element); - return is(bo, 'bpmn:ServiceTask') && is(selected, 'camunda:InputParameter'); -}; - -export default InputOutputHelper; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputParameter.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputParameter.js deleted file mode 100644 index 10e258e3..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputParameter.js +++ /dev/null @@ -1,424 +0,0 @@ -import inputOutputHelper from './InputOutputHelper'; - -var is = require('bpmn-js/lib/util/ModelUtil').is; - -var elementHelper = require('bpmn-js-properties-panel/lib/helper/ElementHelper'), - cmdHelper = require('bpmn-js-properties-panel/lib/helper/CmdHelper'), - utils = require('bpmn-js-properties-panel/lib/Utils'); - -var entryFactory = require('bpmn-js-properties-panel/lib/factory/EntryFactory'), - script = require('bpmn-js-properties-panel/lib/provider/camunda/parts/implementation/Script')( - 'scriptFormat', - 'value', - true - ); - -function createElement(type, parent, factory, properties) { - return elementHelper.createElement(type, properties, parent, factory); -} - -function isScript(elem) { - return is(elem, 'camunda:Script'); -} - -function isList(elem) { - return is(elem, 'camunda:List'); -} - -function isMap(elem) { - return is(elem, 'camunda:Map'); -} - -function ensureInputOutputSupported(element, insideConnector) { - return inputOutputHelper.isInputOutputSupported(element, insideConnector); -} - -export default function(element, bpmnFactory, options, translate) { - var typeInfo = { - 'camunda:Map': { - value: 'map', - label: translate('Map') - }, - 'camunda:List': { - value: 'list', - label: translate('List') - }, - 'camunda:Script': { - value: 'script', - label: translate('Script') - } - }; - - options = options || {}; - - var insideConnector = !!options.insideConnector, - idPrefix = options.idPrefix || ''; - - var getSelected = options.getSelectedParameter; - - if (!ensureInputOutputSupported(element, insideConnector)) { - return []; - } - - var entries = []; - - var isSelected = function(element, node) { - return getSelected(element, node); - }; - - // parameter name //////////////////////////////////////////////////////// - - entries.push( - entryFactory.validationAwareTextField({ - id: idPrefix + 'parameterName', - label: 'Name', - modelProperty: 'name', - - getProperty: function(element, node) { - return (getSelected(element, node) || {}).name; - }, - - setProperty: function(element, values, node) { - var param = getSelected(element, node); - return cmdHelper.updateBusinessObject(element, param, values); - }, - - validate: function(element, values, node) { - var bo = getSelected(element, node); - - var validation = {}; - if (bo) { - var nameValue = values.name; - - if (nameValue) { - if (utils.containsSpace(nameValue)) { - validation.name = 'Name must not contain spaces'; - } - } else { - validation.name = 'Parameter must have a name'; - } - } - - return validation; - }, - - hidden: function(element, node) { - return !isSelected(element, node); - }, - disabled: function(element) { - return !inputOutputHelper.isCreateDeleteSupported(element); - } - }) - ); - - // parameter type ////////////////////////////////////////////////////// - - var selectOptions = [ - { value: 'text', name: 'Text' }, - { value: 'script', name: 'Script' }, - { value: 'list', name: 'List' }, - { value: 'map', name: 'Map' } - ]; - - entries.push( - entryFactory.selectBox({ - id: idPrefix + 'parameterType', - label: 'Type', - selectOptions: selectOptions, - modelProperty: 'parameterType', - - get: function(element, node) { - var bo = getSelected(element, node); - - var parameterType = 'text'; - - if (typeof bo !== 'undefined') { - var definition = bo.get('definition'); - if (typeof definition !== 'undefined') { - var type = definition.$type; - parameterType = typeInfo[type].value; - } - } - - return { - parameterType: parameterType - }; - }, - - set: function(element, values, node) { - var bo = getSelected(element, node); - - var properties = { - value: undefined, - definition: undefined - }; - - var createParameterTypeElem = function(type) { - return createElement(type, bo, bpmnFactory); - }; - - var parameterType = values.parameterType; - - if (parameterType === 'script') { - properties.definition = createParameterTypeElem( - 'camunda:Script' - ); - } else if (parameterType === 'list') { - properties.definition = createParameterTypeElem( - 'camunda:List' - ); - } else if (parameterType === 'map') { - properties.definition = createParameterTypeElem( - 'camunda:Map' - ); - } - - return cmdHelper.updateBusinessObject(element, bo, properties); - }, - - show: function(element, node) { - return isSelected(element, node); - }, - disabled: function(element) { - return !inputOutputHelper.isCreateDeleteSupported(element); - } - }) - ); - - // parameter value (type = text) /////////////////////////////////////////////////////// - - entries.push( - entryFactory.textBox({ - id: idPrefix + 'parameterType-text', - label: 'Value', - modelProperty: 'value', - get: function(element, node) { - return { - value: (getSelected(element, node) || {}).value - }; - }, - - set: function(element, values, node) { - var param = getSelected(element, node); - values.value = values.value || undefined; - return cmdHelper.updateBusinessObject(element, param, values); - }, - - show: function(element, node) { - var bo = getSelected(element, node); - return bo && !bo.definition; - } - }) - ); - - // parameter value (type = script) /////////////////////////////////////////////////////// - - entries.push({ - id: idPrefix + 'parameterType-script', - html: '<div data-show="isScript">' + script.template + '</div>', - get: function(element, node) { - var bo = getSelected(element, node); - return bo && isScript(bo.definition) - ? script.get(element, bo.definition) - : {}; - }, - - set: function(element, values, node) { - var bo = getSelected(element, node); - var update = script.set(element, values); - return cmdHelper.updateBusinessObject( - element, - bo.definition, - update - ); - }, - - validate: function(element, values, node) { - var bo = getSelected(element, node); - return bo && isScript(bo.definition) - ? script.validate(element, bo.definition) - : {}; - }, - - isScript: function(element, node) { - var bo = getSelected(element, node); - return bo && isScript(bo.definition); - }, - - script: script - }); - - // parameter value (type = list) /////////////////////////////////////////////////////// - - entries.push( - entryFactory.table({ - id: idPrefix + 'parameterType-list', - modelProperties: ['value'], - labels: ['Value'], - - getElements: function(element, node) { - var bo = getSelected(element, node); - - if (bo && isList(bo.definition)) { - return bo.definition.items; - } - - return []; - }, - - updateElement: function(element, values, node, idx) { - var bo = getSelected(element, node); - var item = bo.definition.items[idx]; - return cmdHelper.updateBusinessObject(element, item, values); - }, - - addElement: function(element, node) { - var bo = getSelected(element, node); - var newValue = createElement( - 'camunda:Value', - bo.definition, - bpmnFactory, - { value: undefined } - ); - return cmdHelper.addElementsTolist( - element, - bo.definition, - 'items', - [newValue] - ); - }, - - removeElement: function(element, node, idx) { - var bo = getSelected(element, node); - return cmdHelper.removeElementsFromList( - element, - bo.definition, - 'items', - null, - [bo.definition.items[idx]] - ); - }, - - editable: function(element, node, prop, idx) { - var bo = getSelected(element, node); - var item = bo.definition.items[idx]; - return !isMap(item) && !isList(item) && !isScript(item); - }, - - setControlValue: function(element, node, input, prop, value, idx) { - var bo = getSelected(element, node); - var item = bo.definition.items[idx]; - - if (!isMap(item) && !isList(item) && !isScript(item)) { - input.value = value; - } else { - input.value = typeInfo[item.$type].label; - } - }, - - show: function(element, node) { - var bo = getSelected(element, node); - return bo && bo.definition && isList(bo.definition); - } - }) - ); - - // parameter value (type = map) /////////////////////////////////////////////////////// - - entries.push( - entryFactory.table({ - id: idPrefix + 'parameterType-map', - modelProperties: ['key', 'value'], - labels: ['Key', 'Value'], - addLabel: 'Add Entry', - - getElements: function(element, node) { - var bo = getSelected(element, node); - - if (bo && isMap(bo.definition)) { - return bo.definition.entries; - } - - return []; - }, - - updateElement: function(element, values, node, idx) { - var bo = getSelected(element, node); - var entry = bo.definition.entries[idx]; - - if ( - isMap(entry.definition) || - isList(entry.definition) || - isScript(entry.definition) - ) { - values = { - key: values.key - }; - } - - return cmdHelper.updateBusinessObject(element, entry, values); - }, - - addElement: function(element, node) { - var bo = getSelected(element, node); - var newEntry = createElement( - 'camunda:Entry', - bo.definition, - bpmnFactory, - { key: undefined, value: undefined } - ); - return cmdHelper.addElementsTolist( - element, - bo.definition, - 'entries', - [newEntry] - ); - }, - - removeElement: function(element, node, idx) { - var bo = getSelected(element, node); - return cmdHelper.removeElementsFromList( - element, - bo.definition, - 'entries', - null, - [bo.definition.entries[idx]] - ); - }, - - editable: function(element, node, prop, idx) { - var bo = getSelected(element, node); - var entry = bo.definition.entries[idx]; - return ( - prop === 'key' || - (!isMap(entry.definition) && - !isList(entry.definition) && - !isScript(entry.definition)) - ); - }, - - setControlValue: function(element, node, input, prop, value, idx) { - var bo = getSelected(element, node); - var entry = bo.definition.entries[idx]; - - if ( - prop === 'key' || - (!isMap(entry.definition) && - !isList(entry.definition) && - !isScript(entry.definition)) - ) { - input.value = value; - } else { - input.value = typeInfo[entry.definition.$type].label; - } - }, - - show: function(element, node) { - var bo = getSelected(element, node); - return bo && bo.definition && isMap(bo.definition); - } - }) - ); - - return entries; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputUpdater.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputUpdater.js deleted file mode 100644 index 056a2dba..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/InputOutputUpdater.js +++ /dev/null @@ -1,74 +0,0 @@ -/* -* 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 cmdHelper from 'bpmn-js-properties-panel/lib/helper/CmdHelper'; -import { createInputOutput, createElement } from './InputOutput'; -import InputOutputHelper from './InputOutputHelper'; -import { INPUT, OUTPUT } from './implementationConstants'; - -export default ({ element, bo, bpmnFactory, activityInputsOutputs }) => { - const commands = []; - const existedInputOutput = InputOutputHelper.getInputOutput(element); - - let newInputOutput = createInputOutput(element, bpmnFactory, { - inputParameters: [], - outputParameters: [] - }); - - const inputs = activityInputsOutputs.inputs.map(({ name, value }) => - createElement(INPUT, newInputOutput, bpmnFactory, { - name, - type: 'Text', - value - }) - ); - - const outputs = activityInputsOutputs.outputs.map(({ name, value }) => - createElement(OUTPUT, newInputOutput, bpmnFactory, { - name, - type: 'Text', - value - }) - ); - - newInputOutput.inputParameters = inputs; - newInputOutput.outputParameters = outputs; - - const objectToRemove = existedInputOutput ? [existedInputOutput] : []; - const extensionElements = - bo.extensionElements || - createElement('bpmn:ExtensionElements', bo, bpmnFactory, []); - - if (!bo.extensionElements) { - commands.push( - cmdHelper.updateBusinessObject(element, bo, { - extensionElements - }) - ); - } - - commands.push( - cmdHelper.addAndRemoveElementsFromList( - element, - extensionElements, - 'values', - 'extensionElements', - [newInputOutput], - objectToRemove - ) - ); - return commands; -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/ResultVariable.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/ResultVariable.js deleted file mode 100644 index a0b425fe..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/ResultVariable.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -import { is } from 'bpmn-js/lib/util/ModelUtil'; - -import assign from 'lodash.assign'; - -var entryFactory = require('bpmn-js-properties-panel/lib/factory/EntryFactory'), - cmdHelper = require('bpmn-js-properties-panel/lib/helper/CmdHelper'); - -export default function(element, bpmnFactory, options, translate) { - var getBusinessObject = options.getBusinessObject, - hideResultVariable = options.hideResultVariable, - id = options.id || 'resultVariable'; - - var resultVariableEntry = entryFactory.textField({ - id: id, - label: translate('Result Variable'), - modelProperty: 'resultVariable', - - get: function(element) { - var bo = getBusinessObject(element); - return { resultVariable: bo.get('camunda:resultVariable') }; - }, - - set: function(element, values) { - var bo = getBusinessObject(element); - - var resultVariable = values.resultVariable || undefined; - - var props = { - 'camunda:resultVariable': resultVariable - }; - - if (is(bo, 'camunda:DmnCapable') && !resultVariable) { - props = assign( - { 'camunda:mapDecisionResult': 'resultList' }, - props - ); - } - - return cmdHelper.updateBusinessObject(element, bo, props); - }, - - hidden: function() { - if (typeof hideResultVariable === 'function') { - return hideResultVariable.apply(resultVariableEntry, arguments); - } - } - }); - - return [resultVariableEntry]; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/WorkflowActivity.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/WorkflowActivity.js deleted file mode 100644 index 6616f6a4..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/WorkflowActivity.js +++ /dev/null @@ -1,89 +0,0 @@ -import entryFactory from 'bpmn-js-properties-panel/lib/factory/EntryFactory'; -import cmdHelper from 'bpmn-js-properties-panel/lib/helper/CmdHelper'; -import { - implementationType, - IMPLEMENTATION_TYPE_VALUE, - SERVICE_TASK_NAME -} from './implementationConstants'; - -import InputOutputUpdater from './InputOutputUpdater'; - -const workflowActivity = (element, config, bpmnFactory, options, translate) => { - const { getImplementationType, getBusinessObject } = options; - - const isWorkflowActivity = element => - getImplementationType(element) === 'workflowActivity'; - - const workflowActivityEntry = entryFactory.selectBox({ - id: 'activitySelect', - label: translate('Activity Spec'), - selectOptions: config.activities, - emptyParameter: true, - modelProperty: 'workflowActivity', - - get: function(element) { - var bo = getBusinessObject(element); - const value = bo.get(implementationType.ACTIVITY); - const activityValue = - value && value.indexOf(IMPLEMENTATION_TYPE_VALUE) > -1 - ? value.substr(IMPLEMENTATION_TYPE_VALUE.length) - : ''; - - return { - workflowActivity: activityValue - }; - }, - - set: function(element, values) { - var bo = getBusinessObject(element); - - const commands = []; - const dataForUpdate = {}; - - const activityInputsOutputs = config.getActivityInputsOutputs( - values.workflowActivity - ); - - dataForUpdate[ - implementationType.ACTIVITY - ] = `${IMPLEMENTATION_TYPE_VALUE}${values.workflowActivity}`; - - dataForUpdate[implementationType.EXPRESSION] = - implementationType.EXPRESSION_VALUE; - - dataForUpdate[SERVICE_TASK_NAME] = values.workflowActivity; - - commands.push( - cmdHelper.updateBusinessObject(element, bo, dataForUpdate) - ); - return [ - ...commands, - ...InputOutputUpdater({ - element, - bo, - bpmnFactory, - activityInputsOutputs, - commands - }) - ]; - }, - - validate: function(element, values) { - const hasErrors = - isWorkflowActivity(element) && !values.workflowActivity; - config.validationUpdate(element, !hasErrors); - - return hasErrors - ? { workflowActivity: 'Must provide a value' } - : {}; - }, - - hidden: function(element) { - return !isWorkflowActivity(element); - } - }); - - return [workflowActivityEntry]; -}; - -export default workflowActivity; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/WorkflowImplementationType.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/WorkflowImplementationType.js deleted file mode 100644 index 729cc22b..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/WorkflowImplementationType.js +++ /dev/null @@ -1,226 +0,0 @@ -var entryFactory = require('bpmn-js-properties-panel/lib/factory/EntryFactory'), - cmdHelper = require('bpmn-js-properties-panel/lib/helper/CmdHelper'), - extensionElementsHelper = require('bpmn-js-properties-panel/lib/helper/ExtensionElementsHelper'), - elementHelper = require('bpmn-js-properties-panel/lib/helper/ElementHelper'); - -var assign = require('lodash.assign'); -var map = require('lodash.map'); -import { implementationType } from './implementationConstants'; - -var DEFAULT_DELEGATE_PROPS = ['class', 'expression', 'delegateExpression']; - -var DELEGATE_PROPS = { - 'camunda:class': undefined, - 'camunda:expression': undefined, - 'camunda:delegateExpression': undefined, - 'camunda:resultVariable': undefined -}; - -var DMN_CAPABLE_PROPS = { - 'camunda:decisionRef': undefined, - 'camunda:decisionRefBinding': 'latest', - 'camunda:decisionRefVersion': undefined, - 'camunda:mapDecisionResult': 'resultList', - 'camunda:decisionRefTenantId': undefined -}; - -var EXTERNAL_CAPABLE_PROPS = { - 'camunda:type': undefined, - 'camunda:topic': undefined -}; - -const ACTIVITY_PROPS = {}; - -ACTIVITY_PROPS[implementationType] = undefined; - -export default function(element, bpmnFactory, options, translate) { - var DEFAULT_OPTIONS = [ - { value: 'class', name: translate('Java Class') }, - { value: 'expression', name: translate('Expression') }, - { value: 'delegateExpression', name: translate('Delegate Expression') } - ]; - - var DMN_OPTION = [{ value: 'dmn', name: translate('DMN') }]; - - var EXTERNAL_OPTION = [{ value: 'external', name: translate('External') }]; - - var CONNECTOR_OPTION = [ - { value: 'connector', name: translate('Connector') } - ]; - - var SCRIPT_OPTION = [{ value: 'script', name: translate('Script') }]; - - var ACTIVITY_OPTION = [ - { value: 'workflowActivity', name: translate('Activity') } - ]; - - var getType = options.getImplementationType, - getBusinessObject = options.getBusinessObject; - - var hasDmnSupport = options.hasDmnSupport, - hasExternalSupport = options.hasExternalSupport, - hasServiceTaskLikeSupport = options.hasServiceTaskLikeSupport, - hasScriptSupport = options.hasScriptSupport; - - var entries = []; - - var selectOptions = DEFAULT_OPTIONS.concat([]); - - if (hasDmnSupport) { - selectOptions = selectOptions.concat(DMN_OPTION); - } - - if (hasExternalSupport) { - selectOptions = selectOptions.concat(EXTERNAL_OPTION); - } - - if (hasServiceTaskLikeSupport) { - selectOptions = selectOptions.concat(CONNECTOR_OPTION); - } - - if (hasScriptSupport) { - selectOptions = selectOptions.concat(SCRIPT_OPTION); - } - - selectOptions = selectOptions.concat(ACTIVITY_OPTION); - - selectOptions.push({ value: '' }); - - entries.push( - entryFactory.selectBox({ - id: 'implementation', - label: translate('Implementation'), - selectOptions: selectOptions, - modelProperty: 'implType', - - get: function(element) { - return { - implType: getType(element) || '' - }; - }, - - set: function(element, values) { - var bo = getBusinessObject(element); - var oldType = getType(element); - var newType = values.implType; - var props = assign({}, DELEGATE_PROPS); - - if (DEFAULT_DELEGATE_PROPS.indexOf(newType) !== -1) { - var newValue = ''; - if (DEFAULT_DELEGATE_PROPS.indexOf(oldType) !== -1) { - newValue = bo.get('camunda:' + oldType); - } - - props['camunda:' + newType] = newValue; - } - - if (hasDmnSupport) { - props = assign(props, DMN_CAPABLE_PROPS); - if (newType === 'dmn') { - props['camunda:decisionRef'] = ''; - } - } - - if (hasExternalSupport) { - props = assign(props, EXTERNAL_CAPABLE_PROPS); - if (newType === 'external') { - props['camunda:type'] = 'external'; - props['camunda:topic'] = ''; - } - } - - if (hasScriptSupport) { - props['camunda:script'] = undefined; - - if (newType === 'script') { - props['camunda:script'] = elementHelper.createElement( - 'camunda:Script', - {}, - bo, - bpmnFactory - ); - } - } - props = assign(props, ACTIVITY_PROPS); - props[implementationType.ACTIVITY] = undefined; - - var commands = []; - if (newType === 'workflowActivity') { - props[implementationType.ACTIVITY] = ''; - props[implementationType.RESULT_VARIABLE] = undefined; - props[implementationType.EXPRESSION] = undefined; - } else { - var inputsOutputs = extensionElementsHelper.getExtensionElements( - bo, - 'camunda:InputOutput' - ); - commands.push( - map(inputsOutputs, function(inputOutput) { - return extensionElementsHelper.removeEntry( - bo, - element, - inputOutput - ); - }) - ); - } - - commands.push( - cmdHelper.updateBusinessObject(element, bo, props) - ); - - if (hasServiceTaskLikeSupport) { - var connectors = extensionElementsHelper.getExtensionElements( - bo, - 'camunda:Connector' - ); - commands.push( - map(connectors, function(connector) { - return extensionElementsHelper.removeEntry( - bo, - element, - connector - ); - }) - ); - - if (newType === 'connector') { - var extensionElements = bo.get('extensionElements'); - if (!extensionElements) { - extensionElements = elementHelper.createElement( - 'bpmn:ExtensionElements', - { values: [] }, - bo, - bpmnFactory - ); - commands.push( - cmdHelper.updateBusinessObject(element, bo, { - extensionElements: extensionElements - }) - ); - } - var connector = elementHelper.createElement( - 'camunda:Connector', - {}, - extensionElements, - bpmnFactory - ); - commands.push( - cmdHelper.addAndRemoveElementsFromList( - element, - extensionElements, - 'values', - 'extensionElements', - [connector], - [] - ) - ); - } - } - return commands; - } - }) - ); - - return entries; -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/implementationConstants.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/implementationConstants.js deleted file mode 100644 index efc70800..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/custom-properties-provider/provider/camunda/parts/implementation/implementationConstants.js +++ /dev/null @@ -1,34 +0,0 @@ -/* -* 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. -*/ - -export const implementationType = { - ACTIVITY: 'implementation', - EXPRESSION: 'camunda:expression', - EXPRESSION_VALUE: '${ExecuteActivity.execute(execution)}', - RESULT_VARIABLE: 'camunda:resultVariable' -}; - -export const IMPLEMENTATION_TYPE_VALUE = 'activity:'; -export const SERVICE_TASK_NAME = 'name'; - -export const serviceTaskEntries = { - IMPLEMENTATION: 'implementation', - DELEGATE: 'delegate', - RESULT_VARIABLE: 'resultVariable' -}; - -export const INPUT = 'camunda:InputParameter'; -export const OUTPUT = 'camunda:OutputParameter'; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/newDiagram.bpmn b/workflow-designer-ui/src/main/frontend/src/features/version/composition/newDiagram.bpmn deleted file mode 100644 index 6abaf8df..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/newDiagram.bpmn +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn"> - <bpmn2:process id="Process_1" isExecutable="true"> - </bpmn2:process> - <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</bpmn2:definitions> diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/composition/readOnly.js b/workflow-designer-ui/src/main/frontend/src/features/version/composition/readOnly.js deleted file mode 100644 index f1da7dcf..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/composition/readOnly.js +++ /dev/null @@ -1,134 +0,0 @@ -import forEach from 'lodash.foreach'; - -const HIGH_PRIORITY = 10001; - -function ReadOnly( - eventBus, - contextPad, - dragging, - directEditing, - editorActions, - modeling, - palette, - paletteProvider -) { - this._readOnly = false; - this._eventBus = eventBus; - - let self = this; - eventBus.on('readOnly.changed', HIGH_PRIORITY, function(e) { - self._readOnly = e.readOnly; - - if (e.readOnly) { - directEditing.cancel(); - contextPad.close(); - dragging.cancel(); - } - - palette._update(); - }); - - function intercept(obj, fnName, cb) { - var fn = obj[fnName]; - obj[fnName] = function() { - return cb.call(this, fn, arguments); - }; - } - - function ignoreWhenReadOnly(obj, fnName) { - intercept(obj, fnName, function(fn, args) { - if (self._readOnly) { - return; - } - - return fn.apply(this, args); - }); - } - - function throwIfReadOnly(obj, fnName) { - intercept(obj, fnName, function(fn, args) { - if (self._readOnly) { - throw new Error('model is read-only'); - } - - return fn.apply(this, args); - }); - } - - ignoreWhenReadOnly(contextPad, 'open'); - - ignoreWhenReadOnly(dragging, 'init'); - - ignoreWhenReadOnly(directEditing, 'activate'); - - ignoreWhenReadOnly(editorActions._actions, 'undo'); - ignoreWhenReadOnly(editorActions._actions, 'redo'); - ignoreWhenReadOnly(editorActions._actions, 'copy'); - ignoreWhenReadOnly(editorActions._actions, 'paste'); - ignoreWhenReadOnly(editorActions._actions, 'removeSelection'); - // BpmnEditorActions - ignoreWhenReadOnly(editorActions._actions, 'spaceTool'); - ignoreWhenReadOnly(editorActions._actions, 'lassoTool'); - ignoreWhenReadOnly(editorActions._actions, 'globalConnectTool'); - ignoreWhenReadOnly(editorActions._actions, 'distributeElements'); - ignoreWhenReadOnly(editorActions._actions, 'alignElements'); - ignoreWhenReadOnly(editorActions._actions, 'directEditing'); - - throwIfReadOnly(modeling, 'moveShape'); - throwIfReadOnly(modeling, 'updateAttachment'); - throwIfReadOnly(modeling, 'moveElements'); - throwIfReadOnly(modeling, 'moveConnection'); - throwIfReadOnly(modeling, 'layoutConnection'); - throwIfReadOnly(modeling, 'createConnection'); - throwIfReadOnly(modeling, 'createShape'); - throwIfReadOnly(modeling, 'createLabel'); - throwIfReadOnly(modeling, 'appendShape'); - throwIfReadOnly(modeling, 'removeElements'); - throwIfReadOnly(modeling, 'distributeElements'); - throwIfReadOnly(modeling, 'removeShape'); - throwIfReadOnly(modeling, 'removeConnection'); - throwIfReadOnly(modeling, 'replaceShape'); - throwIfReadOnly(modeling, 'pasteElements'); - throwIfReadOnly(modeling, 'alignElements'); - throwIfReadOnly(modeling, 'resizeShape'); - throwIfReadOnly(modeling, 'createSpace'); - throwIfReadOnly(modeling, 'updateWaypoints'); - throwIfReadOnly(modeling, 'reconnectStart'); - throwIfReadOnly(modeling, 'reconnectEnd'); - - intercept(paletteProvider, 'getPaletteEntries', function(fn, args) { - var entries = fn.apply(this, args); - if (self._readOnly) { - forEach(entries, function(value, key) { - delete entries[key]; - }); - } - return entries; - }); -} - -ReadOnly.$inject = [ - 'eventBus', - 'contextPad', - 'dragging', - 'directEditing', - 'editorActions', - 'modeling', - 'palette', - 'paletteProvider' -]; - -module.exports = ReadOnly; - -ReadOnly.prototype.readOnly = function(readOnly) { - var newValue = !!readOnly, - oldValue = !!this._readOnly; - - if (readOnly === undefined || newValue === oldValue) { - return oldValue; - } - - this._readOnly = newValue; - this._eventBus.fire('readOnly.changed', { readOnly: newValue }); - return newValue; -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/create/CreateVersion.js b/workflow-designer-ui/src/main/frontend/src/features/version/create/CreateVersion.js deleted file mode 100644 index 2635fa36..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/create/CreateVersion.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -* 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 { connect } from 'react-redux'; -import { withRouter } from 'react-router-dom'; - -import { hideModalAction } from 'shared/modal/modalWrapperActions'; -import CreateVersionView from 'features/version/create/CreateVersionView'; -import { - newVersionAction, - submitVersionAction -} from 'features/version/create/createVersionConstants'; -import { - getWorkflowId, - getLatestBaseId -} from 'features/workflow/overview/overviewSelectors'; - -function mapStateToProps(state) { - return { - workflowId: getWorkflowId(state), - baseVersionId: getLatestBaseId(state) - }; -} - -function mapDispatchToProps(dispatch) { - return { - submitNewVersion: payload => { - dispatch(submitVersionAction(payload)); - dispatch(hideModalAction()); - }, - closeCreateVersionModal: () => dispatch(hideModalAction()), - versionDetailsChanged: payload => dispatch(newVersionAction(payload)) - }; -} - -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(CreateVersionView) -); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/create/CreateVersionView.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/create/CreateVersionView.jsx deleted file mode 100644 index 101b442d..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/create/CreateVersionView.jsx +++ /dev/null @@ -1,95 +0,0 @@ -/* -* 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 { Button } from 'onap-ui-react'; -import Description from 'shared/components/Description'; -import Select from 'shared/components/Select/index'; -import { VERSION_LEVEL_LIST } from 'wfapp/appConstants'; - -class CreateVersionView extends Component { - static propTypes = { - versionCategories: PropTypes.array, - closeCreateVersionModal: PropTypes.func, - versionDetailsChanged: PropTypes.func, - submitNewVersion: PropTypes.func, - workflowId: PropTypes.string, - baseVersionId: PropTypes.string, - history: PropTypes.object - }; - - constructor(props) { - super(props); - this.state = { - newVersion: '' - }; - } - handleSubmitForm = () => { - const { - submitNewVersion, - workflowId, - baseVersionId, - history - } = this.props; - submitNewVersion({ - description: this.state.newVersion.description, - workflowId: workflowId, - baseId: baseVersionId || null, - history: history - }); - }; - - versionDetailsChanged = val => { - this.setState({ newVersion: val }); - }; - - render() { - const { closeCreateVersionModal } = this.props; - return ( - <form onSubmit={this.handleSubmitForm} autoComplete="off"> - <div className="new-version-page custom-modal-wrapper"> - <div className="form-custom-modal"> - <Select - dataObj={VERSION_LEVEL_LIST} - selectedItem={VERSION_LEVEL_LIST[0].value} - label={I18n.t('version.category')} - disabled - /> - <Description - name="version-description" - description={this.state.newVersion.description} - dataTestId="new-version-description" - onDataChange={this.versionDetailsChanged} - /> - </div> - <div className="modal-action-bar sdc-modal__footer"> - <Button btnType="primary"> - {I18n.t('buttons.createBtn')} - </Button> - <Button - btnType="secondary" - onClick={closeCreateVersionModal}> - {I18n.t('buttons.closeBtn')} - </Button> - </div> - </div> - </form> - ); - } -} - -export default CreateVersionView; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/create/__tests__/CreateVersionView_snapshot-test.js b/workflow-designer-ui/src/main/frontend/src/features/version/create/__tests__/CreateVersionView_snapshot-test.js deleted file mode 100644 index 13faac14..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/create/__tests__/CreateVersionView_snapshot-test.js +++ /dev/null @@ -1,28 +0,0 @@ -/* -* 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 from 'react'; -import renderer from 'react-test-renderer'; - -import CreateVersionView from '../CreateVersionView'; - -describe('Create new version snapshot', () => { - it('renders correctly', () => { - const tree = renderer.create(<CreateVersionView />).toJSON(); - - expect(tree).toMatchSnapshot(); - }); -}); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/create/__tests__/__snapshots__/CreateVersionView_snapshot-test.js.snap b/workflow-designer-ui/src/main/frontend/src/features/version/create/__tests__/__snapshots__/CreateVersionView_snapshot-test.js.snap deleted file mode 100644 index 4e17b936..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/create/__tests__/__snapshots__/CreateVersionView_snapshot-test.js.snap +++ /dev/null @@ -1,81 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Create new version snapshot renders correctly 1`] = ` -<form - autoComplete="off" - onSubmit={[Function]} -> - <div - className="new-version-page custom-modal-wrapper" - > - <div - className="form-custom-modal" - > - <div - className="select-wrapper version-selector sdc-input" - > - <label> - category - </label> - <select - className="inputinput-selector" - data-test-id="vc-select-box" - disabled={true} - value={undefined} - > - <option - data-test-id="vc-option" - value="2" - > - Major - </option> - <option - data-test-id="vc-option" - value="1" - > - Minor - </option> - </select> - </div> - <div - className="description-part" - > - <div - className="sdc-textarea" - > - <div - className="sdc-textarea__label" - > - description - </div> - <textarea - className="custom-textarea field-section sdc-textarea__textarea" - data-test-id="new-version-description" - disabled={false} - onChange={[Function]} - value={undefined} - /> - </div> - </div> - </div> - <div - className="modal-action-bar sdc-modal__footer" - > - <button - className="sdc-button sdc-button__primary " - disabled={false} - onClick={undefined} - > - createBtn - </button> - <button - className="sdc-button sdc-button__secondary " - disabled={false} - onClick={undefined} - > - closeBtn - </button> - </div> - </div> -</form> -`; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/create/createVersionConstants.js b/workflow-designer-ui/src/main/frontend/src/features/version/create/createVersionConstants.js deleted file mode 100644 index 5f72ff7a..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/create/createVersionConstants.js +++ /dev/null @@ -1,30 +0,0 @@ -/* -* 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 { createAction } from 'redux-actions'; - -export const VERSION_DETAILS_CHANGED = 'create/DETAILS_CHANGED'; -export const SUBMIT_VERSION = 'create/SUBMIT_VERSION'; - -export const newVersionAction = createAction( - VERSION_DETAILS_CHANGED, - payload => payload -); - -export const submitVersionAction = createAction( - SUBMIT_VERSION, - payload => payload -); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/create/views/NewVersionContainer.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/create/views/NewVersionContainer.jsx deleted file mode 100644 index 4d884730..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/create/views/NewVersionContainer.jsx +++ /dev/null @@ -1,45 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import { I18n } from 'react-redux-i18n'; -import { SVGIcon } from 'onap-ui-react'; - -const NewVersionContainer = ({ - onCreateVersion, - isVersionsCertifies, - isArchive -}) => { - const disableClass = isVersionsCertifies && !isArchive; - const newVersionDisabledClass = disableClass ? '' : 'newVersionDisabled'; - const svgColor = disableClass ? 'primary' : 'secondary'; - return ( - <div className={`create-new-version ${newVersionDisabledClass}`}> - <div className="create-item-plus-icon" onClick={onCreateVersion}> - <SVGIcon name="plus" color={svgColor} /> - {I18n.t('workflow.overview.newVersion')} - </div> - </div> - ); -}; - -NewVersionContainer.propTypes = { - onCreateVersion: PropTypes.func, - isVersionsCertifies: PropTypes.bool, - isArchive: PropTypes.bool -}; - -export default NewVersionContainer; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/general/General.js b/workflow-designer-ui/src/main/frontend/src/features/version/general/General.js deleted file mode 100644 index ecf84750..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/general/General.js +++ /dev/null @@ -1,39 +0,0 @@ -/* -* 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 { connect } from 'react-redux'; - -import GeneralView from 'features/version/general/GeneralView'; -import { - getVersionInfo, - getIsCertified -} from 'features/version/general/generalSelectors'; -import { workflowVersionDetailsChangedAction } from 'features/version/versionConstants'; -import { isWorkflowArchive } from 'features/workflow/workflowSelectors'; -const mapStateToProps = state => ({ - versionInfo: getVersionInfo(state), - isReadOnly: getIsCertified(state) || isWorkflowArchive(state) -}); - -const mapDispatchToProps = dispatch => ({ - onDataChange: payload => - dispatch(workflowVersionDetailsChangedAction(payload)) -}); - -export default connect( - mapStateToProps, - mapDispatchToProps -)(GeneralView); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/general/GeneralView.js b/workflow-designer-ui/src/main/frontend/src/features/version/general/GeneralView.js deleted file mode 100644 index e069ffb0..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/general/GeneralView.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import { I18n } from 'react-redux-i18n'; - -import Description from 'shared/components/Description'; -import { VersionInfo, LabeledValue } from 'shared/components/VersionInfo'; - -const GeneralView = ({ onDataChange, versionInfo, isReadOnly }) => { - const modifiedValue = I18n.l(versionInfo.modificationTime, { - dateFormat: 'date.short' - }); - const createdValue = I18n.l(versionInfo.creationTime, { - dateFormat: 'date.short' - }); - - return ( - <div className="general-page"> - <div className="general-page-content"> - <Description - description={versionInfo.description} - onDataChange={onDataChange} - disabled={isReadOnly} - /> - <VersionInfo> - <LabeledValue - title={I18n.t('workflow.general.created')} - value={createdValue} - /> - <LabeledValue - title={I18n.t('workflow.general.modified')} - value={modifiedValue} - /> - </VersionInfo> - </div> - </div> - ); -}; - -GeneralView.propTypes = { - onDataChange: PropTypes.func, - versionInfo: PropTypes.object, - isReadOnly: PropTypes.bool -}; - -export default GeneralView; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/general/generalSelectors.js b/workflow-designer-ui/src/main/frontend/src/features/version/general/generalSelectors.js deleted file mode 100644 index cc817fc2..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/general/generalSelectors.js +++ /dev/null @@ -1,33 +0,0 @@ -/* -* 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 { createSelector } from 'reselect'; - -import { versionState } from 'features/version/versionConstants'; - -export const getVersionInfo = state => state && state.currentVersion.general; - -export const getVersionsState = createSelector( - state => state && state.currentVersion.general.state -); - -export const getIsCertified = createSelector( - getVersionInfo, - versionInfo => - versionInfo && - versionInfo.state && - versionInfo.state.toLowerCase() === versionState.CERTIFIED -); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutput.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutput.js deleted file mode 100644 index c9cd5756..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutput.js +++ /dev/null @@ -1,83 +0,0 @@ -/* -* 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 { connect } from 'react-redux'; -import { - showAlertModalAction, - hideModalAction -} from 'shared/modal/modalWrapperActions'; - -import { - getIsShowInputs, - getSearch, - getDataRows, - getTypes, - getError -} from 'features/version/inputOutput/inputOutputSelectors'; -import { getIsCertified } from 'features/version/general/generalSelectors'; -import { - changeError, - showInputs, - showOutputs, - search, - add, - changeName, - changeType, - changeMandatory, - remove -} from 'features/version/inputOutput/inputOutputActions'; -import { isWorkflowArchive } from 'features/workflow/workflowSelectors'; -import InputOutputView from 'features/version/inputOutput/InputOutputView'; - -const mapStateToProps = state => ({ - isShowInputs: getIsShowInputs(state), - search: getSearch(state), - dataRows: getDataRows(state), - types: getTypes(state), - error: getError(state), - isReadOnly: getIsCertified(state) || isWorkflowArchive(state) -}); - -const mapDispatchToProps = dispatch => ({ - handleChangeError: payload => dispatch(changeError(payload)), - handleShowInputs: () => dispatch(showInputs()), - handleShowOutputs: () => dispatch(showOutputs()), - handleSearch: value => dispatch(search(value)), - handleAdd: () => dispatch(add()), - handleNameChange: (name, key) => dispatch(changeName(name, key)), - handleTypeChange: (type, key) => dispatch(changeType(type, key)), - handleMandatoryChange: (mandatory, key) => - dispatch(changeMandatory(mandatory, key)), - handleRemove: (alertProps, key) => { - if (alertProps) { - return dispatch( - showAlertModalAction({ - ...alertProps, - withButtons: true, - actionButtonClick: () => - dispatch(hideModalAction()) && dispatch(remove(key)) - }) - ); - } - - return dispatch(remove(key)); - } -}); - -export default connect( - mapStateToProps, - mapDispatchToProps -)(InputOutputView); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutputView.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutputView.jsx deleted file mode 100644 index 61e34990..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutputView.jsx +++ /dev/null @@ -1,234 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import { Translate, I18n } from 'react-redux-i18n'; -import cn from 'classnames'; -import { SVGIcon } from 'onap-ui-react'; - -import Scrollbars from 'shared/scroll/Scrollbars'; -import SearchInput from 'shared/searchInput/SearchInput'; -import { getValidationsError } from 'features/version/inputOutput/inputOutputValidations'; -import Tab from 'features/version/inputOutput/views/Tab'; -import TableHead from 'features/version/inputOutput/views/TableHead'; -import TableBody from 'features/version/inputOutput/views/TableBody'; -import NoDataRow from 'features/version/inputOutput/views/NoDataRow'; -import DataRow from 'features/version/inputOutput/views/DataRow'; - -class InputOutputView extends React.Component { - componentDidUpdate() { - const { dataRows, error, handleChangeError } = this.props; - - const validationsError = getValidationsError(dataRows); - - const isDiff = Object.keys(validationsError).some(errorKey => { - if (!error.hasOwnProperty(errorKey)) { - return true; - } - - return ( - JSON.stringify(validationsError[errorKey].sort()) !== - JSON.stringify(error[errorKey].sort()) - ); - }); - - if (isDiff) { - handleChangeError(validationsError); - } - } - - handleInputsTabClick = () => { - if (!this.props.isShowInputs) { - this.props.handleShowInputs(); - } - }; - - handleOutputsTabClick = () => { - if (this.props.isShowInputs) { - this.props.handleShowOutputs(); - } - }; - - handleSearchChange = value => { - this.props.handleSearch(value); - }; - - handleNameChange = key => name => { - this.props.handleNameChange(name, key); - }; - - handleTypeChange = key => event => { - this.props.handleTypeChange(event.target.value, key); - }; - - handleMandatoryChange = key => value => { - this.props.handleMandatoryChange(value, key); - }; - - handleRemoveClick = key => () => { - const { name } = this.props.dataRows[key]; - - let alertProps = false; - - if (name.replace(/\s+/g, '')) { - const title = I18n.t('workflow.inputOutput.DELETE'); - const body = I18n.t('workflow.inputOutput.confirmDelete', { - name: name.replace(/s+$/g, '') - }); - const closeButtonText = I18n.t('workflow.inputOutput.CANCEL'); - const actionButtonText = title; - - alertProps = { - title, - body, - closeButtonText, - actionButtonText - }; - } - - this.props.handleRemove(alertProps, key); - }; - - renderDataRows = () => { - const { dataRows, types, error } = this.props; - - if (dataRows.length < 1) { - return ( - <NoDataRow> - <Translate value="workflow.inputOutput.noData" /> - </NoDataRow> - ); - } - - return dataRows.map((data, i) => { - let errorMessage = ''; - - if ( - error.invalidCharacters && - error.invalidCharacters.includes(i) - ) { - errorMessage = I18n.t( - 'workflow.errorMessages.invalidCharacters' - ); - } else if (error.alreadyExists && error.alreadyExists.includes(i)) { - errorMessage = I18n.t('workflow.errorMessages.alreadyExists'); - } else if (error.emptyName && error.emptyName.includes(i)) { - errorMessage = I18n.t('workflow.errorMessages.emptyName'); - } - - return ( - <DataRow - key={`data.${i}`} - data={data} - types={types} - nameErrorMessage={errorMessage} - dataTestId="wf-input-output-row" - handleNameChange={this.handleNameChange(i)} - handleTypeChange={this.handleTypeChange(i)} - handleMandatoryChange={this.handleMandatoryChange(i)} - handleRemoveClick={this.handleRemoveClick(i)} - /> - ); - }); - }; - - render() { - const { isShowInputs, search, handleAdd, isReadOnly } = this.props; - - const addLabel = isShowInputs - ? I18n.t('workflow.inputOutput.addInput') - : I18n.t('workflow.inputOutput.addOutput'); - - const dataRowsView = this.renderDataRows(); - - return ( - <div className="input-output"> - <div className="input-output__header"> - <Tab - isActive={isShowInputs} - dataTestId="wf-input-output-inputs" - handleTabClick={this.handleInputsTabClick}> - <Translate value="workflow.inputOutput.inputs" /> - </Tab> - <Tab - isActive={!isShowInputs} - dataTestId="wf-input-output-outputs" - handleTabClick={this.handleOutputsTabClick}> - <Translate value="workflow.inputOutput.outputs" /> - </Tab> - <div className="input-output__header__right"> - <div className="input-output__search"> - <SearchInput - dataTestId="wf-input-output-search" - onChange={this.handleSearchChange} - value={search} - /> - </div> - <div - className={cn('input-output__add', { - disabled: isReadOnly - })} - data-test-id="wf-input-output-add" - onClick={handleAdd}> - <SVGIcon - label={addLabel} - labelPosition="right" - color="primary" - name="plusThin" - /> - </div> - </div> - </div> - <div className="input-output__table"> - <TableHead /> - <TableBody isReadOnly={isReadOnly}> - <Scrollbars className="scrollbars"> - {dataRowsView} - </Scrollbars> - </TableBody> - </div> - </div> - ); - } -} - -InputOutputView.propTypes = { - isShowInputs: PropTypes.bool, - search: PropTypes.string, - dataRows: PropTypes.arrayOf( - PropTypes.shape({ - name: PropTypes.string, - type: PropTypes.string, - mandatory: PropTypes.bool - }) - ), - types: PropTypes.array, - error: PropTypes.object, - isReadOnly: PropTypes.bool, - handleChangeError: PropTypes.func, - handleShowInputs: PropTypes.func, - handleShowOutputs: PropTypes.func, - handleSearch: PropTypes.func, - handleAdd: PropTypes.func, - handleCurrentDataChange: PropTypes.func, - handleNameChange: PropTypes.func, - handleTypeChange: PropTypes.func, - handleMandatoryChange: PropTypes.func, - handleRemove: PropTypes.func -}; - -export default InputOutputView; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputActions-test.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputActions-test.js deleted file mode 100644 index 465602fc..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputActions-test.js +++ /dev/null @@ -1,150 +0,0 @@ -/* -* 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 { - NAME_MAX_LEN, - STRING, - SET_INPUTS_OUTPUTS, - CHANGE_ERROR, - SHOW_INPUTS, - SHOW_OUTPUTS, - SEARCH, - ADD, - CHANGE_NAME, - CHANGE_TYPE, - CHANGE_MANDATORY, - REMOVE -} from 'features/version/inputOutput/inputOutputConstants'; -import { - setInputsOutputs, - changeError, - showInputs, - showOutputs, - search, - add, - changeName, - changeType, - changeMandatory, - remove -} from 'features/version/inputOutput/inputOutputActions'; - -describe('Input/Output Actions', () => { - it('should have `setInputsOutputs` action', () => { - const inputs = [ - { - name: 'Input', - type: STRING, - mandatory: false - } - ]; - - const outputs = [ - { - name: 'Output', - type: STRING, - mandatory: false - } - ]; - - const expected = { - type: SET_INPUTS_OUTPUTS, - payload: { - inputs, - outputs - } - }; - - expect(setInputsOutputs({ inputs, outputs })).toEqual(expected); - }); - - it('should have `changeError` action', () => { - const payload = { key: 'value' }; - - const expected = { type: CHANGE_ERROR, payload }; - - expect(changeError(payload)).toEqual(expected); - }); - - it('should have `showInputs` action', () => { - const expected = { type: SHOW_INPUTS }; - - expect(showInputs()).toEqual(expected); - }); - - it('should have `showOutputs` action', () => { - const expected = { type: SHOW_OUTPUTS }; - - expect(showOutputs()).toEqual(expected); - }); - - it('should have `search` action', () => { - const payload = 'Search Value'; - - const expected = { type: SEARCH, payload }; - - expect(search(payload)).toEqual(expected); - }); - - it('should have `add` action', () => { - const expected = { type: ADD }; - - expect(add()).toEqual(expected); - }); - - it('should have `changeName` action', () => { - let name = 'This is a long name more that more more more and more'; - let key = 1; - - const expected = { - type: CHANGE_NAME, - payload: { - name: name.substr(0, NAME_MAX_LEN), - key - } - }; - - expect(changeName(name, key)).toEqual(expected); - }); - - it('should have `changeType` action', () => { - const type = 'String'; - const key = 1; - - const expected = { type: CHANGE_TYPE, payload: { type, key } }; - - expect(changeType(type, key)).toEqual(expected); - }); - - it('should have `changeMandatory` action', () => { - const mandatory = true; - const key = 1; - - const expected = { - type: CHANGE_MANDATORY, - payload: { mandatory, key } - }; - - expect(changeMandatory(mandatory, key)).toEqual(expected); - }); - - it('should have `remove` action', () => { - const payload = 1; - - const expected = { type: REMOVE, payload }; - - expect(remove(payload)).toEqual(expected); - }); -}); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputReducer-test.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputReducer-test.js deleted file mode 100644 index b923f4a4..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputReducer-test.js +++ /dev/null @@ -1,191 +0,0 @@ -/* -* 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 { - STRING, - INPUTS, - OUTPUTS -} from 'features/version/inputOutput/inputOutputConstants'; -import inputOutputReducer, { - initialState, - defaultInputOutput -} from 'features/version/inputOutput/inputOutputReducer'; -import { - setInputsOutputs, - changeError, - showInputs, - showOutputs, - search, - add, - changeName, - changeType, - changeMandatory, - remove -} from 'features/version/inputOutput/inputOutputActions'; - -describe('Input/Output Reducer', () => { - it('should return initialState', () => { - expect(inputOutputReducer(undefined, {})).toEqual(initialState); - }); - - it('should set inputs/outputs', () => { - const payload = { - inputs: [ - { - name: 'Input', - type: STRING, - mandatory: false - } - ], - outputs: { - name: 'Output', - type: STRING, - mandatory: false - } - }; - - expect( - inputOutputReducer(undefined, setInputsOutputs(payload)) - ).toEqual({ ...initialState, ...payload }); - }); - - it('should change input/output error', () => { - const payload = { - alreadyExists: [1, 2], - invalidCharacteres: [3, 4] - }; - [INPUTS, OUTPUTS].forEach(current => { - const state = { ...initialState, current }; - expect(inputOutputReducer(state, changeError(payload))).toEqual({ - ...state, - error: { - ...state.error, - [current]: payload - } - }); - }); - }); - - it('should show inputs', () => { - expect(inputOutputReducer(undefined, showInputs())).toEqual({ - ...initialState, - current: INPUTS - }); - }); - - it('should show outputs', () => { - expect(inputOutputReducer(undefined, showOutputs())).toEqual({ - ...initialState, - current: OUTPUTS - }); - }); - - it('should add input/output', () => { - [INPUTS, OUTPUTS].forEach(current => { - const state = { ...initialState, current }; - expect(inputOutputReducer(state, add())).toEqual({ - ...state, - [current]: [...state[current], defaultInputOutput[current]] - }); - }); - }); - - it('should add search', () => { - const payload = 'Search string'; - expect(inputOutputReducer(undefined, search(payload))).toEqual({ - ...initialState, - search: payload - }); - }); - - it('should change input/output name/type/mandatory', () => { - const name = 'New name'; - const type = 'New Type'; - const mandatory = true; - const key = 0; - const state = { - ...initialState, - [INPUTS]: [ - { - name: 'Old name', - type: 'Old type', - mandatory: false - } - ], - [OUTPUTS]: [ - { - name: 'Old name', - type: 'Old type', - mandatory: false - } - ] - }; - [INPUTS, OUTPUTS].forEach(current => { - [ - { - action: changeName(name, key), - field: 'name', - value: name - }, - { - action: changeType(type, key), - field: 'type', - value: type - }, - { - action: changeMandatory(mandatory, key), - field: 'mandatory', - value: mandatory - } - ].forEach(actionMap => { - const actual = inputOutputReducer( - { ...state, current }, - actionMap.action - )[current][key][actionMap.field]; - - const expected = actionMap.value; - - expect(actual).toEqual(expected); - }); - }); - }); - - it('should remove input/output ', () => { - const key = 0; - const state = { - ...initialState, - [INPUTS]: [ - { - name: 'Name', - type: 'String', - mandatory: true - } - ], - [OUTPUTS]: [ - { - name: 'Name', - type: 'String', - mandatory: true - } - ] - }; - [INPUTS, OUTPUTS].forEach(current => { - expect( - inputOutputReducer({ ...state, current }, remove(key))[current] - ).toEqual([]); - }); - }); -}); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputSelectors-test.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputSelectors-test.js deleted file mode 100644 index 8e9bdbd4..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/__tests__/inputOutputSelectors-test.js +++ /dev/null @@ -1,149 +0,0 @@ -/* -* 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 { - getInputOutput, - getCurrent, - getIsShowInputs, - getSearch, - getDataRows, - getTypes, - getError -} from 'features/version/inputOutput/inputOutputSelectors'; - -describe('Input/Output Selectors', () => { - const state = { - currentVersion: { - general: { - id: '1e659854c7e240c881f1dd8d5bd833cc', - name: '1.0', - description: 'Initial version', - baseId: null, - creationTime: '2018-07-19T13:09:39.066+0000', - modificationTime: '2018-07-19T13:09:39.355+0000', - state: 'DRAFT', - inputs: [], - outputs: [] - }, - inputOutput: { - current: 'outputs', - inputs: [ - { - name: 'IP Address', - value: 'String', - mandatory: true, - type: 'Integer' - }, - { - name: 'MAC Address', - value: 'String', - mandatory: false, - type: 'Integer' - }, - { - name: 'IP', - value: 'String', - mandatory: true, - type: 'Boolean' - }, - { - name: 'IP', - value: 'String', - mandatory: false - }, - { - name: '', - value: 'String', - mandatory: false - }, - { - name: '', - value: 'String', - mandatory: false - } - ], - outputs: [ - { - name: 'IP Address', - value: 'String', - mandatory: true - }, - { - name: 'IP', - value: 'String', - mandatory: true - }, - { - name: 'IP', - value: 'String', - mandatory: false, - type: 'Boolean' - } - ], - search: 'IP', - types: ['String', 'Boolean', 'Integer', 'Float'], - error: { - inputs: { - alreadyExists: [1, 2], - invalidCharacters: [] - }, - outputs: { - alreadyExists: [1, 2], - invalidCharacters: [] - } - } - } - } - }; - - it('should `getInputOutput`', () => { - expect(getInputOutput(state)).toEqual(state.currentVersion.inputOutput); - }); - - it('should `getCurrent`', () => { - expect(getCurrent(state)).toEqual( - state.currentVersion.inputOutput.current - ); - }); - - it('should `getIsShowInputs`', () => { - expect(getIsShowInputs(state)).toBeFalsy(); - }); - - it('should `getSearch`', () => { - expect(getSearch(state)).toEqual( - state.currentVersion.inputOutput.search - ); - }); - - it('should `getDataRows`', () => { - expect(getDataRows(state)).toEqual( - state.currentVersion.inputOutput.outputs - ); - }); - - it('should `getTypes`', () => { - expect(getTypes(state)).toEqual(state.currentVersion.inputOutput.types); - }); - - it('should `getError`', () => { - expect(getError(state)).toEqual( - state.currentVersion.inputOutput.error[ - state.currentVersion.inputOutput.current - ] - ); - }); -}); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputActions.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputActions.js deleted file mode 100644 index a9548592..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputActions.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -* 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 { createActions } from 'redux-actions'; - -import { - NAME_MAX_LEN, - NAMESPACE -} from 'features/version/inputOutput/inputOutputConstants'; - -export const { - [NAMESPACE]: { - setInputsOutputs, - changeError, - showInputs, - showOutputs, - search, - add, - changeName, - changeType, - changeMandatory, - remove - } -} = createActions({ - [NAMESPACE]: { - SET_INPUTS_OUTPUTS: undefined, - CHANGE_ERROR: undefined, - SHOW_INPUTS: undefined, - SHOW_OUTPUTS: undefined, - SEARCH: undefined, - ADD: undefined, - CHANGE_NAME: (name, key) => ({ - name: name.substr(0, NAME_MAX_LEN), - key - }), - CHANGE_TYPE: (type, key) => ({ type, key }), - CHANGE_MANDATORY: (mandatory, key) => ({ mandatory, key }), - REMOVE: undefined - } -}); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputConstants.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputConstants.js deleted file mode 100644 index 30f80a6b..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputConstants.js +++ /dev/null @@ -1,39 +0,0 @@ -/* -* 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. -*/ - -export const NAME_MAX_LEN = 50; - -export const INPUTS = 'inputs'; -export const OUTPUTS = 'outputs'; - -export const STRING = 'string'; -export const DEFAULT_STRING = 'STRING'; -export const BOOLEAN = 'boolean'; -export const INTEGER = 'integer'; -export const FLOAT = 'float'; - -export const NAMESPACE = 'inputOutput'; - -export const SET_INPUTS_OUTPUTS = `${NAMESPACE}/SET_INPUTS_OUTPUTS`; -export const CHANGE_ERROR = `${NAMESPACE}/CHANGE_ERROR`; -export const SHOW_INPUTS = `${NAMESPACE}/SHOW_INPUTS`; -export const SHOW_OUTPUTS = `${NAMESPACE}/SHOW_OUTPUTS`; -export const SEARCH = `${NAMESPACE}/SEARCH`; -export const ADD = `${NAMESPACE}/ADD`; -export const CHANGE_NAME = `${NAMESPACE}/CHANGE_NAME`; -export const CHANGE_TYPE = `${NAMESPACE}/CHANGE_TYPE`; -export const CHANGE_MANDATORY = `${NAMESPACE}/CHANGE_MANDATORY`; -export const REMOVE = `${NAMESPACE}/REMOVE`; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputReducer.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputReducer.js deleted file mode 100644 index 881322fa..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputReducer.js +++ /dev/null @@ -1,130 +0,0 @@ -/* -* 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 { - INPUTS, - OUTPUTS, - STRING, - DEFAULT_STRING, - BOOLEAN, - INTEGER, - FLOAT, - SET_INPUTS_OUTPUTS, - CHANGE_ERROR, - SHOW_INPUTS, - SHOW_OUTPUTS, - SEARCH, - ADD, - CHANGE_NAME, - CHANGE_TYPE, - CHANGE_MANDATORY, - REMOVE -} from 'features/version/inputOutput/inputOutputConstants'; - -export const defaultInputOutput = { - [INPUTS]: { - name: '', - type: DEFAULT_STRING, - mandatory: false - }, - [OUTPUTS]: { - name: '', - type: DEFAULT_STRING, - mandatory: false - } -}; - -export const initialState = { - current: INPUTS, - [INPUTS]: [], - [OUTPUTS]: [], - search: '', - types: [STRING, BOOLEAN, INTEGER, FLOAT], - error: { - [INPUTS]: {}, - [OUTPUTS]: {} - } -}; - -const inputOutputReducer = (state = initialState, action) => { - const { type, payload } = action; - switch (type) { - case SET_INPUTS_OUTPUTS: - return { - ...initialState, - ...payload - }; - - case CHANGE_ERROR: - return { - ...state, - error: { - ...state.error, - [state.current]: payload - } - }; - - case SHOW_INPUTS: - return { ...state, current: INPUTS }; - - case SHOW_OUTPUTS: - return { ...state, current: OUTPUTS }; - - case SEARCH: - return { ...state, search: payload }; - - case ADD: - return { - ...state, - [state.current]: [ - ...state[state.current], - defaultInputOutput[state.current] - ] - }; - - /* eslint-disable no-case-declarations */ - case CHANGE_NAME: - case CHANGE_TYPE: - case CHANGE_MANDATORY: - const { key, ...rest } = payload; - return { - ...state, - [state.current]: state[state.current].map( - (row, index) => - key === index - ? { - ...row, - ...rest - } - : row - ) - }; - /* eslint-enable no-case-declarations */ - - case REMOVE: - return { - ...state, - [state.current]: state[state.current].filter( - (_, index) => index !== payload - ) - }; - - default: - return state; - } -}; - -export default inputOutputReducer; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputSelectors.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputSelectors.js deleted file mode 100644 index 3a6c9e8f..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputSelectors.js +++ /dev/null @@ -1,106 +0,0 @@ -/* -* 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 { createSelector } from 'reselect'; -import isEmpty from 'lodash.isempty'; - -import { INPUTS } from 'features/version/inputOutput/inputOutputConstants'; - -export const getInputOutput = state => state.currentVersion.inputOutput; -export const getInputs = createSelector(getInputOutput, data => data.inputs); -export const getOutputs = createSelector(getInputOutput, data => data.outputs); -export const getInputOutputForComposition = state => ({ - inputs: getInputs(state).map(item => ({ - ...item, - type: item.type.toLowerCase() - })), - outputs: getOutputs(state).map(item => ({ - ...item, - type: item.type.toLowerCase() - })) -}); -export const getCurrent = createSelector( - getInputOutput, - inputOutput => inputOutput.current -); - -export const getIsShowInputs = createSelector( - getCurrent, - current => current === INPUTS -); - -export const getSearch = createSelector( - getInputOutput, - inputOutput => inputOutput.search -); - -export const getDataRows = createSelector( - [getInputOutput, getCurrent], - (inputOutput, current) => { - if (inputOutput.search) { - return inputOutput[current].filter(dataRow => - dataRow.name - .toLowerCase() - .includes(inputOutput.search.toLowerCase()) - ); - } - - return inputOutput[current]; - } -); - -export const getTypes = createSelector( - getInputOutput, - inputOutput => inputOutput.types -); - -export const getError = createSelector( - [getInputOutput, getCurrent], - (inputOutput, current) => inputOutput.error[current] -); - -export const getErrorsInputOutput = createSelector( - getInputOutput, - ({ error }) => error -); - -export const getInputErrors = createSelector( - getErrorsInputOutput, - ({ inputs }) => - !isEmpty(inputs) && - Boolean( - inputs.alreadyExists.length || - inputs.invalidCharacters.length || - inputs.emptyName.length - ) -); - -export const getOutputErrors = createSelector( - getErrorsInputOutput, - ({ outputs }) => - !isEmpty(outputs) && - Boolean( - outputs.alreadyExists.length || - outputs.invalidCharacters.length || - outputs.emptyName.length - ) -); - -export const getIOErrors = createSelector( - getInputErrors, - getOutputErrors, - (inputsErrors, outputsErrors) => inputsErrors || outputsErrors -); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputValidations.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputValidations.js deleted file mode 100644 index d4057879..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/inputOutputValidations.js +++ /dev/null @@ -1,64 +0,0 @@ -/* -* 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. -*/ - -export const getValidationsError = dataRows => { - const error = {}; - - const groupBy = dataRows.reduce((result, value, key) => { - const groupKey = value.name.toLowerCase(); - - if (groupKey) { - if (result.hasOwnProperty(groupKey)) { - result[groupKey].push(key); - } else { - result[groupKey] = [key]; - } - } - return result; - }, {}); - - error.alreadyExists = Object.keys(groupBy).reduce((result, value) => { - if (groupBy[value].length > 1) { - result = [...result, ...groupBy[value]]; - } - - return result; - }, []); - - error.emptyName = dataRows.reduce((result, value, key) => { - const name = value.name; - - if (!name) { - result.push(key); - } - - return result; - }, []); - - error.invalidCharacters = dataRows.reduce((result, value, key) => { - const groupKey = value.name; - - if (groupKey) { - if (!/^[\w\d]+$/.test(groupKey)) { - result.push(key); - } - } - - return result; - }, []); - - return error; -}; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/DataRow.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/DataRow.jsx deleted file mode 100644 index 70103f87..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/DataRow.jsx +++ /dev/null @@ -1,87 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; - -import { Input, Checkbox, SVGIcon } from 'onap-ui-react'; - -const DataRow = ({ - data: { name, type, mandatory }, - types, - nameErrorMessage, - dataTestId, - handleNameChange, - handleNameBlur, - handleTypeChange, - handleMandatoryChange, - handleRemoveClick -}) => ( - <div className="input-output__tr"> - <div className="input-output__td"> - <Input - errorMessage={nameErrorMessage} - data-test-id={`${dataTestId}-name`} - onChange={handleNameChange} - onBlur={handleNameBlur} - type="text" - value={name} - /> - </div> - <div className="input-output__td"> - <select - className="input-output-select" - value={type} - data-test-id={`${dataTestId}-select`} - onChange={handleTypeChange}> - {types.map((type, i) => ( - <option key={`type.${i}`} value={type.toUpperCase()}> - {type} - </option> - ))} - </select> - </div> - <div className="input-output__td input-output__td--unflex"> - <Checkbox - value="myVal" - data-test-id={`${dataTestId}-mandatory`} - onChange={handleMandatoryChange} - checked={mandatory} - /> - </div> - <div className="input-output__td input-output__td--unflex input-output__td--icon"> - <SVGIcon - name="trashO" - data-test-id={`${dataTestId}-delete`} - onClick={handleRemoveClick} - /> - </div> - </div> -); - -DataRow.propTypes = { - data: PropTypes.object, - types: PropTypes.array, - nameErrorMessage: PropTypes.string, - dataTestId: PropTypes.string, - handleNameChange: PropTypes.func, - handleNameBlur: PropTypes.func, - handleTypeChange: PropTypes.func, - handleMandatoryChange: PropTypes.func, - handleRemoveClick: PropTypes.func -}; - -export default DataRow; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/NoDataRow.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/NoDataRow.jsx deleted file mode 100644 index af75c79e..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/NoDataRow.jsx +++ /dev/null @@ -1,32 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; - -const NoDataRow = ({ children }) => ( - <div className="input-output__tr input-output__tr--no-hover"> - <div className="input-output__td input-output__td--empty"> - {children} - </div> - </div> -); - -NoDataRow.propTypes = { - children: PropTypes.node -}; - -export default NoDataRow; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/Tab.js b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/Tab.js deleted file mode 100644 index ad56dc15..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/Tab.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import cn from 'classnames'; - -const Tab = ({ children, isActive, dataTestId, handleTabClick }) => { - const className = cn('input-output__tab', { - 'input-output__tab--active': isActive - }); - - return ( - <div - className={className} - data-test-id={`${dataTestId}-tab`} - onClick={handleTabClick}> - {children} - </div> - ); -}; - -Tab.propTypes = { - children: PropTypes.node, - isActive: PropTypes.bool, - dataTestId: PropTypes.string, - handleTabClick: PropTypes.func -}; - -export default Tab; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/TableBody.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/TableBody.jsx deleted file mode 100644 index ed11bbc5..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/TableBody.jsx +++ /dev/null @@ -1,50 +0,0 @@ -/* -* 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. -*/ -/* eslint-disable no-unused-vars */ - -import React from 'react'; -import PropTypes from 'prop-types'; -import cn from 'classnames'; - -class TableBody extends React.Component { - handleNameInputChange = params => { - console.log('handleNameInputChange', { params }); - }; - - handleMandatoryCheckboxChange = params => { - console.log('handleMandatoryCheckboxChange: ', { params }); - }; - - render() { - const { isReadOnly, children } = this.props; - - return ( - <div - className={cn('input-output__table__tbody', { - disabled: isReadOnly - })}> - {children} - </div> - ); - } -} - -TableBody.propTypes = { - isReadOnly: PropTypes.bool, - children: PropTypes.node -}; - -export default TableBody; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/TableHead.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/TableHead.jsx deleted file mode 100644 index 37a8cb43..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/TableHead.jsx +++ /dev/null @@ -1,41 +0,0 @@ -/* -* 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 from 'react'; -import { Translate } from 'react-redux-i18n'; - -export default class TableHead extends React.Component { - render() { - return ( - <div className="input-output__table__thead"> - <div className="input-output__tr input-output__tr--no-hover"> - <div className="input-output__th"> - <Translate value="workflow.inputOutput.name" /> - </div> - <div className="input-output__th"> - <Translate value="workflow.inputOutput.type" /> - </div> - <div className="input-output__th input-output__th--unflex"> - <Translate value="workflow.inputOutput.mandatory" /> - </div> - <div className="input-output__th input-output__th--unflex input-output__th--icon"> - ••• - </div> - </div> - </div> - ); - } -} diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionApi.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionApi.js deleted file mode 100644 index b3a2e13a..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionApi.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -* 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 RestfulAPIUtil from 'services/restAPIUtil'; -import Configuration from 'config/Configuration.js'; -import { CERTIFY_JSON } from 'features/version/versionController/versionControllerConstants'; - -function baseUrl(workflowId) { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/workflows/${workflowId}/versions`; -} - -const Api = { - fetchVersion: ({ workflowId, versionId }) => { - return RestfulAPIUtil.fetch(`${baseUrl(workflowId)}/${versionId}`); - }, - createNewVersion: ({ workflowId, baseId, description }) => { - const urlParams = baseId ? `?baseVersionId=${baseId}` : ``; - return RestfulAPIUtil.post(`${baseUrl(workflowId)}${urlParams}`, { - description - }); - }, - updateVersion: ({ workflowId, ...payload }) => { - return RestfulAPIUtil.put( - `${baseUrl(workflowId)}/${payload.params.id}`, - { - ...payload.params - } - ); - }, - fetchVersionArtifact: ({ workflowId, versionId }) => { - return RestfulAPIUtil.fetch( - `${baseUrl(workflowId)}/${versionId}/artifact` - ); - }, - updateVersionArtifact: ({ - workflowId, - versionId, - workflowName, - versionName, - payload - }) => { - let formData = new FormData(); - var blob = new Blob([payload], { type: 'text/xml' }); - formData.append( - 'fileToUpload', - blob, - `${workflowName}-${versionName}.bpmn` - ); - - return RestfulAPIUtil.put( - `${baseUrl(workflowId)}/${versionId}/artifact`, - formData - ); - }, - deleteVersionArtifact: ({ workflowId, versionId }) => { - return RestfulAPIUtil.delete( - `${baseUrl(workflowId)}/${versionId}/artifact` - ); - }, - certifyVersion: ({ workflowId, versionId }) => { - return RestfulAPIUtil.post( - `${baseUrl(workflowId)}/${versionId}/state`, - CERTIFY_JSON - ); - } -}; - -export default Api; 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 deleted file mode 100644 index 5b945a02..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionConstants.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -* 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 { createAction } from 'redux-actions'; - -export const SET_CURRENT_VERSION = 'workflow/version/SET_CURRENT_VERSION'; -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( - FETCH_REQUESTED -); - -export const workflowVersionDetailsChangedAction = createAction( - DETAILS_CHANGED -); - -export const setWorkflowVersionAction = createAction(SET_CURRENT_VERSION); -export const fetchWorkflowVersionActionFailed = createAction( - FETCH_REQUESTED_FAILED, - error => error -); - -export const versionStateChangedAction = createAction( - VERSION_STATE_CHANGED, - 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 deleted file mode 100644 index 8c37a0e3..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -* 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 { connect } from 'react-redux'; -import { getSavedObjParams } from 'features/version/versionController/versionControllerSelectors'; -import VersionControllerView from 'features/version/versionController/VersionControllerView'; -import { - getVersions, - getSortedVersions -} from 'features/workflow/overview/overviewSelectors'; -import { - isWorkflowArchive, - getWorkflowId, - getWorkflowName -} from 'features/workflow/workflowSelectors'; -import { - saveParamsAction, - certifyVersionAction -} from 'features/version/versionController/versionControllerConstants'; -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), - workflowId: getWorkflowId(state), - versionsList: getSortedVersions(state), - savedParams: getSavedObjParams(state), - hasErrors: getIOErrors(state) || getCompositionHasErrors(state), - isCertifyDisable: getIsCertified(state), - isArchive: isWorkflowArchive(state), - currentWorkflowVersion: state.currentVersion.general, - pluginContext: pluginContextSelector(state), - isCompositionUpdating: getIsCompositionUpdating(state) - }; -} - -function mapDispatchToProps(dispatch) { - return { - getVersions: () => dispatch(getVersions), - saveParamsToServer: params => dispatch(saveParamsAction(params)), - certifyVersion: payload => dispatch(certifyVersionAction(payload)), - changeVersion: payload => - dispatch(workflowVersionFetchRequestedAction(payload)), - toggleCompositionUpdate: payload => - dispatch(toggleCompositionUpdate(payload)) - }; -} - -export default connect( - mapStateToProps, - mapDispatchToProps -)(VersionControllerView); 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 deleted file mode 100644 index 730d92fb..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx +++ /dev/null @@ -1,171 +0,0 @@ -/* -* 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 ActionButtons from 'features/version/versionController/views/ActionButtons'; -import OperationModeButtons from 'features/version/versionController/views/OperationModeButtons'; -import VersionContainer from 'features/version/versionController/views/VersionsContainer'; -import WorkflowTitle from 'features/version/versionController/views/WorkflowTitle'; -import { PluginPubSub } from 'shared/pubsub/plugin-pubsub.ts'; -import { - notificationType, - CATALOG_PATH -} from 'wfapp/pluginContext/pluginContextConstants'; -export default class VersionControllerView extends Component { - static propTypes = { - location: PropTypes.object, - workflowName: PropTypes.string, - currentWorkflowVersion: PropTypes.object, - viewableVersions: PropTypes.arrayOf(Object), - getVersions: PropTypes.func, - versionsList: PropTypes.array, - history: PropTypes.object, - getOverview: PropTypes.func, - match: PropTypes.object, - savedParams: PropTypes.object, - saveParamsToServer: PropTypes.func, - workflowId: PropTypes.string, - certifyVersion: PropTypes.func, - changeVersion: PropTypes.func, - isCertifyDisable: PropTypes.bool, - hasErrors: PropTypes.bool, - isArchive: PropTypes.bool, - operationMode: PropTypes.bool, - pluginContext: PropTypes.object, - isCompositionUpdating: PropTypes.bool, - toggleCompositionUpdate: PropTypes.func - }; - - constructor(props) { - super(props); - } - - routeToOverview = () => { - const { history, match } = this.props; - const workflowId = match.params.workflowId; - history.push(`/workflows/workflow/${workflowId}/overview`); - }; - - sendSaveParamsToServer = () => { - const { - savedParams, - saveParamsToServer, - workflowId, - workflowName - } = this.props; - saveParamsToServer({ params: savedParams, workflowId, workflowName }); - }; - handleSendMsgToCatalog = () => { - const { - pluginContext: { eventsClientId, parentUrl }, - workflowId, - isCertifyDisable - } = this.props; - const client = new PluginPubSub(eventsClientId, parentUrl); - client.notify(notificationType.CLOSE, { - isCompleted: isCertifyDisable, - workflowId, - path: CATALOG_PATH - }); - }; - certifyVersion = () => { - const { - certifyVersion, - workflowId, - currentWorkflowVersion, - savedParams, - workflowName - } = this.props; - certifyVersion({ - workflowId, - workflowName, - versionId: currentWorkflowVersion.id, - params: savedParams - }); - }; - - versionChangeCallback = versionId => { - const { changeVersion, workflowId } = this.props; - changeVersion({ versionId, workflowId }); - }; - - undoClickCallback = () => { - const { - currentWorkflowVersion, - changeVersion, - workflowId - } = this.props; - changeVersion({ versionId: currentWorkflowVersion.id, workflowId }); - }; - - render() { - const { - currentWorkflowVersion, - workflowName, - versionsList, - hasErrors, - isCertifyDisable, - isArchive, - operationMode, - isCompositionUpdating, - toggleCompositionUpdate - } = this.props; - const isReadonly = isCertifyDisable || hasErrors || isArchive; - return ( - <div className="version-controller-bar"> - <WorkflowTitle workflowName={workflowName} /> - <div - className={`vc-container ${ - operationMode ? 'vs-container-operation' : '' - }`}> - {!operationMode && ( - <VersionContainer - currentWorkflowVersion={currentWorkflowVersion} - viewableVersions={versionsList} - onOverviewClick={this.routeToOverview} - onVersionSelectChange={this.versionChangeCallback} - isArchive={isArchive} - /> - )} - {operationMode && ( - <OperationModeButtons - sendMsgToCatalog={this.handleSendMsgToCatalog} - saveDisabled={isReadonly} - onSaveClick={this.sendSaveParamsToServer} - onCertifyClick={this.certifyVersion} - /> - )} - {!operationMode && ( - <ActionButtons - isCompositionUpdating={isCompositionUpdating} - saveDisabled={isReadonly} - onSaveClick={this.sendSaveParamsToServer} - certifyDisabled={isReadonly} - onCertifyClick={this.certifyVersion} - onUndoClick={this.undoClickCallback} - toggleCompositionUpdate={toggleCompositionUpdate} - /> - )} - </div> - </div> - ); - } -} - -VersionControllerView.defaultProps = { - getVersions: () => {} -}; 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 deleted file mode 100644 index 2bcfa300..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/VersionControllerView_snapshot-test.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -* 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 from 'react'; -import renderer from 'react-test-renderer'; - -import VersionsContainer from 'features/version/versionController/views/VersionsContainer'; - -describe('Version Controller View Snapshot', () => { - it('renders correctly', () => { - const versionList = [ - { - id: '7b5f6b086613470985082df2c0f6c713', - name: '1.0', - 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' - }, - { - id: '7b5f6b086613470985082df2c0f6c666', - name: '2.0', - 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', - baseId: '7b5f6b086613470985082df2c0f6c713' - } - ]; - const tree = renderer - .create( - <VersionsContainer - viewableVersions={versionList} - currentWorkflowVersion={versionList[0]} - /> - ) - .toJSON(); - - expect(tree).toMatchSnapshot(); - }); -}); 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 deleted file mode 100644 index ea135fce..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/__tests__/__snapshots__/VersionControllerView_snapshot-test.js.snap +++ /dev/null @@ -1,39 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Version Controller View Snapshot renders correctly 1`] = ` -<div - className="version-section-wrapper" -> - <div - className="version-status-container" - > - version - <select - className="version-selector" - data-test-id="vc-versions-select-box" - onChange={[Function]} - value="7b5f6b086613470985082df2c0f6c713" - > - <option - data-test-id="vc-version-option" - value="7b5f6b086613470985082df2c0f6c713" - > - 1.0 DRAFT - </option> - <option - data-test-id="vc-version-option" - value="7b5f6b086613470985082df2c0f6c666" - > - 2.0 Draft - </option> - </select> - <span - className="version-selector-more-versions" - data-test-id="vc-versions-page-link" - onClick={undefined} - > - viewOverview - </span> - </div> -</div> -`; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/versionControllerConstants.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/versionControllerConstants.js deleted file mode 100644 index 57aef602..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/versionControllerConstants.js +++ /dev/null @@ -1,29 +0,0 @@ -/* -* 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 { createAction } from 'redux-actions'; -export const SAVE_ACTION = 'versionController/SAVE'; -export const CERTIFY_ACTION = 'versionController/CERTIFY'; -export const UNDO_ACTION = 'versionController/UNDO'; -export const CERTIFY_JSON = { - name: 'CERTIFIED' -}; - -export const saveParamsAction = createAction(SAVE_ACTION, payload => payload); -export const certifyVersionAction = createAction( - CERTIFY_ACTION, - payload => payload -); diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/versionControllerSelectors.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/versionControllerSelectors.js deleted file mode 100644 index 19c8bdc2..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/versionControllerSelectors.js +++ /dev/null @@ -1,36 +0,0 @@ -/* -* 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 { createSelector } from 'reselect'; -import { - getInputs, - getOutputs -} from 'features/version/inputOutput/inputOutputSelectors'; -import { getVersionInfo } from 'features/version/general/generalSelectors'; -import { getComposition } from 'features/version/composition/compositionSelectors'; - -export const getSavedObjParams = createSelector( - getOutputs, - getInputs, - getComposition, - getVersionInfo, - (outputs, inputs, composition, general) => ({ - outputs, - inputs, - composition, - ...general - }) -); 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 deleted file mode 100644 index 0a9c2b1a..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -* 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 from 'react'; -import { I18n } from 'react-redux-i18n'; -import { Button } from 'onap-ui-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; - - return ( - <div className="save-submit-cancel-container"> - <div className="action-buttons"> - <div className="select-action-buttons"> - <div className={'separator vc-separator'} /> - <SvgButton - dataTestId="vc-save-btn" - name="version-controller-save" - tooltipText={I18n.t('buttons.saveBtn')} - disabled={saveDisabled} - onClick={onSaveClick} - /> - - <div className={'separator vc-separator'} /> - - <SvgButton - dataTestId="vc-undo-btn" - name="version-controller-undo" - tooltipText={I18n.t('buttons.undoBtn')} - disabled={certifyDisabled} - onClick={onUndoClick} - /> - - <div className={'separator vc-separator'} /> - - <Button - className="certifyBtn" - btnType="primary" - disabled={certifyDisabled} - onClick={() => toggleCompositionUpdate(true)}> - {I18n.t('buttons.certifyBtn')} - </Button> - - {isCompositionUpdating && ( - <CompositionUpdate - certifyBack={() => { - toggleCompositionUpdate(false); - onCertifyClick(); - }} - /> - )} - </div> - </div> - </div> - ); -}; - -ActionButtons.propTypes = { - onSaveClick: PropTypes.func, - certifyDisabled: PropTypes.bool, - onCertifyClick: PropTypes.func, - onUndoClick: PropTypes.func, - saveDisabled: PropTypes.bool, - isCompositionUpdating: PropTypes.bool, - toggleCompositionUpdate: PropTypes.func -}; - -export default ActionButtons; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/OperationModeButtons.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/OperationModeButtons.js deleted file mode 100644 index 4d992adc..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/OperationModeButtons.js +++ /dev/null @@ -1,70 +0,0 @@ -/* -* 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 from 'react'; -import { I18n } from 'react-redux-i18n'; -import { Button } from 'onap-ui-react'; -import PropTypes from 'prop-types'; -import SvgButton from 'features/version/versionController/views/SvgButton'; - -const OperationModeButtons = props => { - const { - onSaveClick, - saveDisabled, - sendMsgToCatalog, - onCertifyClick - } = props; - return ( - <div className="save-submit-cancel-container"> - <div className="action-buttons"> - <div className="select-action-buttons"> - <SvgButton - dataTestId="vc-save-btn" - name="version-controller-save" - tooltipText={I18n.t('buttons.saveBtn')} - disabled={saveDisabled} - onClick={onSaveClick} - /> - - <Button - disabled={saveDisabled} - className="certifyBtn" - btnType="primary" - onClick={onCertifyClick}> - {I18n.t('buttons.completeBtn')} - </Button> - - <SvgButton - tooltipText={I18n.t('buttons.backToCatalog')} - className="vs-back-btn" - dataTestId="vc-back-btn" - name="upload" - onClick={sendMsgToCatalog} - /> - </div> - </div> - </div> - ); -}; - -OperationModeButtons.propTypes = { - onSaveClick: PropTypes.func, - saveDisabled: PropTypes.bool, - sendMsgToCatalog: PropTypes.func, - onCertifyClick: PropTypes.func -}; - -export default OperationModeButtons; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/SvgButton.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/SvgButton.js deleted file mode 100644 index 41bdeb81..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/SvgButton.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -* 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 from 'react'; -import { SVGIcon } from 'onap-ui-react'; -import PropTypes from 'prop-types'; - -const SvgButton = props => { - const { - className = '', - name, - tooltipText, - disabled, - onClick, - dataTestId, - actiontype - } = props; - let onClickAction = disabled ? () => {} : () => onClick(actiontype); - return ( - <div - className={`action-button-wrapper ${ - disabled ? 'disabled' : 'clickable' - }`} - onClick={onClickAction}> - <div className="action-buttons-svg"> - <SVGIcon - className={className} - label={tooltipText} - labelPosition="bottom" - labelClassName="action-button-label" - data-test-id={dataTestId} - name={name} - disabled={disabled} - /> - </div> - </div> - ); -}; - -SvgButton.propTypes = { - name: PropTypes.string, - tooltipText: PropTypes.string, - disabled: PropTypes.bool, - onClick: PropTypes.func, - dataTestId: PropTypes.string, - actiontype: PropTypes.string, - className: PropTypes.string -}; - -export default SvgButton; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionButton.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionButton.js deleted file mode 100644 index 19e148cb..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionButton.js +++ /dev/null @@ -1,38 +0,0 @@ -/* -* 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 from 'react'; -import { Button } from 'onap-ui-react'; -import { I18n } from 'react-redux-i18n'; -import PropTypes from 'prop-types'; - -const VersionButton = props => { - const { onClick, actiontype } = props; - let onClickAction = () => onClick(actiontype); - return ( - <div> - <Button btnType="primary" onClick={onClickAction}> - {I18n.t('buttons.certifyBtn')} - </Button> - </div> - ); -}; - -VersionButton.propTypes = { - onClick: PropTypes.func, - actiontype: PropTypes.string -}; - -export default VersionButton; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionSelect.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionSelect.js deleted file mode 100644 index d8a6d02e..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionSelect.js +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; -import isEmpty from 'lodash.isempty'; - -const VersionSelect = props => { - const { - currentWorkflowVersion, - viewableVersions, - onVersionSelectChange - } = props; - - function onChangeHandler(ev) { - const versionIndex = Object.keys(viewableVersions).find( - key => viewableVersions[key].id === ev.target.value - ); - const currentVersion = viewableVersions[versionIndex].id; - onVersionSelectChange(currentVersion); - } - - return ( - <select - className="version-selector" - key={'selector'} - value={currentWorkflowVersion.id} - onChange={onChangeHandler} - data-test-id="vc-versions-select-box"> - {!isEmpty(viewableVersions) && - viewableVersions.map(item => { - const displayedName = `${item.name} ${ - currentWorkflowVersion.id === item.id - ? currentWorkflowVersion.state.toUpperCase() - : item.state - }`; - return ( - <option - key={'versionSelect' + item.id} - value={item.id} - data-test-id="vc-version-option"> - {displayedName} - </option> - ); - })} - </select> - ); -}; - -VersionSelect.propTypes = { - currentWorkflowVersion: PropTypes.object, - viewableVersions: PropTypes.arrayOf(Object), - onVersionSelectChange: PropTypes.func -}; - -export default VersionSelect; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionsContainer.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionsContainer.js deleted file mode 100644 index c84ab31d..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/VersionsContainer.js +++ /dev/null @@ -1,60 +0,0 @@ -/* -* 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 from 'react'; -import VersionSelect from 'features/version/versionController/views/VersionSelect'; -import { I18n } from 'react-redux-i18n'; -import PropTypes from 'prop-types'; -import ArchiveLabel from 'shared/archiveLabel/ArchiveLabel'; - -const VersionContainer = props => { - const { - currentWorkflowVersion, - viewableVersions, - onOverviewClick, - onVersionSelectChange, - isArchive - } = props; - - return ( - <div className="version-section-wrapper"> - <div className="version-status-container"> - {I18n.t('workflow.version')} - <VersionSelect - currentWorkflowVersion={currentWorkflowVersion} - viewableVersions={viewableVersions} - onVersionSelectChange={onVersionSelectChange} - /> - <span - className="version-selector-more-versions" - data-test-id="vc-versions-page-link" - onClick={onOverviewClick}> - {I18n.t('workflow.overview.viewOverview')} - </span> - {isArchive && <ArchiveLabel />} - </div> - </div> - ); -}; - -VersionContainer.propTypes = { - currentWorkflowVersion: PropTypes.object, - viewableVersions: PropTypes.arrayOf(Object), - onOverviewClick: PropTypes.func, - onVersionSelectChange: PropTypes.func, - isArchive: PropTypes.bool -}; - -export default VersionContainer; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/WorkflowTitle.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/WorkflowTitle.js deleted file mode 100644 index 230ecf08..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/WorkflowTitle.js +++ /dev/null @@ -1,34 +0,0 @@ -/* -* 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 from 'react'; -import PropTypes from 'prop-types'; - -const WorkflowTitle = props => { - const { workflowName } = props; - return ( - <div className="version-section-wrapper"> - <div className="group-name-wrapper"> - <div className="group-name">{workflowName || ''}</div> - </div> - </div> - ); -}; - -WorkflowTitle.propTypes = { - workflowName: PropTypes.string -}; - -export default WorkflowTitle; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionModeReducer.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionModeReducer.js deleted file mode 100644 index 9d4d67ea..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionModeReducer.js +++ /dev/null @@ -1,10 +0,0 @@ -import { SET_OPERRATION_MODE } from './versionConstants'; - -export default (state = false, action) => { - switch (action.type) { - case SET_OPERRATION_MODE: - return true; - default: - return state; - } -}; 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 deleted file mode 100644 index d05af2d7..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionReducer.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -* 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 { - SET_CURRENT_VERSION, - DETAILS_CHANGED, - VERSION_STATE_CHANGED, - TOGGLE_COMPOSITION_UPDATE -} from 'features/version/versionConstants'; - -const initialState = { - isCompositionUpdating: false -}; - -function versionReducer(state = initialState, action) { - switch (action.type) { - case SET_CURRENT_VERSION: - return action.payload; - case DETAILS_CHANGED: - return { - ...state, - ...action.payload - }; - case VERSION_STATE_CHANGED: - return { - ...state, - ...action.payload - }; - case TOGGLE_COMPOSITION_UPDATE: - return { - ...state, - isCompositionUpdating: action.payload.isCompositionUpdating - }; - default: - return state; - } -} - -export default versionReducer; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionSaga.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionSaga.js deleted file mode 100644 index 56dd7a5d..00000000 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionSaga.js +++ /dev/null @@ -1,167 +0,0 @@ -/* -* 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 { all, call, put, takeEvery, takeLatest } from 'redux-saga/effects'; -import { I18n } from 'react-redux-i18n'; - -import { genericNetworkErrorAction } from 'src/appConstants'; -import { - setWorkflowVersionAction, - versionStateChangedAction, - FETCH_REQUESTED -} from 'features/version/versionConstants'; -import { setInputsOutputs } from 'features/version/inputOutput/inputOutputActions'; -import { SUBMIT_VERSION } from 'features/version/create/createVersionConstants'; -import { - SAVE_ACTION, - CERTIFY_ACTION -} from 'features/version/versionController/versionControllerConstants'; -import versionApi from 'features/version/versionApi'; -import { notificationActions } from 'shared/notifications/notificationsActions'; -import { versionState } from 'features/version/versionConstants'; -import overviewApi from '../workflow/overview/overviewApi'; -import { versionListFetchAction } from '../workflow/overview/overviewConstansts'; -import { - updateComposition, - deleteCompositionArtifact -} from 'features/version/composition/compositionActions'; -import { getActivitiesList } from 'features/activities/activitiesActions'; - -/** - * Composition validation - converting artifact string to xml - * and checking if bpmn diagram has only one child - * @param composition - * @returns {boolean} - */ -function validateCurrentArtifact(composition) { - const parser = new DOMParser(); - const xml = parser.parseFromString(composition, 'text/xml'); - return Boolean( - xml.getElementsByTagName('bpmndi:BPMNPlane').BPMNPlane_1.children.length - ); -} - -function* fetchVersion(action) { - try { - yield put(getActivitiesList()); - const data = yield call(versionApi.fetchVersion, action.payload); - const { inputs, outputs, ...rest } = data; - let composition; - - if (rest.hasArtifact) { - composition = yield call( - versionApi.fetchVersionArtifact, - action.payload - ); - } else { - //Clearing the store from old artifact using init the default - yield put(deleteCompositionArtifact()); - } - yield all([ - put(setWorkflowVersionAction(rest)), - put(setInputsOutputs({ inputs, outputs })), - composition && put(updateComposition(composition)) - ]); - } catch (error) { - yield put(genericNetworkErrorAction(error)); - } -} - -function* watchSubmitVersion(action) { - try { - const { workflowId, history } = action.payload; - const data = yield call(versionApi.createNewVersion, action.payload); - const versions = yield call(overviewApi.getVersions, workflowId); - yield put(versionListFetchAction(versions)); - yield call( - history.push(`/workflows/workflow/${workflowId}/version/${data.id}`) - ); - } catch (error) { - yield put(genericNetworkErrorAction(error)); - } -} - -function* watchUpdateVersion(action) { - try { - const { - workflowId, - workflowName, - params: { composition, ...versionData } - } = action.payload; - const isArtifactValid = validateCurrentArtifact(composition); - yield call(versionApi.updateVersion, { - workflowId, - params: versionData - }); - yield put( - notificationActions.showSuccess({ - title: I18n.t('workflow.confirmationMessages.updateTitle'), - message: I18n.t('workflow.confirmationMessages.updateMessage') - }) - ); - if (isArtifactValid) { - yield call(versionApi.updateVersionArtifact, { - workflowId, - workflowName, - versionName: versionData.name.split('.').join('_'), - versionId: versionData.id, - payload: composition - }); - } else { - yield call(versionApi.deleteVersionArtifact, { - workflowId, - versionId: versionData.id - }); - } - return isArtifactValid; - } catch (error) { - yield put(genericNetworkErrorAction(error)); - } -} - -function* watchCertifyVersion(action) { - try { - const isArtifactValid = yield call(watchUpdateVersion, action); - if (!isArtifactValid) - throw new Error('Could not update empty artifact'); - yield call(versionApi.certifyVersion, { - ...action.payload - }); - yield put(versionStateChangedAction({ state: versionState.CERTIFIED })); - yield put( - notificationActions.showSuccess({ - title: I18n.t('workflow.confirmationMessages.certifyTitle'), - message: I18n.t('workflow.confirmationMessages.certifyMessage') - }) - ); - } catch (error) { - yield put( - notificationActions.showError({ - title: I18n.t('workflow.confirmationMessages.certifyTitle'), - message: I18n.t('workflow.composition.certifyArtifact') - }) - ); - yield put(genericNetworkErrorAction(error)); - } -} - -function* versionSaga() { - yield takeLatest(FETCH_REQUESTED, fetchVersion); - yield takeEvery(SUBMIT_VERSION, watchSubmitVersion); - yield takeEvery(SAVE_ACTION, watchUpdateVersion); - yield takeEvery(CERTIFY_ACTION, watchCertifyVersion); -} - -export default versionSaga; |