Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
"searchPlaceholder": "Search Connections",
"test": "Test Connection",
"testDisabled": "Test connection feature is disabled. Please contact an administrator to enable it.",
"testError": {
"title": "Test Connection Failed"
},
"testSuccess": {
"title": "Test Connection Successful"
},
"typeMeta": {
"error": "Failed to retrieve Connection Type Meta",
"standardFields": {
Expand Down
21 changes: 20 additions & 1 deletion airflow-core/src/airflow/ui/src/queries/useTestConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,31 @@
* under the License.
*/
import type { Dispatch, SetStateAction } from "react";
import { useTranslation } from "react-i18next";

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

export const useTestConnection = (setConnected: Dispatch<SetStateAction<boolean | undefined>>) => {
const onSuccess = (res: ConnectionTestResponse) => setConnected(res.status);
const { t: translate } = useTranslation("admin");

const onSuccess = (res: ConnectionTestResponse) => {
setConnected(res.status);
if (res.status) {
toaster.create({
description: res.message,
title: translate("connections.testSuccess.title"),
type: "success",
});
} else {
toaster.create({
description: res.message,
title: translate("connections.testError.title"),
type: "error",
});
}
};

const onError = () => {
setConnected(false);
Expand Down