mirror of
https://github.com/strapi/strapi.git
synced 2025-11-16 10:07:55 +00:00
Move react-query conf in StrapiApp
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
d6c1016859
commit
25c8bbd60e
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
|
import { QueryClientProvider, QueryClient } from 'react-query';
|
||||||
import configureStore from './core/store/configureStore';
|
import configureStore from './core/store/configureStore';
|
||||||
import basename from './utils/basename';
|
import basename from './utils/basename';
|
||||||
import App from './containers/App';
|
import App from './containers/App';
|
||||||
@ -19,6 +20,14 @@ window.strapi = {
|
|||||||
backendURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
backendURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const queryClient = new QueryClient({
|
||||||
|
defaultOptions: {
|
||||||
|
queries: {
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
class StrapiApp {
|
class StrapiApp {
|
||||||
plugins = {};
|
plugins = {};
|
||||||
|
|
||||||
@ -40,10 +49,10 @@ class StrapiApp {
|
|||||||
const store = configureStore(this);
|
const store = configureStore(this);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<QueryClientProvider client={queryClient}>
|
||||||
|
<Theme>
|
||||||
<GlobalStyle />
|
<GlobalStyle />
|
||||||
<Fonts />
|
<Fonts />
|
||||||
<Theme>
|
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<LanguageProvider messages={translationMessages}>
|
<LanguageProvider messages={translationMessages}>
|
||||||
<>
|
<>
|
||||||
@ -55,7 +64,7 @@ class StrapiApp {
|
|||||||
</LanguageProvider>
|
</LanguageProvider>
|
||||||
</Provider>
|
</Provider>
|
||||||
</Theme>
|
</Theme>
|
||||||
</>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import { Switch, Route } from 'react-router-dom';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators, compose } from 'redux';
|
import { bindActionCreators, compose } from 'redux';
|
||||||
import { LoadingIndicatorPage, auth, request } from '@strapi/helper-plugin';
|
import { LoadingIndicatorPage, auth, request } from '@strapi/helper-plugin';
|
||||||
import { QueryClientProvider, QueryClient } from 'react-query';
|
|
||||||
|
|
||||||
import Admin from '../Admin';
|
import Admin from '../Admin';
|
||||||
import AuthPage from '../AuthPage';
|
import AuthPage from '../AuthPage';
|
||||||
@ -29,14 +28,6 @@ window.strapi = Object.assign(window.strapi || {}, {
|
|||||||
lockAppWithOverlay: () => console.log('todo unlockAppWithOverlay'),
|
lockAppWithOverlay: () => console.log('todo unlockAppWithOverlay'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
|
||||||
defaultOptions: {
|
|
||||||
queries: {
|
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function App(props) {
|
function App(props) {
|
||||||
const getDataRef = useRef();
|
const getDataRef = useRef();
|
||||||
const [{ isLoading, hasAdmin }, setState] = useState({ isLoading: true, hasAdmin: false });
|
const [{ isLoading, hasAdmin }, setState] = useState({ isLoading: true, hasAdmin: false });
|
||||||
@ -120,7 +111,6 @@ function App(props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<QueryClientProvider client={queryClient}>
|
|
||||||
<Content>
|
<Content>
|
||||||
<Switch>
|
<Switch>
|
||||||
{authRoutes}
|
{authRoutes}
|
||||||
@ -135,7 +125,6 @@ function App(props) {
|
|||||||
<Route path="" component={NotFoundPage} />
|
<Route path="" component={NotFoundPage} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</Content>
|
</Content>
|
||||||
</QueryClientProvider>
|
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,133 @@ describe('ADMIN | StrapiApp', () => {
|
|||||||
it('should render the app without plugins', () => {
|
it('should render the app without plugins', () => {
|
||||||
const app = StrapiApp({});
|
const app = StrapiApp({});
|
||||||
|
|
||||||
render(app.render());
|
expect(render(app.render())).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"asFragment": [Function],
|
||||||
|
"baseElement": .c1 {
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -webkit-flex;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
|
-webkit-flex-direction: column;
|
||||||
|
-ms-flex-direction: column;
|
||||||
|
flex-direction: column;
|
||||||
|
-webkit-box-pack: space-around;
|
||||||
|
-webkit-justify-content: space-around;
|
||||||
|
-ms-flex-pack: space-around;
|
||||||
|
justify-content: space-around;
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.c1 > div {
|
||||||
|
margin: auto;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
border: 6px solid #f3f3f3;
|
||||||
|
border-top: 6px solid #1c91e7;
|
||||||
|
border-radius: 50%;
|
||||||
|
-webkit-animation: fEWCgj 2s linear infinite;
|
||||||
|
animation: fEWCgj 2s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.c0 {
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -webkit-flex;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
|
-webkit-align-items: center;
|
||||||
|
-webkit-box-align: center;
|
||||||
|
-ms-flex-align: center;
|
||||||
|
align-items: center;
|
||||||
|
-webkit-flex-direction: column;
|
||||||
|
-ms-flex-direction: column;
|
||||||
|
flex-direction: column;
|
||||||
|
position: fixed;
|
||||||
|
top: 72px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 1100;
|
||||||
|
list-style: none;
|
||||||
|
width: 100%;
|
||||||
|
overflow-y: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="c0"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="c1"
|
||||||
|
>
|
||||||
|
<div />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>,
|
||||||
|
"container": <div>
|
||||||
|
<div
|
||||||
|
class="sc-fTxPal krAKpM"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="Loader-sc-1xt0x01-0 JXMaR"
|
||||||
|
>
|
||||||
|
<div />
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
"debug": [Function],
|
||||||
|
"findAllByAltText": [Function],
|
||||||
|
"findAllByDisplayValue": [Function],
|
||||||
|
"findAllByLabelText": [Function],
|
||||||
|
"findAllByPlaceholderText": [Function],
|
||||||
|
"findAllByRole": [Function],
|
||||||
|
"findAllByTestId": [Function],
|
||||||
|
"findAllByText": [Function],
|
||||||
|
"findAllByTitle": [Function],
|
||||||
|
"findByAltText": [Function],
|
||||||
|
"findByDisplayValue": [Function],
|
||||||
|
"findByLabelText": [Function],
|
||||||
|
"findByPlaceholderText": [Function],
|
||||||
|
"findByRole": [Function],
|
||||||
|
"findByTestId": [Function],
|
||||||
|
"findByText": [Function],
|
||||||
|
"findByTitle": [Function],
|
||||||
|
"getAllByAltText": [Function],
|
||||||
|
"getAllByDisplayValue": [Function],
|
||||||
|
"getAllByLabelText": [Function],
|
||||||
|
"getAllByPlaceholderText": [Function],
|
||||||
|
"getAllByRole": [Function],
|
||||||
|
"getAllByTestId": [Function],
|
||||||
|
"getAllByText": [Function],
|
||||||
|
"getAllByTitle": [Function],
|
||||||
|
"getByAltText": [Function],
|
||||||
|
"getByDisplayValue": [Function],
|
||||||
|
"getByLabelText": [Function],
|
||||||
|
"getByPlaceholderText": [Function],
|
||||||
|
"getByRole": [Function],
|
||||||
|
"getByTestId": [Function],
|
||||||
|
"getByText": [Function],
|
||||||
|
"getByTitle": [Function],
|
||||||
|
"queryAllByAltText": [Function],
|
||||||
|
"queryAllByDisplayValue": [Function],
|
||||||
|
"queryAllByLabelText": [Function],
|
||||||
|
"queryAllByPlaceholderText": [Function],
|
||||||
|
"queryAllByRole": [Function],
|
||||||
|
"queryAllByTestId": [Function],
|
||||||
|
"queryAllByText": [Function],
|
||||||
|
"queryAllByTitle": [Function],
|
||||||
|
"queryByAltText": [Function],
|
||||||
|
"queryByDisplayValue": [Function],
|
||||||
|
"queryByLabelText": [Function],
|
||||||
|
"queryByPlaceholderText": [Function],
|
||||||
|
"queryByRole": [Function],
|
||||||
|
"queryByTestId": [Function],
|
||||||
|
"queryByText": [Function],
|
||||||
|
"queryByTitle": [Function],
|
||||||
|
"rerender": [Function],
|
||||||
|
"unmount": [Function],
|
||||||
|
}
|
||||||
|
`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user