Disable certified workflow inputs 19/60119/1
authorMalek <malek.zoabi@amdocs.com>
Sun, 12 Aug 2018 09:19:57 +0000 (12:19 +0300)
committerMalek <malek.zoabi@amdocs.com>
Sun, 12 Aug 2018 09:21:19 +0000 (12:21 +0300)
Issue-ID: SDC-1627
Change-Id: I91f4315b156908c591ad7a9c4429fd435ba85861
Signed-off-by: Malek <malek.zoabi@amdocs.com>
workflow-designer-ui/src/main/frontend/resources/scss/components/_layout.scss
workflow-designer-ui/src/main/frontend/src/features/version/create/__tests__/__snapshots__/CreateVersionView_snapshot-test.js.snap
workflow-designer-ui/src/main/frontend/src/features/version/general/General.js
workflow-designer-ui/src/main/frontend/src/features/version/general/GeneralView.js
workflow-designer-ui/src/main/frontend/src/features/version/general/generalSelectors.js
workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutput.js
workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/InputOutputView.jsx
workflow-designer-ui/src/main/frontend/src/features/version/inputOutput/views/TableBody.jsx
workflow-designer-ui/src/main/frontend/src/features/workflow/create/__tests__/__snapshots__/CreateWorkflowView_snapshot-test.js.snap
workflow-designer-ui/src/main/frontend/src/features/workflow/overview/__tests__/__snapshots__/OverviewView_snapshot-test.js.snap
workflow-designer-ui/src/main/frontend/src/shared/components/Description/index.js

index 316412e..c0cc109 100644 (file)
@@ -18,4 +18,9 @@
         grid-template-rows: 70px 1fr;
         height: 100vh;
     }
+
+    .disabled {
+        pointer-events: none;
+        opacity: 0.4;
+    }
 }
index 55357b5..0b15043 100644 (file)
@@ -50,6 +50,7 @@ exports[`Create new version snapshot renders correctly 1`] = `
           <textarea
             className="custom-textarea field-section sdc-input__input"
             data-test-id="new-version-description"
+            disabled={false}
             onChange={[Function]}
             value=""
           />
index 37fc0ef..a757371 100644 (file)
@@ -18,25 +18,19 @@ import { connect } from 'react-redux';
 
 import GeneralView from 'features/version/general/GeneralView';
 import {
-    getGeneralDescription,
-    getCreationTime,
-    getModificationTime
+    getVersionInfo,
+    getIsCertified
 } from 'features/version/general/generalSelectors';
 import { workflowVersionDetailsChangedAction } from 'features/version/versionConstants';
 
-export function mapStateToProps(state) {
-    return {
-        description: getGeneralDescription(state),
-        created: getCreationTime(state),
-        modified: getModificationTime(state)
-    };
-}
+const mapStateToProps = state => ({
+    versionInfo: getVersionInfo(state),
+    isCertified: getIsCertified(state)
+});
 
-export function mapDispatchToProps(dispatch) {
-    return {
-        onDataChange: payload =>
-            dispatch(workflowVersionDetailsChangedAction(payload))
-    };
-}
+const mapDispatchToProps = dispatch => ({
+    onDataChange: payload =>
+        dispatch(workflowVersionDetailsChangedAction(payload))
+});
 
 export default connect(mapStateToProps, mapDispatchToProps)(GeneralView);
index d10d578..71d5d7d 100644 (file)
@@ -21,9 +21,13 @@ import { I18n, Translate } from 'react-redux-i18n';
 import Description from 'shared/components/Description';
 import { VersionInfo, LabeledValue } from 'shared/components/VersionInfo';
 
-const GeneralView = ({ onDataChange, description, created, modified }) => {
-    const modifiedValue = I18n.l(modified, { dateFormat: 'date.short' });
-    const createdValue = I18n.l(created, { dateFormat: 'date.short' });
+const GeneralView = ({ onDataChange, versionInfo, isCertified }) => {
+    const modifiedValue = I18n.l(versionInfo.modificationTime, {
+        dateFormat: 'date.short'
+    });
+    const createdValue = I18n.l(versionInfo.creationTime, {
+        dateFormat: 'date.short'
+    });
 
     return (
         <div className="general-page">
@@ -32,8 +36,9 @@ const GeneralView = ({ onDataChange, description, created, modified }) => {
             </div>
             <div className="general-page-content">
                 <Description
-                    description={description}
+                    description={versionInfo.description}
                     onDataChange={onDataChange}
+                    disabled={isCertified}
                 />
                 <VersionInfo>
                     <LabeledValue
@@ -52,9 +57,8 @@ const GeneralView = ({ onDataChange, description, created, modified }) => {
 
 GeneralView.propTypes = {
     onDataChange: PropTypes.func,
-    description: PropTypes.string,
-    created: PropTypes.string,
-    modified: PropTypes.string
+    versionInfo: PropTypes.object,
+    isCertified: PropTypes.bool
 };
 
 export default GeneralView;
index 5d8924c..cc817fc 100644 (file)
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-import { createSelector } from 'reselect';
 
-export const getGeneralDescription = state =>
-    state && state.currentVersion.general.description;
-export const getVersionInfo = state => state && state.currentVersion.general;
+import { createSelector } from 'reselect';
 
-export const getCreationTime = state =>
-    state && state.currentVersion.general.creationTime;
+import { versionState } from 'features/version/versionConstants';
 
-export const getModificationTime = state =>
-    state && state.currentVersion.general.modificationTime;
+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
+);
index 9040eb6..f5b3b8e 100644 (file)
@@ -27,6 +27,7 @@ import {
     getTypes,
     getError
 } from 'features/version/inputOutput/inputOutputSelectors';
+import { getIsCertified } from 'features/version/general/generalSelectors';
 import {
     changeError,
     showInputs,
@@ -46,7 +47,8 @@ const mapStateToProps = state => ({
     search: getSearch(state),
     dataRows: getDataRows(state),
     types: getTypes(state),
-    error: getError(state)
+    error: getError(state),
+    isCertified: getIsCertified(state)
 });
 
 const mapDispatchToProps = dispatch => ({
index 0f80117..2eadd22 100644 (file)
@@ -17,6 +17,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import { Translate, I18n } from 'react-redux-i18n';
+import cn from 'classnames';
 import { SVGIcon } from 'sdc-ui/lib/react';
 
 import SearchInput from 'shared/searchInput/SearchInput';
@@ -148,7 +149,7 @@ class InputOutputView extends React.Component {
     };
 
     render() {
-        const { isShowInputs, search, handleAdd } = this.props;
+        const { isShowInputs, search, handleAdd, isCertified } = this.props;
 
         const addLabel = isShowInputs
             ? I18n.t('workflow.inputOutput.addInput')
@@ -180,7 +181,9 @@ class InputOutputView extends React.Component {
                             />
                         </div>
                         <div
-                            className="input-output__add"
+                            className={cn('input-output__add', {
+                                disabled: isCertified
+                            })}
                             data-test-id="wf-input-output-add"
                             onClick={handleAdd}>
                             <SVGIcon
@@ -194,7 +197,9 @@ class InputOutputView extends React.Component {
                 </div>
                 <div className="input-output__table">
                     <TableHead />
-                    <TableBody>{dataRowsView}</TableBody>
+                    <TableBody isCertified={isCertified}>
+                        {dataRowsView}
+                    </TableBody>
                 </div>
             </div>
         );
@@ -213,6 +218,7 @@ InputOutputView.propTypes = {
     ),
     types: PropTypes.array,
     error: PropTypes.object,
+    isCertified: PropTypes.bool,
     handleChangeError: PropTypes.func,
     handleShowInputs: PropTypes.func,
     handleShowOutputs: PropTypes.func,
index 052846b..a85bcfb 100644 (file)
@@ -17,6 +17,7 @@
 
 import React from 'react';
 import PropTypes from 'prop-types';
+import cn from 'classnames';
 
 class TableBody extends React.Component {
     handleNameInputChange = params => {
@@ -28,13 +29,21 @@ class TableBody extends React.Component {
     };
 
     render() {
-        const { children } = this.props;
+        const { isCertified, children } = this.props;
 
-        return <div className="input-output__table__tbody">{children}</div>;
+        return (
+            <div
+                className={cn('input-output__table__tbody', {
+                    disabled: isCertified
+                })}>
+                {children}
+            </div>
+        );
     }
 }
 
 TableBody.propTypes = {
+    isCertified: PropTypes.bool,
     children: PropTypes.node
 };
 
index 1a050ef..fb9cd83 100644 (file)
@@ -48,6 +48,7 @@ exports[`New Workflow View Snapshot renders correctly 1`] = `
           <textarea
             className="custom-textarea field-section sdc-input__input"
             data-test-id="description"
+            disabled={false}
             onChange={[Function]}
             value=""
           />
index 7b3326e..1014e4b 100644 (file)
@@ -59,6 +59,7 @@ exports[`OverviewView Snapshot renders correctly 1`] = `
               <textarea
                 className="custom-textarea field-section sdc-input__input"
                 data-test-id="description"
+                disabled={false}
                 onChange={[Function]}
                 value="desc 1"
               />
index 4aa48f8..12bae31 100644 (file)
@@ -17,7 +17,7 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import { I18n } from 'react-redux-i18n';
 
-const Description = ({ description, onDataChange, dataTestId }) => (
+const Description = ({ description, onDataChange, dataTestId, disabled }) => (
     <div className="description-part">
         <div className="sdc-input">
             <div className="sdc-input__label">
@@ -30,6 +30,7 @@ const Description = ({ description, onDataChange, dataTestId }) => (
                     onDataChange({ description: event.target.value });
                 }}
                 className="custom-textarea field-section sdc-input__input"
+                disabled={disabled}
             />
         </div>
     </div>
@@ -38,7 +39,12 @@ const Description = ({ description, onDataChange, dataTestId }) => (
 Description.propTypes = {
     description: PropTypes.string,
     onDataChange: PropTypes.func,
-    dataTestId: PropTypes.string
+    dataTestId: PropTypes.string,
+    disabled: PropTypes.bool
+};
+
+Description.defaultProps = {
+    disabled: false
 };
 
 export default Description;