refactor(GoogleCloud): Clean up some of the Healthcare API Adapter components (#641)

This commit is contained in:
Erik Ziegler authored and GitHub committed 2019-07-10 14:54:27 +02:00
1 parent 4a09f33446
commit 091cab49e0
21 files changed
+613 -438

No files matched your search

+43 -19
View File
@@ -1,30 +1,33 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './googleCloud.css';
export default class LocationsList extends Component {
constructor(props) {
super(props);
this.state = {
search: '',
};
}
import { withTranslation } from 'react-i18next';
import { Icon } from 'react-viewerbase';
class LocationsList extends Component {
state = {
search: '',
};
static propTypes = {
locations: PropTypes.array,
loading: PropTypes.bool,
loading: PropTypes.bool.isRequired,
error: PropTypes.string,
onSelect: PropTypes.func,
};
static defaultProps = {};
renderTableRow(location) {
static defaultProps = {
loading: true,
};
renderTableRow = location => {
return (
<tr
key={location.locationId}
className={
this.state.highlightedItem === location.locationId
? 'studylistStudy noselect active'
: 'studylistStudy noselect'
? 'noselect active'
: 'noselect'
}
onMouseEnter={() => {
this.onHighlightItem(location.locationId);
@@ -36,21 +39,42 @@ export default class LocationsList extends Component {
<td>{location.name.split('/')[3]}</td>
</tr>
);
}
};
onHighlightItem(locationId) {
this.setState({ highlightedItem: locationId });
}
render() {
if (this.props.error) {
return <p>{this.props.error}</p>;
}
const loadingIcon = (
<Icon name="circle-notch" className="loading-icon-spin loading-icon" />
);
if (this.props.loading) {
return loadingIcon;
}
const body = (
<tbody id="LocationList">
{this.props.locations.map(this.renderTableRow)}
</tbody>
);
return (
<table id="tblLocationList" className="studyListToolbar table noselect">
<tbody id="LocationList">
{this.props.locations.map(project => {
return this.renderTableRow(project);
})}
</tbody>
<table id="tblLocationList" className="gcp-table table noselect">
<thead>
<tr>
<th>{this.props.t('Location')}</th>
</tr>
</thead>
{this.props.locations && body}
</table>
);
}
}
export default withTranslation('Common')(LocationsList);