Skip to content

Commit

Permalink
fix: TW-83178 S3 storage new UI: Error popup doesn't close automatica…
Browse files Browse the repository at this point in the history
…lly after fixing the settings

Merge-request: TC-MR-7275
Merged-by: Andrei Efimov <Andrei.Efimov@jetbrains.com>
  • Loading branch information
wayfarer-rus authored and qodana-bot committed Oct 13, 2023
1 parent ebd3119 commit 99269f0
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function AwsConnectionDialog({
const [initialized, setInitialized] = React.useState(false);
const [htmlContent, setHtmlContent] = React.useState('');
const popupRef = React.useRef<HTMLDivElement>(null);
const { showErrorAlert } = useErrorService();
const { showErrorAlert, clearAlerts } = useErrorService();

const loadHtmlContent = React.useCallback(async () => {
const url = `/admin/oauth/showConnection.html?providerType=AWS&projectId=${projectId}&connectionId=${awsConnectionIdProp}`;
Expand Down Expand Up @@ -164,11 +164,12 @@ export default function AwsConnectionDialog({

const __onClose = React.useCallback(
(newConnection: AwsConnection | undefined) => {
clearAlerts();
setHtmlContent('');
setInitialized(false);
onClose(newConnection);
},
[onClose]
[clearAlerts, onClose]
);

const collectAwsConnectionFormData = React.useCallback(() => {
Expand Down Expand Up @@ -251,6 +252,8 @@ export default function AwsConnectionDialog({
const newConnectionUseSessionCreds: string | undefined =
formData['prop:awsSessionCredentials'];
const url = 'admin/oauth/connections.html';
clearAlerts();

try {
const result = await post(url, formData);
const errors = parseErrorsFromResponse(
Expand All @@ -271,7 +274,7 @@ export default function AwsConnectionDialog({
} catch (e) {
showErrorAlert(errorMessage(e));
}
}, [__onClose, collectAwsConnectionFormData, showErrorAlert]);
}, [__onClose, clearAlerts, collectAwsConnectionFormData, showErrorAlert]);

const [showSuccessText, setShowSuccessText] = React.useState(false);
const [showErrorText, setShowErrorText] = React.useState(false);
Expand All @@ -280,7 +283,7 @@ export default function AwsConnectionDialog({

const testConnection = React.useCallback(async () => {
const formData = collectAwsConnectionFormData();

clearAlerts();
setShowSuccessText(false);
setShowErrorText(false);
setTestingConnection(true);
Expand All @@ -298,7 +301,7 @@ export default function AwsConnectionDialog({
} finally {
setTestingConnection(false);
}
}, [collectAwsConnectionFormData, showErrorAlert]);
}, [clearAlerts, collectAwsConnectionFormData, showErrorAlert]);

const handleEscapeKey = React.useCallback(
(event: React.KeyboardEvent) => {
Expand Down

0 comments on commit 99269f0

Please sign in to comment.