mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Prevents sizing issue when split (#23596)
* Update tests * Remove imports
This commit is contained in:
parent
6937f3549b
commit
28543e11ba
@ -16,10 +16,9 @@ import AutoSizer from 'react-virtualized-auto-sizer';
|
|||||||
import { Explore, ExploreProps } from './Explore';
|
import { Explore, ExploreProps } from './Explore';
|
||||||
import { scanStopAction } from './state/actionTypes';
|
import { scanStopAction } from './state/actionTypes';
|
||||||
import { toggleGraph } from './state/actions';
|
import { toggleGraph } from './state/actions';
|
||||||
import { Provider } from 'react-redux';
|
|
||||||
import { configureStore } from 'app/store/configureStore';
|
|
||||||
import { SecondaryActions } from './SecondaryActions';
|
import { SecondaryActions } from './SecondaryActions';
|
||||||
import { TraceView } from './TraceView/TraceView';
|
import { TraceView } from './TraceView/TraceView';
|
||||||
|
import { getTheme } from '@grafana/ui';
|
||||||
|
|
||||||
const dummyProps: ExploreProps = {
|
const dummyProps: ExploreProps = {
|
||||||
changeSize: jest.fn(),
|
changeSize: jest.fn(),
|
||||||
@ -119,20 +118,7 @@ const dummyProps: ExploreProps = {
|
|||||||
},
|
},
|
||||||
originPanelId: 1,
|
originPanelId: 1,
|
||||||
addQueryRow: jest.fn(),
|
addQueryRow: jest.fn(),
|
||||||
};
|
theme: getTheme(),
|
||||||
|
|
||||||
const setup = (renderMethod: any, propOverrides?: Partial<ExploreProps>) => {
|
|
||||||
const store = configureStore();
|
|
||||||
return renderMethod(
|
|
||||||
<Provider store={store}>
|
|
||||||
<Explore
|
|
||||||
{...{
|
|
||||||
...dummyProps,
|
|
||||||
...propOverrides,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Provider>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const setupErrors = (hasRefId?: boolean) => {
|
const setupErrors = (hasRefId?: boolean) => {
|
||||||
@ -148,7 +134,7 @@ const setupErrors = (hasRefId?: boolean) => {
|
|||||||
|
|
||||||
describe('Explore', () => {
|
describe('Explore', () => {
|
||||||
it('should render component', () => {
|
it('should render component', () => {
|
||||||
const wrapper = setup(shallow);
|
const wrapper = shallow(<Explore {...dummyProps} />);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import memoizeOne from 'memoize-one';
|
|||||||
import store from 'app/core/store';
|
import store from 'app/core/store';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { ErrorBoundaryAlert, stylesFactory } from '@grafana/ui';
|
import { ErrorBoundaryAlert, stylesFactory, withTheme } from '@grafana/ui';
|
||||||
import LogsContainer from './LogsContainer';
|
import LogsContainer from './LogsContainer';
|
||||||
import QueryRows from './QueryRows';
|
import QueryRows from './QueryRows';
|
||||||
import TableContainer from './TableContainer';
|
import TableContainer from './TableContainer';
|
||||||
@ -39,6 +39,7 @@ import {
|
|||||||
TimeZone,
|
TimeZone,
|
||||||
LoadingState,
|
LoadingState,
|
||||||
ExploreMode,
|
ExploreMode,
|
||||||
|
GrafanaTheme,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
|
|
||||||
import { ExploreId, ExploreItemState, ExploreUIState, ExploreUpdateState, ExploreUrlState } from 'app/types/explore';
|
import { ExploreId, ExploreItemState, ExploreUIState, ExploreUpdateState, ExploreUrlState } from 'app/types/explore';
|
||||||
@ -61,8 +62,9 @@ import { scanStopAction } from './state/actionTypes';
|
|||||||
import { ExploreGraphPanel } from './ExploreGraphPanel';
|
import { ExploreGraphPanel } from './ExploreGraphPanel';
|
||||||
import { TraceView } from './TraceView/TraceView';
|
import { TraceView } from './TraceView/TraceView';
|
||||||
import { SecondaryActions } from './SecondaryActions';
|
import { SecondaryActions } from './SecondaryActions';
|
||||||
|
import { compose } from 'redux';
|
||||||
|
|
||||||
const getStyles = stylesFactory(() => {
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
||||||
return {
|
return {
|
||||||
logsMain: css`
|
logsMain: css`
|
||||||
label: logsMain;
|
label: logsMain;
|
||||||
@ -71,8 +73,15 @@ const getStyles = stylesFactory(() => {
|
|||||||
margin-top: 21px;
|
margin-top: 21px;
|
||||||
`,
|
`,
|
||||||
button: css`
|
button: css`
|
||||||
|
label: button;
|
||||||
margin: 1em 4px 0 0;
|
margin: 1em 4px 0 0;
|
||||||
`,
|
`,
|
||||||
|
queryContainer: css`
|
||||||
|
label: queryContainer;
|
||||||
|
// Need to override normal css class and don't want to count on ordering of the classes in html.
|
||||||
|
height: auto !important;
|
||||||
|
padding: ${theme.panelPadding}px;
|
||||||
|
`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -112,6 +121,7 @@ export interface ExploreProps {
|
|||||||
queryResponse: PanelData;
|
queryResponse: PanelData;
|
||||||
originPanelId: number;
|
originPanelId: number;
|
||||||
addQueryRow: typeof addQueryRow;
|
addQueryRow: typeof addQueryRow;
|
||||||
|
theme: GrafanaTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ExploreState {
|
interface ExploreState {
|
||||||
@ -291,10 +301,11 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|||||||
queryResponse,
|
queryResponse,
|
||||||
syncedTimes,
|
syncedTimes,
|
||||||
isLive,
|
isLive,
|
||||||
|
theme,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { showRichHistory } = this.state;
|
const { showRichHistory } = this.state;
|
||||||
const exploreClass = split ? 'explore explore-split' : 'explore';
|
const exploreClass = split ? 'explore explore-split' : 'explore';
|
||||||
const styles = getStyles();
|
const styles = getStyles(theme);
|
||||||
const StartPage = datasourceInstance?.components?.ExploreStartPage;
|
const StartPage = datasourceInstance?.components?.ExploreStartPage;
|
||||||
const showStartPage = !queryResponse || queryResponse.state === LoadingState.NotStarted;
|
const showStartPage = !queryResponse || queryResponse.state === LoadingState.NotStarted;
|
||||||
|
|
||||||
@ -308,8 +319,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|||||||
{datasourceMissing ? this.renderEmptyState() : null}
|
{datasourceMissing ? this.renderEmptyState() : null}
|
||||||
{datasourceInstance && (
|
{datasourceInstance && (
|
||||||
<div className="explore-container">
|
<div className="explore-container">
|
||||||
<div className="panel-container">
|
<div className={cx('panel-container', styles.queryContainer)}>
|
||||||
<div className="panel-content">
|
|
||||||
<QueryRows exploreEvents={this.exploreEvents} exploreId={exploreId} queryKeys={queryKeys} />
|
<QueryRows exploreEvents={this.exploreEvents} exploreId={exploreId} queryKeys={queryKeys} />
|
||||||
<SecondaryActions
|
<SecondaryActions
|
||||||
addQueryRowButtonDisabled={isLive}
|
addQueryRowButtonDisabled={isLive}
|
||||||
@ -320,7 +330,6 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|||||||
onClickRichHistoryButton={this.toggleShowRichHistory}
|
onClickRichHistoryButton={this.toggleShowRichHistory}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<ErrorContainer queryError={queryError} />
|
<ErrorContainer queryError={queryError} />
|
||||||
<AutoSizer onResize={this.onResize} disableHeight>
|
<AutoSizer onResize={this.onResize} disableHeight>
|
||||||
{({ width }) => {
|
{({ width }) => {
|
||||||
@ -491,7 +500,8 @@ const mapDispatchToProps: Partial<ExploreProps> = {
|
|||||||
addQueryRow,
|
addQueryRow,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default hot(module)(
|
export default compose(
|
||||||
// @ts-ignore
|
hot(module),
|
||||||
connect(mapStateToProps, mapDispatchToProps)(Explore)
|
connect(mapStateToProps, mapDispatchToProps),
|
||||||
) as React.ComponentType<{ exploreId: ExploreId }>;
|
withTheme
|
||||||
|
)(Explore) as React.ComponentType<{ exploreId: ExploreId }>;
|
||||||
|
@ -1,147 +1,50 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`Explore should render component 1`] = `
|
exports[`Explore should render component 1`] = `
|
||||||
<ContextProvider
|
<div
|
||||||
value={
|
className="explore"
|
||||||
Object {
|
|
||||||
"store": Object {
|
|
||||||
"dispatch": [Function],
|
|
||||||
"getState": [Function],
|
|
||||||
"replaceReducer": [Function],
|
|
||||||
"subscribe": [Function],
|
|
||||||
Symbol(observable): [Function],
|
|
||||||
},
|
|
||||||
"subscription": Subscription {
|
|
||||||
"handleChangeWrapper": [Function],
|
|
||||||
"listeners": Object {
|
|
||||||
"notify": [Function],
|
|
||||||
},
|
|
||||||
"onStateChange": [Function],
|
|
||||||
"parentSub": undefined,
|
|
||||||
"store": Object {
|
|
||||||
"dispatch": [Function],
|
|
||||||
"getState": [Function],
|
|
||||||
"replaceReducer": [Function],
|
|
||||||
"subscribe": [Function],
|
|
||||||
Symbol(observable): [Function],
|
|
||||||
},
|
|
||||||
"unsubscribe": null,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Explore
|
<Connect(UnConnectedExploreToolbar)
|
||||||
absoluteRange={
|
|
||||||
Object {
|
|
||||||
"from": 0,
|
|
||||||
"to": 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addQueryRow={[MockFunction]}
|
|
||||||
changeSize={[MockFunction]}
|
|
||||||
datasourceInstance={
|
|
||||||
Object {
|
|
||||||
"components": Object {
|
|
||||||
"ExploreStartPage": Object {},
|
|
||||||
},
|
|
||||||
"meta": Object {
|
|
||||||
"logs": true,
|
|
||||||
"metrics": true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
datasourceMissing={false}
|
|
||||||
exploreId="left"
|
exploreId="left"
|
||||||
graphResult={Array []}
|
onChangeTime={[Function]}
|
||||||
initialDatasource="test"
|
|
||||||
initialQueries={Array []}
|
|
||||||
initialRange={
|
|
||||||
Object {
|
|
||||||
"from": "2019-01-01T10:00:00.000Z",
|
|
||||||
"raw": Object {
|
|
||||||
"from": "now-6h",
|
|
||||||
"to": "now",
|
|
||||||
},
|
|
||||||
"to": "2019-01-01T16:00:00.000Z",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
initialUI={
|
|
||||||
Object {
|
|
||||||
"showingGraph": false,
|
|
||||||
"showingLogs": false,
|
|
||||||
"showingTable": false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
initializeExplore={[MockFunction]}
|
|
||||||
initialized={true}
|
|
||||||
isLive={false}
|
|
||||||
loading={false}
|
|
||||||
mode="Metrics"
|
|
||||||
modifyQueries={[MockFunction]}
|
|
||||||
onHiddenSeriesChanged={[MockFunction]}
|
|
||||||
originPanelId={1}
|
|
||||||
queryKeys={Array []}
|
|
||||||
queryResponse={
|
|
||||||
Object {
|
|
||||||
"error": Object {},
|
|
||||||
"request": Object {
|
|
||||||
"app": "explore",
|
|
||||||
"dashboardId": 0,
|
|
||||||
"interval": "1s",
|
|
||||||
"panelId": 1,
|
|
||||||
"requestId": "1",
|
|
||||||
"scopedVars": Object {
|
|
||||||
"apps": Object {
|
|
||||||
"value": "value",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"startTime": 0,
|
|
||||||
"targets": Array [
|
|
||||||
Object {
|
|
||||||
"refId": "A",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"timezone": "UTC",
|
|
||||||
},
|
|
||||||
"series": Array [],
|
|
||||||
"state": "NotStarted",
|
|
||||||
"timeRange": Object {
|
|
||||||
"from": "2019-01-01T10:00:00.000Z",
|
|
||||||
"raw": Object {
|
|
||||||
"from": "now-6h",
|
|
||||||
"to": "now",
|
|
||||||
},
|
|
||||||
"to": "2019-01-01T16:00:00.000Z",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
refreshExplore={[MockFunction]}
|
|
||||||
scanRange={
|
|
||||||
Object {
|
|
||||||
"from": "0",
|
|
||||||
"to": "0",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scanStart={[MockFunction]}
|
|
||||||
scanStopAction={[Function]}
|
|
||||||
scanning={false}
|
|
||||||
setQueries={[MockFunction]}
|
|
||||||
showingGraph={false}
|
|
||||||
showingTable={false}
|
|
||||||
split={false}
|
|
||||||
syncedTimes={false}
|
|
||||||
timeZone="UTC"
|
|
||||||
toggleGraph={[Function]}
|
|
||||||
update={
|
|
||||||
Object {
|
|
||||||
"datasource": false,
|
|
||||||
"mode": false,
|
|
||||||
"queries": false,
|
|
||||||
"range": false,
|
|
||||||
"ui": false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateTimeRange={[MockFunction]}
|
|
||||||
/>
|
/>
|
||||||
</ContextProvider>
|
<div
|
||||||
|
className="explore-container"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="panel-container css-1695s01-queryContainer"
|
||||||
|
>
|
||||||
|
<QueryRows
|
||||||
|
exploreEvents={
|
||||||
|
Emitter {
|
||||||
|
"emitter": EventEmitter {
|
||||||
|
"_events": Object {},
|
||||||
|
"_eventsCount": 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exploreId="left"
|
||||||
|
queryKeys={Array []}
|
||||||
|
/>
|
||||||
|
<SecondaryActions
|
||||||
|
addQueryRowButtonDisabled={false}
|
||||||
|
addQueryRowButtonHidden={false}
|
||||||
|
onClickAddQueryRowButton={[Function]}
|
||||||
|
onClickRichHistoryButton={[Function]}
|
||||||
|
richHistoryButtonActive={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Component
|
||||||
|
queryError={Object {}}
|
||||||
|
/>
|
||||||
|
<AutoSizer
|
||||||
|
disableHeight={true}
|
||||||
|
disableWidth={false}
|
||||||
|
onResize={[Function]}
|
||||||
|
style={Object {}}
|
||||||
|
>
|
||||||
|
<Component />
|
||||||
|
</AutoSizer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
|
Loading…
Reference in New Issue
Block a user