Skip to content

Commit fdc8636

Browse files
committed
add error toast when data source id is undefined
Signed-off-by: Jackie Han <jkhanjob@gmail.com>
1 parent 8a94a9b commit fdc8636

File tree

1 file changed

+14
-8
lines changed
  • public/pages/DetectorsList/containers/List

1 file changed

+14
-8
lines changed

public/pages/DetectorsList/containers/List/List.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,20 @@ export const DetectorList = (props: ListProps) => {
576576
});
577577
};
578578

579-
const handleDataSourceChange = (e) => {
580-
const dataConnectionId = e[0] ? e[0].id : undefined;
581-
582-
setState({
583-
...state,
584-
page: 0,
585-
selectedDataSourceId: dataConnectionId,
586-
});
579+
const handleDataSourceChange = ([selectedDataSource]) => {
580+
const dataSourceId = selectedDataSource?.id;
581+
582+
if (!dataSourceId) {
583+
core.notifications.toasts.addDanger(
584+
prettifyErrorMessage('Unable to set data source.')
585+
);
586+
} else {
587+
setState((prevState) => ({
588+
...prevState,
589+
page: 0,
590+
selectedDataSourceId: dataSourceId,
591+
}));
592+
}
587593
};
588594

589595
const getConfirmModal = () => {

0 commit comments

Comments
 (0)