-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes 1871742: It is not possible to delete a PVC created using a dat…
…a upload
- Loading branch information
Showing
7 changed files
with
142 additions
and
4 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
17 changes: 17 additions & 0 deletions
17
...tend/packages/kubevirt-plugin/src/components/cdi-upload-provider/pvc-delete-extension.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,17 @@ | ||
import * as React from 'react'; | ||
import { Alert, AlertVariant } from '@patternfly/react-core'; | ||
import { k8sKill, K8sResourceKind } from '@console/internal/module/k8s'; | ||
import { DataVolumeModel } from '../../models'; | ||
|
||
export const killCDIBoundPVC = (pvc: K8sResourceKind) => k8sKill(DataVolumeModel, pvc); | ||
|
||
export const PVCDeleteAlertExtension: React.FC<PVCDeleteAlertExtension> = ({ pvc }) => ( | ||
<Alert className="co-m-form-row" isInline variant={AlertVariant.warning} title="PVC Delete"> | ||
Deleting this PVC will also delete{' '} | ||
<strong className="co-break-word">{pvc?.metadata?.name}</strong> Data Volume | ||
</Alert> | ||
); | ||
|
||
type PVCDeleteAlertExtension = { | ||
pvc: K8sResourceKind; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from 'react'; | ||
import { Stack, StackItem } from '@patternfly/react-core'; | ||
import { AsyncComponent, HandlePromiseProps, withHandlePromise } from '../utils'; | ||
import { getName, YellowExclamationTriangleIcon } from '@console/shared'; | ||
import { | ||
createModalLauncher, | ||
ModalTitle, | ||
ModalBody, | ||
ModalSubmitFooter, | ||
ModalComponentProps, | ||
} from '../factory'; | ||
import { k8sKill, K8sResourceCommon } from '@console/internal/module/k8s'; | ||
import { PersistentVolumeClaimModel } from '../../models'; | ||
import { isPVCDelete, PVCDelete, useExtensions } from '@console/plugin-sdk'; | ||
|
||
const DeletePVCModal = withHandlePromise((props: DeletePVCModalProps) => { | ||
const { pvc, inProgress, errorMessage, handlePromise, close, cancel } = props; | ||
const pvcDeleteExtensions = useExtensions<PVCDelete>(isPVCDelete); | ||
const pvcName = getName(pvc); | ||
|
||
const submit = (e) => { | ||
e.preventDefault(); | ||
|
||
const promise = k8sKill(PersistentVolumeClaimModel, pvc).then(() => | ||
Promise.all( | ||
pvcDeleteExtensions.map( | ||
({ properties: { predicate, onPVCKill } }) => predicate(pvc) && onPVCKill(pvc), | ||
), | ||
), | ||
); | ||
return handlePromise(promise, close); | ||
}; | ||
|
||
const alertComponents = pvcDeleteExtensions.map( | ||
({ properties: { predicate, alertLoader } }, i) => | ||
predicate(pvc) && <AsyncComponent key={`ext-${i}`} loader={alertLoader} pvc={pvc} />, | ||
); | ||
|
||
return ( | ||
<form onSubmit={submit} className="modal-content"> | ||
<ModalTitle> | ||
<YellowExclamationTriangleIcon className="co-icon-space-r" /> Delete Persistent Volume Claim | ||
</ModalTitle> | ||
<ModalBody> | ||
<Stack hasGutter> | ||
{alertComponents.map((alert, i) => ( | ||
<StackItem key={`alert-${i}`}>{alert}</StackItem> | ||
))} | ||
<StackItem> | ||
Are you sure you want to delete <strong className="co-break-word">{pvcName}</strong>{' '} | ||
Persistent Volume Claim? | ||
</StackItem> | ||
</Stack> | ||
</ModalBody> | ||
<ModalSubmitFooter | ||
errorMessage={errorMessage} | ||
inProgress={inProgress} | ||
submitText="Delete" | ||
submitDanger | ||
cancel={cancel} | ||
/> | ||
</form> | ||
); | ||
}); | ||
|
||
export type DeletePVCModalProps = { | ||
pvc: K8sResourceCommon; | ||
} & ModalComponentProps & | ||
HandlePromiseProps; | ||
|
||
export default createModalLauncher(DeletePVCModal); |
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