import {Fragment} from 'react'; import {Link} from 'react-router'; import GridEditable, { COL_WIDTH_UNDEFINED, GridColumnHeader, GridColumnOrder, } from 'sentry/components/gridEditable'; import Pagination from 'sentry/components/pagination'; import {t} from 'sentry/locale'; import {useLocation} from 'sentry/utils/useLocation'; import {ValidSort} from 'sentry/views/performance/browser/resources/imageView/utils/useImageResourceSort'; import {useIndexedResourcesQuery} from 'sentry/views/performance/browser/resources/imageView/utils/useIndexedResourcesQuery'; import ResourceSize from 'sentry/views/performance/browser/resources/shared/resourceSize'; import {DurationCell} from 'sentry/views/starfish/components/tableCells/durationCell'; import {renderHeadCell} from 'sentry/views/starfish/components/tableCells/renderHeadCell'; import {WiderHovercard} from 'sentry/views/starfish/components/tableCells/spanDescriptionCell'; import {SpanMetricsField} from 'sentry/views/starfish/types'; const {SPAN_DESCRIPTION, SPAN_SELF_TIME, HTTP_RESPONSE_CONTENT_LENGTH} = SpanMetricsField; type Row = { 'http.response_content_length': number; id: string; project: string; 'resource.render_blocking_status': '' | 'non-blocking' | 'blocking'; 'span.description': string; 'span.self_time': number; }; type Column = GridColumnHeader; type Props = { sort: ValidSort; }; function ResourceTable({sort}: Props) { const location = useLocation(); const {data, isLoading, pageLinks} = useIndexedResourcesQuery(); const columnOrder: GridColumnOrder[] = [ {key: SPAN_DESCRIPTION, width: COL_WIDTH_UNDEFINED, name: 'Resource name'}, {key: `${SPAN_SELF_TIME}`, width: COL_WIDTH_UNDEFINED, name: 'Duration'}, { key: HTTP_RESPONSE_CONTENT_LENGTH, width: COL_WIDTH_UNDEFINED, name: t('Resource size'), }, ]; const tableData: Row[] = data.length ? data.map(span => ({ ...span, 'http.decoded_response_content_length': Math.floor( Math.random() * (1000 - 500) + 500 ), })) : []; const renderBodyCell = (col: Column, row: Row) => { const {key} = col; if (key === SPAN_DESCRIPTION) { return ( } > {row[key]} ); } if (key === 'http.response_content_length') { return ; } if (key === `span.self_time`) { return ; } return {row[key]}; }; return ( renderHeadCell({ column, location, sort, }), renderBodyCell, }} location={location} /> ); } export default ResourceTable;