diff options
author | Einav Weiss Keidar <einavw@amdocs.com> | 2018-03-20 14:45:40 +0200 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-03-20 13:52:31 +0000 |
commit | 7fdf733a64670fceefc3ded35cfa581e1c458179 (patch) | |
tree | b3623ac9a331473830cb0167c0b487f2a176427c /openecomp-ui/src/sdc-app/onboarding/versionsPage/creation | |
parent | c7916a4e5955ccc5f0f5252307363b791ec5c7b9 (diff) |
Adding Prettier and fixing up eslint version
Issue-ID: SDC-1094
Change-Id: Ie83ad95a03899345dd90235daf0323cbe3bc6afd
Signed-off-by: Einav Weiss Keidar <einavw@amdocs.com>
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/versionsPage/creation')
5 files changed, 240 insertions, 211 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js index 66c1c79be5..e0cb925df4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js @@ -13,32 +13,52 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import VersionsPageCreationActionHelper from './VersionsPageCreationActionHelper.js'; import VersionsPageActionHelper from '../VersionsPageActionHelper.js'; import VersionsPageCreationView from './VersionsPageCreationView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {VERSION_CREATION_FORM_NAME} from './VersionsPageCreationConstants.js'; +import { VERSION_CREATION_FORM_NAME } from './VersionsPageCreationConstants.js'; -export const mapStateToProps = ({versionsPage: {versionCreation}}) => { - let {genericFieldInfo} = versionCreation; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); +export const mapStateToProps = ({ versionsPage: { versionCreation } }) => { + let { genericFieldInfo } = versionCreation; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - return {...versionCreation, isFormValid}; + return { ...versionCreation, isFormValid }; }; -export const mapActionsToProps = (dispatch, {itemId, itemType, additionalProps}) => { - return { - onDataChanged: (deltaData, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: VERSION_CREATION_FORM_NAME, customValidations}), - onCancel: () => VersionsPageCreationActionHelper.close(dispatch), - onSubmit: ({baseVersion, payload}) => { - VersionsPageCreationActionHelper.close(dispatch); - VersionsPageCreationActionHelper.createVersion(dispatch, {baseVersion, itemId, payload}).then(response => { - VersionsPageActionHelper.onNavigateToVersion(dispatch, {version: response, itemId, itemType, additionalProps}); - }); - }, - onValidateForm: () => ValidationHelper.validateForm(dispatch, VERSION_CREATION_FORM_NAME) - }; +export const mapActionsToProps = ( + dispatch, + { itemId, itemType, additionalProps } +) => { + return { + onDataChanged: (deltaData, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: VERSION_CREATION_FORM_NAME, + customValidations + }), + onCancel: () => VersionsPageCreationActionHelper.close(dispatch), + onSubmit: ({ baseVersion, payload }) => { + VersionsPageCreationActionHelper.close(dispatch); + VersionsPageCreationActionHelper.createVersion(dispatch, { + baseVersion, + itemId, + payload + }).then(response => { + VersionsPageActionHelper.onNavigateToVersion(dispatch, { + version: response, + itemId, + itemType, + additionalProps + }); + }); + }, + onValidateForm: () => + ValidationHelper.validateForm(dispatch, VERSION_CREATION_FORM_NAME) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(VersionsPageCreationView); +export default connect(mapStateToProps, mapActionsToProps)( + VersionsPageCreationView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js index bc038689a4..6e3be705c0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js @@ -15,65 +15,76 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './VersionsPageCreationConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './VersionsPageCreationConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; -import {actionTypes as VersionsPageActionTypes} from '../VersionsPageConstants.js'; +import { actionTypes as VersionsPageActionTypes } from '../VersionsPageConstants.js'; -function baseUrl({itemId, baseVersion}) { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/items/${itemId}/versions/${baseVersion.id}/`; +function baseUrl({ itemId, baseVersion }) { + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/items/${itemId}/versions/${baseVersion.id}/`; } -function createVersion({itemId, baseVersion, payload: {description, creationMethod} }) { - return RestAPIUtil.post(baseUrl({itemId, baseVersion}), {description, creationMethod}); +function createVersion({ + itemId, + baseVersion, + payload: { description, creationMethod } +}) { + return RestAPIUtil.post(baseUrl({ itemId, baseVersion }), { + description, + creationMethod + }); } - export default { + open(dispatch, { itemType, itemId, additionalProps, baseVersion }) { + dispatch({ + type: actionTypes.OPEN + }); - open(dispatch, {itemType, itemId, additionalProps, baseVersion}) { - dispatch({ - type: actionTypes.OPEN - }); - - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.VERSION_CREATION, - modalComponentProps: {itemType, itemId, additionalProps, baseVersion}, - title: i18n('New Version - From {name}', {name: baseVersion.name}) - } - }); - }, - - close(dispatch){ - dispatch({ - type: actionTypes.CLOSE - }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.VERSION_CREATION, + modalComponentProps: { + itemType, + itemId, + additionalProps, + baseVersion + }, + title: i18n('New Version - From {name}', { + name: baseVersion.name + }) + } + }); + }, - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - }, + close(dispatch) { + dispatch({ + type: actionTypes.CLOSE + }); - createVersion(dispatch, {itemId, baseVersion, payload}){ - return createVersion({itemId, baseVersion, payload}).then(result => { - return ItemsHelper.fetchVersions({itemId}).then(response => { - dispatch({ - type: VersionsPageActionTypes.VERSIONS_LOADED, - versions: response.results, - itemId - }); - dispatch({ - type: actionTypes.VERSION_CREATED, - result - }); - return result; - }); - }); - } + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + }, + createVersion(dispatch, { itemId, baseVersion, payload }) { + return createVersion({ itemId, baseVersion, payload }).then(result => { + return ItemsHelper.fetchVersions({ itemId }).then(response => { + dispatch({ + type: VersionsPageActionTypes.VERSIONS_LOADED, + versions: response.results, + itemId + }); + dispatch({ + type: actionTypes.VERSION_CREATED, + result + }); + return result; + }); + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js index 4ce381d4de..e761232443 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js @@ -16,13 +16,13 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - OPEN: null, - CLOSE: null, - VERSION_CREATED: null + OPEN: null, + CLOSE: null, + VERSION_CREATED: null }); export const VERSION_CREATION_FORM_NAME = 'VCREATIONFORM'; export const defaultState = { - creationMethod: 'major' -};
\ No newline at end of file + creationMethod: 'major' +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js index 620cf4717f..a762e4d338 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js @@ -13,32 +13,39 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, VERSION_CREATION_FORM_NAME, defaultState} from './VersionsPageCreationConstants.js'; +import { + actionTypes, + VERSION_CREATION_FORM_NAME, + defaultState +} from './VersionsPageCreationConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.OPEN: - return { - ...state, - formReady: null, - formName: VERSION_CREATION_FORM_NAME, - data: {...defaultState}, - genericFieldInfo: { - description: { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] - }, - creationMethod: { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - } - } - }; - case actionTypes.CLOSE: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.OPEN: + return { + ...state, + formReady: null, + formName: VERSION_CREATION_FORM_NAME, + data: { ...defaultState }, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ] + }, + creationMethod: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + } + } + }; + case actionTypes.CLOSE: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx index caa85fe107..ba92d26067 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx @@ -20,125 +20,116 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import Form from 'nfvo-components/input/validation/Form.jsx'; const VersionPropType = PropTypes.shape({ - name: PropTypes.string, - description: PropTypes.string, - creationMethod: PropTypes.string + name: PropTypes.string, + description: PropTypes.string, + creationMethod: PropTypes.string }); class VersionsPageCreationView extends React.Component { - - static propTypes = { - data: VersionPropType, - availableMethods: PropTypes.array, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; - - render() { - let {data = {}, genericFieldInfo, baseVersion, onDataChanged, onCancel} = this.props; - let {additionalInfo: {OptionalCreationMethods}} = baseVersion; - let {description, creationMethod} = data; - - return ( - <div className='version-creation-page'> - { genericFieldInfo && <Form - ref={(validationForm) => this.validationForm = validationForm} - hasButtons={true} - onSubmit={() => this.submit()} - submitButtonText={i18n('Create')} - onReset={() => onCancel()} - labledButtons={true} - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.validate()}> - - <div className='version-form-row'> - <Input - label={i18n('Version Category')} - value={creationMethod} - onChange={e => this.onSelectMethod(e)} - type='select' - overlayPos='bottom' - data-test-id='new-version-category' - isValid={genericFieldInfo.creationMethod.isValid} - errorText={genericFieldInfo.creationMethod.errorText} - isRequired> - <option key='' value=''>{i18n('Please select…')}</option> - {OptionalCreationMethods.map(method => <option key={method} value={method}>{i18n(method)}</option>)} - </Input> - </div> - - <div className='version-form-row'> - <Input - label={i18n('Description')} - value={description} - type='text' - overlayPos='bottom' - data-test-id='new-version-description' - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - onChange={description => onDataChanged({description})} - isRequired /> - </div> - - </Form> } - </div> - ); - } - - onSelectMethod(e) { - const selectedIndex = e.target.selectedIndex; - const creationMethod = e.target.options[selectedIndex].value; - this.props.onDataChanged({creationMethod}); - } - - submit() { - let {baseVersion, data: {description, creationMethod}} = this.props; - this.props.onSubmit({baseVersion, payload: {description, creationMethod}}); - } - - validate() { - this.props.onValidateForm(); - } - + static propTypes = { + data: VersionPropType, + availableMethods: PropTypes.array, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; + + render() { + let { + data = {}, + genericFieldInfo, + baseVersion, + onDataChanged, + onCancel + } = this.props; + let { additionalInfo: { OptionalCreationMethods } } = baseVersion; + let { description, creationMethod } = data; + + return ( + <div className="version-creation-page"> + {genericFieldInfo && ( + <Form + ref={validationForm => + (this.validationForm = validationForm) + } + hasButtons={true} + onSubmit={() => this.submit()} + submitButtonText={i18n('Create')} + onReset={() => onCancel()} + labledButtons={true} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.validate()}> + <div className="version-form-row"> + <Input + label={i18n('Version Category')} + value={creationMethod} + onChange={e => this.onSelectMethod(e)} + type="select" + overlayPos="bottom" + data-test-id="new-version-category" + isValid={ + genericFieldInfo.creationMethod.isValid + } + errorText={ + genericFieldInfo.creationMethod.errorText + } + isRequired> + <option key="" value=""> + {i18n('Please select…')} + </option> + {OptionalCreationMethods.map(method => ( + <option key={method} value={method}> + {i18n(method)} + </option> + ))} + </Input> + </div> + + <div className="version-form-row"> + <Input + label={i18n('Description')} + value={description} + type="text" + overlayPos="bottom" + data-test-id="new-version-description" + isValid={genericFieldInfo.description.isValid} + errorText={ + genericFieldInfo.description.errorText + } + onChange={description => + onDataChanged({ description }) + } + isRequired + /> + </div> + </Form> + )} + </div> + ); + } + + onSelectMethod(e) { + const selectedIndex = e.target.selectedIndex; + const creationMethod = e.target.options[selectedIndex].value; + this.props.onDataChanged({ creationMethod }); + } + + submit() { + let { baseVersion, data: { description, creationMethod } } = this.props; + this.props.onSubmit({ + baseVersion, + payload: { description, creationMethod } + }); + } + + validate() { + this.props.onValidateForm(); + } } export default VersionsPageCreationView; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* <div className='software-product-inline-section'> <Input |