2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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';
20 export const actionTypes = keyMirror({
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: {
34 export const defaultState = {
35 licenseKeyGroupsEditor: {
37 operationalScope: {choices: [], other: ''}
41 export const LKG_FORM_NAME = 'LKGFORM';
43 export const optionsInputValues = {
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'}
55 {enum: '', title: i18n('please select…')},
56 {enum: 'Universal', title: 'Universal'},
57 {enum: 'Unique', title: 'Unique'},
58 {enum: 'One_Time', title: 'One Time'}
62 export const extractValue = (item) => {
63 if (item === undefined) {return '';} //TODO fix it later
65 return item ? item === optionInputOther.OTHER ? item : InputOptions.getTitleByName(optionsInputValues, item) : '';
68 export const getOperationalScopes = (operationalScope) => {
69 if(operationalScope.choices.toString() === i18n(optionInputOther.OTHER) && operationalScope.other !== '') {
70 return operationalScope.other;
74 for (let opScope of operationalScope.choices) {
75 allOpScopes += allOpScopes === '' ? InputOptions.getTitleByName(optionsInputValues, opScope) : `, ${InputOptions.getTitleByName(optionsInputValues, opScope)}`;