X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fsparky-fe.git;a=blobdiff_plain;f=src%2Fgeneric-components%2Fnotifications%2FNotificationReducer.js;h=1f5122c4df565f5d628c2b319162904d21628e27;hp=fc9a58105f76026ae9a7670d7e49cb6b3d62a2f9;hb=7eed2ed1366bece336b0d2e28ac8b3d4526964df;hpb=c1917730a648ddbb6cd51307cea9464a697700d8 diff --git a/src/generic-components/notifications/NotificationReducer.js b/src/generic-components/notifications/NotificationReducer.js index fc9a581..1f5122c 100644 --- a/src/generic-components/notifications/NotificationReducer.js +++ b/src/generic-components/notifications/NotificationReducer.js @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 Amdocs + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,49 +17,32 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ import NotificationConstants from './NotificationConstants.js'; export default (state = null, action) => { - switch (action.type) { - case NotificationConstants.NOTIFY_INFO: - return { - type: 'default', - title: action.data.title, - msg: action.data.msg, - timeout: action.data.timeout - }; - - case NotificationConstants.NOTIFY_ERROR: - return { - type: 'error', - title: action.data.title, - msg: action.data.msg, - timeout: action.data.timeout - }; - - case NotificationConstants.NOTIFY_WARNING: - return { - type: 'warning', - title: action.data.title, - msg: action.data.msg, - timeout: action.data.timeout - }; - - case NotificationConstants.NOTIFY_SUCCESS: - return { - type: 'success', + switch (action.type) { + case NotificationConstants.NOTIFY_INFO: + return createStatus('default', action); + case NotificationConstants.NOTIFY_ERROR: + return createStatus('error', action); + case NotificationConstants.NOTIFY_WARNING: + return createStatus('warning', action); + case NotificationConstants.NOTIFY_SUCCESS: + return createStatus('success', action); + case NotificationConstants.NOTIFY_CLOSE: + return null; + default: + return state; + } + +}; + +function createStatus(type, action) { + return { + type: type, title: action.data.title, msg: action.data.msg, timeout: action.data.timeout - }; - case NotificationConstants.NOTIFY_CLOSE: - return null; - - default: - return state; - } - -}; + }; +}