diff --git a/dashboard/src/actions/overviewActions.js b/dashboard/src/actions/overviewActions.js index 0e011bc317..48cd0e0e30 100644 --- a/dashboard/src/actions/overviewActions.js +++ b/dashboard/src/actions/overviewActions.js @@ -1,11 +1,12 @@ 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"; -import { expandUriTemplate } from "../utils/helper"; export const getDatasets = () => async (dispatch, getState) => { const alreadyRendered = getState().overview.loadingDone; @@ -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) { @@ -129,14 +130,26 @@ export const updateDataset = (item) => item.resource_id === dataset.resource_id ); runs[dataIndex].metadata[metaDataActions[actionType]] = - response.data[metaDataActions[actionType]]; + response.data.metadata[metaDataActions[actionType]]; dispatch({ type: TYPES.USER_RUNS, 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?.message)); + 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 }); @@ -193,6 +206,12 @@ export const setSelectedRuns = (rows) => { }; }; +export const setSelectedSavedRuns = (rows) => { + return { + type: TYPES.SELECTED_SAVED_RUNS, + payload: rows, + }; +}; export const updateMultipleDataset = (method, value) => (dispatch, getState) => { const selectedRuns = getState().overview.selectedRuns; @@ -245,7 +264,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/actions/types.js b/dashboard/src/actions/types.js index bf93b1b038..9a6580aa21 100644 --- a/dashboard/src/actions/types.js +++ b/dashboard/src/actions/types.js @@ -43,6 +43,7 @@ export const SELECTED_NEW_RUNS = "SELECTED_NEW_RUNS"; export const EXPIRING_RUNS = "EXPIRING_RUNS"; export const SET_DASHBOARD_LOADING = "SET_DASHBOARD_LOADING"; export const SET_LOADING_FLAG = "SET_LOADING_FLAG"; +export const SELECTED_SAVED_RUNS = "SELECTED_SAVED_RUNS"; /* TABLE OF CONTENT */ export const GET_TOC_DATA = "GET_TOC_DATA"; 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/NewRunsComponent.jsx b/dashboard/src/modules/components/OverviewComponent/NewRunsComponent.jsx index f7e28f4701..bd35aa9404 100644 --- a/dashboard/src/modules/components/OverviewComponent/NewRunsComponent.jsx +++ b/dashboard/src/modules/components/OverviewComponent/NewRunsComponent.jsx @@ -147,6 +147,7 @@ const NewRunsComponent = () => { selectAllRuns(isSelecting), isSelected: areAllRunsSelected, }} + style={{ borderTop: "1px solid #d2d2d2" }} >
{item?.message}
} + {item?.message && + item?.message.split("\n").map((i, key) => { + return{i}
; + })} ))} diff --git a/dashboard/src/reducers/overviewReducer.js b/dashboard/src/reducers/overviewReducer.js index ac9f5a5349..c755c3ae3e 100644 --- a/dashboard/src/reducers/overviewReducer.js +++ b/dashboard/src/reducers/overviewReducer.js @@ -7,6 +7,7 @@ const initialState = { defaultPerPage: 5, initNewRuns: [], selectedRuns: [], + selectedSavedRuns: [], expiringRuns: [], loadingDone: !!sessionStorage.getItem("loadingDone"), }; @@ -37,7 +38,12 @@ const OverviewReducer = (state = initialState, action = {}) => { case TYPES.SELECTED_NEW_RUNS: return { ...state, - selectedRuns: payload, + selectedRuns: [...payload], + }; + case TYPES.SELECTED_SAVED_RUNS: + return { + ...state, + selectedSavedRuns: [...payload], }; case TYPES.EXPIRING_RUNS: return {