Skip to content

Commit

Permalink
display metadata errors on update
Browse files Browse the repository at this point in the history
  • Loading branch information
MVarshini committed Mar 27, 2023
1 parent 903bf17 commit a5c00a8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
23 changes: 18 additions & 5 deletions dashboard/src/actions/overviewActions.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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 });
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/assets/constants/toastConstants.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const DANGER = "danger";
export const ERROR_MSG = "Something went wrong!";
6 changes: 3 additions & 3 deletions dashboard/src/modules/components/OverviewComponent/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ const ToastComponent = () => {
/>
}
>
{item?.message && <p>{item?.message}</p>}
{item?.message &&
item?.message.split("\n").map((i, key) => {
return <p key={i}>{i}</p>;
})}
</Alert>
))}
</AlertGroup>
Expand Down

0 comments on commit a5c00a8

Please sign in to comment.