-
Notifications
You must be signed in to change notification settings - Fork 12
/
OrgHomeHeader.jsx
114 lines (110 loc) · 4.32 KB
/
OrgHomeHeader.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import React from 'react';
import {
Home as HomeIcon,
FileCopy as CopyIcon,
} from '@material-ui/icons';
import { Tooltip, IconButton } from '@material-ui/core';
import { includes, isEmpty, get } from 'lodash';
import { toFullAPIURL, copyURL } from '../../common/utils';
import APIService from '../../services/APIService';
import OwnerButton from '../common/OwnerButton';
import LastUpdatedOnLabel from '../common/LastUpdatedOnLabel';
import ExternalIdLabel from '../common/ExternalIdLabel';
import LocationLabel from '../common/LocationLabel';
import LinkLabel from '../common/LinkLabel';
import CustomAttributesPopup from '../common/CustomAttributesPopup';
import PublicAccessChip from '../common/PublicAccessChip';
import HeaderAttribute from '../common/HeaderAttribute';
import HeaderLogo from '../common/HeaderLogo';
const OrgHomeHeader = ({ org, url }) => {
const [logoURL, setLogoURL] = React.useState(org.logo_url)
const onIconClick = () => copyURL(toFullAPIURL(url));
const onLogoUpload = (base64, name) => {
APIService.new().overrideURL(url).appendToUrl('logo/')
.post({base64: base64, name: name})
.then(response => {
if(get(response, 'status') === 200)
setLogoURL(get(response, 'data.logo_url', logoURL))
})
}
return (
<header className='home-header col-md-12'>
<div className='col-md-12 container' style={{paddingTop: '10px'}}>
<div className='no-side-padding col-md-1 home-icon'>
<HeaderLogo
logoURL={logoURL}
onUpload={onLogoUpload}
defaultIcon={<HomeIcon className='default-svg' />}
/>
</div>
<div className='col-md-11'>
<div className='col-md-12 no-side-padding flex-vertical-center'>
<OwnerButton owner={org.id} ownerType='Organization' href={url} />
</div>
<div className='col-md-12 no-side-padding flex-vertical-center home-resource-full-name'>
<span style={{marginRight: '10px'}}>
{org.name}
</span>
{
includes(['view', 'edit'], org.public_access.toLowerCase()) &&
<PublicAccessChip publicAccess={org.public_access} />
}
<span style={{marginLeft: '10px'}}>
<Tooltip title="Copy URL" placement="right">
<IconButton onClick={onIconClick} color="primary">
<CopyIcon fontSize="small" />
</IconButton>
</Tooltip>
</span>
</div>
{
org.description &&
<div className='col-md-12 no-side-padding flex-vertical-center resource-description'>
{org.description}
</div>
}
<HeaderAttribute label="Company" value={org.company} gridClass="col-md-12" />
<HeaderAttribute label="Custom Attributes" value={!isEmpty(org.extras) && <CustomAttributesPopup attributes={org.extras} />} gridClass="col-md-12" />
<div className='col-md-12 no-side-padding flex-vertical-center' style={{paddingTop: '10px'}}>
{
org.location &&
<span style={{marginRight: '10px'}}>
<LocationLabel location={org.location} noContainerClass iconSize="medium" />
</span>
}
{
org.website &&
<span style={{marginRight: '10px'}}>
<LinkLabel link={org.website} iconSize='medium' noContainerClass />
</span>
}
<span>
<LastUpdatedOnLabel
label='Created'
date={org.created_on}
by={org.created_by}
iconSize='medium'
noContainerClass
/>
</span>
<span style={{marginLeft: '10px'}}>
<LastUpdatedOnLabel
date={org.updated_on}
by={org.updated_by}
iconSize='medium'
noContainerClass
/>
</span>
{
org.external_id &&
<span style={{marginLeft: '10px', marginTop: '-8px'}}>
<ExternalIdLabel externalId={org.external_id} iconSize='medium' />
</span>
}
</div>
</div>
</div>
</header>
)
}
export default OrgHomeHeader;