[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / licenseModel / licenseKeyGroups / LicenseKeyGroupsConstants.js
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13  * or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 import keyMirror from 'nfvo-utils/KeyMirror.js';
17 import i18n from 'nfvo-utils/i18n/i18n.js';
18 import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx';
19
20 export const actionTypes = keyMirror({
21
22         LICENSE_KEY_GROUPS_LIST_LOADED: null,
23         DELETE_LICENSE_KEY_GROUP: null,
24         EDIT_LICENSE_KEY_GROUP: null,
25         ADD_LICENSE_KEY_GROUP: null,
26         LICENSE_KEY_GROUPS_DELETE_CONFIRM: null,
27         licenseKeyGroupsEditor: {
28                 OPEN: null,
29                 CLOSE: null,
30                 DATA_CHANGED: null,
31         }
32 });
33
34 export const defaultState = {
35         licenseKeyGroupsEditor: {
36                 type: '',
37                 operationalScope: {choices: [], other: ''}
38         }
39 };
40
41 export const LKG_FORM_NAME = 'LKGFORM';
42
43 export const optionsInputValues = {
44         OPERATIONAL_SCOPE: [
45                 {enum: '', title: i18n('please select…')},
46                 {enum: 'Network_Wide', title: 'Network Wide'},
47                 {enum: 'Availability_Zone', title: 'Availability Zone'},
48                 {enum: 'Data_Center', title: 'Data Center'},
49                 {enum: 'Tenant', title: 'Tenant'},
50                 {enum: 'VM', title: 'VM'},
51                 {enum: 'CPU', title: 'CPU'},
52                 {enum: 'Core', title: 'Core'}
53         ],
54         TYPE: [
55                 {enum: '', title: i18n('please select…')},
56                 {enum: 'Universal', title: 'Universal'},
57                 {enum: 'Unique', title: 'Unique'},
58                 {enum: 'One_Time', title: 'One Time'}
59         ]
60 };
61
62 export const extractValue = (item) => {
63         if (item === undefined) {return '';} //TODO fix it later
64
65         return  item ? item === optionInputOther.OTHER ? item : InputOptions.getTitleByName(optionsInputValues, item) : '';
66 };
67
68 export const getOperationalScopes = (operationalScope) => {
69         if(operationalScope.choices.toString() === i18n(optionInputOther.OTHER) && operationalScope.other !== '') {
70                 return operationalScope.other;
71         }
72         else {
73                 let allOpScopes = '';
74                 for (let opScope of operationalScope.choices) {
75                         allOpScopes += allOpScopes === '' ? InputOptions.getTitleByName(optionsInputValues, opScope) : `, ${InputOptions.getTitleByName(optionsInputValues, opScope)}`;
76                 }
77                 return allOpScopes;
78         }
79 };