import {Component, Fragment} from 'react'; import PropTypes from 'prop-types'; import Button from 'sentry/components/button'; import GridEditable from 'sentry/components/gridEditable'; const COLUMN_ORDER = [ { key: 'farm', name: 'farm', width: -1, }, { key: 'count(apple)', name: 'apples sold', width: -1, }, { key: 'count(banana)', name: 'banana sold', width: -1, }, ]; const COLUMN_SORT_BY = [ { key: 'count(apple)', order: -1, }, ]; const DATA = [ { farm: 'Old McDonalds', 'count(apple)': 100, 'count(banana)': 500, 'count(cherry)': 200, 'count(date)': 400, 'count(eggplant)': 600, }, { farm: 'Animal Farm', 'count(apple)': 900, 'count(banana)': 600, 'count(cherry)': 200, 'count(date)': 500, 'count(eggplant)': 700, }, { farm: 'Avocado Toast Farm', 'count(apple)': 700, 'count(banana)': 600, 'count(cherry)': 500, 'count(date)': 400, 'count(eggplant)': 500, }, ]; class GridParent extends Component { static propTypes = { withHeader: PropTypes.bool, title: PropTypes.string, }; state = { columnOrder: [...COLUMN_ORDER], columnSortBy: [...COLUMN_SORT_BY], }; handleResizeColumn = (index, newColumn) => { const columnOrder = [...this.state.columnOrder]; columnOrder[index] = {...columnOrder[index], width: newColumn.width}; this.setState({columnOrder}); }; render() { const {withHeader, title} = this.props; const headerButtons = withHeader ? () => : null; return ( ); } } export default { title: 'Components/Tables/GridEditable', }; export const Default = () => (

Basic Table

); Default.storyName = 'default'; Default.parameters = { docs: { description: { story: 'Render a simple resizable table', }, }, }; export const WithAHeader = () => (

Table with title & header buttons

); WithAHeader.storyName = 'with a header'; WithAHeader.parameters = { docs: { description: { story: 'Include a header and action buttons', }, }, }; export const IsLoading = () => (

Loading

); IsLoading.storyName = 'isLoading'; export const IsError = () => (

Error

); IsError.storyName = 'isError';