-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kms): Revert "feat(kms): refacto delete modal"
This reverts commit d7c2efd. ref: MANAGER-15716
- Loading branch information
Showing
9 changed files
with
189 additions
and
78 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
...r/apps/key-management-service/src/components/Modal/terminate/TerminateModal.component.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,119 @@ | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
import { | ||
ButtonType, | ||
PageLocation, | ||
useOvhTracking, | ||
} from '@ovh-ux/manager-react-shell-client'; | ||
import { | ||
ODS_BUTTON_TYPE, | ||
ODS_BUTTON_VARIANT, | ||
ODS_INPUT_TYPE, | ||
ODS_SPINNER_SIZE, | ||
ODS_TEXT_LEVEL, | ||
OdsInputValueChangeEvent, | ||
} from '@ovhcloud/ods-components'; | ||
import { | ||
OsdsButton, | ||
OsdsInput, | ||
OsdsModal, | ||
OsdsSpinner, | ||
OsdsText, | ||
} from '@ovhcloud/ods-components/react'; | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { terminateValue } from './TerminateModal.constants'; | ||
|
||
export type TerminateModalProps = { | ||
closeModal: () => void; | ||
isLoading?: boolean; | ||
onConfirmTerminate: () => void; | ||
}; | ||
|
||
export const TerminateModal: React.FC<TerminateModalProps> = ({ | ||
closeModal, | ||
isLoading, | ||
onConfirmTerminate, | ||
}) => { | ||
const { trackClick } = useOvhTracking(); | ||
const { t } = useTranslation('key-management-service/terminate'); | ||
const [terminateInput, setTerminateInput] = useState(''); | ||
|
||
const close = () => { | ||
setTerminateInput(''); | ||
closeModal(); | ||
}; | ||
|
||
return ( | ||
<OsdsModal | ||
dismissible | ||
color={ODS_THEME_COLOR_INTENT.warning} | ||
headline={t('key_management_service_terminate_heading')} | ||
onOdsModalClose={close} | ||
> | ||
<div className="mt-8"> | ||
{isLoading ? ( | ||
<div className="flex justify-center"> | ||
<OsdsSpinner inline size={ODS_SPINNER_SIZE.md} /> | ||
</div> | ||
) : ( | ||
<> | ||
<OsdsText | ||
color={ODS_THEME_COLOR_INTENT.text} | ||
level={ODS_TEXT_LEVEL.body} | ||
className="block mb-3" | ||
> | ||
{t('key_management_service_terminate_description', { | ||
terminateKeyword: terminateValue, | ||
})} | ||
</OsdsText> | ||
<OsdsInput | ||
disabled={isLoading || undefined} | ||
type={ODS_INPUT_TYPE.text} | ||
value={terminateInput} | ||
onOdsValueChange={(e: OdsInputValueChangeEvent) => | ||
setTerminateInput(e.detail.value) | ||
} | ||
/> | ||
</> | ||
)} | ||
</div> | ||
<OsdsButton | ||
disabled={isLoading || undefined} | ||
slot="actions" | ||
type={ODS_BUTTON_TYPE.button} | ||
variant={ODS_BUTTON_VARIANT.ghost} | ||
color={ODS_THEME_COLOR_INTENT.primary} | ||
onClick={() => { | ||
trackClick({ | ||
location: PageLocation.popup, | ||
buttonType: ButtonType.button, | ||
actionType: 'navigation', | ||
actions: ['delete_kms', 'cancel'], | ||
}); | ||
close(); | ||
}} | ||
> | ||
{t('key_management_service_terminate_cancel')} | ||
</OsdsButton> | ||
<OsdsButton | ||
disabled={isLoading || terminateInput !== terminateValue || undefined} | ||
slot="actions" | ||
type={ODS_BUTTON_TYPE.button} | ||
variant={ODS_BUTTON_VARIANT.flat} | ||
color={ODS_THEME_COLOR_INTENT.primary} | ||
onClick={() => { | ||
trackClick({ | ||
location: PageLocation.popup, | ||
buttonType: ButtonType.button, | ||
actionType: 'navigation', | ||
actions: ['delete_kms', 'confirm'], | ||
}); | ||
setTerminateInput(''); | ||
onConfirmTerminate(); | ||
}} | ||
> | ||
{t('key_management_service_terminate_confirm')} | ||
</OsdsButton> | ||
</OsdsModal> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
...er/apps/key-management-service/src/components/Modal/terminate/TerminateModal.constants.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 const terminateValue = 'TERMINATE'; |
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
Oops, something went wrong.