-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1585 from GowthamShanmugam/bz_2311867_compatibility
Bug 2311867: [release-4.17-compatibility] Prepare cluster for disaster recovery
- Loading branch information
Showing
24 changed files
with
908 additions
and
21 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
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
99 changes: 99 additions & 0 deletions
99
...ages/ocs/dashboards/persistent-internal/status-card/osd-migration/osd-migration-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,99 @@ | ||
import * as React from 'react'; | ||
import { DISASTER_RECOVERY_TARGET_ANNOTATION_WO_SLASH } from '@odf/core/constants'; | ||
import { CommonModalProps, ModalBody, ModalFooter } from '@odf/shared/modals'; | ||
import { StorageClusterModel } from '@odf/shared/models'; | ||
import { getName, getNamespace } from '@odf/shared/selectors'; | ||
import { StorageClusterKind } from '@odf/shared/types'; | ||
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook'; | ||
import { k8sPatch } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { | ||
Modal, | ||
ModalVariant, | ||
Button, | ||
Alert, | ||
AlertVariant, | ||
ButtonVariant, | ||
} from '@patternfly/react-core'; | ||
|
||
export const OSDMigrationModal: React.FC<OSDMigrationModalProps> = ({ | ||
isOpen, | ||
extraProps, | ||
closeModal, | ||
}) => { | ||
const { t } = useCustomTranslation(); | ||
const ocsData = extraProps?.ocsData; | ||
const [errorMessage, setErrorMessage] = React.useState<string>(''); | ||
|
||
const handleOptimize = () => { | ||
const patch = [ | ||
{ | ||
op: 'add', | ||
path: `/metadata/annotations/${DISASTER_RECOVERY_TARGET_ANNOTATION_WO_SLASH}`, | ||
value: 'true', | ||
}, | ||
]; | ||
|
||
k8sPatch({ | ||
model: StorageClusterModel, | ||
resource: { | ||
metadata: { | ||
name: getName(ocsData), | ||
namespace: getNamespace(ocsData), | ||
}, | ||
}, | ||
data: patch, | ||
}) | ||
.then(() => { | ||
closeModal(); | ||
}) | ||
.catch((err) => { | ||
setErrorMessage(err.message); | ||
}); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
variant={ModalVariant.small} | ||
title={t('Prepare the cluster for Regional DR setup')} | ||
isOpen={isOpen} | ||
onClose={closeModal} | ||
> | ||
{t( | ||
'To prepare the cluster for Regional DR setup, you must migrate the OSDs. Migrating OSDs may take some time to complete based on your cluster.' | ||
)} | ||
<ModalBody> | ||
{!!errorMessage && ( | ||
<Alert | ||
isInline | ||
variant={AlertVariant.danger} | ||
title={t('An error occurred')} | ||
> | ||
{errorMessage} | ||
</Alert> | ||
)} | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button | ||
key="close" | ||
variant={ButtonVariant.secondary} | ||
onClick={closeModal} | ||
> | ||
{t('Cancel')} | ||
</Button> | ||
<Button | ||
key="optimize" | ||
variant={ButtonVariant.primary} | ||
onClick={handleOptimize} | ||
> | ||
{t('Yes, migrate OSDs')} | ||
</Button> | ||
</ModalFooter> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export type OSDMigrationModalProps = CommonModalProps<{ | ||
ocsData: StorageClusterKind; | ||
}>; | ||
|
||
export default OSDMigrationModal; |
Oops, something went wrong.