diff --git a/dashboard/src/actions/overviewActions.js b/dashboard/src/actions/overviewActions.js index 0af36b7216..cf6f9ed9f7 100644 --- a/dashboard/src/actions/overviewActions.js +++ b/dashboard/src/actions/overviewActions.js @@ -1,8 +1,9 @@ import * as CONSTANTS from "assets/constants/overviewConstants"; import * as TYPES from "./types"; +import { DANGER, ERROR_MSG } from "assets/constants/toastConstants"; + import API from "../utils/axiosInstance"; -import { DANGER } from "assets/constants/toastConstants"; import { expandUriTemplate } from "../utils/helper"; import { findNoOfDays } from "utils/dateFunctions"; import { showToast } from "./toastActions"; @@ -41,7 +42,7 @@ export const getDatasets = () => async (dispatch, getState) => { } } } catch (error) { - dispatch(showToast(DANGER, error?.response?.data?.message)); + dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG)); dispatch({ type: TYPES.NETWORK_ERROR }); } if (alreadyRendered) { @@ -135,8 +136,20 @@ export const updateDataset = payload: runs, }); dispatch(initializeRuns()); + + const errors = response.data?.errors; + if (errors && Object.keys(errors).length > 0) { + let errorText = ""; + + for (const [key, value] of Object.entries(errors)) { + errorText += `${key} : ${value} \n`; + } + dispatch( + showToast("warning", "Problem updating metadata", errorText) + ); + } } else { - dispatch(showToast(DANGER, response?.data?.errors)); + dispatch(showToast(DANGER, response?.data?.message ?? ERROR_MSG)); } } catch (error) { dispatch(showToast(DANGER, error?.response?.data?.message)); @@ -173,7 +186,7 @@ export const deleteDataset = (dataset) => async (dispatch, getState) => { dispatch(showToast(CONSTANTS.SUCCESS, "Deleted!")); } } catch (error) { - dispatch(showToast(DANGER, error?.response?.data?.message)); + dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG)); dispatch({ type: TYPES.NETWORK_ERROR }); } dispatch({ type: TYPES.COMPLETED }); @@ -245,7 +258,7 @@ export const publishDataset = dispatch(showToast(CONSTANTS.SUCCESS, "Updated!")); } } catch (error) { - dispatch(showToast(DANGER, error?.response?.data?.message)); + dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG)); dispatch({ type: TYPES.NETWORK_ERROR }); } dispatch({ type: TYPES.COMPLETED }); diff --git a/dashboard/src/assets/constants/toastConstants.js b/dashboard/src/assets/constants/toastConstants.js index 161cfe59fc..1de50fbef6 100644 --- a/dashboard/src/assets/constants/toastConstants.js +++ b/dashboard/src/assets/constants/toastConstants.js @@ -1 +1,2 @@ export const DANGER = "danger"; +export const ERROR_MSG = "Something went wrong!"; diff --git a/dashboard/src/modules/components/OverviewComponent/index.less b/dashboard/src/modules/components/OverviewComponent/index.less index 1b7df4c605..291c95d983 100644 --- a/dashboard/src/modules/components/OverviewComponent/index.less +++ b/dashboard/src/modules/components/OverviewComponent/index.less @@ -56,14 +56,14 @@ .pf-c-scroll-outer-wrapper { min-height: 100%; } - .unseen-row { - background-color: #efefef; - } } .pf-c-pagination { padding: 0; } } + .unseen-row { + background-color: #efefef; + } } .separator { margin: 3vh 0; diff --git a/dashboard/src/modules/components/ToastNotificationComponent/index.jsx b/dashboard/src/modules/components/ToastNotificationComponent/index.jsx index 703eb79941..2b317b126f 100644 --- a/dashboard/src/modules/components/ToastNotificationComponent/index.jsx +++ b/dashboard/src/modules/components/ToastNotificationComponent/index.jsx @@ -33,7 +33,10 @@ const ToastComponent = () => { /> } > - {item?.message &&
{item?.message}
} + {item?.message && + item?.message.split("\n").map((i, key) => { + return{i}
; + })} ))}