talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 1 | /*! |
| 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | import React from 'react'; |
| 18 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 19 | import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; |
| 20 | |
| 21 | const Contributor = ({name, role, id, userInfo}) => { |
| 22 | |
| 23 | const selected = id === userInfo.userId ? 'selected' : ''; |
| 24 | |
| 25 | return( |
| 26 | <div className='contributor'> |
| 27 | <div className='contributor-content'> |
| 28 | <div className={`contributor-icon-circle ${selected}`}> |
| 29 | <div className={`contributer-icon ${selected}`}> |
| 30 | <SVGIcon name='user'/> |
| 31 | </div> |
| 32 | </div> |
| 33 | <div className='contributer-info'> |
| 34 | <div className='contributer-name'>{name}</div> |
| 35 | <div className='contributer-role'><p>{role}</p></div> |
| 36 | </div> |
| 37 | </div> |
| 38 | </div> |
| 39 | ); |
| 40 | }; |
| 41 | |
| 42 | const Permissions = ({permissions: {owner, contributors}, onManagePermissions, userInfo, onClosePermissions}) => { |
| 43 | |
| 44 | return ( |
| 45 | <div className='permissions-overlay'> |
| 46 | <div className='permissions-overlay-header'> |
| 47 | <h4 className='permissions-overlay-header-title'>{i18n('PERMISSIONS')}</h4> |
| 48 | </div> |
| 49 | <div className='permissions-overlay-content'> |
| 50 | <Contributor userInfo={userInfo} id={owner.userId} key={owner.fullName} name={owner.fullName} role={owner.role}/> |
| 51 | {contributors.map(item => item.userId !== owner.userId && <Contributor userInfo={userInfo} id={item.userId} key={item.fullName} name={item.fullName} role={item.role}/>)} |
| 52 | </div> |
| 53 | <div className='permissions-overlay-footer'> |
| 54 | { |
| 55 | owner.userId === userInfo.userId && |
| 56 | <div onClick={() => { onClosePermissions(); onManagePermissions(); }} className='manage-permissions-btn'> |
| 57 | {i18n('Manage Permissions')} |
| 58 | </div> |
| 59 | } |
| 60 | </div> |
| 61 | </div> |
| 62 | ); |
| 63 | }; |
| 64 | |
| 65 | export default Permissions; |