afb37bea216f8a96b3ec4d2c12b299edf81699d3
[aai/sparky-fe.git] / src / app / tierSupport / TierSupportActions.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 import {
22   tierSupportActionTypes
23 } from 'app/tierSupport/TierSupportConstants.js';
24 import {
25   getSetGlobalMessageEvent,
26   getClearGlobalMessageEvent
27 } from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
28
29 function createOnNodeDetailsChangeEvent(newDetails) {
30   return {
31     type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED,
32     data: newDetails
33   };
34 }
35
36 function createSplitPaneResizeEvent(initialLoad) {
37   return {
38     type: tierSupportActionTypes.SPLIT_PANE_RESIZE,
39     data: initialLoad
40   };
41 }
42
43 function createOnNodeMenuSelectEvent(selectedMenu) {
44   return {
45     type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED,
46     data: selectedMenu
47   };
48 }
49
50 export function onNodeDetailsChange(newDetails) {
51   return dispatch => {
52     dispatch(createOnNodeDetailsChangeEvent(newDetails));
53   };
54 }
55
56 export function splitPaneResize(initialLoad) {
57   return dispatch => {
58     dispatch(createSplitPaneResizeEvent(initialLoad));
59   };
60 }
61
62 export function onNodeMenuChange(selectedMenu) {
63   return dispatch => {
64     dispatch(createOnNodeMenuSelectEvent(selectedMenu));
65   };
66 }
67
68 export function clearVIData() {
69   return {
70     type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA
71   };
72 }
73
74 export function setNotificationText(msgText, msgSeverity) {
75   if (msgText.length > 0) {
76     return dispatch => {
77       dispatch(
78         getSetGlobalMessageEvent(msgText, msgSeverity));
79     };
80   } else {
81     return dispatch => {
82       dispatch(getClearGlobalMessageEvent());
83     };
84   }
85 }