-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathsftpFailureModal.tsx
More file actions
61 lines (58 loc) · 1.78 KB
/
sftpFailureModal.tsx
File metadata and controls
61 lines (58 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
@license
Copyright (c) 2015-2026 Lablup Inc. All rights reserved.
*/
import { App, GlobalToken, Typography } from 'antd';
import { useErrorMessageResolver } from 'backend.ai-ui';
import { TFunction } from 'i18next';
type ModalInstance = ReturnType<typeof App.useApp>['modal'];
type GetErrorMessage = ReturnType<
typeof useErrorMessageResolver
>['getErrorMessage'];
interface OpenSFTPFailureModalArgs {
modal: ModalInstance;
t: TFunction;
token: GlobalToken;
error: unknown;
getErrorMessage: GetErrorMessage;
onGoToUploadSessions: () => void;
}
/**
* Opens the SFTP session creation failure modal.
*
* Shared by `SFTPServerButton` and `SFTPServerButtonV2` (the legacy and
* Relay-node variants) so that copy, classification, and the recovery CTA
* stay in sync. Uses `modal.error` with `okCancel` to keep the native
* error styling (icon + colors) while still exposing a primary action
* that deep-links to the upload session list — the failure shown here is
* typically downstream of stale upload sessions piling up.
*/
export const openSFTPFailureModal = ({
modal,
t,
token,
error,
getErrorMessage,
onGoToUploadSessions,
}: OpenSFTPFailureModalArgs) => {
modal.error({
okCancel: true,
title: t('data.explorer.SFTPSessionCreationFailed'),
content: (
<Typography.Paragraph
style={{ marginTop: token.marginSM, marginBottom: 0 }}
>
<Typography.Text>
{getErrorMessage(error, { verbosity: 'detail' })}
</Typography.Text>
<br />
<Typography.Text type="secondary">
{t('data.explorer.SFTPSessionFailureHint')}
</Typography.Text>
</Typography.Paragraph>
),
okText: t('session.GoToUploadSessionList'),
cancelText: t('button.Close'),
onOk: onGoToUploadSessions,
});
};