-
Notifications
You must be signed in to change notification settings - Fork 12
/
RowComponent.jsx
44 lines (41 loc) · 2.18 KB
/
RowComponent.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
import React from 'react';
import { Divider, Checkbox } from '@mui/material';
import { includes } from 'lodash';
import Concept from '../concepts/Concept';
import Mapping from '../mappings/Mapping';
import Source from '../sources/Source';
import Collection from '../collections/Collection';
import Organization from '../orgs/Organization';
import User from '../users/User';
const RowComponent = ({resource, item, onSelect, viewFields, history, currentLayoutURL}) => {
const isSourceChild = includes(['concepts', 'mappings'], resource);
const getComponent = () => {
if(resource === 'concepts')
return <Concept {...item} viewFields={viewFields} history={history} currentLayoutURL={currentLayoutURL} style={{paddingLeft: '10px'}} />;
if(resource === 'mappings')
return <Mapping {...item} viewFields={viewFields} history={history} currentLayoutURL={currentLayoutURL} style={{paddingLeft: '10px'}} />;
if(resource === 'sources')
return <Source {...item} viewFields={viewFields} history={history} currentLayoutURL={currentLayoutURL} style={{paddingLeft: '10px'}} />;
if(resource === 'collections')
return <Collection {...item} viewFields={viewFields} history={history} currentLayoutURL={currentLayoutURL} style={{paddingLeft: '10px'}} />;
if(resource === 'organizations')
return <Organization {...item} viewFields={viewFields} history={history} currentLayoutURL={currentLayoutURL} style={{paddingLeft: '10px'}} />;
if(resource === 'users')
return <User {...item} viewFields={viewFields} history={history} currentLayoutURL={currentLayoutURL} style={{paddingLeft: '10px'}} />;
}
return (
<div className='col-sm-12 no-side-padding' key={item.uuid || item.id} style={{width: '100%'}}>
{
isSourceChild &&
<div className='col-sm-1 no-left-padding' style={{textAlign: 'right', maxWidth: '2%'}}>
<Checkbox size='small' onChange={event => onSelect(event, item.url)} />
</div>
}
<div className='col-sm-11 no-right-padding' style={{maxWidth: '97%', overflow: 'auto'}}>
{getComponent()}
</div>
<Divider style={{width: '100%', display: 'inline-block'}} />
</div>
)
}
export default RowComponent;