-
Notifications
You must be signed in to change notification settings - Fork 12
/
ConceptHomeHeader.jsx
124 lines (120 loc) · 4.8 KB
/
ConceptHomeHeader.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
115
116
117
118
119
120
121
122
123
124
import React from 'react';
import { IconButton, Tooltip } from '@material-ui/core';
import { Edit as EditIcon, Delete as DeleteIcon } from '@material-ui/icons';
import { currentUserHasAccess } from '../../common/utils';
import OwnerButton from '../common/OwnerButton';
import SourceButton from '../common/SourceButton';
import ConceptButton from '../common/ConceptButton';
import VersionButton from '../common/VersionButton';
import LastUpdatedOnLabel from '../common/LastUpdatedOnLabel';
import ExternalIdLabel from '../common/ExternalIdLabel';
import CustomAttributesPopup from '../common/CustomAttributesPopup';
import ConceptIcon from './ConceptIcon';
import ConceptFormDrawer from './ConceptFormDrawer';
const ConceptHomeHeader = ({
concept, isVersionedObject, versionedObjectURL, currentURL
}) => {
const isRetired = concept.retired;
const hasAccess = currentUserHasAccess();
const [conceptForm, setConceptForm] = React.useState(false);
return (
<header className='home-header col-md-12'>
<div className='col-md-12 container' style={{paddingTop: '10px'}}>
<ConceptIcon url={currentURL} />
<div className='col-md-11'>
<div className='col-md-12 no-side-padding flex-vertical-center'>
<OwnerButton {...concept} href={versionedObjectURL} />
<span className='separator'>/</span>
<SourceButton label={concept.source} childURI={versionedObjectURL} />
<span className='separator'>/</span>
<ConceptButton label={concept.id} retired={isRetired} href={`#${versionedObjectURL}`} />
{
!isVersionedObject &&
<React.Fragment>
<span className='separator'>/</span>
<VersionButton label={concept.version} retired={isRetired} href={`#${currentURL}`} />
</React.Fragment>
}
{
hasAccess && isVersionedObject &&
<span style={{marginLeft: '8px'}}>
<Tooltip title='Edit Concept'>
<IconButton onClick={() => setConceptForm(true)}>
<EditIcon fontSize='inherit' />
</IconButton>
</Tooltip>
</span>
}
{
hasAccess && isVersionedObject &&
<span style={{marginLeft: '8px'}}>
<Tooltip title='Retire Concept'>
<IconButton>
<DeleteIcon fontSize='inherit' />
</IconButton>
</Tooltip>
</span>
}
</div>
<div className='col-md-12 no-side-padding flex-vertical-center' style={{paddingTop: '5px'}}>
<span style={{marginRight: '10px'}} className={isRetired ? 'retired': ''}>
{concept.display_name}
</span>
<span className='gray-italics-small'>
[{concept.display_locale}]
</span>
</div>
<div className='col-md-12 no-side-padding flex-vertical-center'>
<span className='italic' style={{marginRight: '3px'}}>
Class:
</span>
<span>
{concept.concept_class},
</span>
<span className='italic' style={{marginLeft: '5px', marginRight: '3px'}}>
Datatype:
</span>
<span>
{concept.datatype}
</span>
</div>
<div className='col-md-12 no-side-padding flex-vertical-center'>
<span className='italic' style={{marginRight: '3px'}}>
Custom Attributes:
</span>
<span>
<CustomAttributesPopup attributes={concept.extras} />
</span>
</div>
<div className='col-md-12 no-side-padding flex-vertical-center' style={{marginTop: '2px'}}>
<span>
<LastUpdatedOnLabel
date={concept.updated_on}
by={concept.updated_by}
iconSize='medium'
noContainerClass
/>
</span>
<span style={{marginLeft: '10px'}}>
<LastUpdatedOnLabel
label='Created'
date={concept.created_on}
by={concept.created_by}
iconSize='medium'
noContainerClass
/>
</span>
{
concept.external_id &&
<span style={{marginLeft: '10px', marginTop: '-8px'}}>
<ExternalIdLabel externalId={concept.external_id} iconSize='medium' />
</span>
}
</div>
</div>
</div>
<ConceptFormDrawer reloadOnSuccess edit concept={concept} parentURL={versionedObjectURL} isOpen={conceptForm} onClose={() => setConceptForm(false) } />
</header>
)
}
export default ConceptHomeHeader;