2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 import React, {Component, PropTypes} from 'react';
27 import {connect} from 'react-redux';
29 import ButtonGroup from 'react-bootstrap/lib/ButtonGroup.js';
30 import Button from 'react-bootstrap/lib/Button.js';
32 import ToggleButtonGroupActions from 'generic-components/toggleButtonGroup/ToggleButtonGroupActions.js';
34 let mapActionToProps = (dispatch) => {
36 onButtonToggle: (buttonName) => {
37 dispatch(ToggleButtonGroupActions.onToggle({button: buttonName}));
42 let mapStateToProps = ({toggleButtonGroupData}) => {
44 let {selectedButton} = toggleButtonGroupData;
51 class ToggleButtonGroup extends Component {
54 buttonDefinitions: PropTypes.object.isRequired
57 onButtonSelect(buttonName) {
58 this.props.onButtonToggle(buttonName);
62 let {selectedButton, buttonDefinitions} = this.props;
63 let buttonListElements = [];
64 Object.keys(buttonDefinitions).map(function (item) {
65 buttonListElements.push(
66 <Button id={item} active={selectedButton === item ? true : false}
67 onClick={() => this.onButtonSelect(item)}>
68 <i className={buttonDefinitions[item]} aria-hidden='true'></i>
74 <ButtonGroup bsClass='btn-group displayOptionButtons'>
80 export default connect(mapStateToProps, mapActionToProps)(ToggleButtonGroup);