2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END============================================
19 * ===================================================================
23 import React from 'react'
24 import Button from 'react-bootstrap/Button';
25 import Modal from 'react-bootstrap/Modal';
26 import Form from 'react-bootstrap/Form';
27 import Row from 'react-bootstrap/Row';
28 import Col from 'react-bootstrap/Col';
29 import styled from 'styled-components';
30 import UserService from '../../api/UserService';
32 const ModalStyled = styled(Modal)`
33 background-color: transparent;
36 export default class UserInfoModal extends React.Component {
38 constructor(props, context) {
39 super(props, context);
41 this.handleClose = this.handleClose.bind(this);
42 this.renderPermissions = this.renderPermissions.bind(this);
43 this.renderUserName = this.renderUserName.bind(this);
49 componentWillMount() {
50 UserService.getUserInfo().then(userInfo => {
51 this.setState({ userInfo: userInfo })
56 this.props.history.push('/');
59 if (this.state.userInfo["allPermissions"]) {
60 var listOfPermissions = this.state.userInfo["allPermissions"].map(function(perm) {
61 return <Form.Control plaintext readOnly defaultValue={perm} />;
63 return listOfPermissions;
69 if (this.state.userInfo["userName"]) {
70 return <Form.Control plaintext readOnly defaultValue={this.state.userInfo["userName"]} />
76 if (this.state.userInfo["cldsVersion"]) {
77 return <Form.Control plaintext readOnly defaultValue={this.state.userInfo["cldsVersion"]} />
84 <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose}>
85 <Modal.Header closeButton>
86 <Modal.Title>User Info</Modal.Title>
89 <Form.Group as={Row} controlId="userName">
90 <Form.Label column sm="3">Current User:</Form.Label>
91 <Col>{this.renderUserName()}</Col>
93 <Form.Group as={Row} controlId="cldsVersion">
94 <Form.Label column sm="3">CLDS Version:</Form.Label>
95 <Col>{this.renderVersion()}</Col>
97 <Form.Group as={Row} controlId="userPermissions">
98 <Form.Label column sm="3">User Permissions:</Form.Label>
100 {this.renderPermissions()}
105 <Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button>