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" }} > {columnNames.result} {columnNames.endtime} diff --git a/dashboard/src/modules/components/OverviewComponent/SavedRunsComponent.jsx b/dashboard/src/modules/components/OverviewComponent/SavedRunsComponent.jsx index 33c62a5b7c..dd0d3400a7 100644 --- a/dashboard/src/modules/components/OverviewComponent/SavedRunsComponent.jsx +++ b/dashboard/src/modules/components/OverviewComponent/SavedRunsComponent.jsx @@ -20,7 +20,7 @@ import { editMetadata, publishDataset, setRowtoEdit, - setSelectedRuns, + setSelectedSavedRuns, updateDataset, } from "actions/overviewActions"; import { useDispatch, useSelector } from "react-redux"; @@ -29,23 +29,25 @@ import { SavedRunsRow } from "./common-component"; const SavedRunsComponent = () => { const dispatch = useDispatch(); - const { savedRuns, selectedRuns } = useSelector((state) => state.overview); + const { savedRuns, selectedSavedRuns } = useSelector( + (state) => state.overview + ); /* Selecting */ const areAllRunsSelected = - savedRuns?.length > 0 && savedRuns?.length === selectedRuns?.length; + savedRuns?.length > 0 && savedRuns?.length === selectedSavedRuns?.length; const selectAllRuns = (isSelecting) => { - dispatch(setSelectedRuns(isSelecting ? [...savedRuns] : [])); + dispatch(setSelectedSavedRuns(isSelecting ? [...savedRuns] : [])); }; const onSelectRuns = (run, _rowIndex, isSelecting) => { - const otherSelectedRuns = selectedRuns.filter( + const otherSelectedRuns = selectedSavedRuns.filter( (r) => r.resource_id !== run.resource_id ); const c = isSelecting ? [...otherSelectedRuns, run] : otherSelectedRuns; - dispatch(setSelectedRuns(c)); + dispatch(setSelectedSavedRuns(c)); }; const isRowSelected = (run) => - selectedRuns.filter((item) => item.name === run.name).length > 0; + selectedSavedRuns.filter((item) => item.name === run.name).length > 0; /* Selecting */ /* Actions Row */ @@ -107,6 +109,7 @@ const SavedRunsComponent = () => { selectAllRuns(isSelecting), isSelected: areAllRunsSelected, }} + style={{ borderTop: "1px solid #d2d2d2" }} > {columnNames.result} {columnNames.uploadedtime} diff --git a/dashboard/src/modules/components/OverviewComponent/index.less b/dashboard/src/modules/components/OverviewComponent/index.less index 1b7df4c605..56bfa2d351 100644 --- a/dashboard/src/modules/components/OverviewComponent/index.less +++ b/dashboard/src/modules/components/OverviewComponent/index.less @@ -4,9 +4,6 @@ .bordered { border: 1px solid #d2d2d2; } - .pf-c-table__check:first-child { - border-top: 1px solid #d2d2d2; - } .pf-c-accordion__expanded-content.pf-m-expanded { height: 100%; } @@ -50,20 +47,18 @@ } .newruns-table-container { height: 90%; - .pf-c-table__check { - border-top: 1px solid #d2d2d2; - } + .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}

; + })} ))} 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 {