/** * Copyright 2017 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; import PropTypes from 'prop-types'; import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import DataTable from '../ui/tables/DataTable'; import { DataTableDateFieldCell, DataTableDataFieldCell, DataTableHeaderCell } from '../ui/tables/DataTableCells'; import DataTableColumn from '../ui/tables/DataTableColumn'; import { Loader } from '../ui/Loader'; const messages = defineMessages({ loadingResources: { id: 'StackResourcesTable.loadingResources', defaultMessage: 'Loading Resources...' }, noResourcesAvailable: { id: 'StackResourcesTable.noResourcesAvailable', defaultMessage: 'There are no Resources available.' }, name: { id: 'StackResourcesTable.name', defaultMessage: 'Name' }, status: { id: 'StackResourcesTable.status', defaultMessage: 'Status' }, updatedTime: { id: 'StackResourcesTable.updatedTime', defaultMessage: 'Updated Time' } }); class StackResourcesTable extends React.Component { constructor() { super(); this.state = { filterString: '' }; } renderNoResourcesFound() { return (

); } onFilter(filterString) { this.setState({ filterString: filterString }); } _filterData(filterString, data) { let dataKeys = ['resource_name', 'resource_status']; return filterString ? data.filter(row => { let result = dataKeys.filter(dataKey => row[dataKey].toLowerCase().includes(filterString.toLowerCase()) ); return result.length > 0; }) : data; } render() { let filteredData = this._filterData( this.state.filterString, this.props.resources.toList().toJS() ); return ( } cell={ } /> } cell={ } /> } cell={ } /> ); } } StackResourcesTable.propTypes = { intl: PropTypes.object, isFetchingResources: PropTypes.bool.isRequired, resources: ImmutablePropTypes.map.isRequired }; export default injectIntl(StackResourcesTable);