mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Frontend: Auto reload page when chunk is not found (#33445)
This commit is contained in:
parent
20ee0e9601
commit
3a93313f75
@ -1,6 +1,7 @@
|
|||||||
import React, { FunctionComponent } from 'react';
|
import React, { FunctionComponent } from 'react';
|
||||||
import { Button, stylesFactory } from '@grafana/ui';
|
import { Button, stylesFactory } from '@grafana/ui';
|
||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
|
import { useUrlParams } from 'app/core/navigation/hooks';
|
||||||
|
|
||||||
const getStyles = stylesFactory(() => {
|
const getStyles = stylesFactory(() => {
|
||||||
return css`
|
return css`
|
||||||
@ -13,7 +14,15 @@ interface Props {
|
|||||||
error: Error | null;
|
error: Error | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ErrorLoadingChunk: FunctionComponent<Props> = ({ error }) => (
|
export const ErrorLoadingChunk: FunctionComponent<Props> = ({ error }) => {
|
||||||
|
const [params, updateUrlParams] = useUrlParams();
|
||||||
|
|
||||||
|
if (!params.get('chunkNotFound')) {
|
||||||
|
updateUrlParams({ chunkNotFound: true }, true);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<div className={getStyles()}>
|
<div className={getStyles()}>
|
||||||
<h2>Unable to find application file</h2>
|
<h2>Unable to find application file</h2>
|
||||||
<br />
|
<br />
|
||||||
@ -30,6 +39,7 @@ export const ErrorLoadingChunk: FunctionComponent<Props> = ({ error }) => (
|
|||||||
{error && error.stack ? error.stack : null}
|
{error && error.stack ? error.stack : null}
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
ErrorLoadingChunk.displayName = 'ErrorLoadingChunk';
|
ErrorLoadingChunk.displayName = 'ErrorLoadingChunk';
|
||||||
|
Loading…
Reference in New Issue
Block a user