2019-07-10 09:26:19 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import './googleCloud.css';
|
2019-07-10 14:54:27 +02:00
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
import { Icon } from 'react-viewerbase';
|
2019-07-10 09:26:19 +02:00
|
|
|
|
2019-07-10 14:54:27 +02:00
|
|
|
class DatasetsList extends Component {
|
|
|
|
|
state = {
|
|
|
|
|
search: '',
|
|
|
|
|
};
|
2019-07-10 09:26:19 +02:00
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
|
datasets: PropTypes.array,
|
|
|
|
|
loading: PropTypes.bool,
|
|
|
|
|
error: PropTypes.string,
|
|
|
|
|
onSelect: PropTypes.func,
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-10 14:54:27 +02:00
|
|
|
static defaultProps = {
|
|
|
|
|
loading: true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
renderTableRow = dataset => {
|
2019-07-10 09:26:19 +02:00
|
|
|
return (
|
|
|
|
|
<tr
|
|
|
|
|
key={dataset.name}
|
|
|
|
|
className={
|
|
|
|
|
this.state.highlightedItem === dataset.name
|
2019-07-10 14:54:27 +02:00
|
|
|
? 'noselect active'
|
|
|
|
|
: 'noselect'
|
2019-07-10 09:26:19 +02:00
|
|
|
}
|
|
|
|
|
onMouseEnter={() => {
|
|
|
|
|
this.onHighlightItem(dataset.name);
|
|
|
|
|
}}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
this.props.onSelect(dataset);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<td>{dataset.name.split('/')[5]}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
);
|
2019-07-10 14:54:27 +02:00
|
|
|
};
|
2019-07-10 09:26:19 +02:00
|
|
|
|
|
|
|
|
onHighlightItem(dataset) {
|
|
|
|
|
this.setState({ highlightedItem: dataset });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2019-07-10 14:54:27 +02:00
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
|
2019-07-10 09:26:19 +02:00
|
|
|
return (
|
2019-07-10 14:54:27 +02:00
|
|
|
<table id="tblDatasetList" className="gcp-table table noselect">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>{this.props.t('Dataset')}</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
{this.props.datasets && body}
|
2019-07-10 09:26:19 +02:00
|
|
|
</table>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-10 14:54:27 +02:00
|
|
|
|
|
|
|
|
export default withTranslation('Common')(DatasetsList);
|