mirror of https://github.com/grafana/grafana
AppChrome: Unify logic for chromeless pages that should not have NavBar, CommandPalette, Search etc (#62281)
* Keybindings: No global keybindings on chromeless pages * simplify condition * Refactoring * Align name and file * Move logic into AppChrome * minor fix * Update Page.tsx * Fixing test * Fixed tests * More fixes * Fixed more tests * Fixing final test * Fixed search in old navpull/62777/head
parent
ce50168b70
commit
b8e7ef48d0
@ -1,7 +1,32 @@ |
|||||||
|
import { ToolkitStore } from '@reduxjs/toolkit/dist/configureStore'; |
||||||
import React from 'react'; |
import React from 'react'; |
||||||
|
import { Provider } from 'react-redux'; |
||||||
|
import { Router } from 'react-router-dom'; |
||||||
|
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; |
||||||
|
|
||||||
const TestProvider = ({ children }: React.PropsWithChildren<{}>) => { |
import { locationService } from '@grafana/runtime'; |
||||||
return <>{children}</>; |
import { GrafanaContext, GrafanaContextType } from 'app/core/context/GrafanaContext'; |
||||||
}; |
import { configureStore } from 'app/store/configureStore'; |
||||||
|
import { StoreState } from 'app/types/store'; |
||||||
|
|
||||||
export default TestProvider; |
export interface Props { |
||||||
|
storeState?: Partial<StoreState>; |
||||||
|
store?: ToolkitStore; |
||||||
|
children: React.ReactNode; |
||||||
|
grafanaContext?: GrafanaContextType; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Wrapps component in redux store provider, Router and GrafanaContext |
||||||
|
*/ |
||||||
|
export function TestProvider(props: Props) { |
||||||
|
const { store = configureStore(props.storeState), grafanaContext = getGrafanaContextMock(), children } = props; |
||||||
|
|
||||||
|
return ( |
||||||
|
<Provider store={store}> |
||||||
|
<Router history={locationService.getHistory()}> |
||||||
|
<GrafanaContext.Provider value={grafanaContext}>{children}</GrafanaContext.Provider> |
||||||
|
</Router> |
||||||
|
</Provider> |
||||||
|
); |
||||||
|
} |
||||||
|
|||||||
Loading…
Reference in new issue