Skip to content

Commit 12b358b

Browse files
committed
feat(FR-1797): migrate app launcher related code to React
1 parent 7c8ad20 commit 12b358b

14 files changed

Lines changed: 1805 additions & 326 deletions

react/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"@ant-design/colors": "^7.2.1",
1010
"@ant-design/cssinjs": "^2.0.1",
1111
"@ant-design/icons": "^6.1.0",
12-
"@ant-design/v5-patch-for-react-19": "^1.0.3",
1312
"@ant-design/x": "^2.1.3",
1413
"@cloudscape-design/board-components": "3.0.60",
1514
"@codemirror/lang-jinja": "^6.0.0",
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
'use memo';
2+
3+
import { Typography } from 'antd';
4+
import { BAIButton, BAIFlex, BAIModal, BAIModalProps } from 'backend.ai-ui';
5+
import { useTranslation } from 'react-i18next';
6+
import { graphql, useFragment } from 'react-relay';
7+
import { AppLaunchConfirmationModalFragment$key } from 'src/__generated__/AppLaunchConfirmationModalFragment.graphql';
8+
import { useBackendAIAppLauncher } from 'src/hooks/useBackendAIAppLauncher';
9+
10+
interface AppLaunchConfirmationModalProps extends BAIModalProps {
11+
sessionFrgmt: AppLaunchConfirmationModalFragment$key;
12+
appName: string;
13+
onRequestClose: () => void;
14+
}
15+
16+
/**
17+
* Confirmation modal for apps that require user acknowledgment before launching.
18+
* Used for nniboard and mlflow-ui apps that need to run before tunneling.
19+
*
20+
* This matches the legacy behavior of `_openAppLaunchConfirmationDialog` in
21+
* backend-ai-app-launcher.ts
22+
*/
23+
const AppLaunchConfirmationModal: React.FC<AppLaunchConfirmationModalProps> = ({
24+
sessionFrgmt,
25+
appName,
26+
onRequestClose,
27+
...modalProps
28+
}) => {
29+
const { t } = useTranslation();
30+
31+
const session = useFragment(
32+
graphql`
33+
fragment AppLaunchConfirmationModalFragment on ComputeSessionNode {
34+
id
35+
row_id
36+
name
37+
...useBackendAIAppLauncherFragment
38+
}
39+
`,
40+
sessionFrgmt,
41+
);
42+
43+
const { launchAppWithNotification } = useBackendAIAppLauncher(session);
44+
45+
const handleConfirmAndRun = async () => {
46+
onRequestClose();
47+
48+
await launchAppWithNotification({
49+
app: appName,
50+
onPrepared(workerInfo) {
51+
// Open app in new window after preparation
52+
if (workerInfo.appConnectUrl) {
53+
setTimeout(() => {
54+
window.open(workerInfo.appConnectUrl?.href, '_blank');
55+
}, 1000);
56+
}
57+
},
58+
});
59+
};
60+
61+
return (
62+
<BAIModal
63+
title={t('session.appLauncher.AppMustBeRun')}
64+
onCancel={onRequestClose}
65+
footer={null}
66+
{...modalProps}
67+
>
68+
<BAIFlex direction="column" gap="md" align="stretch">
69+
<Typography.Paragraph>
70+
{t('session.appLauncher.AppMustBeRunDialog')}
71+
</Typography.Paragraph>
72+
<Typography.Paragraph>
73+
{t('dialog.ask.DoYouWantToProceed')}
74+
</Typography.Paragraph>
75+
76+
<BAIButton
77+
type="primary"
78+
size="large"
79+
action={handleConfirmAndRun}
80+
block
81+
>
82+
{t('session.appLauncher.ConfirmAndRun')}
83+
</BAIButton>
84+
</BAIFlex>
85+
</BAIModal>
86+
);
87+
};
88+
89+
export default AppLaunchConfirmationModal;

0 commit comments

Comments
 (0)