Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
frontend/packages/kubevirt-plugin/src/components/modals/vm-status-modal/index.ts
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 @@ | ||
export * from './vm-status-modal'; |
61 changes: 61 additions & 0 deletions
61
frontend/packages/kubevirt-plugin/src/components/modals/vm-status-modal/vm-status-modal.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,61 @@ | ||
import * as React from 'react'; | ||
import { Modal } from '@patternfly/react-core'; | ||
import { HandlePromiseProps, withHandlePromise } from '@console/internal/components/utils'; | ||
import { ModalComponentProps } from '@console/internal/components/factory'; | ||
import { ModalFooter } from '../modal/modal-footer'; | ||
import { PAUSED_VM_MODAL_MESSAGE } from '../../../constants/vm'; | ||
import { VMLikeEntityKind } from '../../../types'; | ||
|
||
const modalTitle = 'Edit pause state'; | ||
|
||
const VMStatusModalComponent = ({ | ||
vmLikeEntity, | ||
isOpen, | ||
setOpen, | ||
title = modalTitle, | ||
handlePromise, | ||
inProgress, | ||
errorMessage, | ||
}: VMStatusModalProps) => { | ||
const [showPatchError, setPatchError] = React.useState<boolean>(false); | ||
|
||
const footer = ( | ||
<ModalFooter | ||
errorMessage={showPatchError && errorMessage} | ||
inProgress={inProgress} | ||
onSubmit={() => { | ||
// this try/catch is only a placeholder for the unpauseVM function | ||
try { | ||
// TODO Create function to unpause VM | ||
} catch (error) { | ||
setPatchError(error); | ||
} | ||
}} | ||
onCancel={() => setOpen(false)} | ||
submitButtonText="Unpause" | ||
/> | ||
); | ||
|
||
return ( | ||
<Modal | ||
title={title} | ||
isOpen={isOpen} | ||
isSmall | ||
onClose={() => setOpen(false)} | ||
footer={footer} | ||
isFooterLeftAligned | ||
> | ||
<div>{PAUSED_VM_MODAL_MESSAGE}</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export type VMStatusModalProps = HandlePromiseProps & | ||
ModalComponentProps & { | ||
vmLikeEntity: VMLikeEntityKind; | ||
title?: string; | ||
isOpen: boolean; | ||
setOpen: (isOpen: boolean) => void; | ||
}; | ||
|
||
export const VMStatusModal = withHandlePromise(VMStatusModalComponent); |
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
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