From ae90ce60cca851f3149a4da59cdce675ffd31a7c Mon Sep 17 00:00:00 2001 From: Yarin Dekel Date: Sun, 12 Aug 2018 14:05:47 +0300 Subject: [PATCH] disable undo and empty name validation Issue-ID: SDC-1628 Change-Id: I48cd1a16677e16f464a75b7aae8eb0992dd86a34 Signed-off-by: Yarin Dekel --- .../version/inputOutput/InputOutputView.jsx | 2 ++ .../version/inputOutput/inputOutputSelectors.js | 10 ++++++++-- .../version/inputOutput/inputOutputValidations.js | 10 ++++++++++ .../version/versionController/VersionController.js | 7 ++++--- .../versionController/VersionControllerView.jsx | 21 +++++++++++---------- .../versionController/views/ActionButtons.js | 2 +- .../frontend/src/features/version/versionSaga.js | 6 +++++- .../src/main/frontend/src/i18n/languages.json | 3 ++- 8 files changed, 43 insertions(+), 18 deletions(-) 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 index 2eadd22f..2ef9ef7f 100644 --- 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 @@ -129,6 +129,8 @@ class InputOutputView extends React.Component { errorMessage = I18n.t('workflow.inputOutput.invalidCharacters'); } else if (error.alreadyExists && error.alreadyExists.includes(i)) { errorMessage = I18n.t('workflow.inputOutput.alreadyExists'); + } else if (error.emptyName && error.emptyName.includes(i)) { + errorMessage = I18n.t('workflow.inputOutput.emptyName'); } return ( 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 index 09dcc261..db07bce7 100644 --- 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 @@ -71,7 +71,11 @@ export const getInputErrors = createSelector( getErrorsInputOutput, ({ inputs }) => !isEmpty(inputs) && - Boolean(inputs.alreadyExists.length || inputs.invalidCharacters.length) + Boolean( + inputs.alreadyExists.length || + inputs.invalidCharacters.length || + inputs.emptyName.length + ) ); export const getOutputErrors = createSelector( @@ -79,7 +83,9 @@ export const getOutputErrors = createSelector( ({ outputs }) => !isEmpty(outputs) && Boolean( - outputs.alreadyExists.length || outputs.invalidCharacters.length + outputs.alreadyExists.length || + outputs.invalidCharacters.length || + outputs.emptyName.length ) ); 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 index a300e215..50a64211 100644 --- 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 @@ -38,6 +38,16 @@ export const getValidationsError = dataRows => { 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; diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js index 2fc71957..fd62c56e 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionController.js @@ -30,6 +30,7 @@ import { certifyVersionAction } from 'features/version/versionController/versionControllerConstants'; import { workflowVersionFetchRequestedAction } from '../versionConstants'; +import { getIsCertified } from 'features/version/general/generalSelectors'; import { getIOErrors } from 'features/version/inputOutput/inputOutputSelectors'; function mapStateToProps(state) { @@ -38,9 +39,9 @@ function mapStateToProps(state) { workflowId: getWorkflowId(state), versionsList: getSortedVersions(state), savedParams: getSavedObjParams(state), - currentWorkflowVersion: state.currentVersion.general, - versionState: state.currentVersion.general.state, - getIOErrors: getIOErrors(state) + getIOErrors: getIOErrors(state), + isCertifyDisable: getIsCertified(state), + currentWorkflowVersion: state.currentVersion.general }; } diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx index 20d5d73b..38321c31 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/VersionControllerView.jsx @@ -19,7 +19,6 @@ import PropTypes from 'prop-types'; import ActionButtons from 'features/version/versionController/views/ActionButtons'; import VersionContainer from 'features/version/versionController/views/VersionsContainer'; import WorkflowTitle from 'features/version/versionController/views/WorkflowTitle'; -import { versionState as versionStateType } from 'features/version/versionConstants'; export default class VersionControllerView extends Component { static propTypes = { @@ -35,10 +34,10 @@ export default class VersionControllerView extends Component { savedParams: PropTypes.object, saveParamsToServer: PropTypes.func, workflowId: PropTypes.string, - versionState: PropTypes.string, certifyVersion: PropTypes.func, changeVersion: PropTypes.func, - getIOErrors: PropTypes.bool + getIOErrors: PropTypes.bool, + isCertifyDisable: PropTypes.bool }; constructor(props) { @@ -60,9 +59,14 @@ export default class VersionControllerView extends Component { const { certifyVersion, workflowId, - currentWorkflowVersion + currentWorkflowVersion, + savedParams } = this.props; - certifyVersion({ workflowId, versionId: currentWorkflowVersion.id }); + certifyVersion({ + workflowId, + versionId: currentWorkflowVersion.id, + params: savedParams + }); }; versionChangeCallback = versionId => { @@ -84,12 +88,9 @@ export default class VersionControllerView extends Component { currentWorkflowVersion, workflowName, versionsList, - versionState, - getIOErrors + getIOErrors, + isCertifyDisable } = this.props; - let isCertifyDisable = - versionState && - versionState.toLowerCase() === versionStateType.CERTIFIED; return (
diff --git a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js index a2f03380..224b249a 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionController/views/ActionButtons.js @@ -46,7 +46,7 @@ const ActionButtons = props => { dataTestId="vc-undo-btn" name="version-controller-undo" tooltipText={I18n.t('buttons.undoBtn')} - disabled={false} + disabled={certifyDisabled} onClick={onUndoClick} /> 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 index be52579e..d8d7fd82 100644 --- a/workflow-designer-ui/src/main/frontend/src/features/version/versionSaga.js +++ b/workflow-designer-ui/src/main/frontend/src/features/version/versionSaga.js @@ -76,7 +76,6 @@ function* watchSubmitVersion(action) { function* watchUpdateVersion(action) { try { - //const { composition, ...versionData } = action.payload; const { workflowId, params: { composition, ...versionData } @@ -105,6 +104,11 @@ function* watchUpdateVersion(action) { function* watchCertifyVersion(action) { try { + const { workflowId, params } = action.payload; + yield call(versionApi.updateVersion, { + workflowId, + params: params + }); yield call(versionApi.certifyVersion, { ...action.payload }); diff --git a/workflow-designer-ui/src/main/frontend/src/i18n/languages.json b/workflow-designer-ui/src/main/frontend/src/i18n/languages.json index 5fd444a6..7aabadae 100644 --- a/workflow-designer-ui/src/main/frontend/src/i18n/languages.json +++ b/workflow-designer-ui/src/main/frontend/src/i18n/languages.json @@ -58,7 +58,8 @@ "CANCEL": "CANCEL", "confirmDlete": "Are you sure you want to delete \"%{name}\"?", "alreadyExists": "Already exists", - "invalidCharacters": "Alphanumeric and underscore only" + "invalidCharacters": "Alphanumeric and underscore only", + "emptyName": "Empty Name" }, "composition": { "bpmnError" : "BPMN.IO Error" -- 2.16.6