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
@@ -131,6 +139,7 @@ const DeploymentDetailPage: React.FC = () => {
131139 createdUser {
132140 email
133141 }
142+ ...DeploymentModifyModalFragment
134143 }
135144 }
136145 ` ,
@@ -154,6 +163,19 @@ const DeploymentDetailPage: React.FC = () => {
154163 ` ,
155164 ) ;
156165
166+ const [ commitDeleteDeployment , isInFlightDeleteDeployment ] =
167+ useMutation < DeploymentDetailPageDeleteMutation > ( graphql `
168+ mutation DeploymentDetailPageDeleteMutation(
169+ $input: DeleteModelDeploymentInput!
170+ ) {
171+ deleteModelDeployment(input: $input) {
172+ deployment {
173+ id
174+ }
175+ }
176+ }
177+ ` ) ;
178+
157179 const deploymentInfoItems : DescriptionsProps [ 'items' ] = [
158180 {
159181 key : 'name' ,
@@ -258,7 +280,7 @@ const DeploymentDetailPage: React.FC = () => {
258280 < Typography . Title level = { 3 } style = { { margin : 0 } } >
259281 { deployment ?. metadata ?. name || '' }
260282 </ Typography . Title >
261- < BAIFlex gap = { 'xxs ' } >
283+ < BAIFlex gap = { 'xs ' } >
262284 < Tooltip title = { t ( 'button.Refresh' ) } >
263285 < Button
264286 loading = { isPendingRefetch }
@@ -270,6 +292,34 @@ const DeploymentDetailPage: React.FC = () => {
270292 } }
271293 />
272294 </ Tooltip >
295+ < Button
296+ onClick = { ( ) => {
297+ toggleModifyModal ( ) ;
298+ } }
299+ >
300+ { t ( 'button.Edit' ) }
301+ </ Button >
302+ < Dropdown
303+ menu = { {
304+ items : [
305+ {
306+ key : 'delete' ,
307+ label : t ( 'button.Delete' ) ,
308+ onClick : ( ) => {
309+ toggleDeleteModal ( ) ;
310+ } ,
311+ } ,
312+ ] ,
313+ } }
314+ trigger = { [ 'click' ] }
315+ >
316+ < Button >
317+ < BAIFlex gap = { 'xxs' } >
318+ { t ( 'button.Action' ) }
319+ < DownOutlined />
320+ </ BAIFlex >
321+ </ Button >
322+ </ Dropdown >
273323 </ BAIFlex >
274324 </ BAIFlex >
275325
@@ -492,6 +542,85 @@ const DeploymentDetailPage: React.FC = () => {
492542 toggleTokenGenerationModal ( ) ;
493543 } }
494544 />
545+
546+ < Suspense >
547+ < DeploymentModifyModal
548+ deploymentFrgmt = { deployment }
549+ open = { isModifyModalOpen }
550+ onRequestClose = { ( success ) => {
551+ if ( success ) {
552+ startRefetchTransition ( ( ) => {
553+ updateFetchKey ( ) ;
554+ } ) ;
555+ }
556+ toggleModifyModal ( ) ;
557+ } }
558+ />
559+ </ Suspense >
560+
561+ < BAIConfirmModalWithInput
562+ open = { isDeleteModalOpen }
563+ onOk = { ( ) => {
564+ commitDeleteDeployment ( {
565+ variables : {
566+ input : {
567+ id : deploymentId || '' ,
568+ } ,
569+ } ,
570+ onCompleted : ( res , errors ) => {
571+ if ( ! res ?. deleteModelDeployment ?. deployment ?. id ) {
572+ message . error ( t ( 'message.FailedToDelete' ) ) ;
573+ return ;
574+ }
575+ if ( errors && errors . length > 0 ) {
576+ const errorMsgList = _ . map ( errors , ( error ) => error . message ) ;
577+ for ( const error of errorMsgList ) {
578+ message . error ( error ) ;
579+ }
580+ } else {
581+ message . success ( t ( 'message.SuccessfullyDeleted' ) ) ;
582+ }
583+ } ,
584+ onError : ( err ) => {
585+ message . error ( err . message || t ( 'message.FailedToDelete' ) ) ;
586+ } ,
587+ } ) ;
588+ toggleDeleteModal ( ) ;
589+ } }
590+ onCancel = { ( ) => {
591+ toggleDeleteModal ( ) ;
592+ } }
593+ confirmText = { deployment ?. metadata ?. name ?? '' }
594+ content = {
595+ < BAIFlex
596+ direction = "column"
597+ gap = "md"
598+ align = "stretch"
599+ style = { { marginBottom : token . marginXS , width : '100%' } }
600+ >
601+ < Alert
602+ type = "warning"
603+ message = { t ( 'dialog.warning.DeleteForeverDesc' ) }
604+ style = { { width : '100%' } }
605+ />
606+ < BAIFlex >
607+ < Typography . Text style = { { marginRight : token . marginXXS } } >
608+ { t ( 'deployment.TypeDeploymentNameToDelete' ) }
609+ </ Typography . Text >
610+ (
611+ < Typography . Text code >
612+ { deployment ?. metadata ?. name }
613+ </ Typography . Text >
614+ )
615+ </ BAIFlex >
616+ </ BAIFlex >
617+ }
618+ title = { t ( 'deployment.DeleteDeployment' ) }
619+ okText = { t ( 'button.Delete' ) }
620+ okButtonProps = { {
621+ loading : isInFlightDeleteDeployment ,
622+ } }
623+ />
495624 </ BAIFlex >
496625 ) ;
497626} ;
0 commit comments