Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added eviction strategy information on details page and a model with …
…checkbox to control it. Also, changed some styling and translation in dedicated-services-modal Signed-off-by: metalice <mschatzm@redhat.com>
- Loading branch information
Showing
11 changed files
with
145 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
8 changes: 0 additions & 8 deletions
8
...ponents/modals/scheduling-modals/dedicated-resources-modal/dedicated-resources-modal.scss
This file was deleted.
Oops, something went wrong.
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
72 changes: 72 additions & 0 deletions
72
...c/components/modals/scheduling-modals/eviction-strategy-modal/eviction-strategy-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,72 @@ | ||
import * as React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { | ||
createModalLauncher, | ||
ModalTitle, | ||
ModalBody, | ||
ModalComponentProps, | ||
} from '@console/internal/components/factory'; | ||
import { k8sPatch } from '@console/internal/module/k8s'; | ||
import { Checkbox, TextVariants, Text } from '@patternfly/react-core'; | ||
import { withHandlePromise, HandlePromiseProps } from '@console/internal/components/utils'; | ||
import { ModalFooter } from '../../modal/modal-footer'; | ||
import { getEvictionStrategyPatch } from '../../../../k8s/patches/vm/vm-scheduling-patches'; | ||
import { getVMLikeModel } from '../../../../selectors/vm/vmlike'; | ||
import { VMLikeEntityKind } from '../../../../types/vmLike'; | ||
import '../shared/scheduling-modals.scss'; | ||
|
||
const EvictionStrategyModal = withHandlePromise<EvictionStrategyModalWithPromiseProps>((props) => { | ||
const { vmLikeEntity, evictionStrategy, inProgress, close, handlePromise } = props; | ||
|
||
const { t } = useTranslation(); | ||
const [isCheckedEvictionStrategy, setIsCheckedEvictionStrategy] = React.useState<boolean>( | ||
!!evictionStrategy, | ||
); | ||
|
||
const onModalSubmit = () => { | ||
if (isCheckedEvictionStrategy !== !!evictionStrategy) { | ||
handlePromise( | ||
k8sPatch( | ||
getVMLikeModel(vmLikeEntity), | ||
vmLikeEntity, | ||
getEvictionStrategyPatch(vmLikeEntity, isCheckedEvictionStrategy), | ||
), | ||
close, | ||
); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="modal-content"> | ||
<ModalTitle>{t('kubevirt-plugin~Eviction Strategy')}</ModalTitle> | ||
<ModalBody> | ||
<Checkbox | ||
id="eviction-strategy" | ||
className="kubevirt-scheduling__checkbox" | ||
isChecked={isCheckedEvictionStrategy} | ||
onChange={() => setIsCheckedEvictionStrategy((value) => !value)} | ||
label="LiveMigrate" | ||
/> | ||
<Text className="kubevirt-scheduling__helper-text" component={TextVariants.small}> | ||
{t( | ||
'kubevirt-plugin~EvictionStrategy can be set to "LiveMigrate" if the VirtualMachineInstance should be migrated instead of shut-off in case of a node drain.', | ||
)} | ||
</Text> | ||
</ModalBody> | ||
<ModalFooter | ||
onCancel={close} | ||
inProgress={inProgress} | ||
onSubmit={onModalSubmit} | ||
submitButtonText={t('kubevirt-plugin~Save')} | ||
/> | ||
</div> | ||
); | ||
}); | ||
|
||
type EvictionStrategyModalWithPromiseProps = HandlePromiseProps & | ||
ModalComponentProps & { | ||
vmLikeEntity: VMLikeEntityKind; | ||
evictionStrategy: string; | ||
}; | ||
|
||
export default createModalLauncher(EvictionStrategyModal); |
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
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