AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 1 | /*! |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 3 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 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 |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 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. |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 15 | */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 16 | import keyMirror from 'nfvo-utils/KeyMirror.js'; |
| 17 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 18 | import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 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 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 41 | export const LKG_FORM_NAME = 'LKGFORM'; |
| 42 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 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 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 62 | export const extractValue = (item) => { |
| 63 | if (item === undefined) {return '';} //TODO fix it later |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 64 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 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 | }; |