Skip to content

Commit 2e509f7

Browse files
committed
display metadata errors on update
1 parent aaa06f1 commit 2e509f7

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

dashboard/src/actions/overviewActions.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as CONSTANTS from "assets/constants/overviewConstants";
22
import * as TYPES from "./types";
33

4+
import { DANGER, ERROR_MSG } from "assets/constants/toastConstants";
5+
46
import API from "../utils/axiosInstance";
5-
import { DANGER } from "assets/constants/toastConstants";
67
import { expandUriTemplate } from "../utils/helper";
78
import { findNoOfDays } from "utils/dateFunctions";
89
import { showToast } from "./toastActions";
@@ -41,7 +42,7 @@ export const getDatasets = () => async (dispatch, getState) => {
4142
}
4243
}
4344
} catch (error) {
44-
dispatch(showToast(DANGER, error?.response?.data?.message));
45+
dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG));
4546
dispatch({ type: TYPES.NETWORK_ERROR });
4647
}
4748
if (alreadyRendered) {
@@ -135,8 +136,20 @@ export const updateDataset =
135136
payload: runs,
136137
});
137138
dispatch(initializeRuns());
139+
140+
const errors = response.data?.errors;
141+
if (errors && Object.keys(errors).length > 0) {
142+
let errorText = "";
143+
144+
for (const [key, value] of Object.entries(errors)) {
145+
errorText += `${key} : ${value} \n`;
146+
}
147+
dispatch(
148+
showToast("warning", "Problem updating metadata", errorText)
149+
);
150+
}
138151
} else {
139-
dispatch(showToast(DANGER, response?.data?.errors));
152+
dispatch(showToast(DANGER, response?.data?.message ?? ERROR_MSG));
140153
}
141154
} catch (error) {
142155
dispatch(showToast(DANGER, error?.response?.data?.message));
@@ -173,7 +186,7 @@ export const deleteDataset = (dataset) => async (dispatch, getState) => {
173186
dispatch(showToast(CONSTANTS.SUCCESS, "Deleted!"));
174187
}
175188
} catch (error) {
176-
dispatch(showToast(DANGER, error?.response?.data?.message));
189+
dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG));
177190
dispatch({ type: TYPES.NETWORK_ERROR });
178191
}
179192
dispatch({ type: TYPES.COMPLETED });
@@ -245,7 +258,7 @@ export const publishDataset =
245258
dispatch(showToast(CONSTANTS.SUCCESS, "Updated!"));
246259
}
247260
} catch (error) {
248-
dispatch(showToast(DANGER, error?.response?.data?.message));
261+
dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG));
249262
dispatch({ type: TYPES.NETWORK_ERROR });
250263
}
251264
dispatch({ type: TYPES.COMPLETED });
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const DANGER = "danger";
2+
export const ERROR_MSG = "Something went wrong!";

dashboard/src/modules/components/OverviewComponent/index.less

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@
5656
.pf-c-scroll-outer-wrapper {
5757
min-height: 100%;
5858
}
59-
.unseen-row {
60-
background-color: #efefef;
61-
}
6259
}
6360
.pf-c-pagination {
6461
padding: 0;
6562
}
6663
}
64+
.unseen-row {
65+
background-color: #efefef;
66+
}
6767
}
6868
.separator {
6969
margin: 3vh 0;

dashboard/src/modules/components/ToastNotificationComponent/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ const ToastComponent = () => {
3333
/>
3434
}
3535
>
36-
{item?.message && <p>{item?.message}</p>}
36+
{item?.message &&
37+
item?.message.split("\n").map((i, key) => {
38+
return <p key={i}>{i}</p>;
39+
})}
3740
</Alert>
3841
))}
3942
</AlertGroup>

0 commit comments

Comments
 (0)