diff options
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups')
8 files changed, 881 insertions, 600 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js index 6edb1e1f0c..997a6e09ed 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js @@ -13,66 +13,92 @@ * 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 FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; import FeatureGroupEditorView from './FeatureGroupEditorView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -export const mapStateToProps = ({licenseModel: {featureGroup, entitlementPool, licenseKeyGroup}}) => { - let {entitlementPoolsList = []} = entitlementPool; - let {licenseKeyGroupsList = []} = licenseKeyGroup; - const {featureGroupEditor} = featureGroup; - let {data, selectedTab, genericFieldInfo, formReady} = featureGroupEditor; - const featureGroupId = data ? data.id : null; - const list = featureGroup.featureGroupsList; +export const mapStateToProps = ({ + licenseModel: { featureGroup, entitlementPool, licenseKeyGroup } +}) => { + let { entitlementPoolsList = [] } = entitlementPool; + let { licenseKeyGroupsList = [] } = licenseKeyGroup; + const { featureGroupEditor } = featureGroup; + let { data, selectedTab, genericFieldInfo, formReady } = featureGroupEditor; + const featureGroupId = data ? data.id : null; + const list = featureGroup.featureGroupsList; - let previousData, FGNames = {}, isFormValid = true, invalidTabs = []; + let previousData, + FGNames = {}, + isFormValid = true, + invalidTabs = []; - if (featureGroupId) { - previousData = list.find(featureGroup => featureGroup.id === featureGroupId); - } + if (featureGroupId) { + previousData = list.find( + featureGroup => featureGroup.id === featureGroupId + ); + } - for (let i = 0; i < list.length; i++) { - FGNames[list[i].name.toLowerCase()] = list[i].id; - } + for (let i = 0; i < list.length; i++) { + FGNames[list[i].name.toLowerCase()] = list[i].id; + } - for (let field in genericFieldInfo) { - if (!genericFieldInfo[field].isValid) { - isFormValid = false; - let tabId = genericFieldInfo[field].tabId; - if (invalidTabs.indexOf(tabId) === -1) { - invalidTabs[invalidTabs.length] = genericFieldInfo[field].tabId; - } - } - } + for (let field in genericFieldInfo) { + if (!genericFieldInfo[field].isValid) { + isFormValid = false; + let tabId = genericFieldInfo[field].tabId; + if (invalidTabs.indexOf(tabId) === -1) { + invalidTabs[invalidTabs.length] = genericFieldInfo[field].tabId; + } + } + } - return { - data, - previousData, - selectedTab, - entitlementPoolsList, - licenseKeyGroupsList, - isFormValid, - formReady, - genericFieldInfo, - invalidTabs, - FGNames - }; + return { + data, + previousData, + selectedTab, + entitlementPoolsList, + licenseKeyGroupsList, + isFormValid, + formReady, + genericFieldInfo, + invalidTabs, + FGNames + }; }; - -const mapActionsToProps = (dispatch, {licenseModelId, version}) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onTabSelect: tab => FeatureGroupsActionHelper.selectEntitlementPoolsEditorTab(dispatch, {tab}), - onSubmit: (previousFeatureGroup, featureGroup) => { - FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch); - FeatureGroupsActionHelper.saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup, version}); - }, - onCancel: () => FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch), - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) - }; +const mapActionsToProps = (dispatch, { licenseModelId, version }) => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onTabSelect: tab => + FeatureGroupsActionHelper.selectEntitlementPoolsEditorTab( + dispatch, + { + tab + } + ), + onSubmit: (previousFeatureGroup, featureGroup) => { + FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch); + FeatureGroupsActionHelper.saveFeatureGroup(dispatch, { + licenseModelId, + previousFeatureGroup, + featureGroup, + version + }); + }, + onCancel: () => + FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch), + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(FeatureGroupEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + FeatureGroupEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx index 6d0acaa65d..fc8269332a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx @@ -19,211 +19,320 @@ import Tabs from 'nfvo-components/input/validation/Tabs.jsx'; import Tab from 'sdc-ui/lib/react/Tab.js'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {TabsForm as Form} from 'nfvo-components/input/validation/Form.jsx'; +import { TabsForm as Form } from 'nfvo-components/input/validation/Form.jsx'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; -import {state as FeatureGroupStateConstants, FG_EDITOR_FORM} from './FeatureGroupsConstants.js'; +import { + state as FeatureGroupStateConstants, + FG_EDITOR_FORM +} from './FeatureGroupsConstants.js'; const FeatureGroupsPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - partNumber: PropTypes.string, - manufacturerReferenceNumber: PropTypes.string, - entitlementPoolsIds: PropTypes.arrayOf(PropTypes.string), - licenseKeyGroupsIds: PropTypes.arrayOf(PropTypes.string) + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + partNumber: PropTypes.string, + manufacturerReferenceNumber: PropTypes.string, + entitlementPoolsIds: PropTypes.arrayOf(PropTypes.string), + licenseKeyGroupsIds: PropTypes.arrayOf(PropTypes.string) }); -const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) => { - let {name, description, partNumber, manufacturerReferenceNumber} = data; - return ( - <GridSection hasLastColSet> - <GridItem colSpan={2}> - <Input - groupClassName='field-section' - onChange={name => onDataChanged({name}, FG_EDITOR_FORM, {name: validateName})} - label={i18n('Name')} - data-test-id='create-fg-name' - value={name} - name='feature-group-name' - type='text' - isRequired={true} - isValid={genericFieldInfo.name.isValid} - errorText={genericFieldInfo.name.errorText} /> - </GridItem> - <GridItem colSpan={2} lastColInRow> - <Input - groupClassName='field-section' - className='description-field' - onChange={description => onDataChanged({description}, FG_EDITOR_FORM)} - data-test-id='create-fg-description' - label={i18n('Description')} - value={description} - name='feature-group-description' - type='textarea' - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} /> - </GridItem> - <GridItem colSpan={2}> - <Input - groupClassName='field-section' - onChange={partNumber => onDataChanged({partNumber}, FG_EDITOR_FORM)} - label={i18n('Part Number')} - data-test-id='create-fg-part-number' - value={partNumber} - isRequired={true} - type='text' - isValid={genericFieldInfo.partNumber.isValid} - errorText={genericFieldInfo.partNumber.errorText} /> - </GridItem> - <GridItem colSpan={2} lastColInRow> - <Input - groupClassName='field-section' - onChange={manufacturerReferenceNumber => onDataChanged({manufacturerReferenceNumber}, FG_EDITOR_FORM)} - label={i18n('Manufacturer Reference Number')} - data-test-id='create-fg-reference-number' - value={manufacturerReferenceNumber} - isRequired={true} - type='text' - isValid={genericFieldInfo.manufacturerReferenceNumber.isValid} - errorText={genericFieldInfo.manufacturerReferenceNumber.errorText} /> - </GridItem> - </GridSection> - ); +const GeneralTab = ({ + data = {}, + onDataChanged, + genericFieldInfo, + validateName +}) => { + let { name, description, partNumber, manufacturerReferenceNumber } = data; + return ( + <GridSection hasLastColSet> + <GridItem colSpan={2}> + <Input + groupClassName="field-section" + onChange={name => + onDataChanged({ name }, FG_EDITOR_FORM, { + name: validateName + }) + } + label={i18n('Name')} + data-test-id="create-fg-name" + value={name} + name="feature-group-name" + type="text" + isRequired={true} + isValid={genericFieldInfo.name.isValid} + errorText={genericFieldInfo.name.errorText} + /> + </GridItem> + <GridItem colSpan={2} lastColInRow> + <Input + groupClassName="field-section" + className="description-field" + onChange={description => + onDataChanged({ description }, FG_EDITOR_FORM) + } + data-test-id="create-fg-description" + label={i18n('Description')} + value={description} + name="feature-group-description" + type="textarea" + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} + /> + </GridItem> + <GridItem colSpan={2}> + <Input + groupClassName="field-section" + onChange={partNumber => + onDataChanged({ partNumber }, FG_EDITOR_FORM) + } + label={i18n('Part Number')} + data-test-id="create-fg-part-number" + value={partNumber} + isRequired={true} + type="text" + isValid={genericFieldInfo.partNumber.isValid} + errorText={genericFieldInfo.partNumber.errorText} + /> + </GridItem> + <GridItem colSpan={2} lastColInRow> + <Input + groupClassName="field-section" + onChange={manufacturerReferenceNumber => + onDataChanged( + { manufacturerReferenceNumber }, + FG_EDITOR_FORM + ) + } + label={i18n('Manufacturer Reference Number')} + data-test-id="create-fg-reference-number" + value={manufacturerReferenceNumber} + isRequired={true} + type="text" + isValid={ + genericFieldInfo.manufacturerReferenceNumber.isValid + } + errorText={ + genericFieldInfo.manufacturerReferenceNumber.errorText + } + /> + </GridItem> + </GridSection> + ); }; -const EntitlementPoolsTab = ({entitlementPoolsList, data, onDataChanged, isReadOnlyMode}) => { - const dualBoxFilterTitle = { - left: i18n('Available Entitlement Pools'), - right: i18n('Selected Entitlement Pools') - }; - if (entitlementPoolsList.length > 0) { - return ( - <DualListboxView - isReadOnlyMode={isReadOnlyMode} - filterTitle={dualBoxFilterTitle} - selectedValuesList={data.entitlementPoolsIds} - availableList={entitlementPoolsList} - onChange={ selectedValuesList => onDataChanged( { entitlementPoolsIds: selectedValuesList }, FG_EDITOR_FORM )}/> - ); - } else { - return ( - <p>{i18n('There are no available entitlement pools')}</p> - ); - } +const EntitlementPoolsTab = ({ + entitlementPoolsList, + data, + onDataChanged, + isReadOnlyMode +}) => { + const dualBoxFilterTitle = { + left: i18n('Available Entitlement Pools'), + right: i18n('Selected Entitlement Pools') + }; + if (entitlementPoolsList.length > 0) { + return ( + <DualListboxView + isReadOnlyMode={isReadOnlyMode} + filterTitle={dualBoxFilterTitle} + selectedValuesList={data.entitlementPoolsIds} + availableList={entitlementPoolsList} + onChange={selectedValuesList => + onDataChanged( + { entitlementPoolsIds: selectedValuesList }, + FG_EDITOR_FORM + ) + } + /> + ); + } else { + return <p>{i18n('There are no available entitlement pools')}</p>; + } }; -const LKGTab = ({licenseKeyGroupsList, data, onDataChanged, isReadOnlyMode}) => { - const dualBoxFilterTitle = { - left: i18n('Available License Key Groups'), - right: i18n('Selected License Key Groups') - }; - if (licenseKeyGroupsList.length > 0) { - return ( - <DualListboxView - isReadOnlyMode={isReadOnlyMode} - filterTitle={dualBoxFilterTitle} - selectedValuesList={data.licenseKeyGroupsIds} - availableList={licenseKeyGroupsList} - onChange={ selectedValuesList => onDataChanged( { licenseKeyGroupsIds: selectedValuesList }, FG_EDITOR_FORM )}/> - ); - } else { - return ( - <p>{i18n('There are no available license key groups')}</p> - ); - } +const LKGTab = ({ + licenseKeyGroupsList, + data, + onDataChanged, + isReadOnlyMode +}) => { + const dualBoxFilterTitle = { + left: i18n('Available License Key Groups'), + right: i18n('Selected License Key Groups') + }; + if (licenseKeyGroupsList.length > 0) { + return ( + <DualListboxView + isReadOnlyMode={isReadOnlyMode} + filterTitle={dualBoxFilterTitle} + selectedValuesList={data.licenseKeyGroupsIds} + availableList={licenseKeyGroupsList} + onChange={selectedValuesList => + onDataChanged( + { licenseKeyGroupsIds: selectedValuesList }, + FG_EDITOR_FORM + ) + } + /> + ); + } else { + return <p>{i18n('There are no available license key groups')}</p>; + } }; class FeatureGroupEditorView extends React.Component { + static propTypes = { + data: FeatureGroupsPropType, + previousData: FeatureGroupsPropType, + isReadOnlyMode: PropTypes.bool, + FGNames: PropTypes.object, + onSubmit: PropTypes.func, + onCancel: PropTypes.func, - static propTypes = { - data: FeatureGroupsPropType, - previousData: FeatureGroupsPropType, - isReadOnlyMode: PropTypes.bool, - FGNames: PropTypes.object, - - onSubmit: PropTypes.func, - onCancel: PropTypes.func, - - selectedTab: PropTypes.number, - onTabSelect: PropTypes.func, - - entitlementPoolsList: DualListboxView.propTypes.availableList, - licenseKeyGroupsList: DualListboxView.propTypes.availableList - }; - - - static defaultProps = { - data: {}, - selectedTab: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL, - }; - - state = { - localEntitlementPoolsListFilter: '', - localLicenseKeyGroupsListFilter: '' - }; - - - render() { - let {selectedTab, onTabSelect, isReadOnlyMode, invalidTabs, data, onDataChanged, genericFieldInfo, entitlementPoolsList, licenseKeyGroupsList} = this.props; - return ( - <div> - { genericFieldInfo && <Form - ref='validationForm' - hasButtons={true} - onSubmit={ () => this.submit() } - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.props.onValidateForm(FG_EDITOR_FORM) } - onReset={ () => this.props.onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - name='feature-group-validation-form' - className='license-model-form feature-group-form'> - <Tabs activeTab={onTabSelect ? selectedTab : undefined} onTabClick={onTabSelect} invalidTabs={invalidTabs} id='vlmFGValTabs' > - <Tab tabId={FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL} title={i18n('General')} > - <fieldset disabled={isReadOnlyMode}> - <GeneralTab data={data} onDataChanged={onDataChanged} genericFieldInfo={genericFieldInfo} validateName={(value)=> this.validateName(value)}/> - </fieldset> - </Tab> - <Tab - tabId={FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.ENTITLEMENT_POOLS} - title={i18n('Entitlement Pools')} > - <fieldset disabled={isReadOnlyMode}> - <EntitlementPoolsTab isReadOnlyMode={isReadOnlyMode} data={data} onDataChanged={onDataChanged} entitlementPoolsList={entitlementPoolsList} /> - </fieldset> - </Tab> - <Tab - tabId={FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.LICENSE_KEY_GROUPS} - title={i18n('License Key Groups')} > - <fieldset disabled={isReadOnlyMode}> - <LKGTab isReadOnlyMode={isReadOnlyMode} data={data} onDataChanged={onDataChanged} licenseKeyGroupsList={licenseKeyGroupsList} /> - </fieldset> - </Tab> - </Tabs> - - </Form> } - </div> - ); - } - - submit() { - const {data: featureGroup, previousData: previousFeatureGroup} = this.props; - this.props.onSubmit(previousFeatureGroup, featureGroup); - } - - validateName(value) { - const {data: {id}, FGNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: FGNames}); - - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('Feature group by the name \'' + value + '\' already exists. Feature group name must be unique')}; - } -} + selectedTab: PropTypes.number, + onTabSelect: PropTypes.func, + + entitlementPoolsList: DualListboxView.propTypes.availableList, + licenseKeyGroupsList: DualListboxView.propTypes.availableList + }; + + static defaultProps = { + data: {}, + selectedTab: + FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL + }; + + state = { + localEntitlementPoolsListFilter: '', + localLicenseKeyGroupsListFilter: '' + }; + render() { + let { + selectedTab, + onTabSelect, + isReadOnlyMode, + invalidTabs, + data, + onDataChanged, + genericFieldInfo, + entitlementPoolsList, + licenseKeyGroupsList + } = this.props; + return ( + <div> + {genericFieldInfo && ( + <Form + ref="validationForm" + hasButtons={true} + onSubmit={() => this.submit()} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => + this.props.onValidateForm(FG_EDITOR_FORM) + } + onReset={() => this.props.onCancel()} + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + name="feature-group-validation-form" + className="license-model-form feature-group-form"> + <Tabs + activeTab={onTabSelect ? selectedTab : undefined} + onTabClick={onTabSelect} + invalidTabs={invalidTabs} + id="vlmFGValTabs"> + <Tab + tabId={ + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + } + title={i18n('General')}> + <fieldset disabled={isReadOnlyMode}> + <GeneralTab + data={data} + onDataChanged={onDataChanged} + genericFieldInfo={genericFieldInfo} + validateName={value => + this.validateName(value) + } + /> + </fieldset> + </Tab> + <Tab + tabId={ + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB + .ENTITLEMENT_POOLS + } + title={i18n('Entitlement Pools')}> + <fieldset disabled={isReadOnlyMode}> + <EntitlementPoolsTab + isReadOnlyMode={isReadOnlyMode} + data={data} + onDataChanged={onDataChanged} + entitlementPoolsList={ + entitlementPoolsList + } + /> + </fieldset> + </Tab> + <Tab + tabId={ + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB + .LICENSE_KEY_GROUPS + } + title={i18n('License Key Groups')}> + <fieldset disabled={isReadOnlyMode}> + <LKGTab + isReadOnlyMode={isReadOnlyMode} + data={data} + onDataChanged={onDataChanged} + licenseKeyGroupsList={ + licenseKeyGroupsList + } + /> + </fieldset> + </Tab> + </Tabs> + </Form> + )} + </div> + ); + } + + submit() { + const { + data: featureGroup, + previousData: previousFeatureGroup + } = this.props; + this.props.onSubmit(previousFeatureGroup, featureGroup); + } + + validateName(value) { + const { data: { id }, FGNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: FGNames + }); + + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "Feature group by the name '" + + value + + "' already exists. Feature group name must be unique" + ) + }; + } +} export default FeatureGroupEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js index 26925487db..55e2710231 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js @@ -13,48 +13,62 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; -import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; -import FeatureGroupListEditorView, {generateConfirmationMsg} from './FeatureGroupListEditorView.jsx'; +import { connect } from 'react-redux'; +import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; +import FeatureGroupListEditorView, { + generateConfirmationMsg +} from './FeatureGroupListEditorView.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as globalMoadlActions } from 'nfvo-components/modal/GlobalModalConstants.js'; -export const mapStateToProps = ({licenseModel: {featureGroup, licenseModelEditor}}) => { - - const {featureGroupEditor: {data}, featureGroupsList} = featureGroup; - const {vendorName, version} = licenseModelEditor.data; - - return { - vendorName, - version, - featureGroupsModal: { - show: Boolean(data), - editMode: Boolean(data && data.id) - }, - featureGroupsList - }; +export const mapStateToProps = ({ + licenseModel: { featureGroup, licenseModelEditor } +}) => { + const { featureGroupEditor: { data }, featureGroupsList } = featureGroup; + const { vendorName, version } = licenseModelEditor.data; + return { + vendorName, + version, + featureGroupsModal: { + show: Boolean(data), + editMode: Boolean(data && data.id) + }, + featureGroupsList + }; }; - -const mapActionsToProps = (dispatch, {licenseModelId}) => { - return { - onDeleteFeatureGroupClick: (featureGroup, version) => dispatch({ - type: globalMoadlActions.GLOBAL_MODAL_WARNING, - data:{ - msg: generateConfirmationMsg(featureGroup), - confirmationButtonText: i18n('Delete'), - title: i18n('Delete'), - onConfirmed: ()=>FeatureGroupsActionHelper.deleteFeatureGroup(dispatch, {featureGroupId: featureGroup.id, licenseModelId, version}) - } - }), - onAddFeatureGroupClick: (actualVersion) => FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, {licenseModelId, version: actualVersion}), - onEditFeatureGroupClick: (featureGroup, actualVersion) => FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, { - featureGroup, - licenseModelId, - version: actualVersion - }) - }; +const mapActionsToProps = (dispatch, { licenseModelId }) => { + return { + onDeleteFeatureGroupClick: (featureGroup, version) => + dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data: { + msg: generateConfirmationMsg(featureGroup), + confirmationButtonText: i18n('Delete'), + title: i18n('Delete'), + onConfirmed: () => + FeatureGroupsActionHelper.deleteFeatureGroup(dispatch, { + featureGroupId: featureGroup.id, + licenseModelId, + version + }) + } + }), + onAddFeatureGroupClick: actualVersion => + FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, { + licenseModelId, + version: actualVersion + }), + onEditFeatureGroupClick: (featureGroup, actualVersion) => + FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, { + featureGroup, + licenseModelId, + version: actualVersion + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(FeatureGroupListEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + FeatureGroupListEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx index f59e000c21..91f77b3111 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx @@ -24,147 +24,184 @@ import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.js import FeatureGroupEditor from './FeatureGroupEditor.js'; class FeatureGroupListEditorView extends React.Component { - static propTypes = { - vendorName: PropTypes.string, - licenseModelId: PropTypes.string.isRequired, - featureGroupsModal: PropTypes.shape({ - show: PropTypes.bool, - editMode: PropTypes.bool - }), - isReadOnlyMode: PropTypes.bool.isRequired, - onAddFeatureGroupClick: PropTypes.func, - onEditFeatureGroupClick: PropTypes.func, - onDeleteFeatureGroupClick: PropTypes.func, - onCancelFeatureGroupsEditor: PropTypes.func, - featureGroupsList: PropTypes.array - }; - - static defaultProps = { - featureGroupsList: [], - featureGroupsModal: { - show: false, - editMode: false - } - }; - - state = { - localFilter: '' - }; - - render() { - let {licenseModelId, featureGroupsModal, isReadOnlyMode, onAddFeatureGroupClick, version} = this.props; - const {localFilter} = this.state; - return ( - <div className='license-model-list-editor feature-groups-list-editor'> - <ListEditorView - title={i18n('Feature Groups')} - plusButtonTitle={i18n('Add Feature Group')} - filterValue={localFilter} - onFilter={value => this.setState({localFilter: value})} - onAdd={() => onAddFeatureGroupClick(version)} - isReadOnlyMode={isReadOnlyMode}> - {this.filterList().map(listItem => this.renderFeatureGroupListItem(listItem, isReadOnlyMode, version))} - </ListEditorView> - {featureGroupsModal.show && <Modal show={featureGroupsModal.show} bsSize='large' animation={true} - className='onborading-modal license-model-modal feature-group-modal'> - <Modal.Header> - <Modal.Title>{`${featureGroupsModal.editMode ? i18n('Edit Feature Group') : i18n('Create New Feature Group')}`}</Modal.Title> - </Modal.Header> - <Modal.Body> - <FeatureGroupEditor - version={version} - licenseModelId={licenseModelId} - isReadOnlyMode={isReadOnlyMode}/> - </Modal.Body> - </Modal> - } - - </div> - ); - } - - - renderFeatureGroupListItem(listItem, isReadOnlyMode, version) { - let {name, description, manufacturerReferenceNumber, entitlementPoolsIds = [], licenseKeyGroupsIds = []} = listItem; - return ( - <ListEditorItemView - key={listItem.id} - onDelete={() => this.deleteFeatureGroupItem(listItem, version)} - onSelect={() => this.editFeatureGroupItem(listItem, version)} - className='list-editor-item-view' - isReadOnlyMode={isReadOnlyMode}> - <div className='list-editor-item-view-field'> - <div className='title'>{i18n('Name')}</div> - <div className='text name'>{name}</div> - </div> - - <div className='list-editor-item-view-field smaller-field'> - <div className='feature-groups-count-field'> - <div className='title'>{i18n('EP')}</div> - <div className='feature-groups-count-ep'>{entitlementPoolsIds.length || 0}</div> - </div> - </div> - <div className='list-editor-item-view-field smaller-field'> - <div className='feature-groups-count-field'> - <div className='title'>{i18n('LKG')}</div> - <div className='feature-groups-count-lk'>{licenseKeyGroupsIds.length || 0}</div> - </div> - </div> - - <div className='list-editor-item-view-field'> - <div className='feature-groups-count-field'> - <div className='title title-no-wrap'>{i18n('Manufacturer Reference Number')}</div> - <div className='feature-groups-mrn-ep'>{manufacturerReferenceNumber}</div> - </div> - </div> - - <div className='list-editor-item-view-field'> - <div className='title'>{i18n('Description')}</div> - <div className='text description'>{description}</div> - </div> - - - - </ListEditorItemView> - ); - } - - filterList() { - let {featureGroupsList} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return featureGroupsList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return featureGroupsList; - } - } - - editFeatureGroupItem(featureGroup, version) { - this.props.onEditFeatureGroupClick(featureGroup, version); - } - - deleteFeatureGroupItem(featureGroup, version) { - this.props.onDeleteFeatureGroupClick(featureGroup, version); - } + static propTypes = { + vendorName: PropTypes.string, + licenseModelId: PropTypes.string.isRequired, + featureGroupsModal: PropTypes.shape({ + show: PropTypes.bool, + editMode: PropTypes.bool + }), + isReadOnlyMode: PropTypes.bool.isRequired, + onAddFeatureGroupClick: PropTypes.func, + onEditFeatureGroupClick: PropTypes.func, + onDeleteFeatureGroupClick: PropTypes.func, + onCancelFeatureGroupsEditor: PropTypes.func, + featureGroupsList: PropTypes.array + }; + + static defaultProps = { + featureGroupsList: [], + featureGroupsModal: { + show: false, + editMode: false + } + }; + + state = { + localFilter: '' + }; + + render() { + let { + licenseModelId, + featureGroupsModal, + isReadOnlyMode, + onAddFeatureGroupClick, + version + } = this.props; + const { localFilter } = this.state; + return ( + <div className="license-model-list-editor feature-groups-list-editor"> + <ListEditorView + title={i18n('Feature Groups')} + plusButtonTitle={i18n('Add Feature Group')} + filterValue={localFilter} + onFilter={value => this.setState({ localFilter: value })} + onAdd={() => onAddFeatureGroupClick(version)} + isReadOnlyMode={isReadOnlyMode}> + {this.filterList().map(listItem => + this.renderFeatureGroupListItem( + listItem, + isReadOnlyMode, + version + ) + )} + </ListEditorView> + {featureGroupsModal.show && ( + <Modal + show={featureGroupsModal.show} + bsSize="large" + animation={true} + className="onborading-modal license-model-modal feature-group-modal"> + <Modal.Header> + <Modal.Title>{`${ + featureGroupsModal.editMode + ? i18n('Edit Feature Group') + : i18n('Create New Feature Group') + }`}</Modal.Title> + </Modal.Header> + <Modal.Body> + <FeatureGroupEditor + version={version} + licenseModelId={licenseModelId} + isReadOnlyMode={isReadOnlyMode} + /> + </Modal.Body> + </Modal> + )} + </div> + ); + } + + renderFeatureGroupListItem(listItem, isReadOnlyMode, version) { + let { + name, + description, + manufacturerReferenceNumber, + entitlementPoolsIds = [], + licenseKeyGroupsIds = [] + } = listItem; + return ( + <ListEditorItemView + key={listItem.id} + onDelete={() => this.deleteFeatureGroupItem(listItem, version)} + onSelect={() => this.editFeatureGroupItem(listItem, version)} + className="list-editor-item-view" + isReadOnlyMode={isReadOnlyMode}> + <div className="list-editor-item-view-field"> + <div className="title">{i18n('Name')}</div> + <div className="text name">{name}</div> + </div> + + <div className="list-editor-item-view-field smaller-field"> + <div className="feature-groups-count-field"> + <div className="title">{i18n('EP')}</div> + <div className="feature-groups-count-ep"> + {entitlementPoolsIds.length || 0} + </div> + </div> + </div> + <div className="list-editor-item-view-field smaller-field"> + <div className="feature-groups-count-field"> + <div className="title">{i18n('LKG')}</div> + <div className="feature-groups-count-lk"> + {licenseKeyGroupsIds.length || 0} + </div> + </div> + </div> + + <div className="list-editor-item-view-field"> + <div className="feature-groups-count-field"> + <div className="title title-no-wrap"> + {i18n('Manufacturer Reference Number')} + </div> + <div className="feature-groups-mrn-ep"> + {manufacturerReferenceNumber} + </div> + </div> + </div> + + <div className="list-editor-item-view-field"> + <div className="title">{i18n('Description')}</div> + <div className="text description">{description}</div> + </div> + </ListEditorItemView> + ); + } + + filterList() { + let { featureGroupsList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return featureGroupsList.filter( + ({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + } + ); + } else { + return featureGroupsList; + } + } + + editFeatureGroupItem(featureGroup, version) { + this.props.onEditFeatureGroupClick(featureGroup, version); + } + + deleteFeatureGroupItem(featureGroup, version) { + this.props.onDeleteFeatureGroupClick(featureGroup, version); + } } export default FeatureGroupListEditorView; export function generateConfirmationMsg(featureGroupToDelete) { - let name = featureGroupToDelete ? featureGroupToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{name}"?', {name: name}); - let subMsg = featureGroupToDelete.referencingLicenseAgreements - && featureGroupToDelete.referencingLicenseAgreements.length > 0 ? - i18n('This feature group is associated with one ore more license agreements') : - ''; - return ( - <div> - <p>{msg}</p> - <p>{subMsg}</p> - </div> - ); + let name = featureGroupToDelete ? featureGroupToDelete.name : ''; + let msg = i18n('Are you sure you want to delete "{name}"?', { name: name }); + let subMsg = + featureGroupToDelete.referencingLicenseAgreements && + featureGroupToDelete.referencingLicenseAgreements.length > 0 + ? i18n( + 'This feature group is associated with one ore more license agreements' + ) + : ''; + return ( + <div> + <p>{msg}</p> + <p>{subMsg}</p> + </div> + ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js index 9e7fe8e0dd..22e21a613a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js @@ -15,132 +15,202 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes as featureGroupsActionConstants} from './FeatureGroupsConstants.js'; +import { actionTypes as featureGroupsActionConstants } from './FeatureGroupsConstants.js'; import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; import LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; function baseUrl(licenseModelId, version) { - const restPrefix = Configuration.get('restPrefix'); - const {id: versionId} = version; - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/feature-groups`; + const restPrefix = Configuration.get('restPrefix'); + const { id: versionId } = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/feature-groups`; } function fetchFeatureGroup(licenseModelId, featureGroupId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${featureGroupId}`); + return RestAPIUtil.fetch( + `${baseUrl(licenseModelId, version)}/${featureGroupId}` + ); } function fetchFeatureGroupsList(licenseModelId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } function deleteFeatureGroup(licenseModelId, featureGroupId, version) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${featureGroupId}`); + return RestAPIUtil.destroy( + `${baseUrl(licenseModelId, version)}/${featureGroupId}` + ); } function addFeatureGroup(licenseModelId, featureGroup, version) { - return RestAPIUtil.post(baseUrl(licenseModelId, version), { - name: featureGroup.name, - description: featureGroup.description, - partNumber: featureGroup.partNumber, - manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, - addedLicenseKeyGroupsIds: featureGroup.licenseKeyGroupsIds, - addedEntitlementPoolsIds: featureGroup.entitlementPoolsIds - }); + return RestAPIUtil.post(baseUrl(licenseModelId, version), { + name: featureGroup.name, + description: featureGroup.description, + partNumber: featureGroup.partNumber, + manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, + addedLicenseKeyGroupsIds: featureGroup.licenseKeyGroupsIds, + addedEntitlementPoolsIds: featureGroup.entitlementPoolsIds + }); } -function updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, version) { - - const {licenseKeyGroupsIds = []} = featureGroup; - const {licenseKeyGroupsIds: prevLicenseKeyGroupsIds = []} = previousFeatureGroup; - const {entitlementPoolsIds = []} = featureGroup; - const {entitlementPoolsIds: prevEntitlementPoolsIds = []} = previousFeatureGroup; - return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${featureGroup.id}`, { - name: featureGroup.name, - description: featureGroup.description, - partNumber: featureGroup.partNumber, - manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, - addedLicenseKeyGroupsIds: licenseKeyGroupsIds.filter(licenseKeyGroupId => prevLicenseKeyGroupsIds.indexOf(licenseKeyGroupId) === -1), - removedLicenseKeyGroupsIds: prevLicenseKeyGroupsIds.filter(prevLicenseKeyGroupId => licenseKeyGroupsIds.indexOf(prevLicenseKeyGroupId) === -1), - addedEntitlementPoolsIds: entitlementPoolsIds.filter(entitlementPoolId => prevEntitlementPoolsIds.indexOf(entitlementPoolId) === -1), - removedEntitlementPoolsIds: prevEntitlementPoolsIds.filter(prevEntitlementPoolId => entitlementPoolsIds.indexOf(prevEntitlementPoolId) === -1) - - }); +function updateFeatureGroup( + licenseModelId, + previousFeatureGroup, + featureGroup, + version +) { + const { licenseKeyGroupsIds = [] } = featureGroup; + const { + licenseKeyGroupsIds: prevLicenseKeyGroupsIds = [] + } = previousFeatureGroup; + const { entitlementPoolsIds = [] } = featureGroup; + const { + entitlementPoolsIds: prevEntitlementPoolsIds = [] + } = previousFeatureGroup; + return RestAPIUtil.put( + `${baseUrl(licenseModelId, version)}/${featureGroup.id}`, + { + name: featureGroup.name, + description: featureGroup.description, + partNumber: featureGroup.partNumber, + manufacturerReferenceNumber: + featureGroup.manufacturerReferenceNumber, + addedLicenseKeyGroupsIds: licenseKeyGroupsIds.filter( + licenseKeyGroupId => + prevLicenseKeyGroupsIds.indexOf(licenseKeyGroupId) === -1 + ), + removedLicenseKeyGroupsIds: prevLicenseKeyGroupsIds.filter( + prevLicenseKeyGroupId => + licenseKeyGroupsIds.indexOf(prevLicenseKeyGroupId) === -1 + ), + addedEntitlementPoolsIds: entitlementPoolsIds.filter( + entitlementPoolId => + prevEntitlementPoolsIds.indexOf(entitlementPoolId) === -1 + ), + removedEntitlementPoolsIds: prevEntitlementPoolsIds.filter( + prevEntitlementPoolId => + entitlementPoolsIds.indexOf(prevEntitlementPoolId) === -1 + ) + } + ); } export default { - fetchFeatureGroup(dispatch, {licenseModelId, featureGroupId, version}) { - return fetchFeatureGroup(licenseModelId, featureGroupId, version); - }, + fetchFeatureGroup(dispatch, { licenseModelId, featureGroupId, version }) { + return fetchFeatureGroup(licenseModelId, featureGroupId, version); + }, - fetchFeatureGroupsList(dispatch, {licenseModelId, version}) { - return fetchFeatureGroupsList(licenseModelId, version).then(response => dispatch({ - type: featureGroupsActionConstants.FEATURE_GROUPS_LIST_LOADED, - response - })); - }, + fetchFeatureGroupsList(dispatch, { licenseModelId, version }) { + return fetchFeatureGroupsList(licenseModelId, version).then(response => + dispatch({ + type: featureGroupsActionConstants.FEATURE_GROUPS_LIST_LOADED, + response + }) + ); + }, - deleteFeatureGroup(dispatch, {licenseModelId, featureGroupId, version}) { - return deleteFeatureGroup(licenseModelId, featureGroupId, version).then(() => { - dispatch({ - type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS, - featureGroupId - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - }, + deleteFeatureGroup(dispatch, { licenseModelId, featureGroupId, version }) { + return deleteFeatureGroup(licenseModelId, featureGroupId, version).then( + () => { + dispatch({ + type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS, + featureGroupId + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + } + ); + }, - saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup, version}) { - if (previousFeatureGroup) { - return updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, version).then(() =>{ - dispatch({ - type: featureGroupsActionConstants.EDIT_FEATURE_GROUPS, - featureGroup - }); - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - else { - return addFeatureGroup(licenseModelId, featureGroup, version).then(response => { - dispatch({ - type: featureGroupsActionConstants.ADD_FEATURE_GROUPS, - featureGroup: { - ...featureGroup, - id: response.value, - referencingLicenseAgreements: [] - } - }); - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - }, + saveFeatureGroup( + dispatch, + { licenseModelId, previousFeatureGroup, featureGroup, version } + ) { + if (previousFeatureGroup) { + return updateFeatureGroup( + licenseModelId, + previousFeatureGroup, + featureGroup, + version + ).then(() => { + dispatch({ + type: featureGroupsActionConstants.EDIT_FEATURE_GROUPS, + featureGroup + }); + EntitlementPoolsActionHelper.fetchEntitlementPoolsList( + dispatch, + { licenseModelId, version } + ); + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList( + dispatch, + { licenseModelId, version } + ); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } else { + return addFeatureGroup(licenseModelId, featureGroup, version).then( + response => { + dispatch({ + type: featureGroupsActionConstants.ADD_FEATURE_GROUPS, + featureGroup: { + ...featureGroup, + id: response.value, + referencingLicenseAgreements: [] + } + }); + EntitlementPoolsActionHelper.fetchEntitlementPoolsList( + dispatch, + { licenseModelId, version } + ); + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList( + dispatch, + { licenseModelId, version } + ); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + } + ); + } + }, - selectEntitlementPoolsEditorTab(dispatch, {tab}) { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.SELECT_TAB, - tab - }); - }, + selectEntitlementPoolsEditorTab(dispatch, { tab }) { + dispatch({ + type: featureGroupsActionConstants.featureGroupsEditor.SELECT_TAB, + tab + }); + }, - openFeatureGroupsEditor(dispatch, {featureGroup, licenseModelId, version}) { - return Promise.all([ - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}), - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}) - ]).then(() => { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.OPEN, - featureGroup - }); - }); - }, + openFeatureGroupsEditor( + dispatch, + { featureGroup, licenseModelId, version } + ) { + return Promise.all([ + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, { + licenseModelId, + version + }), + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, { + licenseModelId, + version + }) + ]).then(() => { + dispatch({ + type: featureGroupsActionConstants.featureGroupsEditor.OPEN, + featureGroup + }); + }); + }, - closeFeatureGroupsEditor(dispatch) { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.CLOSE - }); - } + closeFeatureGroupsEditor(dispatch) { + dispatch({ + type: featureGroupsActionConstants.featureGroupsEditor.CLOSE + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js index 4c5a94f239..feeb5b6c39 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js @@ -16,27 +16,27 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - FEATURE_GROUPS_LIST_LOADED: null, - ADD_FEATURE_GROUPS: null, - EDIT_FEATURE_GROUPS: null, - DELETE_FEATURE_GROUPS: null, + FEATURE_GROUPS_LIST_LOADED: null, + ADD_FEATURE_GROUPS: null, + EDIT_FEATURE_GROUPS: null, + DELETE_FEATURE_GROUPS: null, - ENTITLEMENT_POOLS_LIST_LOADED: null, + ENTITLEMENT_POOLS_LIST_LOADED: null, - featureGroupsEditor: { - OPEN: null, - CLOSE: null, - DATA_CHANGED: null, - SELECT_TAB: null - } + featureGroupsEditor: { + OPEN: null, + CLOSE: null, + DATA_CHANGED: null, + SELECT_TAB: null + } }); export const FG_EDITOR_FORM = 'FG_EDITOR_FORM'; export const state = keyMirror({ - SELECTED_FEATURE_GROUP_TAB: { - GENERAL: 1, - ENTITLEMENT_POOLS: 2, - LICENSE_KEY_GROUPS: 3 - } + SELECTED_FEATURE_GROUP_TAB: { + GENERAL: 1, + ENTITLEMENT_POOLS: 2, + LICENSE_KEY_GROUPS: 3 + } }); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js index 5688fc0f16..aa1081ed20 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js @@ -14,65 +14,82 @@ * permissions and limitations under the License. */ -import {actionTypes, FG_EDITOR_FORM, state as FeatureGroupStateConstants} from './FeatureGroupsConstants.js'; - - +import { + actionTypes, + FG_EDITOR_FORM, + state as FeatureGroupStateConstants +} from './FeatureGroupsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.featureGroupsEditor.OPEN: - return { - ...state, - data: action.featureGroup || {}, - formReady: null, - formName: FG_EDITOR_FORM, - genericFieldInfo: { - 'description': { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - }, - 'partNumber': { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - }, - 'manufacturerReferenceNumber': { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 100}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - }, - 'name': { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - } - } - }; - case actionTypes.featureGroupsEditor.CLOSE: - return {}; - case actionTypes.featureGroupsEditor.SELECT_TAB: - return { - ...state, - selectedTab: action.tab - }; - - case actionTypes.featureGroupsEditor.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: - return { - ...state, - selectedEntitlementPoolsButtonTab: action.buttonTab - }; - case actionTypes.featureGroupsEditor.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB: - return { - ...state, - selectedLicenseKeyGroupsButtonTab: action.buttonTab - }; - default: - return state; - } + switch (action.type) { + case actionTypes.featureGroupsEditor.OPEN: + return { + ...state, + data: action.featureGroup || {}, + formReady: null, + formName: FG_EDITOR_FORM, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + }, + partNumber: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + }, + manufacturerReferenceNumber: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 100 } + ], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + }, + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + } + } + }; + case actionTypes.featureGroupsEditor.CLOSE: + return {}; + case actionTypes.featureGroupsEditor.SELECT_TAB: + return { + ...state, + selectedTab: action.tab + }; + case actionTypes.featureGroupsEditor + .SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: + return { + ...state, + selectedEntitlementPoolsButtonTab: action.buttonTab + }; + case actionTypes.featureGroupsEditor + .SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB: + return { + ...state, + selectedLicenseKeyGroupsButtonTab: action.buttonTab + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js index 3b5f1c55e4..072bba403d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js @@ -13,19 +13,27 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './FeatureGroupsConstants.js'; +import { actionTypes } from './FeatureGroupsConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FEATURE_GROUPS_LIST_LOADED: - return [...action.response.results]; - case actionTypes.ADD_FEATURE_GROUPS: - return [...state, action.featureGroup]; - case actionTypes.EDIT_FEATURE_GROUPS: - const indexForEdit = state.findIndex(featureGroup => featureGroup.id === action.featureGroup.id); - return [...state.slice(0, indexForEdit), action.featureGroup, ...state.slice(indexForEdit + 1)]; - case actionTypes.DELETE_FEATURE_GROUPS: - return state.filter(featureGroup => featureGroup.id !== action.featureGroupId); - default: - return state; - } + switch (action.type) { + case actionTypes.FEATURE_GROUPS_LIST_LOADED: + return [...action.response.results]; + case actionTypes.ADD_FEATURE_GROUPS: + return [...state, action.featureGroup]; + case actionTypes.EDIT_FEATURE_GROUPS: + const indexForEdit = state.findIndex( + featureGroup => featureGroup.id === action.featureGroup.id + ); + return [ + ...state.slice(0, indexForEdit), + action.featureGroup, + ...state.slice(indexForEdit + 1) + ]; + case actionTypes.DELETE_FEATURE_GROUPS: + return state.filter( + featureGroup => featureGroup.id !== action.featureGroupId + ); + default: + return state; + } }; |