-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add delete accelerator profile modal
updated text fix test fix
- Loading branch information
1 parent
8c9e2ec
commit 701bbc4
Showing
5 changed files
with
130 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
frontend/src/pages/acceleratorProfiles/screens/list/DeleteAcceleratorProfileModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import DeleteModal from '~/pages/projects/components/DeleteModal'; | ||
import { AcceleratorKind } from '~/k8sTypes'; | ||
import { deleteAcceleratorProfile } from '~/services/acceleratorProfileService'; | ||
|
||
type DeleteAcceleratorProfileModalProps = { | ||
acceleratorProfile?: AcceleratorKind; | ||
onClose: (deleted: boolean) => void; | ||
}; | ||
|
||
const DeleteAcceleratorProfileModal: React.FC<DeleteAcceleratorProfileModalProps> = ({ | ||
acceleratorProfile, | ||
onClose, | ||
}) => { | ||
const [isDeleting, setIsDeleting] = React.useState(false); | ||
const [error, setError] = React.useState<Error | undefined>(); | ||
|
||
const onBeforeClose = (deleted: boolean) => { | ||
onClose(deleted); | ||
setIsDeleting(false); | ||
setError(undefined); | ||
}; | ||
|
||
const deleteName = acceleratorProfile?.spec.displayName || 'this accelerator profile'; | ||
|
||
return ( | ||
<DeleteModal | ||
title="Delete accelerator profile?" | ||
isOpen={!!acceleratorProfile} | ||
onClose={() => onBeforeClose(false)} | ||
submitButtonLabel="Delete accelerator profile" | ||
onDelete={() => { | ||
if (acceleratorProfile) { | ||
setIsDeleting(true); | ||
deleteAcceleratorProfile(acceleratorProfile.metadata.name) | ||
.then(() => { | ||
onBeforeClose(true); | ||
}) | ||
.catch((e) => { | ||
setError(e); | ||
setIsDeleting(false); | ||
}); | ||
} | ||
}} | ||
deleting={isDeleting} | ||
error={error} | ||
deleteName={deleteName} | ||
> | ||
The <b>{deleteName}</b> accelerator profile will be deleted and will be unavailable for any | ||
workbenches and runtimes. Existing resources will retain their settings but cannot revert to | ||
this profile once changed. | ||
</DeleteModal> | ||
); | ||
}; | ||
|
||
export default DeleteAcceleratorProfileModal; |