@@ -44,7 +44,8 @@ import {
4444 ExclamationCircleIcon ,
4545 InfoCircleIcon ,
4646 PencilAltIcon ,
47- RedoIcon
47+ RedoIcon ,
48+ TrashIcon
4849} from '@patternfly/react-icons' ;
4950import { QueryEntries } from '@app/Caches/Query/QueryEntries' ;
5051import { Link } from 'react-router-dom' ;
@@ -60,6 +61,7 @@ import { TracingEnabled } from '@app/Common/TracingEnabled';
6061import { InfinispanComponentStatus } from '@app/Common/InfinispanComponentStatus' ;
6162import { PageHeader } from '@patternfly/react-component-groups' ;
6263import { UpdateAliasCache } from '@app/Caches/UpdateAliasCache' ;
64+ import { DeleteCache } from '@app/Caches/DeleteCache' ;
6365
6466const DetailCache = ( props : { cacheName : string } ) => {
6567 const cacheName = props . cacheName ;
@@ -71,6 +73,7 @@ const DetailCache = (props: { cacheName: string }) => {
7173 const [ activeTabKey1 , setActiveTabKey1 ] = useState < number | string > ( '' ) ;
7274 const [ activeTabKey2 , setActiveTabKey2 ] = useState < number | string > ( 10 ) ;
7375 const [ isOpen , setIsOpen ] = useState ( false ) ;
76+ const [ isOpenDelete , setIsOpenDelete ] = useState ( false ) ;
7477 const [ cacheAction , setCacheAction ] = useState < string > ( '' ) ;
7578 const isAdmin = ConsoleServices . security ( ) . hasConsoleACL ( ConsoleACL . ADMIN , connectedUser ) ;
7679 const isCacheReader = ConsoleServices . security ( ) . hasCacheConsoleACL ( ConsoleACL . READ , cacheName , connectedUser ) ;
@@ -209,6 +212,10 @@ const DetailCache = (props: { cacheName: string }) => {
209212 return cache && cache ?. features ?. indexed ;
210213 } ;
211214
215+ const displayDelete = ( ) => {
216+ return isAdmin && cache ;
217+ } ;
218+
212219 const displayEditConfigManage = ( ) => {
213220 return isAdmin && cache ;
214221 } ;
@@ -296,6 +303,25 @@ const DetailCache = (props: { cacheName: string }) => {
296303 ) ;
297304 } ;
298305
306+ const buildDelete = ( ) => {
307+ if ( ! displayDelete ( ) ) return ;
308+
309+ return (
310+ < DropdownItem
311+ value = { 'deleteCache' }
312+ key = "manageDeleteLink"
313+ data-cy = "manageDeleteLink"
314+ icon = { < TrashIcon /> }
315+ onClick = { ( ev ) => {
316+ setIsOpenDelete ( true ) ;
317+ setIsOpen ( false ) ;
318+ } }
319+ >
320+ { t ( 'caches.actions.action-delete' ) }
321+ </ DropdownItem >
322+ ) ;
323+ } ;
324+
299325 const buildRefresh = ( ) => {
300326 return (
301327 < React . Fragment >
@@ -460,6 +486,7 @@ const DetailCache = (props: { cacheName: string }) => {
460486 { buildIndexManage ( ) }
461487 { buildBackupsManage ( ) }
462488 { buildRefresh ( ) }
489+ { buildDelete ( ) }
463490 </ DropdownList >
464491 </ Dropdown >
465492 </ ToolbarItem >
@@ -513,6 +540,20 @@ const DetailCache = (props: { cacheName: string }) => {
513540 ) }
514541 { buildDetailContent ( ) }
515542 </ PageSection >
543+ < DeleteCache
544+ cacheName = { cacheName }
545+ isModalOpen = { isOpenDelete }
546+ closeModal = { ( deleteDone : boolean ) => {
547+ if ( deleteDone ) {
548+ navigate ( {
549+ pathname : '/' ,
550+ search : location . search
551+ } ) ;
552+ } else {
553+ setIsOpenDelete ( false ) ;
554+ }
555+ } }
556+ />
516557 < UpdateAliasCache
517558 cacheName = { cacheName }
518559 isModalOpen = { cacheAction == 'aliases' }
0 commit comments