diff options
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools')
5 files changed, 76 insertions, 53 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js index ef705d67e4..dec7d9c3b8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js @@ -20,6 +20,12 @@ import { actionTypes as entitlementPoolsActionTypes } from './EntitlementPoolsCo import { actionTypes as limitEditorActions } from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; import { default as getValue, getStrValue } from 'nfvo-utils/getValue.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import { + actionTypes as modalActionTypes, + modalSizes +} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); @@ -137,9 +143,9 @@ const EntitlementPoolsActionHelper = { openEntitlementPoolsEditor( dispatch, - { entitlementPool, licenseModelId, version } = {} + { entitlementPool, licenseModelId, version, isReadOnlyMode } = {} ) { - if (licenseModelId && version) { + if (licenseModelId && version && entitlementPool) { this.fetchLimits(dispatch, { licenseModelId, version, @@ -150,6 +156,22 @@ const EntitlementPoolsActionHelper = { type: entitlementPoolsActionTypes.entitlementPoolsEditor.OPEN, entitlementPool }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.EP_EDITOR, + modalComponentProps: { + version, + licenseModelId, + isReadOnlyMode, + size: modalSizes.LARGE + }, + title: + licenseModelId && version && entitlementPool + ? i18n('Edit Entitlement Pool') + : i18n('Create New Entitlement Pool') + } + }); }, async deleteEntitlementPool( @@ -181,6 +203,9 @@ const EntitlementPoolsActionHelper = { dispatch({ type: entitlementPoolsActionTypes.entitlementPoolsEditor.CLOSE }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); }, async saveEntitlementPool( diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx index d5ca81cfac..d0e91e382b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx @@ -46,12 +46,27 @@ const EntitlementPoolPropType = PropTypes.shape({ name: PropTypes.string, description: PropTypes.string, thresholdUnits: PropTypes.string, - thresholdValue: PropTypes.string, + thresholdValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), increments: PropTypes.string, startDate: PropTypes.string, expiryDate: PropTypes.string }); +const TabButton = props => { + const { onClick, disabled, className } = props; + const dataTestId = props['data-test-id']; + return ( + <div + className={className} + onClick={disabled ? undefined : onClick} + data-test-id={dataTestId} + role="tab" + disabled={disabled}> + {props.children} + </div> + ); +}; + class EntitlementPoolsEditorView extends React.Component { static propTypes = { data: EntitlementPoolPropType, @@ -95,7 +110,7 @@ class EntitlementPoolsEditorView extends React.Component { const isTabsDisabled = !data.id || !this.props.isFormValid; return ( - <div> + <div className="entitlement-pools-modal license-model-modal"> <Tabs type="menu" activeTab={selectedTab} @@ -191,23 +206,29 @@ class EntitlementPoolsEditorView extends React.Component { )} </Tab> {selectedTab !== tabIds.GENERAL ? ( - <Button + <TabButton + tabId={tabIds.ADD_LIMIT_BUTTON} disabled={ - this.state.selectedLimit || isReadOnlyMode + !!this.state.selectedLimit || isReadOnlyMode } - className="add-limit-button" - tabId={tabIds.ADD_LIMIT_BUTTON} - btnType="link" - iconName="plus"> - {i18n('Add Limit')} - </Button> + data-test-id="add-limits-tab" + className="add-limit-button"> + <Button + disabled={ + !!this.state.selectedLimit || isReadOnlyMode + } + btnType="link" + iconName="plus"> + {i18n('Add Limit')} + </Button> + </TabButton> ) : ( - <div key="empty_ep_tab_key" /> + <TabButton key="empty_ep_tab_key" /> ) // Render empty div to not break tabs } </Tabs> <ModalButtons - className="entitlement-pools-editor-buttons" + className="sdc-modal__footer" selectedLimit={this.state.selectedLimit} isFormValid={this.props.isFormValid} isReadOnlyMode={isReadOnlyMode} diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js index 4679b9ec81..93e78a753b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js @@ -27,7 +27,6 @@ const mapStateToProps = ({ licenseModel: { entitlementPool, licenseModelEditor } }) => { const { entitlementPoolsList } = entitlementPool; - const { data } = entitlementPool.entitlementPoolEditor; const { vendorName } = licenseModelEditor.data; return { @@ -35,21 +34,27 @@ const mapStateToProps = ({ entitlementPoolsList: sortByStringProperty( entitlementPoolsList, SORTING_PROPERTY_NAME - ), - isDisplayModal: Boolean(data), - isModalInEditMode: Boolean(data && data.id) + ) }; }; -const mapActionsToProps = (dispatch, { licenseModelId, version }) => { +const mapActionsToProps = ( + dispatch, + { licenseModelId, version, isReadOnlyMode } +) => { return { onAddEntitlementPoolClick: () => - EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch), + EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch, { + licenseModelId, + version, + isReadOnlyMode + }), onEditEntitlementPoolClick: entitlementPool => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch, { entitlementPool, licenseModelId, - version + version, + isReadOnlyMode }), onDeleteEntitlementPool: entitlementPool => dispatch({ diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx index 0648d6632d..2592687298 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx @@ -17,11 +17,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import Modal from 'nfvo-components/modal/Modal.jsx'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; -import EntitlementPoolsEditor from './EntitlementPoolsEditor.js'; import { extractUnits } from './EntitlementPoolsConstants'; class EntitlementPoolsListEditorView extends React.Component { @@ -46,14 +44,7 @@ class EntitlementPoolsListEditorView extends React.Component { }; render() { - let { - licenseModelId, - isReadOnlyMode, - isDisplayModal, - isModalInEditMode, - version - } = this.props; - let { onAddEntitlementPoolClick } = this.props; + let { isReadOnlyMode, onAddEntitlementPoolClick } = this.props; const { localFilter } = this.state; return ( @@ -72,28 +63,6 @@ class EntitlementPoolsListEditorView extends React.Component { ) )} </ListEditorView> - <Modal - show={isDisplayModal} - bsSize="large" - animation={true} - className="onborading-modal license-model-modal entitlement-pools-modal"> - <Modal.Header> - <Modal.Title>{`${ - isModalInEditMode - ? i18n('Edit Entitlement Pool') - : i18n('Create New Entitlement Pool') - }`}</Modal.Title> - </Modal.Header> - <Modal.Body> - {isDisplayModal && ( - <EntitlementPoolsEditor - version={version} - licenseModelId={licenseModelId} - isReadOnlyMode={isReadOnlyMode} - /> - )} - </Modal.Body> - </Modal> </div> ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/components/FormContent.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/components/FormContent.jsx index 531b6b73b2..b734a88d67 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/components/FormContent.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/components/FormContent.jsx @@ -161,11 +161,13 @@ export const EntitlementPoolsFormContent = ({ data-test-id="create-ep-manufacturerReferenceNumber-value" value={manufacturerReferenceNumber} type="text" + groupClassName="no-bottom-margin" /> </GridItem> <GridItem colSpan={2} lastColInRow> <div className="date-section"> <Input + groupClassName="no-bottom-margin" type="date" label={i18n('Start Date')} value={startDate} @@ -188,6 +190,7 @@ export const EntitlementPoolsFormContent = ({ selectsStart /> <Input + groupClassName="no-bottom-margin" type="date" label={i18n('Expiry Date')} value={expiryDate} |