@@ -10,26 +10,23 @@ import { useInstanceId } from '../next-architecture/ui/AuthProvider';
1010import DeleteConfirmation from '../ui-elements/DeleteConfirmation' ;
1111import * as T from '../ui-elements/Table' ;
1212import { useShellHooks } from '@scality/module-federation' ;
13- import { ArtescaLibraryNotAvailable } from '../next-architecture/ui/ArtescaLibraryProvider' ;
14- import { useArtescaLibrary } from '../next-architecture/ui/ArtescaLibraryProvider' ;
1513
1614export const DeleteEndpoint = ( {
1715 hostname,
18- isBuiltin,
16+ endpointsDeletionDisabledMap,
17+ endpointsDeletionDisabledStatus,
1918} : {
2019 hostname : string ;
21- isBuiltin : boolean ;
20+ endpointsDeletionDisabledMap : Record < string , boolean > ;
21+ endpointsDeletionDisabledStatus : 'idle' | 'loading' | 'error' | 'success' ;
2222} ) => {
2323 const [ isConfirmDeleteOpen , setIsConfirmDeleteOpen ] = useState ( false ) ;
2424 const accountsLocationsEndpointsAdapter =
2525 useAccountsLocationsEndpointsAdapter ( ) ;
26- const {
27- refetchAccountsLocationsEndpointsMutation,
28- accountsLocationsAndEndpoints,
29- status : accountsLocationsEndpointsStatus ,
30- } = useAccountsLocationsAndEndpoints ( {
31- accountsLocationsEndpointsAdapter,
32- } ) ;
26+ const { refetchAccountsLocationsEndpointsMutation } =
27+ useAccountsLocationsAndEndpoints ( {
28+ accountsLocationsEndpointsAdapter,
29+ } ) ;
3330 const instanceId = useInstanceId ( ) ;
3431 const managementClient = useManagementClient ( ) ;
3532 const { useAuth } = useShellHooks ( ) ;
@@ -47,37 +44,6 @@ export const DeleteEndpoint = ({
4744 status : waiterStatus ,
4845 } = useWaitForRunningConfigurationVersionToBeUpdated ( ) ;
4946
50- const artescaLibrary = useArtescaLibrary ( ) ;
51- const {
52- useArtescaPlusVeeamDefaultOrOpenMode,
53- ARTESCA_PLUS_VEEAM_S3_ENDPOINT_NAME ,
54- } =
55- artescaLibrary instanceof ArtescaLibraryNotAvailable
56- ? {
57- useArtescaPlusVeeamDefaultOrOpenMode : undefined ,
58- ARTESCA_PLUS_VEEAM_S3_ENDPOINT_NAME : undefined ,
59- }
60- : artescaLibrary ;
61- const {
62- artescaPlusVeeamDefaultOrOpenMode,
63- artescaPlusVeeamDefaultOrOpenModeStatus,
64- } = useArtescaPlusVeeamDefaultOrOpenMode ( ) ;
65-
66- const isDisabledForArtescaPlusVeeam =
67- hostname === ARTESCA_PLUS_VEEAM_S3_ENDPOINT_NAME ;
68-
69- // Disable endpoint deletion when there is only one non-Veeam, non-builtin endpoint remaining
70- // to avoid going back to default mode
71- const isLastNonVeeamEndpoint =
72- accountsLocationsEndpointsStatus === 'success' &&
73- accountsLocationsAndEndpoints . endpoints . filter (
74- ( endpoint ) =>
75- endpoint . hostname !== ARTESCA_PLUS_VEEAM_S3_ENDPOINT_NAME &&
76- endpoint . isBuiltin === false ,
77- ) . length === 1 ;
78- const isDisabledForOpenMode =
79- artescaPlusVeeamDefaultOrOpenMode === 'open' && isLastNonVeeamEndpoint ;
80-
8147 const handleDeleteApprove = ( ) => {
8248 setReferenceVersion ( {
8349 onRefTaken : ( ) => {
@@ -97,12 +63,8 @@ export const DeleteEndpoint = ({
9763 }
9864 } , [ waiterStatus , refetchAccountsLocationsEndpointsMutation ] ) ;
9965
100- const tooltipMessage = isBuiltin
66+ const tooltipMessage = endpointsDeletionDisabledMap [ hostname ]
10167 ? 'This Data Service can not be deleted'
102- : isDisabledForArtescaPlusVeeam
103- ? 'This is the Data Service created for Artesca + Veeam deployment and it should not be deleted'
104- : isDisabledForOpenMode
105- ? 'The deletion of Data Services has been disabled for Open Mode'
10668 : 'Delete Data Service' ;
10769
10870 return (
@@ -117,10 +79,8 @@ export const DeleteEndpoint = ({
11779 titleText = { `Are you sure you want to delete Data Service: ${ hostname } ?` }
11880 />
11981 < T . ActionButton
120- disabled = {
121- isBuiltin || isDisabledForArtescaPlusVeeam || isDisabledForOpenMode
122- }
123- isLoading = { artescaPlusVeeamDefaultOrOpenModeStatus === 'loading' }
82+ disabled = { endpointsDeletionDisabledMap [ hostname ] }
83+ isLoading = { endpointsDeletionDisabledStatus === 'loading' }
12484 icon = { < Icon name = "Delete" /> }
12585 tooltip = { {
12686 overlay : tooltipMessage ,
0 commit comments