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

+41 -18
View File
@@ -1,14 +1,13 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './googleCloud.css';
import { withTranslation } from 'react-i18next';
import { Icon } from 'react-viewerbase';
export default class DatasetsList extends Component {
constructor(props) {
super(props);
this.state = {
search: '',
};
}
class DatasetsList extends Component {
state = {
search: '',
};
static propTypes = {
datasets: PropTypes.array,
@@ -16,16 +15,19 @@ export default class DatasetsList extends Component {
error: PropTypes.string,
onSelect: PropTypes.func,
};
static defaultProps = {};
renderTableRow(dataset) {
static defaultProps = {
loading: true,
};
renderTableRow = dataset => {
return (
<tr
key={dataset.name}
className={
this.state.highlightedItem === dataset.name
? 'studylistStudy noselect active'
: 'studylistStudy noselect'
? 'noselect active'
: 'noselect'
}
onMouseEnter={() => {
this.onHighlightItem(dataset.name);
@@ -37,21 +39,42 @@ export default class DatasetsList extends Component {
<td>{dataset.name.split('/')[5]}</td>
</tr>
);
}
};
onHighlightItem(dataset) {
this.setState({ highlightedItem: dataset });
}
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="DatasetList">
{this.props.datasets.map(this.renderTableRow)}
</tbody>
);
return (
<table id="tblDatasetList" className="studyListToolbar table noselect">
<tbody id="DatasetList">
{this.props.datasets.map(dataset => {
return this.renderTableRow(dataset);
})}
</tbody>
<table id="tblDatasetList" className="gcp-table table noselect">
<thead>
<tr>
<th>{this.props.t('Dataset')}</th>
</tr>
</thead>
{this.props.datasets && body}
</table>
);
}
}
export default withTranslation('Common')(DatasetsList);