Skip to content

Commit 53a4d56

Browse files
[v3-1-test] Add toaster notifications for Connection Test (#59354) (#59368)
* Add toaster notifications for Test Connection * refactor: move test connection translations to admin.json (cherry picked from commit acce763) Co-authored-by: Yeonguk Choo <choo121600@gmail.com>
1 parent ac38f6f commit 53a4d56

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

airflow-core/src/airflow/ui/public/i18n/locales/en/admin.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
"searchPlaceholder": "Search Connections",
5050
"test": "Test Connection",
5151
"testDisabled": "Test connection feature is disabled. Please contact an administrator to enable it.",
52+
"testError": {
53+
"title": "Test Connection Failed"
54+
},
55+
"testSuccess": {
56+
"title": "Test Connection Successful"
57+
},
5258
"typeMeta": {
5359
"error": "Failed to retrieve Connection Type Meta",
5460
"standardFields": {

airflow-core/src/airflow/ui/src/queries/useTestConnection.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,31 @@
1717
* under the License.
1818
*/
1919
import type { Dispatch, SetStateAction } from "react";
20+
import { useTranslation } from "react-i18next";
2021

2122
import { useConnectionServiceTestConnection } from "openapi/queries";
2223
import type { ConnectionTestResponse } from "openapi/requests/types.gen";
24+
import { toaster } from "src/components/ui";
2325

2426
export const useTestConnection = (setConnected: Dispatch<SetStateAction<boolean | undefined>>) => {
25-
const onSuccess = (res: ConnectionTestResponse) => setConnected(res.status);
27+
const { t: translate } = useTranslation("admin");
28+
29+
const onSuccess = (res: ConnectionTestResponse) => {
30+
setConnected(res.status);
31+
if (res.status) {
32+
toaster.create({
33+
description: res.message,
34+
title: translate("connections.testSuccess.title"),
35+
type: "success",
36+
});
37+
} else {
38+
toaster.create({
39+
description: res.message,
40+
title: translate("connections.testError.title"),
41+
type: "error",
42+
});
43+
}
44+
};
2645

2746
const onError = () => {
2847
setConnected(false);

0 commit comments

Comments
 (0)