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 UserInfo extends React.Component {
38 constructor(props, context) {
39 super(props, context);
41 this.handleClose = this.handleClose.bind(this);
42 this.initialValues = this.initialValues.bind(this);
43 this.renderReadTemplatePermission = this.renderReadTemplatePermission.bind(this);
44 this.renderReadModelPermission = this.renderReadModelPermission.bind(this);
45 this.renderReadToscaPermission = this.renderReadToscaPermission.bind(this);
46 this.renderUpdateTemplatePermission = this.renderUpdateTemplatePermission.bind(this);
47 this.renderUpdateModelPermission = this.renderUpdateModelPermission.bind(this);
48 this.renderUpdateToscaPermission = this.renderUpdateToscaPermission.bind(this);
49 this.renderUserName = this.renderUserName.bind(this);
52 userInfo: {permissionReadTemplate: true,
53 permissionReadCl: true,
54 permissionReadTosca: true,
55 permissionUpdateCl: true,
56 permissionUpdateTemplate: true,
57 permissionUpdateTosca: true,
65 UserService.getUserInfo().then(userInfo => {
66 this.setState({ userInfo: userInfo })
70 this.props.history.push('/');
72 renderReadTemplatePermission() {
73 if (this.state.userInfo["permissionReadTemplate"]) {
74 return <Form.Control plaintext readOnly defaultValue="Read Template" />
79 renderReadModelPermission() {
80 if (this.state.userInfo["permissionReadCl"]) {
81 return <Form.Control plaintext readOnly defaultValue="Read Model" />
86 renderReadToscaPermission() {
87 if (this.state.userInfo["permissionReadTosca"]) {
88 return <Form.Control plaintext readOnly defaultValue="Read Tosca" />
93 renderUpdateTemplatePermission() {
94 if (this.state.userInfo["permissionUpdateTemplate"]) {
95 return <Form.Control plaintext readOnly defaultValue="Edit Template" />
100 renderUpdateModelPermission() {
101 if (this.state.userInfo["permissionUpdateCl"]) {
102 return <Form.Control plaintext readOnly defaultValue="Edit Model" />
107 renderUpdateToscaPermission() {
108 if (this.state.userInfo["permissionUpdateTosca"]) {
109 return <Form.Control plaintext readOnly defaultValue="Edit Tosca" />
115 if (this.state.userInfo["userName"]) {
116 return <Form.Control plaintext readOnly defaultValue={this.state.userInfo["userName"]} />
122 if (this.state.userInfo["cldsVersion"]) {
123 return <Form.Control plaintext readOnly defaultValue={this.state.userInfo["cldsVersion"]} />
130 <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} onEntered={this.initialValues}>
131 <Modal.Header closeButton>
132 <Modal.Title>User Info</Modal.Title>
135 <Form.Group as={Row} controlId="userName">
136 <Form.Label column sm="3">Current User:</Form.Label>
137 <Col>{this.renderUserName()}</Col>
139 <Form.Group as={Row} controlId="cldsVersion">
140 <Form.Label column sm="3">CLDS Version:</Form.Label>
141 <Col>{this.renderVersion()}</Col>
143 <Form.Group as={Row} controlId="userPermissions">
144 <Form.Label column sm="3">User Permissions:</Form.Label>
146 {this.renderReadTemplatePermission()}
147 {this.renderReadModelPermission()}
148 {this.renderReadToscaPermission()}
149 {this.renderUpdateTemplatePermission()}
150 {this.renderUpdateModelPermission()}
151 {this.renderUpdateToscaPermission()}
156 <Button variant="secondary" type="null" onClick={this.handleClose}>Cacel</Button>