Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug event alert toast on test query #1105

Merged
merged 3 commits into from
Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions frontend/src/components/EventAlertForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const EventAlertForm = ({
const { kpiFormLoading, kpiFormData, testQueryData } = useSelector(
(state) => state.kpiExplorer
);

const [testqrylocal, setTestqrylocal] = useState(testQueryData);
const [option, setOption] = useState([]);
const [datasourceid, setDataSourceId] = useState(undefined);
const [query, setQuery] = useState(undefined);
Expand Down Expand Up @@ -94,8 +94,13 @@ const EventAlertForm = ({
if (alertFormData.data_source === 0 || alertFormData.data_source === null) {
obj['data_source'] = 'Enter Data Source';
}
if (alertFormData.alert_query === '') {
obj['alert_query'] = 'Enter Query';
if (
alertFormData.alert_query === '' ||
testqrylocal === undefined ||
testqrylocal?.data?.status === undefined ||
testqrylocal?.data?.status === 'failure'
) {
obj['alert_query'] = 'Enter Valid Query and Test';
}
if (alertFormData.alert_settings === '') {
obj['alert_settings'] = 'Enter Alert Settings';
Expand Down Expand Up @@ -167,20 +172,30 @@ const EventAlertForm = ({
}, [kpiFormData, connectionType]);

useEffect(() => {
if (testQueryData && testQueryData?.status === 'success') {
setTestqrylocal(testQueryData);
if (
testQueryData &&
testQueryData?.data &&
testQueryData?.data?.status === 'success'
) {
customToast({
type: 'success',
header: 'Test Connection Successful',
description: testQueryData.msg
description: testQueryData?.data?.msg
});
}
if (testQueryData && testQueryData?.status === 'failure') {
if (
testQueryData &&
testQueryData?.data &&
testQueryData?.data?.status === 'failure'
) {
customToast({
type: 'error',
header: 'Test Connection Failed',
description: testQueryData.msg
description: testQueryData?.data?.msg
});
}
setError({ ...error, alert_query: '' });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [testQueryData]);

Expand Down Expand Up @@ -426,6 +441,7 @@ const EventAlertForm = ({
...alertFormData,
alert_query: e.target.value
});
setTestqrylocal(undefined);
}}></textarea>
<div className="test-query-connection">
<div className="test-query" onClick={() => onTestQuery()}>
Expand Down