Skip to content

Commit 8932900

Browse files
authored
Update metadata (#3361)
Fix dashboard metadata update so that save/seen/favorite will work.
1 parent 8518937 commit 8932900

File tree

8 files changed

+54
-25
lines changed

8 files changed

+54
-25
lines changed

dashboard/src/actions/overviewActions.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
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";
7+
import { expandUriTemplate } from "../utils/helper";
68
import { findNoOfDays } from "utils/dateFunctions";
79
import { showToast } from "./toastActions";
8-
import { expandUriTemplate } from "../utils/helper";
910

1011
export const getDatasets = () => async (dispatch, getState) => {
1112
const alreadyRendered = getState().overview.loadingDone;
@@ -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) {
@@ -129,14 +130,26 @@ export const updateDataset =
129130
(item) => item.resource_id === dataset.resource_id
130131
);
131132
runs[dataIndex].metadata[metaDataActions[actionType]] =
132-
response.data[metaDataActions[actionType]];
133+
response.data.metadata[metaDataActions[actionType]];
133134
dispatch({
134135
type: TYPES.USER_RUNS,
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?.message));
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 });
@@ -193,6 +206,12 @@ export const setSelectedRuns = (rows) => {
193206
};
194207
};
195208

209+
export const setSelectedSavedRuns = (rows) => {
210+
return {
211+
type: TYPES.SELECTED_SAVED_RUNS,
212+
payload: rows,
213+
};
214+
};
196215
export const updateMultipleDataset =
197216
(method, value) => (dispatch, getState) => {
198217
const selectedRuns = getState().overview.selectedRuns;
@@ -245,7 +264,7 @@ export const publishDataset =
245264
dispatch(showToast(CONSTANTS.SUCCESS, "Updated!"));
246265
}
247266
} catch (error) {
248-
dispatch(showToast(DANGER, error?.response?.data?.message));
267+
dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG));
249268
dispatch({ type: TYPES.NETWORK_ERROR });
250269
}
251270
dispatch({ type: TYPES.COMPLETED });

dashboard/src/actions/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const SELECTED_NEW_RUNS = "SELECTED_NEW_RUNS";
4343
export const EXPIRING_RUNS = "EXPIRING_RUNS";
4444
export const SET_DASHBOARD_LOADING = "SET_DASHBOARD_LOADING";
4545
export const SET_LOADING_FLAG = "SET_LOADING_FLAG";
46+
export const SELECTED_SAVED_RUNS = "SELECTED_SAVED_RUNS";
4647

4748
/* TABLE OF CONTENT */
4849
export const GET_TOC_DATA = "GET_TOC_DATA";
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/NewRunsComponent.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ const NewRunsComponent = () => {
147147
selectAllRuns(isSelecting),
148148
isSelected: areAllRunsSelected,
149149
}}
150+
style={{ borderTop: "1px solid #d2d2d2" }}
150151
></Th>
151152
<Th width={35}>{columnNames.result}</Th>
152153
<Th width={25}>{columnNames.endtime}</Th>

dashboard/src/modules/components/OverviewComponent/SavedRunsComponent.jsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
editMetadata,
2121
publishDataset,
2222
setRowtoEdit,
23-
setSelectedRuns,
23+
setSelectedSavedRuns,
2424
updateDataset,
2525
} from "actions/overviewActions";
2626
import { useDispatch, useSelector } from "react-redux";
@@ -29,23 +29,25 @@ import { SavedRunsRow } from "./common-component";
2929

3030
const SavedRunsComponent = () => {
3131
const dispatch = useDispatch();
32-
const { savedRuns, selectedRuns } = useSelector((state) => state.overview);
32+
const { savedRuns, selectedSavedRuns } = useSelector(
33+
(state) => state.overview
34+
);
3335

3436
/* Selecting */
3537
const areAllRunsSelected =
36-
savedRuns?.length > 0 && savedRuns?.length === selectedRuns?.length;
38+
savedRuns?.length > 0 && savedRuns?.length === selectedSavedRuns?.length;
3739
const selectAllRuns = (isSelecting) => {
38-
dispatch(setSelectedRuns(isSelecting ? [...savedRuns] : []));
40+
dispatch(setSelectedSavedRuns(isSelecting ? [...savedRuns] : []));
3941
};
4042
const onSelectRuns = (run, _rowIndex, isSelecting) => {
41-
const otherSelectedRuns = selectedRuns.filter(
43+
const otherSelectedRuns = selectedSavedRuns.filter(
4244
(r) => r.resource_id !== run.resource_id
4345
);
4446
const c = isSelecting ? [...otherSelectedRuns, run] : otherSelectedRuns;
45-
dispatch(setSelectedRuns(c));
47+
dispatch(setSelectedSavedRuns(c));
4648
};
4749
const isRowSelected = (run) =>
48-
selectedRuns.filter((item) => item.name === run.name).length > 0;
50+
selectedSavedRuns.filter((item) => item.name === run.name).length > 0;
4951
/* Selecting */
5052

5153
/* Actions Row */
@@ -107,6 +109,7 @@ const SavedRunsComponent = () => {
107109
selectAllRuns(isSelecting),
108110
isSelected: areAllRunsSelected,
109111
}}
112+
style={{ borderTop: "1px solid #d2d2d2" }}
110113
></Th>
111114
<Th>{columnNames.result}</Th>
112115
<Th>{columnNames.uploadedtime}</Th>

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
.bordered {
55
border: 1px solid #d2d2d2;
66
}
7-
.pf-c-table__check:first-child {
8-
border-top: 1px solid #d2d2d2;
9-
}
107
.pf-c-accordion__expanded-content.pf-m-expanded {
118
height: 100%;
129
}
@@ -50,20 +47,18 @@
5047
}
5148
.newruns-table-container {
5249
height: 90%;
53-
.pf-c-table__check {
54-
border-top: 1px solid #d2d2d2;
55-
}
50+
5651
.pf-c-scroll-outer-wrapper {
5752
min-height: 100%;
5853
}
59-
.unseen-row {
60-
background-color: #efefef;
61-
}
6254
}
6355
.pf-c-pagination {
6456
padding: 0;
6557
}
6658
}
59+
.unseen-row {
60+
background-color: #efefef;
61+
}
6762
}
6863
.separator {
6964
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>

dashboard/src/reducers/overviewReducer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const initialState = {
77
defaultPerPage: 5,
88
initNewRuns: [],
99
selectedRuns: [],
10+
selectedSavedRuns: [],
1011
expiringRuns: [],
1112
loadingDone: !!sessionStorage.getItem("loadingDone"),
1213
};
@@ -37,7 +38,12 @@ const OverviewReducer = (state = initialState, action = {}) => {
3738
case TYPES.SELECTED_NEW_RUNS:
3839
return {
3940
...state,
40-
selectedRuns: payload,
41+
selectedRuns: [...payload],
42+
};
43+
case TYPES.SELECTED_SAVED_RUNS:
44+
return {
45+
...state,
46+
selectedSavedRuns: [...payload],
4147
};
4248
case TYPES.EXPIRING_RUNS:
4349
return {

0 commit comments

Comments
 (0)