Entitlement Pool - Support Type Field
Change-Id: Ibd9996cce04849332bd23dd62e6143386cdd9a70
Issue-ID: SDC-2820
Signed-off-by: Ben David, Elad (eb7504) <eb7504@intl.att.com>
diff --git a/openecomp-ui/resources/scss/modules/_entitlementPools.scss b/openecomp-ui/resources/scss/modules/_entitlementPools.scss
index 736927f..8e8b820 100644
--- a/openecomp-ui/resources/scss/modules/_entitlementPools.scss
+++ b/openecomp-ui/resources/scss/modules/_entitlementPools.scss
@@ -4,6 +4,9 @@
@extend .heading-1;
color: $purple;
}
+ .type {
+ color: $orange;
+ }
}
}
diff --git a/openecomp-ui/resources/scss/modules/_licenseModelOverview.scss b/openecomp-ui/resources/scss/modules/_licenseModelOverview.scss
index eca87b6..02a8922 100644
--- a/openecomp-ui/resources/scss/modules/_licenseModelOverview.scss
+++ b/openecomp-ui/resources/scss/modules/_licenseModelOverview.scss
@@ -346,9 +346,6 @@
display: flex;
flex-direction: column;
justify-content: space-between;
- *:last-child {
- margin-top: 20px;
- }
*:only-child {
margin-top: 0;
}
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js
index be33af7..d6a3c8b 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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 dec7d9c..f1e2f2d 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
@@ -41,6 +41,7 @@
return RestAPIUtil.post(baseUrl(licenseModelId, version), {
name: entitlementPool.name,
description: entitlementPool.description,
+ type: entitlementPool.type,
thresholdValue: entitlementPool.thresholdValue,
thresholdUnits: getValue(entitlementPool.thresholdUnits),
increments: entitlementPool.increments,
@@ -62,6 +63,7 @@
{
name: entitlementPool.name,
description: entitlementPool.description,
+ type: entitlementPool.type,
thresholdValue: entitlementPool.thresholdValue,
thresholdUnits: getValue(entitlementPool.thresholdUnits),
increments: entitlementPool.increments,
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js
index d4a2f09..571b512 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js
@@ -58,6 +58,12 @@
};
export const optionsInputValues = {
+ TYPE: [
+ { enum: '', title: i18n('please select…') },
+ { enum: 'Universal', title: 'Universal' },
+ { enum: 'Unique', title: 'Unique' },
+ { enum: 'One_Time', title: 'One Time' }
+ ],
TIME: [
{ enum: '', title: i18n('please select…') },
{ enum: 'Hour', title: 'Hour' },
@@ -91,9 +97,9 @@
return '';
} //TODO fix it later
return item
- ? item.choice === optionInputOther.OTHER
- ? item.other
- : InputOptions.getTitleByName(optionsInputValues, item.choice)
+ ? item === optionInputOther.OTHER
+ ? item
+ : InputOptions.getTitleByName(optionsInputValues, item)
: '';
};
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js
index eb9cd51..674a8eb 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js
@@ -56,6 +56,11 @@
errorText: '',
validations: [{ type: 'maxLength', data: 1000 }]
},
+ type: {
+ isValid: true,
+ errorText: '',
+ validations: [{ type: 'required', data: true }]
+ },
increments: {
isValid: true,
errorText: '',
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 2592687..7e980f1 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx
@@ -20,7 +20,8 @@
import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx';
import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx';
-import { extractUnits } from './EntitlementPoolsConstants';
+import { optionsInputValues, extractUnits } from './EntitlementPoolsConstants';
+import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx';
class EntitlementPoolsListEditorView extends React.Component {
static propTypes = {
@@ -89,6 +90,7 @@
let {
id,
name,
+ type,
description,
thresholdValue,
thresholdUnits,
@@ -111,7 +113,12 @@
<div className="textEllipses text name">{name}</div>
</div>
</div>
-
+ <div className="list-editor-item-view-field">
+ <div className="title">{i18n('Type')}</div>
+ <div className="text type">
+ {InputOptions.getTitleByName(optionsInputValues, type)}
+ </div>
+ </div>
<div className="list-editor-item-view-field">
<div className="title">{i18n('Entitlement')}</div>
<div className="entitlement-pools-count">
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 b734a88..9eb38de 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
@@ -19,7 +19,10 @@
import GridSection from 'nfvo-components/grid/GridSection.jsx';
import GridItem from 'nfvo-components/grid/GridItem.jsx';
import Input from 'nfvo-components/input/validation/Input.jsx';
-import { SP_ENTITLEMENT_POOL_FORM } from '../EntitlementPoolsConstants.js';
+import {
+ optionsInputValues,
+ SP_ENTITLEMENT_POOL_FORM
+} from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js';
import { DATE_FORMAT } from 'sdc-app/onboarding/OnboardingConstants.js';
import { optionsInputValues as LicenseModelOptionsInputValues } from '../../LicenseModelConstants.js';
import UuId from 'sdc-app/onboarding/licenseModel/components/UuId.jsx';
@@ -34,6 +37,7 @@
}) => {
let {
name,
+ type,
description,
thresholdUnits,
thresholdValue,
@@ -45,7 +49,7 @@
versionUUID
} = data;
return (
- <GridSection hasLastColSet>
+ <GridSection hasLostColSet>
<GridItem colSpan={2}>
<Input
onChange={name =>
@@ -62,7 +66,44 @@
type="text"
/>
</GridItem>
- <GridItem colSpan={2} lastColInRow>
+ <GridItem colSpan={2}>
+ <Input
+ isRequired={true}
+ onChange={e => {
+ const selectedIndex = e.target.selectedIndex;
+ const val = e.target.options[selectedIndex].value;
+ onDataChanged({ type: val }, SP_ENTITLEMENT_POOL_FORM);
+ }}
+ value={type}
+ label={i18n('Type')}
+ data-test-id="create-ep-type"
+ isValid={genericFieldInfo.type.isValid}
+ errorText={genericFieldInfo.type.errorText}
+ groupClassName="bootstrap-input-options"
+ className="input-options-select"
+ overlayPos="bottom"
+ type="select">
+ {optionsInputValues.TYPE.map(type => (
+ <option key={type.enum} value={type.enum}>
+ {type.title}
+ </option>
+ ))}
+ </Input>
+ </GridItem>
+ <GridItem colSpan={2} stretch>
+ <Input
+ onChange={description =>
+ onDataChanged({ description }, SP_ENTITLEMENT_POOL_FORM)
+ }
+ isValid={genericFieldInfo.description.isValid}
+ errorText={genericFieldInfo.description.errorText}
+ label={i18n('Description')}
+ value={description}
+ data-test-id="create-ep-description"
+ type="textarea"
+ />
+ </GridItem>
+ <GridItem>
<Input
onChange={e => {
// setting the unit to the correct value
@@ -97,21 +138,30 @@
)
)}
</Input>
- </GridItem>
- <GridItem colSpan={2} stretch>
<Input
- onChange={description =>
- onDataChanged({ description }, SP_ENTITLEMENT_POOL_FORM)
+ type="date"
+ label={i18n('Start Date')}
+ value={startDate}
+ dateFormat={DATE_FORMAT}
+ startDate={startDate}
+ endDate={expiryDate}
+ onChange={startDate =>
+ onDataChanged(
+ {
+ startDate: startDate
+ ? startDate.format(DATE_FORMAT)
+ : ''
+ },
+ SP_ENTITLEMENT_POOL_FORM,
+ { startDate: validateStartDate }
+ )
}
- isValid={genericFieldInfo.description.isValid}
- errorText={genericFieldInfo.description.errorText}
- label={i18n('Description')}
- value={description}
- data-test-id="create-ep-description"
- type="textarea"
+ isValid={genericFieldInfo.startDate.isValid}
+ errorText={genericFieldInfo.startDate.errorText}
+ selectsStart
/>
</GridItem>
- <GridItem colSpan={2} lastColInRow>
+ <GridItem>
<Input
className="entitlement-pools-form-row-threshold-value"
onChange={thresholdValue =>
@@ -131,16 +181,30 @@
type="text"
/>
<Input
- onChange={increments =>
- onDataChanged({ increments }, SP_ENTITLEMENT_POOL_FORM)
- }
- label={i18n('Increments')}
- value={increments}
- data-test-id="create-ep-increments"
- type="text"
+ type="date"
+ label={i18n('Expiry Date')}
+ value={expiryDate}
+ dateFormat={DATE_FORMAT}
+ startDate={startDate}
+ endDate={expiryDate}
+ onChange={expiryDate => {
+ onDataChanged(
+ {
+ expiryDate: expiryDate
+ ? expiryDate.format(DATE_FORMAT)
+ : ''
+ },
+ SP_ENTITLEMENT_POOL_FORM
+ );
+ onDataChanged({ startDate }, SP_ENTITLEMENT_POOL_FORM, {
+ startDate: validateStartDate
+ });
+ }}
+ isValid={genericFieldInfo.expiryDate.isValid}
+ errorText={genericFieldInfo.expiryDate.errorText}
+ selectsEnd
/>
</GridItem>
-
<GridItem colSpan={2}>
<Input
className="entitlement-pools-form-row-threshold-value"
@@ -161,64 +225,19 @@
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}
- dateFormat={DATE_FORMAT}
- startDate={startDate}
- endDate={expiryDate}
- onChange={startDate =>
- onDataChanged(
- {
- startDate: startDate
- ? startDate.format(DATE_FORMAT)
- : ''
- },
- SP_ENTITLEMENT_POOL_FORM,
- { startDate: validateStartDate }
- )
- }
- isValid={genericFieldInfo.startDate.isValid}
- errorText={genericFieldInfo.startDate.errorText}
- selectsStart
- />
- <Input
- groupClassName="no-bottom-margin"
- type="date"
- label={i18n('Expiry Date')}
- value={expiryDate}
- dateFormat={DATE_FORMAT}
- startDate={startDate}
- endDate={expiryDate}
- onChange={expiryDate => {
- onDataChanged(
- {
- expiryDate: expiryDate
- ? expiryDate.format(DATE_FORMAT)
- : ''
- },
- SP_ENTITLEMENT_POOL_FORM
- );
- onDataChanged(
- { startDate },
- SP_ENTITLEMENT_POOL_FORM,
- {
- startDate: validateStartDate
- }
- );
- }}
- isValid={genericFieldInfo.expiryDate.isValid}
- errorText={genericFieldInfo.expiryDate.errorText}
- selectsEnd
- />
- </div>
+ <GridItem colSpan={2}>
+ <Input
+ onChange={increments =>
+ onDataChanged({ increments }, SP_ENTITLEMENT_POOL_FORM)
+ }
+ label={i18n('Increments')}
+ value={increments}
+ data-test-id="create-ep-increments"
+ groupClassName="no-bottom-margin"
+ type="text"
+ />
</GridItem>
{id && versionUUID && <UuId id={id} versionUUID={versionUUID} />}
</GridSection>
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/components/FormContent.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/components/FormContent.jsx
index c2c62b1..2486428 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/components/FormContent.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/components/FormContent.jsx
@@ -214,7 +214,6 @@
groupClassName="no-bottom-margin"
/>
</GridItem>
-
<GridItem colSpan={2}>
<Input
onChange={increments =>
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx
index ec5c76b..cceca25 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx
@@ -15,7 +15,10 @@
*/
import React, { Component } from 'react';
import i18n from 'nfvo-utils/i18n/i18n.js';
-import { extractUnits } from '../../entitlementPools/EntitlementPoolsConstants.js';
+import {
+ extractValue,
+ extractUnits
+} from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js';
import ArrowCol from './listItemsComponents/ArrowCol.jsx';
import ItemInfo from './listItemsComponents/ItemInfo.jsx';
import IconCol from './listItemsComponents/IconCol.jsx';
@@ -30,6 +33,7 @@
epData: {
name,
description,
+ type,
thresholdValue,
thresholdUnits,
manufacturerReferenceNumber
@@ -46,6 +50,13 @@
<IconCol className="ep-icon" text="EP" />
<ItemInfo name={name} description={description} />
<AdditionalDataCol>
+ {type && (
+ <AdditionalDataElement
+ className="vlm-list-item-entitlement-metric"
+ name={i18n('Type')}
+ value={extractValue(type)}
+ />
+ )}
{thresholdValue && (
<AdditionalDataElement
className="vlm-list-item-entitlement-metric"
diff --git a/openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js b/openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js
index 11422b4..d558b9a 100644
--- a/openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js
+++ b/openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js
@@ -28,6 +28,7 @@
thresholdValue: 76,
thresholdUnits: '%',
increments: 'string',
+ type: 'Universal',
startDate: new Date().getTime(),
expiryDate: new Date().getTime()
});