Fix: Propagate unhandled errors when saving Dashboard (#24081)
* only handle error for cases we handle * added missing case * remove not used import
This commit is contained in:
@@ -25,7 +25,7 @@ export const SaveDashboardErrorProxy: React.FC<SaveDashboardErrorProxyProps> = (
|
|||||||
const { onDashboardSave } = useDashboardSave(dashboard);
|
const { onDashboardSave } = useDashboardSave(dashboard);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error.data) {
|
if (error.data && isHandledError(error.data.status)) {
|
||||||
error.isHandled = true;
|
error.isHandled = true;
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@@ -106,6 +106,18 @@ const ConfirmPluginDashboardSaveModal: React.FC<SaveDashboardModalProps> = ({ on
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isHandledError = (errorStatus: string) => {
|
||||||
|
switch (errorStatus) {
|
||||||
|
case 'version-mismatch':
|
||||||
|
case 'name-exists':
|
||||||
|
case 'plugin-dashboard':
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getConfirmPluginDashboardSaveModalStyles = stylesFactory((theme: GrafanaTheme) => ({
|
const getConfirmPluginDashboardSaveModalStyles = stylesFactory((theme: GrafanaTheme) => ({
|
||||||
modal: css`
|
modal: css`
|
||||||
width: 500px;
|
width: 500px;
|
||||||
|
|||||||
Reference in New Issue
Block a user