blob: 50d1fe86259e4c0081017f6d28ab7619a803a37c [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
Michael Landoefa037d2017-02-19 12:57:33 +02002 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
AviZi280f8012017-06-09 02:39:56 +03003 *
Michael Landoefa037d2017-02-19 12:57:33 +02004 * 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
AviZi280f8012017-06-09 02:39:56 +03007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Michael Landoefa037d2017-02-19 12:57:33 +020010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
AviZi280f8012017-06-09 02:39:56 +030012 * 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.
Michael Landoefa037d2017-02-19 12:57:33 +020015 */
Michael Landoefa037d2017-02-19 12:57:33 +020016import keyMirror from 'nfvo-utils/KeyMirror.js';
17import i18n from 'nfvo-utils/i18n/i18n.js';
AviZi280f8012017-06-09 02:39:56 +030018import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx';
Michael Landoefa037d2017-02-19 12:57:33 +020019
20export 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
34export const defaultState = {
35 licenseKeyGroupsEditor: {
36 type: '',
37 operationalScope: {choices: [], other: ''}
38 }
39};
40
AviZi280f8012017-06-09 02:39:56 +030041export const LKG_FORM_NAME = 'LKGFORM';
42
Michael Landoefa037d2017-02-19 12:57:33 +020043export 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
AviZi280f8012017-06-09 02:39:56 +030062export const extractValue = (item) => {
63 if (item === undefined) {return '';} //TODO fix it later
Michael Landoefa037d2017-02-19 12:57:33 +020064
AviZi280f8012017-06-09 02:39:56 +030065 return item ? item === optionInputOther.OTHER ? item : InputOptions.getTitleByName(optionsInputValues, item) : '';
66};
67
68export 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};