mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Inspect: Use AutoSizer for managing width for content in tabs. (#21511)
* wrap content in autosizer * replace lib * removing react-virtualized, correct type in editor.ts * remove caret * remove dep from grafana/ui and remove story util
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
|
||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||
import { JSONFormatter, Drawer, Select, Table, TabsBar, Tab, TabContent } from '@grafana/ui';
|
||||
@@ -106,7 +107,7 @@ export class PanelInspector extends PureComponent<Props, State> {
|
||||
return <metaDS.components.MetadataInspector datasource={metaDS} data={data} />;
|
||||
}
|
||||
|
||||
renderDataTab() {
|
||||
renderDataTab(width: number) {
|
||||
const { data, selected } = this.state;
|
||||
if (!data || !data.length) {
|
||||
return <div>No Data</div>;
|
||||
@@ -140,7 +141,7 @@ export class PanelInspector extends PureComponent<Props, State> {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Table width={330} height={400} data={processed[selected]} />
|
||||
<Table width={width} height={400} data={processed[selected]} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -174,17 +175,28 @@ export class PanelInspector extends PureComponent<Props, State> {
|
||||
})}
|
||||
</TabsBar>
|
||||
<TabContent>
|
||||
{tab === InspectTab.Data && this.renderDataTab()}
|
||||
<AutoSizer disableHeight>
|
||||
{({ width }) => {
|
||||
if (width === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div style={{ width }}>
|
||||
{tab === InspectTab.Data && this.renderDataTab(width)}
|
||||
|
||||
{tab === InspectTab.Meta && this.renderMetadataInspector()}
|
||||
{tab === InspectTab.Meta && this.renderMetadataInspector()}
|
||||
|
||||
{tab === InspectTab.Issue && this.renderIssueTab()}
|
||||
{tab === InspectTab.Issue && this.renderIssueTab()}
|
||||
|
||||
{tab === InspectTab.Raw && (
|
||||
<div>
|
||||
<JSONFormatter json={last} open={2} />
|
||||
</div>
|
||||
)}
|
||||
{tab === InspectTab.Raw && (
|
||||
<div>
|
||||
<JSONFormatter json={last} open={2} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
</AutoSizer>
|
||||
</TabContent>
|
||||
</Drawer>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user