2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 import React, {Component} from 'react';
22 import {connect} from 'react-redux';
23 import i18n from 'utils/i18n/i18n';
25 import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx';
28 requestEditEntityAttributes
29 } from './EditAttributeActions.js';
32 ATTRIBUTE_MODIFICATION
33 } from './EditAttributeConstants.js';
34 import ChangeAttributeForm from 'editAttributes/changeAttributeForm/ChangeAttributeForm.jsx';
35 import {NO_VALUE_SELECTED} from 'editAttributes/changeAttributeForm/ChangeAttributeFormConstants.js';
37 let mapStateToProps = ({setAttributes}) => {
40 feedbackMsgSeverity = ''
49 let mapActionToProps = (dispatch) => {
51 handleSubmit: (values) => {
53 let attrMap = new Map();
54 attrMap.set('provStatus', 'prov-status');
55 attrMap.set('inMaint', 'in-maint');
56 attrMap.set('isClosedLoopDisabled', 'is-closed-loop-disabled');
59 let valueString = JSON.stringify(values);
60 JSON.parse(valueString, (key, value) => {
61 if(value !== NO_VALUE_SELECTED) {
62 let formattedKey = attrMap.get(key);
63 if(formattedKey !== undefined) {
65 ...attributes, [formattedKey]: value
72 dispatch(requestEditEntityAttributes(uri, attributes));
74 clearFeedbackMessage: () => {
75 dispatch(clearFeebackMessage());
80 class SetAttribute extends Component {
86 clearFeedbackMessage} = this.props;
89 <div className='header'>
90 <div className='application-title'>{i18n(SET_ATTRIBUTE_TITLE)}</div>
92 <div className='secondary-header'>
94 className='secondary-title'>{i18n(ATTRIBUTE_MODIFICATION)}</span>
95 <InlineMessage level={feedbackMsgSeverity}
96 messageTxt={feedbackMsgText}/>
100 onSubmit={(values) => {
101 handleSubmit(values);
103 buttonSelected={() => {
104 clearFeedbackMessage();
111 export default connect(mapStateToProps, mapActionToProps)(SetAttribute);