11import AccessTokenList from '../components/AccessTokenList' ;
2+ import BAIConfirmModalWithInput from '../components/BAIConfirmModalWithInput' ;
23import DeploymentRevisionList from '../components/DeploymentRevisionList' ;
34import FlexActivityIndicator from '../components/FlexActivityIndicator' ;
45import {
56 CheckOutlined ,
67 CloseOutlined ,
8+ DownOutlined ,
79 ReloadOutlined ,
810} from '@ant-design/icons' ;
911import { useToggle } from 'ahooks' ;
1012import {
13+ Alert ,
1114 App ,
1215 Button ,
1316 Descriptions ,
17+ Dropdown ,
1418 Tag ,
1519 theme ,
1620 Tooltip ,
@@ -30,10 +34,12 @@ import { Suspense, useState, useTransition } from 'react';
3034import { Trans , useTranslation } from 'react-i18next' ;
3135import { graphql , useLazyLoadQuery , useMutation } from 'react-relay' ;
3236import { useParams } from 'react-router-dom' ;
37+ import { DeploymentDetailPageDeleteMutation } from 'src/__generated__/DeploymentDetailPageDeleteMutation.graphql' ;
3338import {
3439 DeploymentDetailPageQuery ,
3540 DeploymentDetailPageQuery$data ,
3641} from 'src/__generated__/DeploymentDetailPageQuery.graphql' ;
42+ import DeploymentModifyModal from 'src/components/DeploymentModifyModal' ;
3743import DeploymentTokenGenerationModal from 'src/components/DeploymentTokenGenerationModal' ;
3844import RevisionCreationModal from 'src/components/RevisionCreationModal' ;
3945import RouteList from 'src/components/RouteList' ;
@@ -60,12 +66,14 @@ const DeploymentDetailPage: React.FC = () => {
6066 useToggle ( ) ;
6167 const [ isTokenGenerationModalOpen , { toggle : toggleTokenGenerationModal } ] =
6268 useToggle ( ) ;
69+ const [ isModifyModalOpen , { toggle : toggleModifyModal } ] = useToggle ( ) ;
70+ const [ isDeleteModalOpen , { toggle : toggleDeleteModal } ] = useToggle ( ) ;
6371
6472 const { deployment } = useLazyLoadQuery < DeploymentDetailPageQuery > (
6573 graphql `
6674 query DeploymentDetailPageQuery($deploymentId: ID!) {
6775 deployment(id: $deploymentId) {
68- id
76+ id @required(action: THROW)
6977 metadata {
7078 name
7179 status
@@ -128,6 +136,7 @@ const DeploymentDetailPage: React.FC = () => {
128136 createdUser {
129137 email
130138 }
139+ ...DeploymentModifyModalFragment
131140 }
132141 }
133142 ` ,
@@ -151,6 +160,19 @@ const DeploymentDetailPage: React.FC = () => {
151160 ` ,
152161 ) ;
153162
163+ const [ commitDeleteDeployment , isInFlightDeleteDeployment ] =
164+ useMutation < DeploymentDetailPageDeleteMutation > ( graphql `
165+ mutation DeploymentDetailPageDeleteMutation(
166+ $input: DeleteModelDeploymentInput!
167+ ) {
168+ deleteModelDeployment(input: $input) {
169+ deployment {
170+ id
171+ }
172+ }
173+ }
174+ ` ) ;
175+
154176 const deploymentInfoItems : DescriptionsProps [ 'items' ] = [
155177 {
156178 key : 'name' ,
@@ -255,7 +277,7 @@ const DeploymentDetailPage: React.FC = () => {
255277 < Typography . Title level = { 3 } style = { { margin : 0 } } >
256278 { deployment ?. metadata ?. name || '' }
257279 </ Typography . Title >
258- < BAIFlex gap = { 'xxs ' } >
280+ < BAIFlex gap = { 'xs ' } >
259281 < Tooltip title = { t ( 'button.Refresh' ) } >
260282 < Button
261283 loading = { isPendingRefetch }
@@ -267,6 +289,34 @@ const DeploymentDetailPage: React.FC = () => {
267289 } }
268290 />
269291 </ Tooltip >
292+ < Button
293+ onClick = { ( ) => {
294+ toggleModifyModal ( ) ;
295+ } }
296+ >
297+ { t ( 'button.Edit' ) }
298+ </ Button >
299+ < Dropdown
300+ menu = { {
301+ items : [
302+ {
303+ key : 'delete' ,
304+ label : t ( 'button.Delete' ) ,
305+ onClick : ( ) => {
306+ toggleDeleteModal ( ) ;
307+ } ,
308+ } ,
309+ ] ,
310+ } }
311+ trigger = { [ 'click' ] }
312+ >
313+ < Button >
314+ < BAIFlex gap = { 'xxs' } >
315+ { t ( 'button.Action' ) }
316+ < DownOutlined />
317+ </ BAIFlex >
318+ </ Button >
319+ </ Dropdown >
270320 </ BAIFlex >
271321 </ BAIFlex >
272322
@@ -489,6 +539,85 @@ const DeploymentDetailPage: React.FC = () => {
489539 toggleTokenGenerationModal ( ) ;
490540 } }
491541 />
542+
543+ < Suspense >
544+ < DeploymentModifyModal
545+ deploymentFrgmt = { deployment }
546+ open = { isModifyModalOpen }
547+ onRequestClose = { ( success ) => {
548+ if ( success ) {
549+ startRefetchTransition ( ( ) => {
550+ updateFetchKey ( ) ;
551+ } ) ;
552+ }
553+ toggleModifyModal ( ) ;
554+ } }
555+ />
556+ </ Suspense >
557+
558+ < BAIConfirmModalWithInput
559+ open = { isDeleteModalOpen }
560+ onOk = { ( ) => {
561+ commitDeleteDeployment ( {
562+ variables : {
563+ input : {
564+ id : deploymentId || '' ,
565+ } ,
566+ } ,
567+ onCompleted : ( res , errors ) => {
568+ if ( ! res ?. deleteModelDeployment ?. deployment ?. id ) {
569+ message . error ( t ( 'message.FailedToDelete' ) ) ;
570+ return ;
571+ }
572+ if ( errors && errors . length > 0 ) {
573+ const errorMsgList = _ . map ( errors , ( error ) => error . message ) ;
574+ for ( const error of errorMsgList ) {
575+ message . error ( error ) ;
576+ }
577+ } else {
578+ message . success ( t ( 'message.SuccessfullyDeleted' ) ) ;
579+ }
580+ } ,
581+ onError : ( err ) => {
582+ message . error ( err . message || t ( 'message.FailedToDelete' ) ) ;
583+ } ,
584+ } ) ;
585+ toggleDeleteModal ( ) ;
586+ } }
587+ onCancel = { ( ) => {
588+ toggleDeleteModal ( ) ;
589+ } }
590+ confirmText = { deployment ?. metadata ?. name ?? '' }
591+ content = {
592+ < BAIFlex
593+ direction = "column"
594+ gap = "md"
595+ align = "stretch"
596+ style = { { marginBottom : token . marginXS , width : '100%' } }
597+ >
598+ < Alert
599+ type = "warning"
600+ message = { t ( 'dialog.warning.DeleteForeverDesc' ) }
601+ style = { { width : '100%' } }
602+ />
603+ < BAIFlex >
604+ < Typography . Text style = { { marginRight : token . marginXXS } } >
605+ { t ( 'deployment.TypeDeploymentNameToDelete' ) }
606+ </ Typography . Text >
607+ (
608+ < Typography . Text code >
609+ { deployment ?. metadata ?. name }
610+ </ Typography . Text >
611+ )
612+ </ BAIFlex >
613+ </ BAIFlex >
614+ }
615+ title = { t ( 'deployment.DeleteDeployment' ) }
616+ okText = { t ( 'button.Delete' ) }
617+ okButtonProps = { {
618+ loading : isInFlightDeleteDeployment ,
619+ } }
620+ />
492621 </ BAIFlex >
493622 ) ;
494623} ;
0 commit comments