mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* WIP: intial commit * Switch: Adds tooltip * Refactor: Adds props to LogsPanelEditor * Refactor: Moves LogRowContextProvider to grafana/ui * Refactor: Moves LogRowContext and Alert to grafana/ui * Refactor: Moves LogLabelStats to grafana/ui * Refactor: Moves LogLabels and LogLabel to grafana/ui * Refactor: Moves LogMessageAnsi and ansicolor to grafana/ui * Refactor: Moves calculateFieldStats, LogsParsers and getParser to grafana/data * Refactor: Moves findHighlightChunksInText to grafana/data * Refactor: Moves LogRow to grafana/ui * Refactor: Moving ExploreGraphPanel to grafana/ui * Refactor: Copies Logs to grafana/ui * Refactor: Moves ToggleButtonGroup to grafana/ui * Refactor: Adds Logs to LogsPanel * Refactor: Moves styles to emotion * Feature: Adds LogsRows * Refactor: Introduces render limit * Styles: Moves styles to emotion * Styles: Moves styles to emotion * Styles: Moves styles to emotion * Styles: Moves styles to emotion * Refactor: Adds sorting to LogsPanelEditor * Tests: Adds tests for sorting * Refactor: Changes according to PR comments * Refactor: Changes according to PR comments * Refactor: Moves Logs and ExploreGraphPanel out of grafana/ui * Fix: Shows the Show context label again
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { hot } from 'react-hot-loader';
|
|
import { connect } from 'react-redux';
|
|
import { LoadingState } from '@grafana/data';
|
|
import { Collapse } from '@grafana/ui';
|
|
|
|
import { ExploreId, ExploreItemState } from 'app/types/explore';
|
|
import { StoreState } from 'app/types';
|
|
|
|
import { toggleTable } from './state/actions';
|
|
import Table from './Table';
|
|
import TableModel from 'app/core/table_model';
|
|
|
|
interface TableContainerProps {
|
|
exploreId: ExploreId;
|
|
loading: boolean;
|
|
onClickCell: (key: string, value: string) => void;
|
|
showingTable: boolean;
|
|
tableResult?: TableModel;
|
|
toggleTable: typeof toggleTable;
|
|
}
|
|
|
|
export class TableContainer extends PureComponent<TableContainerProps> {
|
|
onClickTableButton = () => {
|
|
this.props.toggleTable(this.props.exploreId, this.props.showingTable);
|
|
};
|
|
|
|
render() {
|
|
const { loading, onClickCell, showingTable, tableResult } = this.props;
|
|
|
|
return (
|
|
<Collapse label="Table" loading={loading} collapsible isOpen={showingTable} onToggle={this.onClickTableButton}>
|
|
{tableResult && <Table data={tableResult} loading={loading} onClickCell={onClickCell} />}
|
|
</Collapse>
|
|
);
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state: StoreState, { exploreId }: { exploreId: string }) {
|
|
const explore = state.explore;
|
|
// @ts-ignore
|
|
const item: ExploreItemState = explore[exploreId];
|
|
const { loadingState, showingTable, tableResult } = item;
|
|
const loading =
|
|
tableResult && tableResult.rows.length > 0
|
|
? false
|
|
: loadingState === LoadingState.Loading || loadingState === LoadingState.Streaming;
|
|
return { loading, showingTable, tableResult };
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
toggleTable,
|
|
};
|
|
|
|
export default hot(module)(
|
|
connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(TableContainer)
|
|
);
|