From f1ed743b1a08ef3a4affea70ba8e91bf77601357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cdorac-ext=E2=80=9D?= <103416234+doracretu3pillar@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:28:26 +0200 Subject: [PATCH] Close the modal when API response --- .../percona/pmm-dump/SendToSupportModal.tsx | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/public/app/percona/pmm-dump/SendToSupportModal.tsx b/public/app/percona/pmm-dump/SendToSupportModal.tsx index 033e83be07977..ad8b18e3991ec 100644 --- a/public/app/percona/pmm-dump/SendToSupportModal.tsx +++ b/public/app/percona/pmm-dump/SendToSupportModal.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/css'; -import React, { FC } from 'react'; +import React, { FC, useCallback } from 'react'; import { Modal, Button, Form, Field, Input, useStyles2 } from '@grafana/ui'; import { Messages } from 'app/percona/pmm-dump/PMMDump.messages'; @@ -27,19 +27,26 @@ export const SendToSupportModal: FC = ({ onClose, dumpIds }) => { directory: '', }; - const onSubmit = (values: SendToSupportForm) => { - dispatch( - sendToSupportAction({ - sftp_parameters: { - user: values.user, - address: values.address, - password: values.password, - directory: values.directory || undefined, - }, - dump_ids: dumpIds, - }) - ); - }; + const onSubmit = useCallback( + (values: SendToSupportForm) => { + dispatch( + sendToSupportAction({ + sftp_parameters: { + user: values.user, + address: values.address, + password: values.password, + directory: values.directory || undefined, + }, + dump_ids: dumpIds, + }) + ); + + if (!isLoading) { + onClose(); + } + }, + [isLoading, dumpIds, onClose, dispatch] + ); return (