From 20d0dc060ba6b264b82a265c487d350e498a5135 Mon Sep 17 00:00:00 2001 From: sstoykov Date: Mon, 26 Nov 2018 16:20:40 -0500 Subject: [PATCH 01/16] Removed edit attribute code Removed obsolete code related to the edit attributes feature from sparky-fe. Issue-ID: AAI-1956 Change-Id: I2a125b825991b832d6249acfcd03a189005e52b4 Signed-off-by: sstoykov --- gulpfile.js | 9 +- resources/scss/_modules.scss | 1 - .../scss/setAttribute/_editAttributeform.scss | 119 ---------------- src/editAttributes/AppStore.js | 51 ------- src/editAttributes/Application.jsx | 37 ----- src/editAttributes/EditAttributeActions.js | 92 ------------ src/editAttributes/EditAttributeConstants.js | 45 ------ src/editAttributes/EditAttributeReducer.js | 51 ------- src/editAttributes/EditAttributes.jsx | 111 --------------- .../changeAttributeForm/ChangeAttributeForm.jsx | 156 --------------------- .../ChangeAttributeFormConstants.js | 41 ------ .../ChangeAttributeFormReducer.js | 33 ----- src/editAttributes/changeAttributeForm/validate.js | 46 ------ src/editAttributes/index.html | 34 ----- src/editAttributes/main.app.jsx | 33 ----- src/editAttributes/networking/NetworkCalls.js | 32 ----- src/editAttributes/networking/NetworkConstants.js | 34 ----- src/editAttributes/networking/NetworkUtils.js | 28 ---- webpack.config.js | 7 +- webpack.devConfig.js | 7 +- 20 files changed, 4 insertions(+), 963 deletions(-) delete mode 100644 resources/scss/setAttribute/_editAttributeform.scss delete mode 100644 src/editAttributes/AppStore.js delete mode 100644 src/editAttributes/Application.jsx delete mode 100644 src/editAttributes/EditAttributeActions.js delete mode 100644 src/editAttributes/EditAttributeConstants.js delete mode 100644 src/editAttributes/EditAttributeReducer.js delete mode 100644 src/editAttributes/EditAttributes.jsx delete mode 100644 src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx delete mode 100644 src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js delete mode 100644 src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js delete mode 100644 src/editAttributes/changeAttributeForm/validate.js delete mode 100644 src/editAttributes/index.html delete mode 100644 src/editAttributes/main.app.jsx delete mode 100644 src/editAttributes/networking/NetworkCalls.js delete mode 100644 src/editAttributes/networking/NetworkConstants.js delete mode 100644 src/editAttributes/networking/NetworkUtils.js diff --git a/gulpfile.js b/gulpfile.js index fcb485d..93670fc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -37,14 +37,11 @@ let dist = 'dist/'; let path = { output: dist, aaiOutput: dist + '/aai/', - saOutput: dist + '/editAttributes/', assets: './resources/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', json: './src/**/*.json', aaiIndex: './src/index.html', - saIndex: './src/editAttributes/index.html', scss: './resources/scss/**/*.scss', aaiCss: dist + '/css', - saCss: dist + '/editAttributes/css', war: [dist + '**/*.html', dist + '**/*.js', dist + '**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '**/*.json', 'webapp/**'], bundleSrc:[dist + '**/*.map'], wardest: dist @@ -52,19 +49,17 @@ let path = { taskMaker.defineTask('clean', {taskName: 'clean', src: path.output}); taskMaker.defineTask('copy', {taskName: 'copy-aai-index.html', src: path.aaiIndex, dest: path.output, rename: 'index.html'}); -taskMaker.defineTask('copy', {taskName: 'copy-sa-index.html', src: path.saIndex, dest: path.saOutput, rename: 'index.html'}); -taskMaker.defineTask('copy', {taskName: 'copy-sa-index.html', src: path.saIndex, dest: path.saOutput, rename: 'index.html'}); taskMaker.defineTask('copy', {taskName: 'copy-map-file', src: path.bundleSrc, dest: path.output, rename: 'mappingFile'}); taskMaker.defineTask('clean', {taskName: 'clean-map-file', src: path.bundleSrc}); /** Uncomment the loine below to generate a .war file with a local build */ // taskMaker.defineTask('compress', {taskName: 'compress-war', src: path.war, filename: appName + '.war', dest: path.wardest}) gulp.task('copy-dev-stuff', callback => { - return runSequence(['copy-aai-index.html', 'copy-sa-index.html'], callback); + return runSequence(['copy-aai-index.html'], callback); }); gulp.task('copy-stuff', callback => { - return runSequence(['copy-aai-index.html', 'copy-sa-index.html'], callback); + return runSequence(['copy-aai-index.html'], callback); }); gulp.task('dev', callback => { diff --git a/resources/scss/_modules.scss b/resources/scss/_modules.scss index e5ca532..4ac848f 100644 --- a/resources/scss/_modules.scss +++ b/resources/scss/_modules.scss @@ -25,7 +25,6 @@ @import "tier-support/splitPane"; @import "d3/_forceDirectedGraph.scss"; @import "d3/_aggregationMap.scss"; -@import "setAttribute/editAttributeform.scss"; @import "inventory/inventory.scss"; @import "vnfSearch/vnfSearch.scss"; @import "tier-support/tierSupport.scss"; diff --git a/resources/scss/setAttribute/_editAttributeform.scss b/resources/scss/setAttribute/_editAttributeform.scss deleted file mode 100644 index ceb5d45..0000000 --- a/resources/scss/setAttribute/_editAttributeform.scss +++ /dev/null @@ -1,119 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -html { - font-family: $base-font-regular; -} - -form { - margin: 50px 20px 20px 20px; - font-size: $body-font-1; -} - -div.attribute-field, div.centre { - display: flex; - flex-flow: row; - justify-content: center; - margin: 10px 5px; -} - -form > div > h2, -div.centre > span.error-message{ - min-width: 550px; - margin: 15px 0px 5px 0px; -} - -div.attribute-field > label { - font-weight: bold; - margin-right: 10px; - min-width: 170px; - text-align: right; - padding: 6px 9px; -} - -div.attribute-field > div { - flex: 1; - max-width: 500px; - display: flex; - flex-flow: column; - position: relative; -} - -div.attribute-field > div > * { - flex: 1; - padding: 5px 8px; - border: solid 1px $border-color5; -} - -div.attribute-field > div > select { - min-height: 30px; -} - -div > span.error-message { - font-weight: bold; - color: $background-color10; - border: none; -} - -div > span.error-message:before { - display: inline-block; - text-rendering: auto; - content: '\F06A'; - margin-right: 5px; - font: normal normal normal 14px/1 FontAwesome; -} - -form > div > button { - margin: 10px; - border-radius: 5px; - padding: 10px 5px 5px 5px; - font-weight: bold; - font-size: $heading-font-3; -} - -form > div > button[type=submit] { - color: $primary-background-color; - background-image: linear-gradient($background-color12, $background-color5); - border: solid 1px $border-color3; -} - -form > div > button[type=submit]:before { - display: inline-block; - font: normal normal normal 14px/1 FontAwesome; - text-rendering: auto; - content: '\F1D8'; - margin-right: 5px; -} - -form>div button[type=submit][disabled] { - opacity: .6; - cursor: not-allowed; -} - -form > div > button[type=button] { - color: $text-color3; - background-image: linear-gradient($primary-background-color, $background-color8); - border: solid 1px $border-color5; -} - -form>div button[type=button][disabled] { - opacity: .6; - cursor: not-allowed; -} diff --git a/src/editAttributes/AppStore.js b/src/editAttributes/AppStore.js deleted file mode 100644 index 888c659..0000000 --- a/src/editAttributes/AppStore.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import {combineReducers, createStore, compose, applyMiddleware} from 'redux'; -import thunkMiddleware from 'redux-thunk'; -import {reducer as formReducer} from 'redux-form'; - -import SetAttributeReducer from './EditAttributeReducer.js'; - -function createCompose() { - if (window.devToolsExtension) { - return compose( - applyMiddleware(thunkMiddleware), - window.devToolsExtension()); - } - else { - return applyMiddleware(thunkMiddleware); - } -} - -export const storeCreator = (initialState) => createStore( - combineReducers({ - setAttributes: SetAttributeReducer, - form: formReducer - }), - initialState, - createCompose() -); - - -const store = storeCreator(); - -export default store; - diff --git a/src/editAttributes/Application.jsx b/src/editAttributes/Application.jsx deleted file mode 100644 index 0817795..0000000 --- a/src/editAttributes/Application.jsx +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import {Provider} from 'react-redux'; -import store from 'editAttributes/AppStore.js'; - - -class Application extends Component { - - render() { - return ( - - {this.props.children} - - ); - } -} - -export default Application; diff --git a/src/editAttributes/EditAttributeActions.js b/src/editAttributes/EditAttributeActions.js deleted file mode 100644 index 468d7f4..0000000 --- a/src/editAttributes/EditAttributeActions.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import NetworkCalls from './networking/NetworkCalls.js'; -import { - POST, - BACKEND_POST_HEADER, - CREDENTIALS -} from './networking/NetworkConstants.js'; -import { - createEditEntityAttributeRequestObject -} from './networking/NetworkUtils.js'; -import { - setAttributesActionTypes, - EDIT_ENTITY_ATTRIBUTES_URL, - RESPONSE_CODE_SUCCESS, - RESPONSE_CODE_NOT_AUTHORIZED, - RESPONSE_MESSAGE_SUCCESS, - RESPONSE_MESSAGE_NOT_AUTHORIZED, - RESPONSE_MESSAGE_FAILURE, - RESPONSE_MESSAGE_NETWORK_ERROR -} from './EditAttributeConstants.js'; - -function errorReturnedEvent(errorMsg) { - return { - type: setAttributesActionTypes.SET_ATTRIBUTE_ERROR, - data: {errorMsg: errorMsg} - }; -} - -function successReturnedEvent() { - return { - type: setAttributesActionTypes.SET_ATTRIBUTE_SUCCESS, - data: {successMsg: RESPONSE_MESSAGE_SUCCESS} - }; -} - -function clearFeedbackMessageEvent() { - return { - type: setAttributesActionTypes.CLEAR_FEEDBACK_MESSAGE, - data: {} - }; -} - -export function clearFeebackMessage() { - return dispatch => { - dispatch(clearFeedbackMessageEvent()); - }; -} - -export function requestEditEntityAttributes(entityURI, entityAttributes) { - - let postBody = JSON.stringify( - createEditEntityAttributeRequestObject(entityURI, entityAttributes)); - return dispatch => { - return NetworkCalls.fetchRequest(EDIT_ENTITY_ATTRIBUTES_URL, - CREDENTIALS, POST, BACKEND_POST_HEADER, postBody).then( - (responseJson) => { - if (responseJson) { - if (responseJson.resultCode === RESPONSE_CODE_SUCCESS) { - dispatch(successReturnedEvent()); - } else if (responseJson.resultCode === RESPONSE_CODE_NOT_AUTHORIZED) { - dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NOT_AUTHORIZED)); - } else { - dispatch(errorReturnedEvent(RESPONSE_MESSAGE_FAILURE)); - } - } - } - ).catch( - () => { - dispatch(errorReturnedEvent(RESPONSE_MESSAGE_NETWORK_ERROR)); - } - ); - }; -} diff --git a/src/editAttributes/EditAttributeConstants.js b/src/editAttributes/EditAttributeConstants.js deleted file mode 100644 index c0a35ed..0000000 --- a/src/editAttributes/EditAttributeConstants.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import keyMirror from 'utils/KeyMirror.js'; -import { - BASE_URL -} from './networking/NetworkConstants.js'; - -export const SET_ATTRIBUTE_TITLE = 'A&AI'; -export const ATTRIBUTE_MODIFICATION = 'ATTRIBUTE MODIFICATION'; - - - -export const EDIT_ENTITY_ATTRIBUTES_URL = BASE_URL + '/editEntity/editAttributes'; - -export const RESPONSE_CODE_SUCCESS = 200; -export const RESPONSE_CODE_NOT_AUTHORIZED = 403; - -export const RESPONSE_MESSAGE_SUCCESS = 'Success'; -export const RESPONSE_MESSAGE_NOT_AUTHORIZED = 'User not authorized'; -export const RESPONSE_MESSAGE_FAILURE = 'Failed to update entity'; -export const RESPONSE_MESSAGE_NETWORK_ERROR = 'Network error'; - -export const setAttributesActionTypes = keyMirror({ - SET_ATTRIBUTE_ERROR: null, - SET_ATTRIBUTE_SUCCESS: null, - CLEAR_FEEDBACK_MESSAGE: null -}); diff --git a/src/editAttributes/EditAttributeReducer.js b/src/editAttributes/EditAttributeReducer.js deleted file mode 100644 index 90c959d..0000000 --- a/src/editAttributes/EditAttributeReducer.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import {setAttributesActionTypes} from './EditAttributeConstants.js'; -import { - MESSAGE_LEVEL_SUCCESS, - MESSAGE_LEVEL_DANGER -} from 'utils/GlobalConstants.js'; - -export default (state = {}, action) => { - switch (action.type) { - case setAttributesActionTypes.SET_ATTRIBUTE_ERROR: - return { - ...state, - feedbackMsgText: action.data.errorMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_DANGER - }; - - case setAttributesActionTypes.SET_ATTRIBUTE_SUCCESS: - return { - ...state, - feedbackMsgText: action.data.successMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_SUCCESS - }; - - case setAttributesActionTypes.CLEAR_FEEDBACK_MESSAGE: - return { - ...state, - feedbackMsgText: '', - feedbackMsgSeverity: '' - }; - } - return state; -}; diff --git a/src/editAttributes/EditAttributes.jsx b/src/editAttributes/EditAttributes.jsx deleted file mode 100644 index 6aa390f..0000000 --- a/src/editAttributes/EditAttributes.jsx +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import {connect} from 'react-redux'; -import i18n from 'utils/i18n/i18n'; - -import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx'; -import { - clearFeebackMessage, - requestEditEntityAttributes -} from './EditAttributeActions.js'; -import { - SET_ATTRIBUTE_TITLE, - ATTRIBUTE_MODIFICATION -} from './EditAttributeConstants.js'; -import ChangeAttributeForm from 'editAttributes/changeAttributeForm/ChangeAttributeForm.jsx'; -import {NO_VALUE_SELECTED} from 'editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js'; - -let mapStateToProps = ({setAttributes}) => { - let { - feedbackMsgText = '', - feedbackMsgSeverity = '' - } = setAttributes; - - return { - feedbackMsgText, - feedbackMsgSeverity - }; -}; - -let mapActionToProps = (dispatch) => { - return { - handleSubmit: (values) => { - let uri = values.uri; - let attrMap = new Map(); - attrMap.set('provStatus', 'prov-status'); - attrMap.set('inMaint', 'in-maint'); - attrMap.set('isClosedLoopDisabled', 'is-closed-loop-disabled'); - - let attributes = {}; - let valueString = JSON.stringify(values); - JSON.parse(valueString, (key, value) => { - if(value !== NO_VALUE_SELECTED) { - let formattedKey = attrMap.get(key); - if(formattedKey !== undefined) { - attributes = { - ...attributes, [formattedKey]: value - }; - } - return value; - } - }); - - dispatch(requestEditEntityAttributes(uri, attributes)); - }, - clearFeedbackMessage: () => { - dispatch(clearFeebackMessage()); - } - }; -}; - -class SetAttribute extends Component { - render() { - let { - feedbackMsgText, - feedbackMsgSeverity, - handleSubmit, - clearFeedbackMessage} = this.props; - return ( -
-
-
{i18n(SET_ATTRIBUTE_TITLE)}
-
-
- {i18n(ATTRIBUTE_MODIFICATION)} - -
- - { - handleSubmit(values); - }} - buttonSelected={() => { - clearFeedbackMessage(); - }}/> -
- ); - } -} - -export default connect(mapStateToProps, mapActionToProps)(SetAttribute); diff --git a/src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx b/src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx deleted file mode 100644 index b97d6bd..0000000 --- a/src/editAttributes/changeAttributeForm/ChangeAttributeForm.jsx +++ /dev/null @@ -1,156 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import {Field, Fields, reduxForm, propTypes} from 'redux-form'; -import i18n from 'utils/i18n/i18n'; - -import { - LABEL_NODE_URI, - LABEL_PROV_STATUS, - LABEL_ATTRIBUTES, - LABEL_IN_MAINT, - LABEL_IS_CLOSED_LOOP, - BUTTON_SUBMIT, - BUTTON_CLEAR, - NO_VALUE_SELECTED, - PREPROV, - NVTPROV, - DECOM, - PROV, - CAPPED, - RETIRED, - TRUE, - FALSE -} from './ChangeAttributeFormConstants.js'; -import validate from './validate.js'; - -class ChangeAttributeForm extends Component { - - static propTypes = { - ...propTypes - }; - - renderTextField = ({input, label, type, meta: {touched, error}}) => ( -
- -
- input.value === '' ? input.onBlur(' ') : input.onBlur()}/> - {touched && ((error && {error}))} -
-
- ); - - - booleanOptions = [ - , - , - - ]; - - provStatusOptions = [ - , - , - , - , - , - , - - ]; - - renderAttributeFields = (fields) => ( -
-
- {(fields.provStatus.meta.touched || - fields.inMaint.meta.touched || - fields.isClosedLoopDisabled.meta.touched) && - fields.provStatus.meta.error && - {fields.provStatus.meta.error}} -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- ); - - render() { - const { - handleSubmit, - buttonSelected, - pristine, - reset, - submitting} = this.props; - - return ( -
- -

{i18n(LABEL_ATTRIBUTES)}

- -
- - -
- - ); - } -} - -export default reduxForm({ - form: 'changeAttributeForm', - validate -})(ChangeAttributeForm); - diff --git a/src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js b/src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js deleted file mode 100644 index ae6eee5..0000000 --- a/src/editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -export const LABEL_NODE_URI = 'Target Entity URI'; -export const LABEL_PROV_STATUS = 'prov-status'; -export const LABEL_IN_MAINT = 'in-maint'; -export const LABEL_IS_CLOSED_LOOP = 'is-closed-loop-disabled'; -export const LABEL_ATTRIBUTES = 'ATTRIBUTES'; - -export const BUTTON_SUBMIT = 'Submit'; -export const BUTTON_CLEAR = 'Clear'; - -export const NO_VALUE_SELECTED = 'No Value Selected'; -export const PREPROV = 'PREPROV'; -export const NVTPROV = 'NVTPROV'; -export const PROV = 'PROV'; -export const CAPPED = 'CAPPED'; -export const DECOM = 'DECOM'; -export const RETIRED = 'RETIRED'; -export const TRUE = 'TRUE'; -export const FALSE = 'FALSE'; - -export const ERROR_MISSING_ATTR = 'At least one attribute must be set'; -export const ERROR_REQUIRED = 'Required'; diff --git a/src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js b/src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js deleted file mode 100644 index 4edd1eb..0000000 --- a/src/editAttributes/changeAttributeForm/ChangeAttributeFormReducer.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -/*import { combineReducers } from 'redux' - import { reducer as formReducer } from 'redux-form' - - - - const reducer = combineReducers({ - form: formReducer.validation({ - changeAttributeForm: validate - }) - }); - - export default reducer; - */ diff --git a/src/editAttributes/changeAttributeForm/validate.js b/src/editAttributes/changeAttributeForm/validate.js deleted file mode 100644 index 450bb02..0000000 --- a/src/editAttributes/changeAttributeForm/validate.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import i18n from 'utils/i18n/i18n'; - -import { - ERROR_MISSING_ATTR, - ERROR_REQUIRED, - NO_VALUE_SELECTED -} from './ChangeAttributeFormConstants.js'; - -const validate = (values) => { - const errors = {}; - - if (!values.uri || values.uri.replace(/\s/g, '') === '') { - errors.uri = i18n(ERROR_REQUIRED); - } - if ((!values.provStatus || values.provStatus === NO_VALUE_SELECTED) && - (!values.inMaint || values.inMaint === NO_VALUE_SELECTED) && - (!values.isClosedLoopDisabled || - values.isClosedLoopDisabled === - NO_VALUE_SELECTED)) { - errors.provStatus = i18n(ERROR_MISSING_ATTR); - } - - return errors; -}; - -export default validate; diff --git a/src/editAttributes/index.html b/src/editAttributes/index.html deleted file mode 100644 index afd9a22..0000000 --- a/src/editAttributes/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Edit Attributes - - - -
- - - - diff --git a/src/editAttributes/main.app.jsx b/src/editAttributes/main.app.jsx deleted file mode 100644 index 17a4b18..0000000 --- a/src/editAttributes/main.app.jsx +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React from 'react'; -import ReactDOM from 'react-dom'; - -import 'resources/scss/bootstrap.scss'; -import 'resources/css/font-awesome.min.css'; -import 'resources/scss/style.scss'; - -import Application from './Application.jsx'; -import SetAttribute from './EditAttributes.jsx'; - -ReactDOM.render( - , - document.getElementById('set-attribute-app')); diff --git a/src/editAttributes/networking/NetworkCalls.js b/src/editAttributes/networking/NetworkCalls.js deleted file mode 100644 index 7038e5e..0000000 --- a/src/editAttributes/networking/NetworkCalls.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -export default { - fetchRequest(URL, CREDENTIALS, METHOD, HEADER, BODY) { - return fetch(URL, { - credentials: CREDENTIALS, - method: METHOD, - headers: HEADER, - body: BODY - }).then( - (response) => response.json() - ); - } -}; diff --git a/src/editAttributes/networking/NetworkConstants.js b/src/editAttributes/networking/NetworkConstants.js deleted file mode 100644 index 09629fc..0000000 --- a/src/editAttributes/networking/NetworkConstants.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -export const POST = 'POST'; -export const POST_HEADER = { - 'Accept': 'application/json' -}; -export const BACKEND_POST_HEADER = { - 'Accept': 'application/json', - 'Content-Type': 'application/json' -}; -export const CREDENTIALS = 'same-origin'; -export const ERROR_RETRIEVING_DATA = 'Error fetching data from server'; -const BACKEND_IP_ADDRESS = document.location.hostname; -const BACKEND_PORT_NUMBER = window.location.port; -const PROTOCOL = window.location.protocol; -export const BASE_URL = PROTOCOL + '//' + BACKEND_IP_ADDRESS + ':' + BACKEND_PORT_NUMBER; diff --git a/src/editAttributes/networking/NetworkUtils.js b/src/editAttributes/networking/NetworkUtils.js deleted file mode 100644 index c8e65cb..0000000 --- a/src/editAttributes/networking/NetworkUtils.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -export function createEditEntityAttributeRequestObject(uri, attributes) { - return { - 'entity-uri': uri, - 'attributes': { - ...attributes - } - }; -} diff --git a/webpack.config.js b/webpack.config.js index b357f9a..7d2e53a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,10 +30,6 @@ module.exports = { bundle: [ 'app/main.app.jsx', 'webpack/hot/only-dev-server' - ], - 'editAttributes/editAttributesBundle': [ - 'editAttributes/main.app.jsx', - 'webpack/hot/only-dev-server' ] }, output: { @@ -48,8 +44,7 @@ module.exports = { app: 'src/app', 'generic-components': 'src/generic-components', utils: 'src/utils', - images: 'resources/images', - editAttributes: 'src/editAttributes' + images: 'resources/images' }, extensions: ["", ".webpack.js", ".web.js", ".js", ".json", ".jsx"] }, diff --git a/webpack.devConfig.js b/webpack.devConfig.js index 9f13b15..9e58faf 100644 --- a/webpack.devConfig.js +++ b/webpack.devConfig.js @@ -31,10 +31,6 @@ module.exports = { bundle: [ 'app/main.app.jsx', 'webpack/hot/only-dev-server' - ], - 'editAttributes/editAttributesBundle': [ - 'editAttributes/main.app.jsx', - 'webpack/hot/only-dev-server' ] }, output: { @@ -49,8 +45,7 @@ module.exports = { app: 'src/app', 'generic-components': 'src/generic-components', utils: 'src/utils', - images: 'resources/images', - editAttributes: 'src/editAttributes' + images: 'resources/images' }, extensions: ["", ".webpack.js", ".web.js", ".js", ".json", ".jsx"] }, -- 2.16.6 From 27fd1057ae501585c447860dc2b640259a7a0eff Mon Sep 17 00:00:00 2001 From: awudzins Date: Thu, 14 Feb 2019 12:28:42 +0100 Subject: [PATCH 02/16] Improve code coverage in TreeNode Improve code coverage in TreeNode Issue-ID: AAI-1618 Change-Id: Idec9566b108743c7c3a515d3f7fdce6f31b15324 Signed-off-by: adam.wudzinski --- test/generic-components/treeNode/TreeNode.test.js | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/generic-components/treeNode/TreeNode.test.js diff --git a/test/generic-components/treeNode/TreeNode.test.js b/test/generic-components/treeNode/TreeNode.test.js new file mode 100644 index 0000000..1c669e6 --- /dev/null +++ b/test/generic-components/treeNode/TreeNode.test.js @@ -0,0 +1,41 @@ +import TreeNode from 'generic-components/treeNode/TreeNode'; +import React from 'react'; +import { mount } from 'enzyme'; + +describe('TreeNode', () => { + let treeNode; + + beforeEach(() => { + treeNode = mount().instance(); + }); + + + it('Should be invisible when created', () => { + // then + expect(treeNode.state['visible']).toEqual(false) + }); + + it('Should be visible when toggled', () => { + // given + expect(treeNode.state['visible']).toEqual(false) + + // when + treeNode.toggle(); + + // then + expect(treeNode.state['visible']).toEqual(true) + }); + + it('Should be invisible when double toggled', () => { + // given + expect(treeNode.state['visible']).toEqual(false); + + // when + treeNode.toggle(); + treeNode.toggle(); + + // then + expect(treeNode.state['visible']).toEqual(false); + }); + +}); -- 2.16.6 From 27fe29a076553c26e2c56dccaf52d2af789eae3a Mon Sep 17 00:00:00 2001 From: andrzejszukuc Date: Thu, 14 Feb 2019 13:38:12 +0100 Subject: [PATCH 03/16] Integration tests for MainScreenWrapperReducer Change-Id: I7e947ea2ccab8877a3b8bb01d8e6b999bee1901f Issue-ID: AAI-2143 Signed-off-by: Andrzej Szukuc --- package.json | 7 +- src/app/MainScreenWrapperActionHelper.js | 14 +- src/app/contextHandler/ContextHandlerActions.js | 22 +- src/app/personlaization/PersonalizationActions.js | 6 +- test/MainScreenWrapperReducer.test.js | 486 ++++++++++++++++++++++ 5 files changed, 502 insertions(+), 33 deletions(-) create mode 100644 test/MainScreenWrapperReducer.test.js diff --git a/package.json b/package.json index 7402e2b..2b8334a 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "isparta-loader": "^2.0.0", "istanbul": "^1.0.0-alpha.2", "istanbul-instrumenter-loader": "^0.2.0", - "jest": "^22.4.3", + "jest": "^23.0.1", "jest-enzyme": "^6.0.0", "jest-fetch-mock": "^1.5.0", "json-loader": "^0.5.4", @@ -99,14 +99,15 @@ "prompt": "^0.2.14", "react-addons-test-utils": "^15.1.0", "react-hot-loader": "^3.0.0-beta.6", - "redux-mock-store": "^1.4.0", + "redux-mock-store": "^1.5.3", "sass-loader": "^3.1.2", "source-map-loader": "^0.1.5", "style-loader": "^0.13.1", "url-loader": "^0.5.7", "webpack": "^1.13.1", "webpack-bundle-analyzer": "^3.0.3", - "webpack-dev-server": "^1.14.1" + "webpack-dev-server": "^1.14.1", + "randomstring": "^1.1.5" }, "jest": { "verbose": true, diff --git a/src/app/MainScreenWrapperActionHelper.js b/src/app/MainScreenWrapperActionHelper.js index dd7450b..3477b03 100644 --- a/src/app/MainScreenWrapperActionHelper.js +++ b/src/app/MainScreenWrapperActionHelper.js @@ -74,8 +74,7 @@ function createOverlayDataFoundEvent(overlayData, paramName, curData, responseEv } function overlayViewData(dataFetchRequest, paramName, curData, responseEventKey) { - return dispatch => { - dataFetchRequest().then( + return dispatch => dataFetchRequest().then( (response) => { return response.json(); } @@ -87,8 +86,7 @@ function overlayViewData(dataFetchRequest, paramName, curData, responseEventKey) dispatch(getSetGlobalMessageEvent(ERROR_RETRIEVING_DATA, MESSAGE_LEVEL_DANGER)); dispatch(createOverlayDataFoundEvent({}, paramName, curData, responseEventKey)); }); - }; -} +}; export function overlayNetworkCallback(urlApi, postBody, paramName, curData, responseEventKey) { let dataFetchRequest = @@ -113,8 +111,7 @@ function createViewDataFoundEvent(viewData, paramName, curViewData) { } function extensibleViewData(dataFetchRequest, paramName, curViewData) { - return dispatch => { - return dataFetchRequest().then( + return dispatch => dataFetchRequest().then( (response) => { return response.json(); } @@ -127,7 +124,6 @@ function extensibleViewData(dataFetchRequest, paramName, curViewData) { dispatch(createViewDataFoundEvent({}, paramName, curViewData)); //To-do: If need to send a flag later on to the view, add a function to have the flag }); - }; } export function extensibleViewNetworkCallback(urlApi, postBody, paramName, curViewData) { @@ -136,9 +132,7 @@ export function extensibleViewNetworkCallback(urlApi, postBody, paramName, curVi () => fetchRequestObj(BASE_URL + urlApi, POST, POST_HEADER, postBody); - return dispatch => { - dispatch(extensibleViewData(dataFetchRequest, paramName, curViewData)); - }; + return dispatch => dispatch(extensibleViewData(dataFetchRequest, paramName, curViewData)); } export function extensibleViewMessageCallback(msgText, msgSeverity) { diff --git a/src/app/contextHandler/ContextHandlerActions.js b/src/app/contextHandler/ContextHandlerActions.js index f3ede6d..35091b5 100644 --- a/src/app/contextHandler/ContextHandlerActions.js +++ b/src/app/contextHandler/ContextHandlerActions.js @@ -81,8 +81,7 @@ function createSubscriptionPayloadEvent(payload) { } function fetchSubscriptionPayload(fetchRequestCallback) { - return dispatch => { - return fetchRequestCallback().then( + return dispatch => fetchRequestCallback().then( (response) => { if (response.status >= STATUS_CODE_3XX_REDIRECTION) { return Promise.reject(new Error(response.status)); @@ -100,16 +99,13 @@ function fetchSubscriptionPayload(fetchRequestCallback) { dispatch(getSetGlobalMessageEvent(SUBSCRIPTION_FAILED_MESSAGE , MESSAGE_LEVEL_WARNING)); } ); - }; } export function getSubscriptionPayload() { let externalfetchRequest = () => networkCall.getRequest(SUBSCRIPTION_PAYLOAD_URL, GET); - return dispatch => { - dispatch(fetchSubscriptionPayload(externalfetchRequest)); - }; + return dispatch => dispatch(fetchSubscriptionPayload(externalfetchRequest)); } function validateExternalParams(externalURLParams) { @@ -129,8 +125,8 @@ function createSuggestionFoundEvent(suggestion) { function fetchDataForExternalRequest(fetchRequestCallback) { - return dispatch => { - return fetchRequestCallback().then( + return dispatch => + fetchRequestCallback().then( (response) => { if (response.status === STATUS_CODE_204_NO_CONTENT || response.status >= STATUS_CODE_3XX_REDIRECTION) { return Promise.reject(new Error(response.status)); @@ -158,7 +154,6 @@ function fetchDataForExternalRequest(fetchRequestCallback) { dispatch(getSetGlobalMessageEvent(FAILED_REQUEST , MESSAGE_LEVEL_DANGER)); } ); - }; } function validateAndFetchExternalParams(externalParams) { @@ -172,17 +167,12 @@ function validateAndFetchExternalParams(externalParams) { let externalfetchRequest = () => networkCall.fetchRequestObj(EXTERNAL_REQ_ENTITY_SEARCH_URL, POST, POST_HEADER, postBody); - return dispatch => { - dispatch(fetchDataForExternalRequest(externalfetchRequest)); - }; + return dispatch => dispatch(fetchDataForExternalRequest(externalfetchRequest)); } } export function externalUrlRequest(urlParams) { let externalURLParams = getExternalParamValues(urlParams); - return dispatch => { - dispatch( - validateAndFetchExternalParams(externalURLParams)); - }; + return dispatch => dispatch(validateAndFetchExternalParams(externalURLParams)); } export function externalMessageRequest(jsonParams) { return dispatch => { diff --git a/src/app/personlaization/PersonalizationActions.js b/src/app/personlaization/PersonalizationActions.js index b10d85f..bdf54ca 100644 --- a/src/app/personlaization/PersonalizationActions.js +++ b/src/app/personlaization/PersonalizationActions.js @@ -74,7 +74,5 @@ export function getPersonalizationDetails(){ let personalizationFetchRequest = () => networkCall.getRequest(GET_PERSONALIZED_VALUES_URL, GET); - return dispatch => { - dispatch(fetchPersonalizedValues(personalizationFetchRequest)); - }; -} \ No newline at end of file + return dispatch => dispatch(fetchPersonalizedValues(personalizationFetchRequest)); +} diff --git a/test/MainScreenWrapperReducer.test.js b/test/MainScreenWrapperReducer.test.js new file mode 100644 index 0000000..e9324cc --- /dev/null +++ b/test/MainScreenWrapperReducer.test.js @@ -0,0 +1,486 @@ +import thunk from 'redux-thunk'; +import randstr from 'randomstring'; +import configureMockStore from 'redux-mock-store'; + +import MainScreenWrapperReducer from 'app/MainScreenWrapperReducer' +import {aaiActionTypes} from 'app/MainScreenWrapperConstants'; +import {getPersonalizationDetails} from 'app/personlaization/PersonalizationActions'; +import {getInvalidSearchInputEvent} from'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions'; +import {extensibleViewNetworkCallback, showMainMenu, clearExtensibleViewData, setSecondaryTitle} from 'app/MainScreenWrapperActionHelper'; +import {externalUrlRequest, getSubscriptionPayload} from 'app/contextHandler/ContextHandlerActions' + +import {globalInlineMessageBarActionTypes} from "app/globalInlineMessageBar/GlobalInlineMessageBarConstants"; +import {globalAutoCompleteSearchBarActionTypes} from "app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants"; +import { + contextHandlerActionTypes, + FAILED_REQUEST, + MULTIPLE_RESULT, SUBSCRIPTION_FAILED_MESSAGE, + WRONG_EXTERNAL_REQUEST_MESSAGE, + WRONG_RESULT, + ZERO_RESULT +} from "app/contextHandler/ContextHandlerConstants"; +import {PERSONALIZATION_FAILED_MESSAGE, personalizationActionTypes} from "app/personlaization/PersonalizationConstans"; + +describe('MainScreenWrapperReducerTests', () => { + fetch = require('jest-fetch-mock'); + const mockStore = configureMockStore([thunk])(); + const initialState = {Baz : 'Fooo'}; + const error = '401'; + + beforeEach(() => { + fetch.resetMocks(); + mockStore.clearActions(); + }); + + describe('extensibleViewNetworkCallbackTests', () => { + const paramName = 'boo'; + const postBody = 'baz'; + const curView = {Boz : 'Fooz'}; + const requestUrl = 'www.foo.com'; + const response = {Foo: 'Bar'}; + + describe('success tests', () => { + beforeEach(async () => { + //given + fetch.once(JSON.stringify(response)); + await mockStore.dispatch(extensibleViewNetworkCallback(requestUrl, postBody, paramName, curView)); + }); + + it('action on success test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED); + }); + + it('reducer on success test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({ + boo: response, + ...curView + }); + }); + }); + + describe('failure tests', () => { + beforeEach(async () => { + //given + fetch.mockRejectOnce(error); + await mockStore.dispatch(extensibleViewNetworkCallback(requestUrl, postBody, paramName, curView)); + }); + + it('action on failure test', () => { + //given + const [firstAction, secondAction, ...tail] = mockStore.getActions(); + + //then + expect(tail).toEqual([]); + expect(firstAction.type).toEqual(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(secondAction.type).toEqual(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED); + }); + + it('reducer on failure test', () => { + //given + const [firstAction, secondAction, ..._] = mockStore.getActions(); + + //when + const afterFirstState = MainScreenWrapperReducer(initialState, firstAction); + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, secondAction); + + //then + expect(afterFirstState).toEqual(initialState); + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({ + boo: {}, + ...curView + }); + }); + }); + }); + + describe.each([true, false])('showMainMenuTests', value => { + beforeEach(async () => { + //given + await mockStore.dispatch(showMainMenu(value)); + }); + + it('action on show: ' + value + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.AAI_SHOW_MENU); + }); + + it('reducer on show: ' + value + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + showMenu, + toggleButtonActive, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(showMenu).toBe(value); + expect(toggleButtonActive).toBe(value); + }); + }); + + describe('clearExtensibleViewDataTests', () => { + beforeEach(async () => { + //given + await mockStore.dispatch(clearExtensibleViewData()); + }); + + it('action test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA); + }); + + it('reducer test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({}); + }); + }); + + describe('getInvalidSearchInputEventTests', () => { + const msg = randstr.generate(); + + beforeEach(async () => { + await mockStore.dispatch(getInvalidSearchInputEvent(msg)); + }); + + it('action msg: ' + msg + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT); + }); + + it('reducer msg: ' + msg + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({clearView : true}); + }); + }); + + describe('externalUrlRequestTests', () => { + const someUrlParams = 'view=A&entityId=B&entityType=C'; + + describe.each([{ + title: 'on empty url params', + prepareMock: () => {}, + urlParams: '', + expectedResponse: WRONG_EXTERNAL_REQUEST_MESSAGE + }, { + title: 'on request rejected by the server', + prepareMock: () => fetch.mockRejectOnce('401'), + urlParams: someUrlParams, + expectedResponse: FAILED_REQUEST + }, { + title: 'on empty suggestions', + prepareMock: () => fetch.once(JSON.stringify({})), + urlParams: someUrlParams, + expectedResponse: WRONG_RESULT + }, { + title: 'on no results', + prepareMock: () => fetch.once(JSON.stringify({totalFound: 0, suggestions: []})), + urlParams: someUrlParams, + expectedResponse: ZERO_RESULT + }, { + title: 'on multiple results', + prepareMock: () => fetch.once(JSON.stringify({totalFound: 2, suggestions: ['Foo', 'Bar']})), + urlParams: someUrlParams, + expectedResponse: MULTIPLE_RESULT + }])('failure tests', ({title, prepareMock, urlParams, expectedResponse}) => { + beforeEach(async () => { + //given + prepareMock(); + await mockStore.dispatch(externalUrlRequest(urlParams)); + }); + + it('action ' + title + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(action.data.msgText).toEqual(expectedResponse); + }); + + it('reducer ' + title + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, action); + + //then + expect(state).toEqual(initialState); + }); + }); + + describe("success tests", () => { + //given + const response = {totalFound: 1, suggestions: ['Foo']}; + + beforeEach(async () => { + //given + fetch.resetMocks(); + fetch.once(JSON.stringify(response)); + + await mockStore.dispatch(externalUrlRequest(someUrlParams)); + }); + + it('action on exactly one suggestion test', () => { + //when + const [firstAction, secondAction, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(firstAction.type).toBe( globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE); + expect(secondAction.type).toBe(contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND); + }); + + it('reducer on exactly one suggestion test', () => { + //given + const [firstAction, secondAction, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, firstAction); + const { + externalRequestFound, + ...rest + } = MainScreenWrapperReducer(state, secondAction); + + //then + expect(state).toEqual(initialState); + expect(rest).toEqual(initialState); + expect(externalRequestFound).toEqual({suggestion: response.suggestions[0]}); + }); + }); + }); + + describe('setSecondaryTitleTests', () => { + //given + const title = randstr.generate(); + + beforeEach(async () => { + //given + await mockStore.dispatch(setSecondaryTitle(title)); + }); + + it('action test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.SET_SECONDARY_TITLE); + }); + + it('reducer test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + secondaryTitle, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(secondaryTitle).toEqual(title); + }); + }); + + describe('getSubscriptionPayloadTests', () => { + describe('failure tests', () => { + beforeEach(async () => { + //given + fetch.mockRejectOnce(error); + await mockStore.dispatch(getSubscriptionPayload()); + }); + + it('action on request rejected by server test', async () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(action.data.msgText).toEqual(SUBSCRIPTION_FAILED_MESSAGE); + }); + + it('reducer on request rejected by server test', async () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, action); + + //then + expect(state).toEqual(initialState); + }); + }); + + const subscriptionData = 'Foo'; + + describe.each([{ + title: 'on disabled subscription', + payload: {subscriptionEnabled: false}, + type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY, + detail : undefined + }, { + title: 'on enabled subscription', + payload: {subscriptionEnabled: true, subscriptionDetails: subscriptionData}, + type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND, + detail : subscriptionData + }])('success tests', ({title, payload, type, detail}) => { + beforeEach(async () => { + //given + fetch.once(JSON.stringify(payload)); + await mockStore.dispatch(getSubscriptionPayload()); + }); + + it('action ' + title + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(type); + }); + + it('reducer ' + title + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + subscriptionEnabled, + subscriptionPayload, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(subscriptionEnabled).toBe(payload.subscriptionEnabled); + expect(subscriptionPayload).toEqual(detail); + }); + }); + }); + + describe("getPersonalizationDetailsTests", () => { + describe('failure tests', () => { + beforeEach(async () => { + //given + fetch.mockRejectOnce(error); + await mockStore.dispatch(getPersonalizationDetails()); + }); + + it('action on request rejected by server test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(action.data.msgText).toEqual(PERSONALIZATION_FAILED_MESSAGE); + }); + + it('reducer on request rejected by server test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, action); + + //then + expect(state).toEqual(initialState); + }); + }); + + describe('success tests', () => { + const personalizationPayload = {topLeftHeader: 'Foo', htmlDocumentTitle: 'Bar'}; + + beforeEach(async () => { + //given + fetch.once(JSON.stringify(personalizationPayload)); + await mockStore.dispatch(getPersonalizationDetails()); + }); + + it('action on personalization payload found test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(personalizationActionTypes.PERSONALIZATION_PAYLOAD_FOUND); + }); + + it("Reducer on personalization payload found test", async () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + aaiTopLeftPersonalizedHeader, + aaiPersonalizedHtmlDocumentTitle, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(aaiTopLeftPersonalizedHeader).toEqual(personalizationPayload.topLeftHeader); + expect(aaiPersonalizedHtmlDocumentTitle).toEqual(personalizationPayload.htmlDocumentTitle); + }); + }); + }); +}); -- 2.16.6 From 85fa41b6a03a3914788e825cb28db84b33772489 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Fri, 1 Mar 2019 18:45:51 -0800 Subject: [PATCH 04/16] Add missing INFO.yaml blocks Add missing information so that the new verify job passes. Change-Id: I4ac120e5eb46e918fc54072f6bee64a48a871651 Issue-ID: CIMAN-134 Signed-off-by: Jessica Wagantall --- INFO.yaml | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/INFO.yaml b/INFO.yaml index c250b41..96ba718 100644 --- a/INFO.yaml +++ b/INFO.yaml @@ -1,18 +1,24 @@ --- project: 'aai-sparky-fe' project_creation_date: '2017-05-03' +project_category: '' lifecycle_state: 'Incubation' -project_lead: &onap_releng_ptl +project_lead: &onap_aai_ptl name: 'James Forsyth' email: 'jf2512@att.com' id: 'jimmydot' company: 'ATT' timezone: 'America/Detroit' -primary_contact: *onap_releng_ptl +primary_contact: *onap_aai_ptl issue_tracking: type: 'jira' url: 'https://jira.onap.org/projects/AAI' key: 'AAI' +mailing_list: + type: 'groups.io' + url: 'lists.onap.org' + tag: '<[sub-project_name]>' +realtime_discussion: '' meetings: - type: 'zoom' agenda: 'https://wiki.onap.org/display/DW/AAI+Meeting+Notes' @@ -21,13 +27,46 @@ meetings: channel: 'n/a' repeats: 'weekly' time: '14:00 UTC' +repositories: + - 'aai-aai-common' + - 'aai-aai-config' + - 'aai-aai-data' + - 'aai-aai-service' + - 'aai-babel' + - 'aai-cacher' + - 'aai-chameleon' + - 'aai-champ' + - 'aai-data-router' + - 'aai-eis' + - 'aai-enricher' + - 'aai-event-client' + - 'aai-gallifrey' + - 'aai-gap' + - 'aai-gizmo' + - 'aai-graphadmin' + - 'aai-graphgraph' + - 'aai-logging-service' + - 'aai-model-loader' + - 'aai-oom' + - 'aai-resources' + - 'aai-rest-client' + - 'aai-router-core' + - 'aai-schema-service' + - 'aai-search-data-service' + - 'aai-sparky-be' + - 'aai-sparky-fe' + - 'aai-spike' + - 'aai-tabular-data-service' + - 'aai-test-config' + - 'aai-traversal' + - 'aai-validation' committers: - - <<: *onap_releng_ptl + - <<: *onap_aai_ptl - name: 'Manisha Aggarwal' email: 'ma9181@att.com' company: 'ATT' id: 'ma9181' - timezone: 'America/New York' + timezone: 'America/New_York' - name: 'Steven Blimkie' email: 'Steven.Blimkie@amdocs.com' company: 'Amdocs' @@ -42,7 +81,7 @@ committers: email: 'vk250x@att.com' company: 'ATT' id: 'vk250x' - timezone: 'America/New York' + timezone: 'America/New_York' tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: -- 2.16.6 From eec9820acfb269178e8f8c8bdc2ecfb2d13ad5f4 Mon Sep 17 00:00:00 2001 From: bogumil_zebek Date: Mon, 11 Feb 2019 13:04:55 +0100 Subject: [PATCH 05/16] Add tests to Inventory module Change-Id: I9a6b1749f80f8d4a4e28291e7f028bd7f864c86a Issue-ID: AAI-2143 Signed-off-by: Zebek Bogumil --- src/app/inventory/InventoryActions.js | 14 +- src/app/inventory/InventoryReducer.js | 4 - test/app/inventory/Inventory.test.js | 30 ++++ test/app/inventory/InventoryActions.test.js | 219 ++++++++++++++++++++++++++++ test/app/inventory/InventoryReducer.test.js | 186 +++++++++++++++++++++++ 5 files changed, 440 insertions(+), 13 deletions(-) create mode 100644 test/app/inventory/Inventory.test.js create mode 100644 test/app/inventory/InventoryActions.test.js create mode 100644 test/app/inventory/InventoryReducer.test.js diff --git a/src/app/inventory/InventoryActions.js b/src/app/inventory/InventoryActions.js index 66e9339..7454c08 100644 --- a/src/app/inventory/InventoryActions.js +++ b/src/app/inventory/InventoryActions.js @@ -111,8 +111,7 @@ function getCountByDateQueryURL() { } export function onLoadTotalCountByDate() { - return function (dispatch) { - fetch(getCountByDateQueryURL(), { + return dispatch => fetch(getCountByDateQueryURL(), { credentials: SAME_ORIGIN, method: GET, headers: POST_HEADER @@ -124,12 +123,11 @@ export function onLoadTotalCountByDate() { ).catch( () => dispatch(getFailedCountByDateQueryEvent()) ); - }; + } export function onCountByTypeLoad() { - return function (dispatch) { - fetch(getCountByTypeQueryURL(), { + return dispatch => fetch(getCountByTypeQueryURL(), { credentials: SAME_ORIGIN, method: GET, headers: POST_HEADER @@ -141,12 +139,11 @@ export function onCountByTypeLoad() { ).catch( () => dispatch(getFailedCountByTypeQueryEvent()) ); - }; + } export function onTopographicMapMounted(requestObject) { - return function (dispatch) { - fetch(getDynamicTopographicQueryURL(requestObject.entityType), { + return dispatch => fetch(getDynamicTopographicQueryURL(requestObject.entityType), { credentials: SAME_ORIGIN, method: GET, headers: POST_HEADER @@ -160,6 +157,5 @@ export function onTopographicMapMounted(requestObject) { dispatch(getFailedTopographicVisualizationQueryEvent()); } ); - }; } diff --git a/src/app/inventory/InventoryReducer.js b/src/app/inventory/InventoryReducer.js index c42fc97..6ae3a5f 100644 --- a/src/app/inventory/InventoryReducer.js +++ b/src/app/inventory/InventoryReducer.js @@ -28,21 +28,18 @@ export default(state = {}, action) => { ...state, mapPlotPoints: action.data.plotPoints }; - break; case InventoryActionTypes.COUNT_BY_ENTITY_SUCCESS: return { ...state, countByType: action.data.countByType }; - break; case InventoryActionTypes.COUNT_BY_DATE_SUCCESS: return { ...state, countByDate: action.data.countByDate }; - break; case InventoryActionTypes.TOPOGRAPHIC_QUERY_FAILED: case InventoryActionTypes.COUNT_BY_ENTITY_FAILED: @@ -52,7 +49,6 @@ export default(state = {}, action) => { feedbackMsgSeverity: action.data.severity, feedbackMsgText: action.data.message }; - break; default: break; diff --git a/test/app/inventory/Inventory.test.js b/test/app/inventory/Inventory.test.js new file mode 100644 index 0000000..45b3450 --- /dev/null +++ b/test/app/inventory/Inventory.test.js @@ -0,0 +1,30 @@ +import React from 'react'; +import thunk from 'redux-thunk'; + +import configureMockStore from 'redux-mock-store'; +import expect from 'expect'; + +import Inventory from 'app/inventory/Inventory'; +import {shallow} from 'enzyme'; + + +const mockStore = configureMockStore([thunk]); +const store = mockStore({inventoryReducer: {}}); + +describe('Inventory component', () => { + + fetch = require('jest-fetch-mock'); + + it('should be rendered', () => { + + // when + let wrapper = shallow( + + ); + + // then + let actual = wrapper.render().text(); + expect(actual).toInclude('Active Inventory'); + }); + +}); diff --git a/test/app/inventory/InventoryActions.test.js b/test/app/inventory/InventoryActions.test.js new file mode 100644 index 0000000..9efe54d --- /dev/null +++ b/test/app/inventory/InventoryActions.test.js @@ -0,0 +1,219 @@ +import configureMockStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; +import fetchMock from 'fetch-mock'; +import expect from 'expect'; + +import {onLoadTotalCountByDate, onCountByTypeLoad, onTopographicMapMounted} from 'app/inventory/InventoryActions'; +import {InventoryActionTypes} from 'app/inventory/InventoryConstants'; + + +const middlewares = [thunk]; +const mockStore = configureMockStore(middlewares); + + +function mockRequestToEntityCountHistoryEndpoint(postfix, response) { + fetchMock.getOnce( + `http://localhost:/rest/visualization${postfix}`, + response + ); +} + +describe('InventoryActions', () => { + + afterEach(() => { + fetchMock.restore() + }); + + describe('verify onLoadTotalCountByDate', () => { + it('creates COUNT_BY_DATE_SUCCESS response when there is no error', async () => { + + // given + mockRequestToEntityCountHistoryEndpoint("/entityCountHistory?type=graph",{ + status: 200, + body: { + "result": { + "keyA": "valueA", + "keyB": "valueB" + } + } + }); + + const expectedActions = [ + { + type: InventoryActionTypes.COUNT_BY_DATE_SUCCESS, + data: { + countByDate: { + "keyA": "valueA", + "keyB": "valueB" + } + } + }]; + + const store = mockStore(); + + // when + await store.dispatch(onLoadTotalCountByDate()); + + // then + expect(store.getActions()).toEqual(expectedActions); + }); + + + it('creates COUNT_BY_DATE_FAILED response when there is a problem with remote service', async () => { + + // given + mockRequestToEntityCountHistoryEndpoint("/entityCountHistory?type=graph",{ + status: 500 + }); + + const expectedActions = [ + { + type: InventoryActionTypes.COUNT_BY_DATE_FAILED, + data: { + message: 'Error fetching data from server', + severity: 'danger' + } + }]; + + const store = mockStore(); + + // when + await store.dispatch(onLoadTotalCountByDate()); + + // then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + + + describe('verify onCountByTypeLoad', () => { + it('creates COUNT_BY_ENTITY_SUCCESS response when there is no error', async () => { + + // given + mockRequestToEntityCountHistoryEndpoint("/entityCountHistory?type=table",{ + status: 200, + body: { + "result": { + "keyA": "valueA", + "keyB": "valueB" + } + } + }); + + const expectedActions = [ + { + type: InventoryActionTypes.COUNT_BY_ENTITY_SUCCESS, + data: { + countByType: { + "keyA": "valueA", + "keyB": "valueB" + } + } + }]; + + const store = mockStore(); + + // when + await store.dispatch(onCountByTypeLoad()); + + // then + expect(store.getActions()).toEqual(expectedActions); + }); + + + it('creates COUNT_BY_ENTITY_FAILED response when there is a problem with remote service', async () => { + + // given + mockRequestToEntityCountHistoryEndpoint("/entityCountHistory?type=table",{ + status: 500 + }); + + const expectedActions = [ + { + type: InventoryActionTypes.COUNT_BY_ENTITY_FAILED, + data: { + message: 'Error fetching data from server', + severity: 'danger' + } + }]; + + const store = mockStore(); + + // when + await store.dispatch(onCountByTypeLoad()); + + // then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + + + describe('verify onTopographicMapMounted', () => { + it('creates TOPOGRAPHIC_QUERY_SUCCESS response when there is no error', async () => { + + // given + const requestObject = { + entityType: "entityType" + }; + mockRequestToEntityCountHistoryEndpoint("/geovisualization/?entity=entityType",{ + status: 200, + body: { + "plotPoints": { + "keyA": "valueA", + "keyB": "valueB" + } + } + }); + + const expectedActions = [ + { + type: InventoryActionTypes.TOPOGRAPHIC_QUERY_SUCCESS, + data: { + plotPoints: { + "keyA": "valueA", + "keyB": "valueB" + } + } + }]; + + const store = mockStore(); + + // when + await store.dispatch(onTopographicMapMounted(requestObject)); + + // then + expect(store.getActions()).toEqual(expectedActions); + }); + + + it('creates TOPOGRAPHIC_QUERY_FAILED response when there is a problem with remote service', async () => { + + // given + const requestObject = { + entityType: "entityType" + }; + mockRequestToEntityCountHistoryEndpoint("/geovisualization/?entity=entityType",{ + status: 500 + }); + + const expectedActions = [ + { + type: InventoryActionTypes.TOPOGRAPHIC_QUERY_FAILED, + data: { + message: 'Error fetching data from server', + severity: 'danger' + } + }]; + + const store = mockStore(); + + // when + await store.dispatch(onTopographicMapMounted(requestObject)); + + // then + expect(store.getActions()).toEqual(expectedActions); + }); + }); +}); diff --git a/test/app/inventory/InventoryReducer.test.js b/test/app/inventory/InventoryReducer.test.js new file mode 100644 index 0000000..49f8e58 --- /dev/null +++ b/test/app/inventory/InventoryReducer.test.js @@ -0,0 +1,186 @@ +import fetchMock from 'fetch-mock'; +import expect from 'expect'; +import {InventoryActionTypes} from "app/inventory/InventoryConstants"; +import reducer from 'app/inventory/InventoryReducer'; + + + +function verifyStateProducedByReducer(action, currentState, expectedState) { + // when + const actual = reducer(currentState, action); + + // then + expect(actual).toEqual(expectedState); +} + +describe('InventoryReducer', () => { + + afterEach(() => { + fetchMock.restore() + }); + + it('verify store state after TOPOGRAPHIC_QUERY_SUCCESS action', async () => { + + // given + const action = { + type: InventoryActionTypes.TOPOGRAPHIC_QUERY_SUCCESS, + data: { + "plotPoints": { + "keyA": "valueA", + "keyB": "valueB" + } + } + }; + + const expectedState = { + state: "dummy", + mapPlotPoints: { + "keyA": "valueA", + "keyB": "valueB" + } + }; + + + const currentState = {state: "dummy"}; + + verifyStateProducedByReducer(action, currentState, expectedState); + + }); + + it('verify store state after COUNT_BY_ENTITY_SUCCESS action', async () => { + + // given + const action = { + type: InventoryActionTypes.COUNT_BY_ENTITY_SUCCESS, + data: { + "countByType": { + "keyA": "valueA", + "keyB": "valueB" + } + } + }; + + const expectedState = { + state: "dummy", + countByType: { + "keyA": "valueA", + "keyB": "valueB" + } + }; + + const currentState = {state: "dummy"}; + + verifyStateProducedByReducer(action, currentState, expectedState); + }); + + + it('verify store state after COUNT_BY_DATE_SUCCESS action', async () => { + + // given + const action = { + type: InventoryActionTypes.COUNT_BY_DATE_SUCCESS, + data: { + "countByDate": { + "keyA": "valueA", + "keyB": "valueB" + } + } + }; + + const expectedState = { + state: "dummy", + countByDate: { + "keyA": "valueA", + "keyB": "valueB" + } + }; + + const currentState = {state: "dummy"}; + + verifyStateProducedByReducer(action, currentState, expectedState); + }); + + it('verify store state after TOPOGRAPHIC_QUERY_FAILED action', async () => { + + // given + const action = { + type: InventoryActionTypes.TOPOGRAPHIC_QUERY_FAILED, + data: { + severity: "ERROR", + message: "Some error occurred" + } + }; + + const expectedState = { + state: "dummy", + feedbackMsgSeverity: "ERROR", + feedbackMsgText: "Some error occurred" + + }; + + const currentState = {state: "dummy"}; + + verifyStateProducedByReducer(action, currentState, expectedState); + }); + + it('verify store state after COUNT_BY_ENTITY_FAILED action', async () => { + + // given + const action = { + type: InventoryActionTypes.COUNT_BY_ENTITY_FAILED, + data: { + severity: "ERROR", + message: "Some error occurred" + } + }; + + const expectedState = { + state: "dummy", + feedbackMsgSeverity: "ERROR", + feedbackMsgText: "Some error occurred" + + }; + + const currentState = {state: "dummy"}; + + verifyStateProducedByReducer(action, currentState, expectedState); + }); + + it('verify store state after COUNT_BY_DATE_FAILED action', async () => { + + // given + const action = { + type: InventoryActionTypes.COUNT_BY_DATE_FAILED, + data: { + severity: "ERROR", + message: "Some error occurred" + } + }; + + const expectedState = { + state: "dummy", + feedbackMsgSeverity: "ERROR", + feedbackMsgText: "Some error occurred" + + }; + + const currentState = {state: "dummy"}; + + verifyStateProducedByReducer(action, currentState, expectedState); + }); + + it('verify store state after unknown action', async () => { + + // given + const action = { + type: 'unknown', + }; + + const expectedState = {state: "dummy"}; + + const currentState = {state: "dummy"}; + + verifyStateProducedByReducer(action, currentState, expectedState); + }); + +}); -- 2.16.6 From 5b062c1f5005e14b6f18563ee875a06f5c1bc299 Mon Sep 17 00:00:00 2001 From: andrzejszukuc Date: Thu, 14 Mar 2019 12:28:39 +0100 Subject: [PATCH 06/16] Add tests for TopographicMap Change-Id: Ifaac36ba87862dfc09837a6f18b50092ef43ad25 Issue-ID: AAI-2143 Signed-off-by: Andrzej Szukuc --- test/generic-components/map/TopographicMap.test.js | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 test/generic-components/map/TopographicMap.test.js diff --git a/test/generic-components/map/TopographicMap.test.js b/test/generic-components/map/TopographicMap.test.js new file mode 100644 index 0000000..b393f4e --- /dev/null +++ b/test/generic-components/map/TopographicMap.test.js @@ -0,0 +1,88 @@ +import TopographicMap from 'generic-components/map/TopographicMap' +import {PROJECTION_TYPES} from "generic-components/map/MapConstants.js" +import React from 'react'; +import {shallow, mount} from 'enzyme' + +describe('Utility methods tests', () => { + const sut = shallow().instance(); + + describe('areArraysEqual tests', () => { + it('Empty arrays should be equal', () => { + expect(sut.areArraysEqual([], [])).toBe(true); + }); + + it('Nested empty arrays should be equal', () => { + expect(sut.areArraysEqual([[]], [[]])).toBe(true); + expect(sut.areArraysEqual([[],[]], [[],[]])).toBe(true); + }); + + it('A nested empty array should not be equal to an empty array', () => { + expect(sut.areArraysEqual([[]], [])).toBe(false); + }); + + it('Should not coerce elements', () => { + expect(sut.areArraysEqual([undefined], [null])).toBe(false); + expect(sut.areArraysEqual([['x']],['x'])).toBe(true); + expect(sut.areArraysEqual([['xx']],['xx'])).toBe(false); + expect(sut.areArraysEqual([true], ["true"])).toBe(false); + expect(sut.areArraysEqual([1], ["1"])).toBe(false); + }); + }); + + describe('extractNestedObjectInJson tests', () => { + it('Should return an empty object from an empty object', () => { + expect(sut.extractNestedObjectInJson({},['a'])).toBeUndefined(); + expect(sut.extractNestedObjectInJson({},['a', 'b'])).toBeUndefined(); + }); + + it('Should extract a nested element', () => { + const value = "Foo"; + expect(sut.extractNestedObjectInJson({a:{b: value}},['a', 'b'])).toBe(value); + }); + }); +}); + +describe('TopographicMap integration tests', () => { + const svgTag = 'svg'; + const circleTag = 'circle'; + + const worldBounds = [ + {longtitude: 28.70, latitude: -127.50}, + {longtitude: 48.85, latitude: -55.90}]; + + const outsideUSA = [{longitude: 19.145136, latitude: 51.919438}]; + const insideUSA = [ + {longitude:-122.4196396, latitude:37.7771187}, + {longitude:-122.4196396, latitude:37.6771187}, + {longitude:-122.4196396, latitude:37.5771187}, + {longitude:-122.4196396, latitude:37.4771187}]; + + describe('AlbertsUSA projection tests', () => { + it('Points outside USA should not be supported', () => { + expect(() => mount()).toThrow(); + expect(() => mount()).toThrow(); + expect(() => mount()).toThrow(); + }); + + it('Should generate n points on a map', () => { + const sut = mount(); + expect(sut.find(svgTag).find(circleTag).length).toBe(insideUSA.length); + }); + }); + + describe('Equirectangular projection tests', () => { + function createEquirectangularProjection(points) { + return mount(); + } + + it('Should display points', () => { + const sutInsideUSA = createEquirectangularProjection(insideUSA); + const sutOutsideUSA = createEquirectangularProjection(outsideUSA); + const sutMixed = createEquirectangularProjection(insideUSA.concat(outsideUSA)); + + expect(sutInsideUSA.find(svgTag).find(circleTag).length).toBe(insideUSA.length); + expect(sutOutsideUSA.find(svgTag).find(circleTag).length).toBe(outsideUSA.length); + expect(sutMixed.find(svgTag).find(circleTag).length).toBe(insideUSA.length + outsideUSA.length); + }); + }); +}); -- 2.16.6 From b0f2f345cc2d1cc3812ad8a06fc1898daf5842d0 Mon Sep 17 00:00:00 2001 From: Adam Wudzinski Date: Tue, 26 Mar 2019 16:47:06 +0100 Subject: [PATCH 07/16] Remove unused code Remove unsed code from generic-components and change tests directory structure to reflect src structure Change-Id: Iada2efb0f7cfb05557eb7cd709b8a0ed75976b03 Issue-ID: AAI-1618 Signed-off-by: awudzins --- resources/scss/_components.scss | 3 - .../componentManager/ComponentManager.jsx | 306 --------------------- .../componentManager/ComponentManagerConstants.js | 28 -- .../componentManager/ComponentManagerContainer.jsx | 111 -------- .../confirmations/ConfirmationModalView.jsx | 76 ----- .../dynamicViewLoader/DynamicViewLoaderActions.js | 33 --- .../DynamicViewLoaderConstants.js | 27 -- .../dynamicViewLoader/DynamicViewLoaderReducer.js | 37 --- .../dynamicViewLoader/dynamicViewLoader.jsx | 94 ------- src/generic-components/graph/SVGShape.jsx | 61 ---- src/generic-components/input/SelectInput.jsx | 77 ------ src/generic-components/input/ToggleInput.jsx | 76 ----- .../input/inputOptions/InputOptions.jsx | 241 ---------------- .../notifications/NotificationConstants.js | 29 -- .../notifications/NotificationModal.jsx | 121 -------- .../notifications/NotificationReducer.js | 48 ---- src/generic-components/panel/SlidePanel.jsx | 137 --------- .../toggleButtonGroup/ToggleButtonGroup.jsx | 76 ----- .../toggleButtonGroup/ToggleButtonGroupActions.js | 27 -- .../ToggleButtonGroupConstants.js | 26 -- .../toggleButtonGroup/ToggleButtonGroupReducer.js | 34 --- src/generic-components/treeNode/TreeNode.jsx | 74 ----- test/{ => app}/MainScreenWrapperReducer.test.js | 0 .../ConfigurableViewActions.test.js | 0 .../ConfigurableViewReducer.test.js | 0 .../GlobalAutoCompleteSearchBar.test.js | 0 .../GlobalAutoCompleteSearchBarReducer.test.js | 0 .../GlobalInlineMessageBar.test.js | 0 .../GlobalInlineMessageBarAction.test.js | 0 .../GlobalInlineMessageBarReducer.test.js | 0 test/{ => app}/networking/NetworkCalls.test.js | 0 test/{ => app}/networking/NetworkUtil.test.js | 0 .../tierSupport/SelectedNodeDetails.test.js | 0 .../tierSupport/SelectedNodeDetailsReducer.test.js | 0 .../tierSupport/TierSupportActions.test.js | 0 .../tierSupport/TierSupportReducer.test.js | 0 test/{ => app}/vnfSearch/VnfSearch.test.js | 0 test/{ => app}/vnfSearch/VnfSearchActions.test.js | 0 .../vnfSearch/VnfSearchNfRoleVisualization.test.js | 0 .../vnfSearch/VnfSearchNfTypeVisualization.test.js | 0 ...nfSearchOrchestratedStatusVisualization.test.js | 0 .../VnfSearchProvStatusVisualization.test.js | 0 test/{ => app}/vnfSearch/VnfSearchReducer.test.js | 0 .../VnfSearchTotalCountVisualization.test.js | 0 .../AutoCompleteSearchBar.test.js | 0 .../notifications/NotificationReducer.test.js | 197 ------------- test/generic-components/treeNode/TreeNode.test.js | 41 --- test/input/SelectInput.test.js | 13 - test/input/ToggleInput.test.js | 12 - 49 files changed, 2005 deletions(-) delete mode 100644 src/generic-components/componentManager/ComponentManager.jsx delete mode 100644 src/generic-components/componentManager/ComponentManagerConstants.js delete mode 100644 src/generic-components/componentManager/ComponentManagerContainer.jsx delete mode 100644 src/generic-components/confirmations/ConfirmationModalView.jsx delete mode 100644 src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js delete mode 100644 src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js delete mode 100644 src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js delete mode 100644 src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx delete mode 100644 src/generic-components/graph/SVGShape.jsx delete mode 100644 src/generic-components/input/SelectInput.jsx delete mode 100644 src/generic-components/input/ToggleInput.jsx delete mode 100644 src/generic-components/input/inputOptions/InputOptions.jsx delete mode 100644 src/generic-components/notifications/NotificationConstants.js delete mode 100644 src/generic-components/notifications/NotificationModal.jsx delete mode 100644 src/generic-components/notifications/NotificationReducer.js delete mode 100644 src/generic-components/panel/SlidePanel.jsx delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js delete mode 100644 src/generic-components/treeNode/TreeNode.jsx rename test/{ => app}/MainScreenWrapperReducer.test.js (100%) rename test/{ => app}/configurableViews/ConfigurableViewActions.test.js (100%) rename test/{ => app}/configurableViews/ConfigurableViewReducer.test.js (100%) rename test/{ => app}/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js (100%) rename test/{ => app}/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js (100%) rename test/{ => app}/globalInlineMessageBar/GlobalInlineMessageBar.test.js (100%) rename test/{ => app}/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js (100%) rename test/{ => app}/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js (100%) rename test/{ => app}/networking/NetworkCalls.test.js (100%) rename test/{ => app}/networking/NetworkUtil.test.js (100%) rename test/{ => app}/tierSupport/SelectedNodeDetails.test.js (100%) rename test/{ => app}/tierSupport/SelectedNodeDetailsReducer.test.js (100%) rename test/{ => app}/tierSupport/TierSupportActions.test.js (100%) rename test/{ => app}/tierSupport/TierSupportReducer.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearch.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearchActions.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearchNfRoleVisualization.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearchNfTypeVisualization.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearchProvStatusVisualization.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearchReducer.test.js (100%) rename test/{ => app}/vnfSearch/VnfSearchTotalCountVisualization.test.js (100%) rename test/{ => generic-components}/autoCompleteSearchBar/AutoCompleteSearchBar.test.js (100%) delete mode 100644 test/generic-components/notifications/NotificationReducer.test.js delete mode 100644 test/generic-components/treeNode/TreeNode.test.js delete mode 100644 test/input/SelectInput.test.js delete mode 100644 test/input/ToggleInput.test.js diff --git a/resources/scss/_components.scss b/resources/scss/_components.scss index ca926f0..2f696cc 100644 --- a/resources/scss/_components.scss +++ b/resources/scss/_components.scss @@ -20,12 +20,9 @@ */ @import "components/validationForm"; -@import "components/slidePanel"; -@import "components/toggleInput"; @import "components/notifications"; @import "components/dropdownMultiSelect"; @import "components/inlineMessage"; -@import "components/toggleButtonGroup"; @import "components/titledComponent"; @import "components/containerPanel"; @import "components/filterBar"; diff --git a/src/generic-components/componentManager/ComponentManager.jsx b/src/generic-components/componentManager/ComponentManager.jsx deleted file mode 100644 index 7b94279..0000000 --- a/src/generic-components/componentManager/ComponentManager.jsx +++ /dev/null @@ -1,306 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; - -import ComponentManagerContainer from - 'generic-components/componentManager/ComponentManagerContainer.jsx'; -import { - MIN_PANEL_WIDTH, - MIN_PANEL_HEIGHT, - MAX_PANEL_WIDTH, - EDIT_ICON, - LAYOUT_STATIC -} from 'generic-components/componentManager/ComponentManagerConstants.js'; - -var widthProvider = require('react-grid-layout').WidthProvider; -var ReactGridLayout = require('react-grid-layout'); -ReactGridLayout = widthProvider(ReactGridLayout); - -export default class ComponentManager extends Component { - constructor(props) { - super(props); - - if (props.layoutType === LAYOUT_STATIC && - Object.keys(props.layoutFormat).length > 0) { - this.state = { - layout: props.layoutFormat.layout, - panels: props.layoutFormat.panels, - containers: props.layoutFormat.containers - }; - } else { - this.state = { - layout: [], - panels: [], - containers: [] - }; - } - this.onLayoutChange = this.onLayoutChange.bind(this); - } - - createContainer( - containerId, xPos, yPos, width, height, staticLayout = false) { - if (staticLayout) { - return { - id: containerId, - properties: { - x: xPos, - y: yPos, - w: width, - h: height, - isDraggable: false, - isResizable: false - } - }; - } else { - return { - id: containerId, - properties: { - x: xPos, - y: yPos, - w: width, - h: height, - minW: MIN_PANEL_WIDTH, - maxW: MAX_PANEL_WIDTH, - minH: MIN_PANEL_HEIGHT - } - }; - } - } - - createPanel(id, title, panelSource, panelProps, actionList) { - return { - id: id, - title: title, - source: panelSource, - props: panelProps, - actions: actionList - }; - } - - addNewComponent(compProps, containingContainerId) { - let containerId = containingContainerId; - let actionsList = []; - - if (typeof containerId === 'undefined' || containerId === null) { - // new component being added isn't associated with a - // container yet, so create one - containerId = 'container:' + (new Date).getTime(); - let updatedContainerProps = []; - this.state.containers.forEach((containerProps) => { - updatedContainerProps.push(containerProps); - }); - updatedContainerProps.push( - this.createContainer(containerId, 0, Infinity, 12, 2)); - this.setState({containers: updatedContainerProps}); - - actionsList = [ - { - type: 'close', id: containerId, callback: () => { - this.removeExistingComponent(containerId); - } - } - ]; - } else { - // we are updating a static container with a new panel, add the edit - // action so it can be updated moving forward - actionsList = [ - { - type: 'custom', - id: containingContainerId, - icon: EDIT_ICON, - callback: () => { - this.props.addPanelCallback(containingContainerId); - } - } - ]; - } - - let updatedPanelProps = []; - this.state.panels.forEach((panelProp) => { - if (panelProp.id !== containingContainerId) { - // add all existing panels except the one with a - // matching id (this is an edit scenario, will replace - // with new panel below - updatedPanelProps.push(panelProp); - } - }); - updatedPanelProps.push( - this.createPanel( - containerId, - compProps.title, - compProps.visualizationSource, - compProps.visualizationProps, - actionsList)); - this.setState({panels: updatedPanelProps}); - } - - removeExistingComponent(id) { - let updatedPanelProps = this.state.panels.filter((panelProp) => { - return id !== panelProp.id; - }); - this.setState({panels: updatedPanelProps}); - - let updatedContainerProps = this.state.containers.filter( - (containerProp) => { - return id !== containerProp.id; - }); - this.setState({containers: updatedContainerProps}); - } - - getLayoutProperties() { - return { - layout: this.state.layout, - containers: this.state.containers, - panels: this.state.panels - }; - } - - setLayoutProperties(layoutProperties) { - this.setState({ - layout: layoutProperties.layout, - containers: layoutProperties.containers, - panels: layoutProperties.panels - }); - } - - fetchMatchingPanel(containerId) { - let actionsList = []; - let matchingPanel = ( - - {'Please select a visualization'} - - ); - this.state.panels.forEach((panel) => { - if (panel.id === containerId) { - let GeneratedComponent = - this.props.componentPropertiesProvider[panel.source].component.class; - let visProps = panel.props; - matchingPanel = ( - - - - ); - } - }); - return matchingPanel; - } - - preparedContainers() { - let containersToRender = []; - - this.state.containers.forEach((container) => { - let matchingPanel = this.fetchMatchingPanel(container.id); - - containersToRender.push(
- {matchingPanel} -
); - }); - - return containersToRender; - } - - onLayoutChange(layout) { - this.setState({layout: layout}); - this.props.onLayoutChange(layout); - } - - buildStaticContainers(layoutFormat) { - let staticContainers = []; - let nextRowIndex = 0; - - layoutFormat.layout.forEach((row) => { - let nextColIndex = 0; - let currentTallestContainer = 0; - - row.forEach((col) => { - let containerId = 'container:' + nextRowIndex + '-' + nextColIndex; - let xPos = nextColIndex; - let yPos = nextRowIndex; - let width = 12 * col.width; - let height = col.height; - - nextColIndex = nextColIndex + width; - currentTallestContainer = Math.max(currentTallestContainer, col.height); - - staticContainers.push( - this.createContainer( - containerId, - xPos, - yPos, - width, - height, - true - ) - ); - }); - - nextRowIndex = currentTallestContainer; - }); - - return staticContainers; - } - - componentWillReceiveProps(nextProps) { - if (nextProps.layoutFormat !== this.props.layoutFormat) { - // layout format being passed in are the containers, panels and layout - // for the newly view - this.setState({ - layout: nextProps.layoutFormat.layout, - panels: nextProps.layoutFormat.panels, - containers: nextProps.layoutFormat.containers - }); - } - } - - render() { - - return ( -
- - {this.preparedContainers()} - -
- ); - } -} -ComponentManager.defaultProps = { - cols: 12, - rewHeight: 100, - onLayoutChange: function () { - }, - showHeader: true, - showTitle: true, - showBorder: true -}; diff --git a/src/generic-components/componentManager/ComponentManagerConstants.js b/src/generic-components/componentManager/ComponentManagerConstants.js deleted file mode 100644 index c2f5616..0000000 --- a/src/generic-components/componentManager/ComponentManagerConstants.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -export const MIN_PANEL_WIDTH = 1; -export const MIN_PANEL_HEIGHT = 1; -export const MAX_PANEL_WIDTH = 12; - -export const EDIT_ICON = 'fa-pencil'; - -export const LAYOUT_STATIC = 'static'; -export const LAYOUT_DYNAMIC = 'dynamic'; diff --git a/src/generic-components/componentManager/ComponentManagerContainer.jsx b/src/generic-components/componentManager/ComponentManagerContainer.jsx deleted file mode 100644 index cd51d37..0000000 --- a/src/generic-components/componentManager/ComponentManagerContainer.jsx +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import ButtonGroup from 'react-bootstrap/lib/ButtonGroup'; -import Button from 'react-bootstrap/lib/Button'; - -import i18n from 'utils/i18n/i18n'; - -const ICON_CLASS_CLOSE = 'fa fa-times'; - -export default class ComponentManagerContainer extends Component { - - static propType = { - id: PropTypes.string, - title: PropTypes.string, - actions: PropTypes.array, - showHeader: PropTypes.bool, - showTitle: PropTypes.bool, - showBorder: PropTypes.bool, - }; - - static defaultProps = { - id: '', - title: 'Some Title', - actions: [], - showHeader: true, - showTitle: true, - showBorder: true - }; - - constructor(props) { - super(props); - } - - render() { - let { - title, - actions, - children, - showHeader, - showTitle, - showBorder - } = this.props; - let buttons = []; - actions.forEach((action) => { - switch (action.type) { - case 'close': - buttons.push( - - ); - break; - case 'custom': - buttons.push( - - ); - break; - } - }); - - let containerClass = showBorder - ? 'titled-container titled-container-boarders' - : 'titled-container'; - let headerClass = showHeader ? 'titled-container-header' : 'hidden'; - let titleClass = showTitle ? '' : 'hidden'; - - return ( -
- {buttons} -
- {i18n(title)} -
-
- {children} -
-
- ); - } -} diff --git a/src/generic-components/confirmations/ConfirmationModalView.jsx b/src/generic-components/confirmations/ConfirmationModalView.jsx deleted file mode 100644 index 39fea97..0000000 --- a/src/generic-components/confirmations/ConfirmationModalView.jsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React from 'react'; -import { PropTypes } from 'prop-types'; -import Button from 'react-bootstrap/lib/Button.js'; - -import i18n from 'utils/i18n/i18n.js'; -import Modal from 'generic-components/modal/Modal.jsx'; - -let typeClass = { - 'default': 'primary', - error: 'danger', - warning: 'warning', - success: 'success' -}; - - -class ConfirmationModalView extends React.Component { - - static propTypes = { - show: PropTypes.bool, - type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), - msg: PropTypes.node, - title: PropTypes.string, - confirmationDetails: PropTypes.object - }; - - static defaultProps = { - show: false, - type: 'warning', - title: 'Warning', - msg: '' - }; - - render() { - let {title, type, msg, show} = this.props; - - return ( - - - {title} - - {msg} - - - - - - ); - }; -} - -export default ConfirmationModalView; diff --git a/src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js b/src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js deleted file mode 100644 index 1d6a401..0000000 --- a/src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import { - dynamicViewLoaderActionTypes -} - from 'generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js'; - -export function processLayoutSourceChange(layoutSource) { - return { - type: dynamicViewLoaderActionTypes.DVL_LAYOUT_SOURCE_CHANGE, - data: { - layoutSource: layoutSource - } - }; -} diff --git a/src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js b/src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js deleted file mode 100644 index 2afe167..0000000 --- a/src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import keyMirror from 'utils/KeyMirror.js'; - -export const dynamicViewLoaderActionTypes = keyMirror({ - DVL_LAYOUT_SOURCE_CHANGE: null -}); - -export const DYNAMIC_VIEW_LOADER_TITLE = 'Dynamic View'; diff --git a/src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js b/src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js deleted file mode 100644 index 390856a..0000000 --- a/src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import {combineReducers} from 'redux'; - -import {dynamicViewLoaderActionTypes} from 'generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js'; - -export default combineReducers({ - dynamicViewLoadData: (state = {}, action) => { - switch (action.type) { - case dynamicViewLoaderActionTypes.DVL_LAYOUT_SOURCE_CHANGE: - return { - ...state, - layoutSource: action.data.layoutSource - }; - } - - return state; - } -}); diff --git a/src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx b/src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx deleted file mode 100644 index 7732951..0000000 --- a/src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx +++ /dev/null @@ -1,94 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import {connect} from 'react-redux'; - -import DateRangeSelector from 'generic-components/dateRangeSelector/DateRangeSelector.jsx'; -import ComponentManager from 'generic-components/componentManager/ComponentManager.jsx'; -import {DYNAMIC_VIEW_LOADER_TITLE} from 'generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js'; -import {processLayoutSourceChange} from 'generic-components/dynamicViewLoader/DynamicViewLoaderActions.js'; -import {visualizationProviderProperties} from 'generic-components/dynamicViewLoader/VisualizationProvider.js'; -import {LAYOUT_STATIC} from 'generic-components/componentManager/ComponentManagerConstants.js'; - -import i18n from 'utils/i18n/i18n'; -import customViews from 'resources/views/customViews.json'; - -const mapStateToProps = - ({dynamicViewReducer: {dynamicViewLoadData}}) => { - let { - viewTitle = i18n(DYNAMIC_VIEW_LOADER_TITLE), - layoutSource = {} - } = dynamicViewLoadData; - - return { - viewTitle, - layoutSource - }; - }; - -let mapActionToProps = (dispatch) => { - return { - onLayoutSourceChange: (layoutSource) => { - dispatch(processLayoutSourceChange(layoutSource)); - } - }; -}; - -class DynamicViewLoader extends Component { - static propTypes = { - viewTitle: PropTypes.string, - layoutSource: PropTypes.object - }; - - componentWillMount() { - let viewName = this.props.location.pathname.split('/'); - - for (let view in customViews) { - if (customViews[view]['viewName'] === viewName[1]) { - this.props.onLayoutSourceChange(customViews[view]['layoutProperties']); - } - } - } - - render() { - let {viewTitle, layoutSource} = this.props; - - return ( -
-
- - {viewTitle} - - -
- -
- ); - } -} -export default connect(mapStateToProps, mapActionToProps)(DynamicViewLoader); diff --git a/src/generic-components/graph/SVGShape.jsx b/src/generic-components/graph/SVGShape.jsx deleted file mode 100644 index 8b33598..0000000 --- a/src/generic-components/graph/SVGShape.jsx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import NodeVisualElementConstants from './NodeVisualElementConstants'; - -class SVGShape extends Component { - - static propTypes = { - shapeType: PropTypes.string.isRequired, - shapeAttributes: PropTypes.object.isRequired, - shapeClass: PropTypes.object.isRequired, - textValue: PropTypes.string - }; - - static defaultProps = { - shapeType: '', - shapeAttributes: {}, - shapeClass: {}, - textValue: '' - }; - - render() { - let {shapeType, shapeAttributes, shapeClass, textValue} = this.props; - - switch (shapeType) { - case NodeVisualElementConstants.SVG_CIRCLE: - return ; - - case NodeVisualElementConstants.SVG_LINELINE: - return ; - - case NodeVisualElementConstants.TEXT: - return {textValue}; - - default: - return undefined; - } - } -} - -export default SVGShape; diff --git a/src/generic-components/input/SelectInput.jsx b/src/generic-components/input/SelectInput.jsx deleted file mode 100644 index dbe6a20..0000000 --- a/src/generic-components/input/SelectInput.jsx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -/** - * The HTML structure here is aligned with bootstrap HTML structure for form - * elements. In this way we have proper styling and it is aligned with other - * form elements on screen. - * - * Select and MultiSelect options: - * - * label - the label to be shown which paired with the input - * - * all other "react-select" props - as documented on - * http://jedwatson.github.io/react-select/ - * or - * https://github.com/JedWatson/react-select - */ -import React, {Component} from 'react'; -import Select from 'react-select'; -import 'react-select/dist/react-select.css'; - -class SelectInput extends Component { - - inputValue = []; - - render() { - let {label, value, ...other} = this.props; - return ( -
-
- {label && } - - -
-
- ); - } - - click = () => { - let value = !this.state.value; - this.setState({value}); - - let onChange = this.props.onChange; - if (onChange) { - onChange(value); - } - } - - getValue() { - return this.state.value; - } -} diff --git a/src/generic-components/input/inputOptions/InputOptions.jsx b/src/generic-components/input/inputOptions/InputOptions.jsx deleted file mode 100644 index bf17df1..0000000 --- a/src/generic-components/input/inputOptions/InputOptions.jsx +++ /dev/null @@ -1,241 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React from 'react'; -import { PropTypes } from 'prop-types'; -import i18n from 'utils/i18n/i18n.js'; -import classNames from 'classnames'; -import Select from 'generic-components/input/SelectInput.jsx'; - -export const other = {OTHER: 'Other'}; - -class InputOptions extends React.Component { - - static propTypes = { - values: PropTypes.arrayOf(PropTypes.shape({ - enum: PropTypes.string, - title: PropTypes.string - })), - isEnabledOther: PropTypes.bool, - title: PropTypes.string, - selectedValue: PropTypes.string, - multiSelectedEnum: PropTypes.array, - selectedEnum: PropTypes.string, - otherValue: PropTypes.string, - onEnumChange: PropTypes.func, - onOtherChange: PropTypes.func, - isRequired: PropTypes.bool, - isMultiSelect: PropTypes.bool - }; - - - static contextTypes = { - isReadOnlyMode: PropTypes.bool - }; - - state = { - otherInputDisabled: !this.props.otherValue - }; - - oldProps = { - selectedEnum: '', - otherValue: '', - multiSelectedEnum: [] - }; - - render() { - let {label, isRequired, values, otherValue, onOtherChange, isMultiSelect, onBlur, multiSelectedEnum, selectedEnum, hasError, validations, children} = this.props; - - let currentMultiSelectedEnum = []; - let currentSelectedEnum = ''; - let {otherInputDisabled} = this.state; - if (isMultiSelect) { - currentMultiSelectedEnum = multiSelectedEnum; - if (!otherInputDisabled) { - currentSelectedEnum = - multiSelectedEnum ? multiSelectedEnum.toString() : undefined; - } - } - else { - currentSelectedEnum = selectedEnum; - } - - let isReadOnlyMode = this.context.isReadOnlyMode; - - return ( -
- - {isMultiSelect && otherInputDisabled ? - onBlur()} - disabled={isReadOnlyMode || Boolean(this.props.disabled)} - onChange={ value => this.enumChanged(value)} - type='select'> - {values && - values.length && - values.map(val => this.renderOptions(val))} - {onOtherChange && } - {children} - - - {!otherInputDisabled &&
} - onBlur()} - onChange={() => this.changedOtherInput()}/> -
- } -
- ); - } - - renderOptions(val) { - return ( - - ); - } - - - renderMultiSelectOptions(values) { - let {onOtherChange} = this.props; - let optionsList = []; - if (onOtherChange) { - optionsList = values.map(option => { - return { - label: option.title, - value: option.enum, - }; - }).concat([{ - label: i18n(other.OTHER), - value: i18n(other.OTHER), - }]); - } - else { - optionsList = values.map(option => { - return { - label: option.title, - value: option.enum, - }; - }); - } - if (optionsList.length > 0 && optionsList[0].value === '') { - optionsList.shift(); - } - return optionsList; - } - - getValue() { - let res = ''; - let {isMultiSelect} = this.props; - let {otherInputDisabled} = this.state; - - if (otherInputDisabled) { - res = - isMultiSelect - ? this.refs._myInput.getValue() - : this.refs._myInput.value; - } else { - res = this.refs._otherValue.value; - } - return res; - } - - enumChanged() { - let enumValue = this.refs._myInput.value; - let {onEnumChange, isMultiSelect, onChange} = this.props; - this.setState({ - otherInputDisabled: enumValue !== other.OTHER - }); - if (onEnumChange) { - onEnumChange(isMultiSelect ? [enumValue] : enumValue); - } - - if (onChange) { - onChange(enumValue); - } - - } - - multiSelectEnumChanged(enumValue) { - let {onEnumChange} = this.props; - let selectedValues = enumValue.map(enumVal => { - return enumVal.value; - }); - - if (this.state.otherInputDisabled === false) { - selectedValues.shift(); - } - else if (selectedValues.includes(i18n(other.OTHER))) { - selectedValues = [i18n(other.OTHER)]; - } - - this.setState({ - otherInputDisabled: !selectedValues.includes(i18n(other.OTHER)) - }); - onEnumChange(selectedValues); - } - - changedOtherInput() { - let {onOtherChange} = this.props; - onOtherChange(this.refs._otherValue.value); - } - - componentDidUpdate() { - let {otherValue, selectedEnum, onInputChange, multiSelectedEnum} = this.props; - if (this.oldProps.otherValue !== otherValue - || this.oldProps.selectedEnum !== selectedEnum - || this.oldProps.multiSelectedEnum !== multiSelectedEnum) { - this.oldProps = { - otherValue, - selectedEnum, - multiSelectedEnum - }; - onInputChange(); - } - } - -} - -export default InputOptions; diff --git a/src/generic-components/notifications/NotificationConstants.js b/src/generic-components/notifications/NotificationConstants.js deleted file mode 100644 index 299ddaa..0000000 --- a/src/generic-components/notifications/NotificationConstants.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import keyMirror from 'utils/KeyMirror.js'; - -export default keyMirror({ - NOTIFY_ERROR: null, - NOTIFY_SUCCESS: null, - NOTIFY_WARNING: null, - NOTIFY_INFO: null, - NOTIFY_CLOSE: null -}); diff --git a/src/generic-components/notifications/NotificationModal.jsx b/src/generic-components/notifications/NotificationModal.jsx deleted file mode 100644 index 0e747d5..0000000 --- a/src/generic-components/notifications/NotificationModal.jsx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -/** - * NotificationModal options: - * - * show: whether to show notification or not, - * type: the type of the notification. valid values are: 'default', 'error', - * 'warning', 'success' msg: the notification content. could be a string or - * node (React component) title: the notification title timeout: timeout for - * the notification to fade out. if timeout == 0 then the notification is - * rendered until the user closes it - * - */ -import React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import {connect} from 'react-redux'; -import Button from 'react-bootstrap/lib/Button.js'; - -import i18n from 'utils/i18n/i18n.js'; -import Modal from 'generic-components/modal/Modal.jsx'; -import NotificationConstants from './NotificationConstants.js'; - -let typeClass = { - 'default': 'primary', - error: 'danger', - warning: 'warning', - success: 'success' -}; - -const mapActionsToProps = (dispatch) => { - return { - onCloseClick: () => dispatch({type: NotificationConstants.NOTIFY_CLOSE}) - }; -}; - -const mapStateToProps = ({notification}) => { - - let show = notification !== null && notification.title !== 'Conflict'; - let mapResult = {show}; - if (show) { - mapResult = {show, ...notification}; - } - - return mapResult; -}; - -class NotificationModal extends Component { - - static propTypes = { - show: PropTypes.bool, - type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), - msg: PropTypes.node, - title: PropTypes.string, - timeout: PropTypes.number - }; - - static defaultProps = { - show: false, - type: 'default', - title: '', - msg: '', - timeout: 0 - }; - - state = {type: undefined}; - - componentWillReceiveProps(nextProps) { - if (this.props.show !== nextProps.show && nextProps.show === false) { - this.setState({type: this.props.type}); - } - else { - this.setState({type: undefined}); - } - } - - componentDidUpdate() { - if (this.props.timeout) { - setTimeout(this.props.onCloseClick, this.props.timeout); - } - } - - render() { - let {title, type, msg, show} = this.props; - if (!show) { - type = this.state.type; - } - return ( - - - {title} - - {msg} - - - - - ); - } -} - -export default connect(mapStateToProps, mapActionsToProps)(NotificationModal); diff --git a/src/generic-components/notifications/NotificationReducer.js b/src/generic-components/notifications/NotificationReducer.js deleted file mode 100644 index 1f5122c..0000000 --- a/src/generic-components/notifications/NotificationReducer.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import NotificationConstants from './NotificationConstants.js'; - -export default (state = null, action) => { - 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 - }; -} diff --git a/src/generic-components/panel/SlidePanel.jsx b/src/generic-components/panel/SlidePanel.jsx deleted file mode 100644 index 1550cee..0000000 --- a/src/generic-components/panel/SlidePanel.jsx +++ /dev/null @@ -1,137 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React from 'react'; -import { PropTypes } from 'prop-types'; -import FontAwesome from 'react-fontawesome'; -import ReactDOM from 'react-dom'; - -class SlidePanel extends React.Component { - - static PropTypes = { - direction: PropTypes.string.isRequired, - className: PropTypes.string, - title: PropTypes.string, - isOpen: PropTypes.bool - }; - - static defaultProps = { - title: '', - className: '', - isOpen: true - }; - - state = { - isOpen: this.props.isOpen, - direction: this.props.direction, - width: 0, - arrowWidth: 0 - }; - - componentDidMount() { - this.setSliderPosition(); - } - - componentDidUpdate() { - this.setSliderPosition(); - } - - render() { - - let {children, className} = this.props; - let {isOpen} = this.state; - - return ( -
- {this.renderHeader(isOpen)} -
{children}
-
- ); - } - - renderHeader(isOpen) { - let {direction: initialDirection, title} = this.props; - let {direction: currentDirection} = this.state; - - let iconName = currentDirection === - 'right' - ? 'angle-double-right collapse-double-icon' - : 'angle-double-left collapse-double-icon'; - - let awestyle = {padding: '5px'}; - - if (!isOpen && initialDirection === 'right') { - awestyle.marginLeft = '-1px'; - } - return ( -
- { initialDirection === 'left' && - {title}} - - { initialDirection === 'right' && - {title}} -
- ); - } - - handleClick = () => { - this.setState({ - isOpen: !this.state.isOpen, - direction: this.state.direction === 'left' ? 'right' : 'left' - }); - } - - setSliderPosition = () => { - - let el = ReactDOM.findDOMNode(this); - let {style} = el; - - let {direction: initialDirection} = this.props; - let arrowIconSize = Math.floor(ReactDOM.findDOMNode(this.refs.arrowIcon) - .getBoundingClientRect().width) * 2; - if (!this.state.isOpen) { - if (this.props.direction === 'left') { - style.left = arrowIconSize - el.getBoundingClientRect().width + 'px'; - } - if (initialDirection === 'right') { - style.right = arrowIconSize - el.getBoundingClientRect().width + 'px'; - } - } - else { - if (initialDirection === 'left') { - style.left = '0px'; - } - - if (this.props.direction === 'right') { - style.right = '0px'; - } - } - } - -} - -export default SlidePanel; diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx b/src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx deleted file mode 100644 index 0fe8939..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import {connect} from 'react-redux'; - -import ButtonGroup from 'react-bootstrap/lib/ButtonGroup.js'; -import Button from 'react-bootstrap/lib/Button.js'; - -import ToggleButtonGroupActions from 'generic-components/toggleButtonGroup/ToggleButtonGroupActions.js'; - -let mapActionToProps = (dispatch) => { - return { - onButtonToggle: (buttonName) => { - dispatch(ToggleButtonGroupActions.onToggle({button: buttonName})); - } - }; -}; - -let mapStateToProps = ({toggleButtonGroupData}) => { - - let {selectedButton} = toggleButtonGroupData; - - return { - selectedButton - }; -}; - -class ToggleButtonGroup extends Component { - - static propTypes = { - buttonDefinitions: PropTypes.object.isRequired - }; - - onButtonSelect(buttonName) { - this.props.onButtonToggle(buttonName); - } - - render() { - let {selectedButton, buttonDefinitions} = this.props; - let buttonListElements = []; - Object.keys(buttonDefinitions).map(function (item) { - buttonListElements.push( - - ); - }.bind(this)); - - return ( - - {buttonListElements} - - ); - } -} -export default connect(mapStateToProps, mapActionToProps)(ToggleButtonGroup); diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js b/src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js deleted file mode 100644 index a04d127..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import ToggleButtonGroupConstants from './ToggleButtonGroupConstants.js'; - -export default { - onToggle(buttonName) { - return {type: ToggleButtonGroupConstants.BUTTON_TOGGLED, data: buttonName}; - } -}; diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js b/src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js deleted file mode 100644 index 47c458a..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -// events -const BUTTON_TOGGLED = 'BUTTON_TOGGLED'; - -module.exports = { - BUTTON_TOGGLED: BUTTON_TOGGLED -}; diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js b/src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js deleted file mode 100644 index e5a069b..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import {BUTTON_TOGGLED} from 'generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js'; - -export default (state = {}, action) => { - - switch (action.type) { - - case BUTTON_TOGGLED: - return { - ...state, - selectedButton: action.data.button - }; - } - return state; -}; diff --git a/src/generic-components/treeNode/TreeNode.jsx b/src/generic-components/treeNode/TreeNode.jsx deleted file mode 100644 index 2807ca4..0000000 --- a/src/generic-components/treeNode/TreeNode.jsx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -import React, {Component} from 'react'; -import classNames from 'classnames'; - - - - -class TreeNode extends Component { - - - constructor(props) { - super(props); - this.state = { - visible: false, - }; - } - - toggle = () => { - this.setState({visible: !this.state.visible}); - }; - - render() { - var childNodes; - var classObj; - if (this.props.node !== undefined && this.props.node.childNodes !== undefined) { - childNodes = this.props.node.childNodes.map(function (node, index) { - return
  • ; - }); - - classObj = { - togglable: true, - 'togglable-down': this.state.visible, - 'togglable-up': !this.state.visible - }; - } - - var style; - if (!this.state.visible) { - style = {display: 'none'}; - } - - return ( -
    - - {this.props.node.title} - -
      - {childNodes} -
    -
    - ); - } -} - -export default TreeNode; diff --git a/test/MainScreenWrapperReducer.test.js b/test/app/MainScreenWrapperReducer.test.js similarity index 100% rename from test/MainScreenWrapperReducer.test.js rename to test/app/MainScreenWrapperReducer.test.js diff --git a/test/configurableViews/ConfigurableViewActions.test.js b/test/app/configurableViews/ConfigurableViewActions.test.js similarity index 100% rename from test/configurableViews/ConfigurableViewActions.test.js rename to test/app/configurableViews/ConfigurableViewActions.test.js diff --git a/test/configurableViews/ConfigurableViewReducer.test.js b/test/app/configurableViews/ConfigurableViewReducer.test.js similarity index 100% rename from test/configurableViews/ConfigurableViewReducer.test.js rename to test/app/configurableViews/ConfigurableViewReducer.test.js diff --git a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js similarity index 100% rename from test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js rename to test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js diff --git a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js similarity index 100% rename from test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js rename to test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js diff --git a/test/globalInlineMessageBar/GlobalInlineMessageBar.test.js b/test/app/globalInlineMessageBar/GlobalInlineMessageBar.test.js similarity index 100% rename from test/globalInlineMessageBar/GlobalInlineMessageBar.test.js rename to test/app/globalInlineMessageBar/GlobalInlineMessageBar.test.js diff --git a/test/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js b/test/app/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js similarity index 100% rename from test/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js rename to test/app/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js diff --git a/test/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js b/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js similarity index 100% rename from test/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js rename to test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js diff --git a/test/networking/NetworkCalls.test.js b/test/app/networking/NetworkCalls.test.js similarity index 100% rename from test/networking/NetworkCalls.test.js rename to test/app/networking/NetworkCalls.test.js diff --git a/test/networking/NetworkUtil.test.js b/test/app/networking/NetworkUtil.test.js similarity index 100% rename from test/networking/NetworkUtil.test.js rename to test/app/networking/NetworkUtil.test.js diff --git a/test/tierSupport/SelectedNodeDetails.test.js b/test/app/tierSupport/SelectedNodeDetails.test.js similarity index 100% rename from test/tierSupport/SelectedNodeDetails.test.js rename to test/app/tierSupport/SelectedNodeDetails.test.js diff --git a/test/tierSupport/SelectedNodeDetailsReducer.test.js b/test/app/tierSupport/SelectedNodeDetailsReducer.test.js similarity index 100% rename from test/tierSupport/SelectedNodeDetailsReducer.test.js rename to test/app/tierSupport/SelectedNodeDetailsReducer.test.js diff --git a/test/tierSupport/TierSupportActions.test.js b/test/app/tierSupport/TierSupportActions.test.js similarity index 100% rename from test/tierSupport/TierSupportActions.test.js rename to test/app/tierSupport/TierSupportActions.test.js diff --git a/test/tierSupport/TierSupportReducer.test.js b/test/app/tierSupport/TierSupportReducer.test.js similarity index 100% rename from test/tierSupport/TierSupportReducer.test.js rename to test/app/tierSupport/TierSupportReducer.test.js diff --git a/test/vnfSearch/VnfSearch.test.js b/test/app/vnfSearch/VnfSearch.test.js similarity index 100% rename from test/vnfSearch/VnfSearch.test.js rename to test/app/vnfSearch/VnfSearch.test.js diff --git a/test/vnfSearch/VnfSearchActions.test.js b/test/app/vnfSearch/VnfSearchActions.test.js similarity index 100% rename from test/vnfSearch/VnfSearchActions.test.js rename to test/app/vnfSearch/VnfSearchActions.test.js diff --git a/test/vnfSearch/VnfSearchNfRoleVisualization.test.js b/test/app/vnfSearch/VnfSearchNfRoleVisualization.test.js similarity index 100% rename from test/vnfSearch/VnfSearchNfRoleVisualization.test.js rename to test/app/vnfSearch/VnfSearchNfRoleVisualization.test.js diff --git a/test/vnfSearch/VnfSearchNfTypeVisualization.test.js b/test/app/vnfSearch/VnfSearchNfTypeVisualization.test.js similarity index 100% rename from test/vnfSearch/VnfSearchNfTypeVisualization.test.js rename to test/app/vnfSearch/VnfSearchNfTypeVisualization.test.js diff --git a/test/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js b/test/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js similarity index 100% rename from test/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js rename to test/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js diff --git a/test/vnfSearch/VnfSearchProvStatusVisualization.test.js b/test/app/vnfSearch/VnfSearchProvStatusVisualization.test.js similarity index 100% rename from test/vnfSearch/VnfSearchProvStatusVisualization.test.js rename to test/app/vnfSearch/VnfSearchProvStatusVisualization.test.js diff --git a/test/vnfSearch/VnfSearchReducer.test.js b/test/app/vnfSearch/VnfSearchReducer.test.js similarity index 100% rename from test/vnfSearch/VnfSearchReducer.test.js rename to test/app/vnfSearch/VnfSearchReducer.test.js diff --git a/test/vnfSearch/VnfSearchTotalCountVisualization.test.js b/test/app/vnfSearch/VnfSearchTotalCountVisualization.test.js similarity index 100% rename from test/vnfSearch/VnfSearchTotalCountVisualization.test.js rename to test/app/vnfSearch/VnfSearchTotalCountVisualization.test.js diff --git a/test/autoCompleteSearchBar/AutoCompleteSearchBar.test.js b/test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js similarity index 100% rename from test/autoCompleteSearchBar/AutoCompleteSearchBar.test.js rename to test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js diff --git a/test/generic-components/notifications/NotificationReducer.test.js b/test/generic-components/notifications/NotificationReducer.test.js deleted file mode 100644 index 40d6b05..0000000 --- a/test/generic-components/notifications/NotificationReducer.test.js +++ /dev/null @@ -1,197 +0,0 @@ -import NotificationReducer from 'generic-components/notifications/NotificationReducer'; -import NotificationConstants from "generic-components/notifications/NotificationConstants"; - - -describe('NotificationReducer', () => { - const defaultState = { - type: 'default', - title: 'some default title', - msg: 'some default message', - timeout: 1 - }; - - it('Should return default state when action type is not supported', () => { - // given - const unsupportedAction = { - type: undefined - }; - - // when - const actualState = NotificationReducer(defaultState, unsupportedAction); - - // then - expect(actualState).toEqual(defaultState); - }); - - it('Should return state with type default when action type is info', () => { - // given - const expectedState = { - type: 'default', - title: 'some title', - msg: 'some message', - timeout: 5 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_INFO, - data: { - title: "some title", - msg: "some message", - timeout: 5 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - - it('Should return status with type success when action type is success', () => { - // given - const expectedState = { - type: 'success', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_SUCCESS, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type success when action type is success', () => { - // given - const expectedState = { - type: 'success', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_SUCCESS, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type error when action type is error', () => { - // given - const expectedState = { - type: 'error', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_ERROR, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type error when action type is error', () => { - // given - const expectedState = { - type: 'error', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_ERROR, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type warning when action type is warning', () => { - // given - const expectedState = { - type: 'warning', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_WARNING, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return null when action type is close', () => { - // given - const expectedState = null; - - const infoAction = { - type: NotificationConstants.NOTIFY_CLOSE, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - -}); diff --git a/test/generic-components/treeNode/TreeNode.test.js b/test/generic-components/treeNode/TreeNode.test.js deleted file mode 100644 index 1c669e6..0000000 --- a/test/generic-components/treeNode/TreeNode.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import TreeNode from 'generic-components/treeNode/TreeNode'; -import React from 'react'; -import { mount } from 'enzyme'; - -describe('TreeNode', () => { - let treeNode; - - beforeEach(() => { - treeNode = mount().instance(); - }); - - - it('Should be invisible when created', () => { - // then - expect(treeNode.state['visible']).toEqual(false) - }); - - it('Should be visible when toggled', () => { - // given - expect(treeNode.state['visible']).toEqual(false) - - // when - treeNode.toggle(); - - // then - expect(treeNode.state['visible']).toEqual(true) - }); - - it('Should be invisible when double toggled', () => { - // given - expect(treeNode.state['visible']).toEqual(false); - - // when - treeNode.toggle(); - treeNode.toggle(); - - // then - expect(treeNode.state['visible']).toEqual(false); - }); - -}); diff --git a/test/input/SelectInput.test.js b/test/input/SelectInput.test.js deleted file mode 100644 index a669361..0000000 --- a/test/input/SelectInput.test.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import Select from 'react-select'; - -import SelectInput from 'generic-components/input/SelectInput.jsx'; - -describe('SelectInput Tests', () => { - it('render select input - visible', () => { - const select = mount( ); - expect(select).toHaveLength(1); // ensure the message bar is mounted - expect(select.find(Select)).toHaveLength(1); // ensure the InlineMessage is mounted - }); -}) diff --git a/test/input/ToggleInput.test.js b/test/input/ToggleInput.test.js deleted file mode 100644 index 80f0345..0000000 --- a/test/input/ToggleInput.test.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; - -import ToggleInput from 'generic-components/input/ToggleInput.jsx'; - -describe('ToggleInput Tests', () => { - it('render toggle input - visible', () => { - const toggle = mount( ); - expect(toggle).toHaveLength(1); // ensure the message bar is mounted - expect(toggle.find('input')).toHaveLength(1); // ensure the InlineMessage is mounted - }); -}) -- 2.16.6 From bbac6201bccda26bbff7c64b12160ae06319b752 Mon Sep 17 00:00:00 2001 From: Mariusz Sygnowski Date: Mon, 8 Apr 2019 13:52:20 +0200 Subject: [PATCH 08/16] Adding missing packege Change-Id: Ica3a109ee099ec2fd57b19d69abd0b8d3de9158f Issue-ID: AAI-2337 Signed-off-by: Mariusz Sygnowski --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2b8334a..ef4d259 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "redux": "^3.3.1", "redux-form": "^6.2.1", "redux-thunk": "^2.1.0", + "sinon": "^7.3.1", "topojson": "^2.2.0", "uuid-js": "^0.7.5", "validator": "^4.3.0", -- 2.16.6 From 12af2f20c2313a3fc1fe5761eaf2e885d3c8b751 Mon Sep 17 00:00:00 2001 From: Mariusz Sygnowski Date: Tue, 9 Apr 2019 11:32:23 +0200 Subject: [PATCH 09/16] Fixing failing test + covarage improvement Change-Id: Id13e334cc1493274081758079a1f896f35af6b80 Issue-ID: AAI-2341 Signed-off-by: Mariusz Sygnowski --- test/app/networking/NetworkCalls.test.js | 51 ++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/test/app/networking/NetworkCalls.test.js b/test/app/networking/NetworkCalls.test.js index 373fbac..a3b6176 100644 --- a/test/app/networking/NetworkCalls.test.js +++ b/test/app/networking/NetworkCalls.test.js @@ -90,34 +90,53 @@ describe("Network Utils", () => { describe('#getRequest', () => { it("should fetch any request", () => { - const json = suite.sandbox.stub(); - const fetchPromise = Promise.resolve({json}); - global.fetch = suite.sandbox.stub(); - - global.fetch - .withArgs('URL', { - credentials: 'same-origin', - method: 'GET' - }) - .returns(fetchPromise); - - NetworkCalls.getRequest("URL", "GET"); - - return fetchPromise.then(() => { - sinon.assert.calledOnce(json); - }); + // given + global.fetch = suite.sandbox.stub(); + const json = suite.sandbox.stub(); + const url = "localhost"; + + global.fetch + .withArgs(url, { + credentials: 'same-origin', + method: 'GET' + }) + .returns(json); + + // when + const request = NetworkCalls.getRequest(url, "GET"); + + //then + expect(request).toBe(json) + sinon.assert.calledOnce(global.fetch); }); }); describe('#genericRequest', () => { it('should fetch any generic request', () => { + // given global.fetch = suite.sandbox.stub(); const then = suite.sandbox.stub(); fetch.returns({then}); + + // when NetworkCalls.genericRequest("localhost", "/relativeUrl", "GET"); + // then expect(then.firstCall.args[0]({json: () => "d"})).toEqual("d"); + sinon.assert.calledOnce(fetch); + }); + it('should fetch any generic request - non relative', () => { + // given + global.fetch = suite.sandbox.stub(); + const then = suite.sandbox.stub(); + fetch.returns({then}); + + // when + NetworkCalls.genericRequest("localhost", false, "GET"); + + // then + expect(then.firstCall.args[0]({json: () => "d"})).toEqual("d"); sinon.assert.calledOnce(fetch); }); }); -- 2.16.6 From 5d6f9413bc956f905d7b35fe59d626e285e973cf Mon Sep 17 00:00:00 2001 From: Adam Wudzinski Date: Wed, 10 Apr 2019 16:43:31 +0200 Subject: [PATCH 10/16] GlobalInlineMessageBarReducer test Add test for default route and minor test refactor Change-Id: I91f0167318ab94eb4c5033dfe594e2bc4e65114f Issue-ID: AAI-1618 Signed-off-by: awudzins --- .../GlobalInlineMessageBarReducer.test.js | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js b/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js index 62389b4..bbcb7c1 100644 --- a/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js +++ b/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js @@ -1,13 +1,14 @@ -import GlobalInlineMessageBarReducer from 'app/globalInlineMessageBar/GlobalInlineMessageBarReducer.js'; +import GlobalInlineMessageBarReducer from 'app/globalInlineMessageBar/GlobalInlineMessageBarReducer'; import { globalInlineMessageBarActionTypes -} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants'; import { MESSAGE_LEVEL_WARNING -} from 'utils/GlobalConstants.js' +} from 'utils/GlobalConstants' describe('GlobalInlineMessageBarReducerTests', () => { it('Action Type: SET_GLOBAL_MESSAGE', () => { + // Given const action = { type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, data: { @@ -16,7 +17,11 @@ describe('GlobalInlineMessageBarReducerTests', () => { } }; let state = {}; + + // When state = GlobalInlineMessageBarReducer(state, action); + + // Then expect(state).toEqual({ feedbackMsgText: action.data.msgText, feedbackMsgSeverity: action.data.msgSeverity @@ -24,6 +29,7 @@ describe('GlobalInlineMessageBarReducerTests', () => { }); it('Action Type: CLEAR_GLOBAL_MESSAGE', () => { + // Given const action = { type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE }; @@ -31,10 +37,31 @@ describe('GlobalInlineMessageBarReducerTests', () => { feedbackMsgText: 'some error message here', feedbackMsgSeverity: MESSAGE_LEVEL_WARNING }; + + // When state = GlobalInlineMessageBarReducer(state, action); + + // Then expect(state).toEqual({ feedbackMsgText: '', feedbackMsgSeverity: '' }); }); -}) + + it('Action Type: unknown', () => { + // Given + const action = { + type: "TestUnknownType" + }; + const initialState = { + feedbackMsgText: 'some error message here', + feedbackMsgSeverity: MESSAGE_LEVEL_WARNING + }; + + // When + const newState = GlobalInlineMessageBarReducer(initialState, action); + + // Then + expect(newState).toEqual(initialState); + }); +}); -- 2.16.6 From 8d1e8bb11b0cfe24e48cdd2e96dde74a8a70f77c Mon Sep 17 00:00:00 2001 From: Adam Wudzinski Date: Thu, 11 Apr 2019 11:33:50 +0200 Subject: [PATCH 11/16] MainScreenWrapperActionHelper test Add tests for MainScreenWrapperActionHelper Change-Id: I5bd959da5635546be6ab0761801a24b1ea1ee084 Issue-ID: AAI-1618 Signed-off-by: awudzins --- test/app/MainScreenWrapperActionHelper.test.js | 132 +++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 test/app/MainScreenWrapperActionHelper.test.js diff --git a/test/app/MainScreenWrapperActionHelper.test.js b/test/app/MainScreenWrapperActionHelper.test.js new file mode 100644 index 0000000..011010e --- /dev/null +++ b/test/app/MainScreenWrapperActionHelper.test.js @@ -0,0 +1,132 @@ +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk' +import { + windowResize, + showMainMenu, + extensibleViewMessageCallback, + clearExtensibleViewData, + setSecondaryTitle +} from 'app/MainScreenWrapperActionHelper'; +import { + getSetGlobalMessageEvent, + getClearGlobalMessageEvent +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions'; +import { + globalInlineMessageBarActionTypes +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants'; +import {aaiActionTypes} from 'app/MainScreenWrapperConstants'; + +const mockStore = configureStore([thunk]); + +describe('MainScreenWrapperActionHelper', () => { + let store; + + beforeEach(() => { + store = mockStore({ tierSupportReducer: {} }); + }); + + describe('windowResize', () => { + it('emits action', () => { + // Given + const expectedActions = [{ + type: aaiActionTypes.AAI_WINDOW_RESIZE + }]; + + // When + store.dispatch(windowResize()); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('showMainMenu', () => { + it('emits action with payload', () => { + // Given + const input = "testInput"; + const expectedActions = [{ + type: aaiActionTypes.AAI_SHOW_MENU, + data: { + showMenu: input + } + }]; + + // When + store.dispatch(showMainMenu(input)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('extensibleViewMessageCallback', () => { + const msgSeverity = "msgSeverity"; + + it('emits action with payload when msgText is not blank', () => { + // Given + const msgText = "msgText"; + const expectedActions = [{ + type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { + msgText: msgText, + msgSeverity: msgSeverity + } + }]; + + // When + store.dispatch(extensibleViewMessageCallback(msgText, msgSeverity)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + + it('emits action when msgText is blank', () => { + // Given + const msgText = ""; + const expectedActions = [{ + type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE + + }]; + + // When + store.dispatch(extensibleViewMessageCallback(msgText, msgSeverity)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('clearExtensibleViewData', () => { + it('emits action with payload', () => { + // Given + const expectedActions = [{ + type: aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA, + data: {} + }]; + + // When + store.dispatch(clearExtensibleViewData()); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('setSecondaryTitle', () => { + it('emits action with payload', () => { + // Given + const title = "testTitle"; + const expectedActions = [{ + type: aaiActionTypes.SET_SECONDARY_TITLE, + data: title + }]; + + // When + store.dispatch(setSecondaryTitle(title)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + +}); -- 2.16.6 From 786f2bd8636c9b9ddd661aaffe3bceac6e041739 Mon Sep 17 00:00:00 2001 From: Jimmy Forsyth Date: Fri, 3 May 2019 18:33:22 -0400 Subject: [PATCH 12/16] Upversion for Dublin release Issue-ID: AAI-2403 Change-Id: Ia58036bd5a6e79699ed9530fa87340d24a5044b1 Signed-off-by: Jimmy Forsyth --- pom.xml | 2 +- version.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 422b04f..d4c768a 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ org.onap.aai sparky-fe war - 1.4.0-SNAPSHOT + 1.4.1-SNAPSHOT aai-sparky-fe http://maven.apache.org diff --git a/version.properties b/version.properties index 66827fd..e653a66 100644 --- a/version.properties +++ b/version.properties @@ -5,7 +5,7 @@ major_version=1 minor_version=4 -patch_version=0 +patch_version=1 base_version=${major_version}.${minor_version}.${patch_version} -- 2.16.6 From 4e5e8eb11e629d4906a01cc4e433d40b286c542c Mon Sep 17 00:00:00 2001 From: Jimmy Forsyth Date: Wed, 19 Jun 2019 17:29:05 -0400 Subject: [PATCH 13/16] Upversion for global jjb transition Issue-ID: AAI-2497 Change-Id: I036e45fc734c09cad41b2c9b20375a395320adde Signed-off-by: Jimmy Forsyth --- pom.xml | 2 +- version.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d4c768a..720f428 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ org.onap.aai sparky-fe war - 1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT aai-sparky-fe http://maven.apache.org diff --git a/version.properties b/version.properties index e653a66..b11eaff 100644 --- a/version.properties +++ b/version.properties @@ -4,8 +4,8 @@ # because they are used in Jenkins, whose plug-in doesn't support major_version=1 -minor_version=4 -patch_version=1 +minor_version=5 +patch_version=0 base_version=${major_version}.${minor_version}.${patch_version} -- 2.16.6 From db14c699054e4f03d0a141c30809556403013ae0 Mon Sep 17 00:00:00 2001 From: Jimmy Forsyth Date: Tue, 9 Jul 2019 10:43:45 -0400 Subject: [PATCH 14/16] Upversion to oparent 2 and remove staging plugin Issue-ID: AAI-2497 Change-Id: I97de01a7789a06de9685c2b38f49cba84e84f605 Signed-off-by: Jimmy Forsyth --- pom.xml | 18 ++++++++---------- version.properties | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 720f428..c86ce5d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,10 +23,15 @@ 4.0.0 + + org.onap.oparent + oparent + 2.0.0 + org.onap.aai sparky-fe war - 1.5.0-SNAPSHOT + 1.5.1-SNAPSHOT aai-sparky-fe http://maven.apache.org @@ -104,15 +109,8 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexusproxy} - 176c31dfe190a - ecomp-staging - + org.apache.maven.plugins + maven-deploy-plugin diff --git a/version.properties b/version.properties index b11eaff..4814eb2 100644 --- a/version.properties +++ b/version.properties @@ -5,7 +5,7 @@ major_version=1 minor_version=5 -patch_version=0 +patch_version=1 base_version=${major_version}.${minor_version}.${patch_version} -- 2.16.6 From 85be10eac05a4d95b58f1afbca6d2018f91434c2 Mon Sep 17 00:00:00 2001 From: Jimmy Forsyth Date: Thu, 8 Aug 2019 16:58:09 -0400 Subject: [PATCH 15/16] Add build debug Issue-ID: AAI-2576 Signed-off-by: Jimmy Forsyth Change-Id: Ia013dc3026e349c7692240822e130c90f2c7b377 --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index c86ce5d..725d77f 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,14 @@ npm generate-resources + + + install -ddd + + gulp build -- 2.16.6 From ee4af7e495077ef58a3de3312d2e180c59465f59 Mon Sep 17 00:00:00 2001 From: Jimmy Forsyth Date: Wed, 14 Aug 2019 16:01:40 -0400 Subject: [PATCH 16/16] Upversion sparky-fe in elalto Issue-ID: AAI-2579 Signed-off-by: Jimmy Forsyth Change-Id: I2ffa8c8695097187c8f0723ba4ff3551c8188490 --- pom.xml | 2 +- version.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 725d77f..942f647 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ org.onap.aai sparky-fe war - 1.5.1-SNAPSHOT + 1.6.0-SNAPSHOT aai-sparky-fe http://maven.apache.org diff --git a/version.properties b/version.properties index 4814eb2..704dc53 100644 --- a/version.properties +++ b/version.properties @@ -4,8 +4,8 @@ # because they are used in Jenkins, whose plug-in doesn't support major_version=1 -minor_version=5 -patch_version=1 +minor_version=6 +patch_version=0 base_version=${major_version}.${minor_version}.${patch_version} -- 2.16.6