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
119 changes: 110 additions & 9 deletions react/src/components/DeploymentConfigurationSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,58 @@
@license
Copyright (c) 2015-2026 Lablup Inc. All rights reserved.
*/
import { DeploymentConfigurationSectionDeleteMutation } from '../__generated__/DeploymentConfigurationSectionDeleteMutation.graphql';
import type {
DeploymentConfigurationSection_deployment$data,
DeploymentConfigurationSection_deployment$key,
} from '../__generated__/DeploymentConfigurationSection_deployment.graphql';
import type { DeploymentRevisionDetail_revision$key } from '../__generated__/DeploymentRevisionDetail_revision.graphql';
import { useWebUINavigate } from '../hooks';
import DeploymentRevisionDetail from './DeploymentRevisionDetail';
Comment thread
yomybaby marked this conversation as resolved.
import DeploymentRevisionDetailDrawer from './DeploymentRevisionDetailDrawer';
import DeploymentRevisionHistoryTab from './DeploymentRevisionHistoryTab';
import DeploymentSettingModal from './DeploymentSettingModal';
import DeploymentTagChips from './DeploymentTagChips';
import ErrorBoundaryWithNullFallback from './ErrorBoundaryWithNullFallback';
import { EditOutlined, LoadingOutlined, PlusOutlined } from '@ant-design/icons';
import {
DeleteFilled,
EditOutlined,
LoadingOutlined,
MoreOutlined,
PlusOutlined,
} from '@ant-design/icons';
import { useToggle } from 'ahooks';
import {
Alert,
App,
Button,
Descriptions,
Dropdown,
Empty,
Skeleton,
Space,
Typography,
theme,
} from 'antd';
import {
BAICard,
BAIConfirmModalWithInput,
BAIFetchKeyButton,
BAIFlex,
BAIId,
BAIText,
BAIUnmountAfterClose,
BooleanTag,
filterOutEmpty,
toLocalId,
useBAILogger,
useInterval,
} from 'backend.ai-ui';
import { parseAsStringLiteral, useQueryState } from 'nuqs';
import React, { Suspense, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { graphql, useFragment } from 'react-relay';
import { graphql, useFragment, useMutation } from 'react-relay';
import { useLocation } from 'react-router-dom';

interface DeploymentConfigurationSectionProps {
deploymentFrgmt: DeploymentConfigurationSection_deployment$key | null;
Expand Down Expand Up @@ -156,6 +171,10 @@ const DeploymentConfigurationSection: React.FC<

const { t } = useTranslation();
const { token } = theme.useToken();
const { message } = App.useApp();
const { logger } = useBAILogger();
const webuiNavigate = useWebUINavigate();
const location = useLocation();

const deployment = useFragment(
graphql`
Expand Down Expand Up @@ -218,6 +237,47 @@ const DeploymentConfigurationSection: React.FC<
settingModalOpen,
{ setLeft: closeSettingModal, setRight: openSettingModal },
] = useToggle(false);
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);

const [commitDeleteMutation, isInFlightDeleteMutation] =
useMutation<DeploymentConfigurationSectionDeleteMutation>(graphql`
mutation DeploymentConfigurationSectionDeleteMutation(
$input: DeleteDeploymentInput!
) {
deleteModelDeployment(input: $input) {
id
}
}
`);

const deploymentName = deployment?.metadata.name ?? '';
const isAdminContext = location.pathname.startsWith('/admin-deployments');
const listPath = isAdminContext ? '/admin-deployments' : '/deployments';
Comment thread
yomybaby marked this conversation as resolved.

const handleDelete = () => {
if (!deployment?.id) return;
commitDeleteMutation({
variables: {
input: {
id: toLocalId(deployment.id) ?? deployment.id,
},
},
onCompleted: (_response, errors) => {
if (errors && errors.length > 0) {
logger.error('Failed to delete deployment', errors);
message.error(t('deployment.FailedToDeleteDeployment'));
return;
}
message.success(t('deployment.DeploymentDeleted'));
setIsDeleteModalOpen(false);
webuiNavigate(listPath);
},
onError: (error) => {
logger.error('Failed to delete deployment', error);
message.error(t('deployment.FailedToDeleteDeployment'));
},
});
};

const handleShowRevisionDrawer = (
frgmt: DeploymentRevisionDetail_revision$key,
Expand Down Expand Up @@ -249,13 +309,33 @@ const DeploymentConfigurationSection: React.FC<
value=""
onChange={onRefetch}
/>
<Button
icon={<EditOutlined />}
disabled={isDeploymentDestroying}
onClick={openSettingModal}
>
{t('button.Edit')}
</Button>
<Space.Compact>
<Button
icon={<EditOutlined />}
disabled={isDeploymentDestroying}
onClick={openSettingModal}
>
{t('button.Edit')}
</Button>
<Dropdown
trigger={['click']}
menu={{
items: [
{
key: 'delete',
label: t('deployment.DeleteDeployment'),
icon: <DeleteFilled />,
danger: true,
disabled:
isDeploymentDestroying || isInFlightDeleteMutation,
onClick: () => setIsDeleteModalOpen(true),
},
],
}}
>
<Button icon={<MoreOutlined />} aria-label={t('button.More')} />
</Dropdown>
</Space.Compact>
</BAIFlex>
}
styles={{ body: { paddingTop: 0 } }}
Expand Down Expand Up @@ -359,6 +439,27 @@ const DeploymentConfigurationSection: React.FC<
onClose={() => setDrawerState(null)}
/>
</BAIUnmountAfterClose>
<BAIConfirmModalWithInput
open={isDeleteModalOpen}
title={t('deployment.DeleteDeployment')}
content={
<BAIFlex direction="column" gap="md" align="stretch">
<Alert type="warning" title={t('dialog.warning.CannotBeUndone')} />
<BAIFlex>
<Typography.Text style={{ marginRight: token.marginXXS }}>
{t('dialog.TypeNameToConfirmDeletion')}
</Typography.Text>
(<Typography.Text code>{deploymentName}</Typography.Text>)
</BAIFlex>
</BAIFlex>
}
confirmText={deploymentName}
inputProps={{ placeholder: deploymentName }}
okText={t('button.Delete')}
okButtonProps={{ loading: isInFlightDeleteMutation }}
onOk={handleDelete}
onCancel={() => setIsDeleteModalOpen(false)}
/>
</>
);
};
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Generieren",
"GoBackToStartPage": "Zurück zur Seite {{title}}",
"Info": "Info",
"More": "Mehr",
"Move": "Verschieben",
"Next": "Weiter",
"No": "Nein",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Παράγω",
"GoBackToStartPage": "Επιστροφή στη σελίδα {{title}}",
"Info": "Πληροφορίες",
"More": "Περισσότερα",
"Move": "Μετακίνηση",
"Next": "Επόμενο",
"No": "Οχι",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Generate",
"GoBackToStartPage": "Go back to the {{title}} page",
"Info": "Info",
"More": "More",
"Move": "Move",
Comment thread
yomybaby marked this conversation as resolved.
"Next": "Next",
"No": "No",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Genere",
"GoBackToStartPage": "Volver a la página {{title}}",
"Info": "Info",
"More": "Más",
"Move": "Mover",
"Next": "Siguiente",
"No": "No",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Luo",
"GoBackToStartPage": "Palaa sivulle {{title}}",
"Info": "Tiedot",
"More": "Lisää",
"Move": "Siirrä",
"Next": "Seuraava",
"No": "Ei",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "produire",
"GoBackToStartPage": "Retour à la page {{title}}",
"Info": "Info",
"More": "Plus",
"Move": "Déplacer",
"Next": "Suivant",
"No": "Non",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Hasilkan",
"GoBackToStartPage": "Kembali ke halaman {{title}}",
"Info": "Info",
"More": "Selengkapnya",
"Move": "Pindahkan",
"Next": "Berikutnya",
"No": "Tidak",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "creare",
"GoBackToStartPage": "Torna alla pagina {{title}}",
"Info": "Info",
"More": "Altro",
"Move": "Sposta",
"Next": "Avanti",
"No": "No",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "生む",
"GoBackToStartPage": "{{title}}ページに戻る",
"Info": "情報",
"More": "その他",
"Move": "移動",
"Next": "次のページ",
"No": "番号",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "생성하기",
"GoBackToStartPage": "{{title}} 페이지로 돌아가기",
"Info": "정보",
"More": "더보기",
"Move": "이동",
"Next": "다음",
"No": "아니오",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/mn.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Үүсгэх",
"GoBackToStartPage": "{{title}} хуудас руу буцах",
"Info": "Мэдээлэл",
"More": "Дэлгэрэнгүй",
"Move": "Зөөх",
"Next": "Дараачийн",
"No": "Үгүй",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Menjana",
"GoBackToStartPage": "Kembali ke halaman {{title}}",
"Info": "Info",
"More": "Lagi",
"Move": "Pindah",
"Next": "Seterusnya",
"No": "Tidak",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Generować",
"GoBackToStartPage": "Wróć do strony {{title}}",
"Info": "Info",
"More": "Więcej",
"Move": "Przeprowadzka",
"Next": "Następny",
"No": "Nie",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Gerar",
"GoBackToStartPage": "Voltar para a página {{title}}",
"Info": "Info",
"More": "Mais",
"Move": "Mover",
"Next": "Seguinte",
"No": "Não",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Gerar",
"GoBackToStartPage": "Voltar à página {{title}}",
"Info": "Info",
"More": "Mais",
"Move": "Mover",
"Next": "Seguinte",
"No": "Não",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Генерировать",
"GoBackToStartPage": "Вернуться на страницу {{title}}",
"Info": "Информация",
"More": "Ещё",
"Move": "Переместить",
"Next": "Следующий",
"No": "Нет",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "สร้าง",
"GoBackToStartPage": "กลับไปยังหน้า {{title}}",
"Info": "ข้อมูล",
"More": "เพิ่มเติม",
"Move": "เคลื่อนไหว",
"Next": "ถัดไป",
"No": "ไม่",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "üret",
"GoBackToStartPage": "{{title}} sayfasına geri dönün",
"Info": "Bilgi",
"More": "Daha fazla",
"Move": "Hareket",
"Next": "Sonraki",
"No": "Hayır",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "Tạo ra",
"GoBackToStartPage": "Quay lại trang {{title}}",
"Info": "Thông tin",
"More": "Thêm",
"Move": "Di chuyển",
"Next": "Kế tiếp",
"No": "Không",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "产生",
"GoBackToStartPage": "返回 {{title}} 页面",
"Info": "详情",
"More": "更多",
"Move": "移动",
"Next": "下一页",
"No": "不",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
"Generate": "產生",
"GoBackToStartPage": "返回 {{title}} 頁面",
"Info": "詳情",
"More": "更多",
"Move": "移动",
"Next": "下一页",
"No": "不",
Expand Down
Loading