diff --git a/public/app/features/explore/Explore.test.tsx b/public/app/features/explore/Explore.test.tsx index b6d1e7ce14d..0637abe2bdb 100644 --- a/public/app/features/explore/Explore.test.tsx +++ b/public/app/features/explore/Explore.test.tsx @@ -16,10 +16,9 @@ import AutoSizer from 'react-virtualized-auto-sizer'; import { Explore, ExploreProps } from './Explore'; import { scanStopAction } from './state/actionTypes'; import { toggleGraph } from './state/actions'; -import { Provider } from 'react-redux'; -import { configureStore } from 'app/store/configureStore'; import { SecondaryActions } from './SecondaryActions'; import { TraceView } from './TraceView/TraceView'; +import { getTheme } from '@grafana/ui'; const dummyProps: ExploreProps = { changeSize: jest.fn(), @@ -119,20 +118,7 @@ const dummyProps: ExploreProps = { }, originPanelId: 1, addQueryRow: jest.fn(), -}; - -const setup = (renderMethod: any, propOverrides?: Partial) => { - const store = configureStore(); - return renderMethod( - - - - ); + theme: getTheme(), }; const setupErrors = (hasRefId?: boolean) => { @@ -148,7 +134,7 @@ const setupErrors = (hasRefId?: boolean) => { describe('Explore', () => { it('should render component', () => { - const wrapper = setup(shallow); + const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 2f0637ee87e..e98051ae888 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -10,7 +10,7 @@ import memoizeOne from 'memoize-one'; import store from 'app/core/store'; // Components -import { ErrorBoundaryAlert, stylesFactory } from '@grafana/ui'; +import { ErrorBoundaryAlert, stylesFactory, withTheme } from '@grafana/ui'; import LogsContainer from './LogsContainer'; import QueryRows from './QueryRows'; import TableContainer from './TableContainer'; @@ -39,6 +39,7 @@ import { TimeZone, LoadingState, ExploreMode, + GrafanaTheme, } from '@grafana/data'; import { ExploreId, ExploreItemState, ExploreUIState, ExploreUpdateState, ExploreUrlState } from 'app/types/explore'; @@ -61,8 +62,9 @@ import { scanStopAction } from './state/actionTypes'; import { ExploreGraphPanel } from './ExploreGraphPanel'; import { TraceView } from './TraceView/TraceView'; import { SecondaryActions } from './SecondaryActions'; +import { compose } from 'redux'; -const getStyles = stylesFactory(() => { +const getStyles = stylesFactory((theme: GrafanaTheme) => { return { logsMain: css` label: logsMain; @@ -71,8 +73,15 @@ const getStyles = stylesFactory(() => { margin-top: 21px; `, button: css` + label: button; 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; originPanelId: number; addQueryRow: typeof addQueryRow; + theme: GrafanaTheme; } interface ExploreState { @@ -291,10 +301,11 @@ export class Explore extends React.PureComponent { queryResponse, syncedTimes, isLive, + theme, } = this.props; const { showRichHistory } = this.state; const exploreClass = split ? 'explore explore-split' : 'explore'; - const styles = getStyles(); + const styles = getStyles(theme); const StartPage = datasourceInstance?.components?.ExploreStartPage; const showStartPage = !queryResponse || queryResponse.state === LoadingState.NotStarted; @@ -308,18 +319,16 @@ export class Explore extends React.PureComponent { {datasourceMissing ? this.renderEmptyState() : null} {datasourceInstance && (
-
-
- - -
+
+ +
@@ -491,7 +500,8 @@ const mapDispatchToProps: Partial = { addQueryRow, }; -export default hot(module)( - // @ts-ignore - connect(mapStateToProps, mapDispatchToProps)(Explore) -) as React.ComponentType<{ exploreId: ExploreId }>; +export default compose( + hot(module), + connect(mapStateToProps, mapDispatchToProps), + withTheme +)(Explore) as React.ComponentType<{ exploreId: ExploreId }>; diff --git a/public/app/features/explore/__snapshots__/Explore.test.tsx.snap b/public/app/features/explore/__snapshots__/Explore.test.tsx.snap index 1ce9e949c29..2f20a32111d 100644 --- a/public/app/features/explore/__snapshots__/Explore.test.tsx.snap +++ b/public/app/features/explore/__snapshots__/Explore.test.tsx.snap @@ -1,147 +1,50 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Explore should render component 1`] = ` - - - +
+
+ + +
+ + + + +
+
`;