import React, { Component } from 'react'; import PropTypes from 'prop-types'; import './googleCloud.css'; import { withTranslation } from 'react-i18next'; import { Icon } from '@ohif/ui'; class ProjectsList extends Component { state = { search: '', highlightedItem: null, }; static propTypes = { projects: PropTypes.array, loading: PropTypes.bool.isRequired, error: PropTypes.string, onSelect: PropTypes.func.isRequired, t: PropTypes.func, }; static defaultProps = { loading: true, }; renderTableRow = project => { return ( { this.onHighlightItem(project.projectId); }} onClick={() => { this.onHighlightItem(project.projectId); this.props.onSelect(project); }} > {project.name} {project.projectId} ); }; onHighlightItem(project) { this.setState({ highlightedItem: project }); } render() { const { loading, projects, filter, error } = this.props; if (error) { return

{error}

; } const loadingIcon = ( ); if (loading) { return loadingIcon; } const lowerCaseFilter = filter.toLowerCase(); const filteredProjects = projects.filter(project => typeof project.name === 'string' && (filter === "" || project.name.toLowerCase().includes(lowerCaseFilter)) ); const body = ( { filteredProjects.map(this.renderTableRow) } ); return ( {projects && body}
{this.props.t('Project')} {this.props.t('ID')}
); } } export default withTranslation('Common')(ProjectsList);