-
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.
feat(key-management-service): create credential step 3 (#13157)
ref: 14180 Signed-off-by: Vincent BONMARCHAND <[email protected]>
- Loading branch information
Showing
48 changed files
with
273 additions
and
22 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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions
48
...rvice/src/pages/credential/create/confirmation/CreateCredentialConfirmation.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,48 @@ | ||
import React, { useState } from 'react'; | ||
import { OsdsButton } from '@ovhcloud/ods-components/react'; | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import CreateCredentialConfirmationDetails from './CreateCredentialConfirmationDetails.component'; | ||
import CreateCredentialConfirmationPrivateKey from './CreateCredentialConfirmationPrivateKey.component'; | ||
import { OkmsCredential } from '@/types/okmsCredential.type'; | ||
import { ROUTES_URLS } from '@/routes/routes.constants'; | ||
|
||
type CreateCredentialConfirmationProps = { | ||
okmsCredential: OkmsCredential; | ||
}; | ||
|
||
const CreateCredentialConfirmation = ({ | ||
okmsCredential, | ||
}: CreateCredentialConfirmationProps) => { | ||
const { t } = useTranslation('key-management-service/credential'); | ||
const [isKeyDownloaded, setIsKeyDownloaded] = useState(false); | ||
const { okmsId } = useParams(); | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<div className="grid grid-cols-1 gap-4 md:gap-6 max-w-screen-lg"> | ||
<CreateCredentialConfirmationDetails okmsCredential={okmsCredential} /> | ||
<CreateCredentialConfirmationPrivateKey | ||
privateKey={okmsCredential.privateKeyPEM} | ||
credentialId={okmsCredential.id} | ||
isKeyDownloaded={isKeyDownloaded} | ||
setIsKeyDownloaded={setIsKeyDownloaded} | ||
/> | ||
<span> | ||
<OsdsButton | ||
color={ODS_THEME_COLOR_INTENT.primary} | ||
disabled={!isKeyDownloaded || undefined} | ||
onClick={() => navigate(`/${okmsId}/${ROUTES_URLS.credentials}`)} | ||
inline | ||
> | ||
{t( | ||
'key_management_service_credential_create_confirmation_button_done_label', | ||
)} | ||
</OsdsButton> | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreateCredentialConfirmation; |
58 changes: 58 additions & 0 deletions
58
...rc/pages/credential/create/confirmation/CreateCredentialConfirmationDetails.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,58 @@ | ||
import { Subtitle } from '@ovh-ux/manager-react-components'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { OsdsTile } from '@ovhcloud/ods-components/react'; | ||
import CreateCredentialConfirmationDetailsText from './CreateCredentialConfirmationDetailsText.component'; | ||
import { OkmsCredential } from '@/types/okmsCredential.type'; | ||
import { getDaysFromDate } from '@/utils/credential/validityDateUtils'; | ||
|
||
type CreateCredentialConfirmationDetailsProps = { | ||
okmsCredential: OkmsCredential; | ||
}; | ||
|
||
const CreateCredentialConfirmationDetails = ({ | ||
okmsCredential, | ||
}: CreateCredentialConfirmationDetailsProps) => { | ||
const { t } = useTranslation('key-management-service/credential'); | ||
|
||
return ( | ||
<OsdsTile> | ||
<div className="flex flex-col w-full gap-7 md:gap-9"> | ||
<Subtitle> | ||
{t( | ||
'key_management_service_credential_create_confirmation_details_title', | ||
)} | ||
</Subtitle> | ||
<CreateCredentialConfirmationDetailsText | ||
label={t( | ||
'key_management_service_credential_create_confirmation_details_id_label', | ||
)} | ||
value={okmsCredential.id} | ||
/> | ||
<CreateCredentialConfirmationDetailsText | ||
label={t( | ||
'key_management_service_credential_create_confirmation_details_display-name_label', | ||
)} | ||
value={okmsCredential.name} | ||
/> | ||
<CreateCredentialConfirmationDetailsText | ||
label={t( | ||
'key_management_service_credential_create_confirmation_details_description_label', | ||
)} | ||
value={okmsCredential.description} | ||
/> | ||
<CreateCredentialConfirmationDetailsText | ||
label={t( | ||
'key_management_service_credential_create_confirmation_details_validity_label', | ||
)} | ||
value={t( | ||
'key_management_service_credential_create_confirmation_details_validity_suffix', | ||
{ days: getDaysFromDate(new Date(okmsCredential.expiredAt)) }, | ||
)} | ||
/> | ||
</div> | ||
</OsdsTile> | ||
); | ||
}; | ||
|
||
export default CreateCredentialConfirmationDetails; |
20 changes: 20 additions & 0 deletions
20
...ages/credential/create/confirmation/CreateCredentialConfirmationDetailsText.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,20 @@ | ||
import { Description } from '@ovh-ux/manager-react-components'; | ||
import React from 'react'; | ||
|
||
type CreateCredentialConfirmationDetailsTextProps = { | ||
label: string; | ||
value: string; | ||
}; | ||
|
||
const CreateCredentialConfirmationDetailsText = ({ | ||
label, | ||
value, | ||
}: CreateCredentialConfirmationDetailsTextProps) => { | ||
return ( | ||
<div className="grid grid-cols-2"> | ||
<Description>{`${label}:`}</Description> | ||
<Description>{value}</Description> | ||
</div> | ||
); | ||
}; | ||
export default CreateCredentialConfirmationDetailsText; |
84 changes: 84 additions & 0 deletions
84
...pages/credential/create/confirmation/CreateCredentialConfirmationPrivateKey.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,84 @@ | ||
import { Subtitle } from '@ovh-ux/manager-react-components'; | ||
import { | ||
ODS_BUTTON_SIZE, | ||
ODS_BUTTON_VARIANT, | ||
ODS_ICON_NAME, | ||
} from '@ovhcloud/ods-components'; | ||
import { | ||
OsdsButton, | ||
OsdsCheckbox, | ||
OsdsCheckboxButton, | ||
OsdsMessage, | ||
OsdsText, | ||
OsdsTile, | ||
} from '@ovhcloud/ods-components/react'; | ||
import React, { Dispatch, SetStateAction } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
|
||
type CreateCredentialConfirmationPrivateKeyProps = { | ||
privateKey: string; | ||
credentialId: string; | ||
isKeyDownloaded: boolean; | ||
setIsKeyDownloaded: Dispatch<SetStateAction<boolean>>; | ||
}; | ||
|
||
const CreateCredentialConfirmationPrivateKey = ({ | ||
privateKey, | ||
credentialId, | ||
isKeyDownloaded, | ||
setIsKeyDownloaded, | ||
}: CreateCredentialConfirmationPrivateKeyProps) => { | ||
const { t } = useTranslation('key-management-service/credential'); | ||
return ( | ||
<OsdsTile> | ||
<div className="flex flex-col w-full gap-7 md:gap-9"> | ||
<Subtitle> | ||
{t( | ||
'key_management_service_credential_create_confirmation_private-key_title', | ||
)} | ||
</Subtitle> | ||
<OsdsMessage | ||
icon={ODS_ICON_NAME.WARNING} | ||
color={ODS_THEME_COLOR_INTENT.warning} | ||
> | ||
{t( | ||
'key_management_service_credential_create_confirmation_private-key_warn', | ||
)} | ||
</OsdsMessage> | ||
<span> | ||
<OsdsButton | ||
variant={ODS_BUTTON_VARIANT.stroked} | ||
color={ODS_THEME_COLOR_INTENT.primary} | ||
href={`data:text/plain;charset=utf-8,${encodeURIComponent( | ||
privateKey.replace(/\n/g, '\r\n'), | ||
)}`} | ||
download={`${credentialId}_privatekey.pem`} | ||
inline | ||
size={ODS_BUTTON_SIZE.sm} | ||
> | ||
{t( | ||
'key_management_service_credential_create_confirmation_private-key_download_label', | ||
)} | ||
</OsdsButton> | ||
</span> | ||
<OsdsCheckbox | ||
checked={isKeyDownloaded} | ||
onOdsCheckedChange={() => setIsKeyDownloaded(!isKeyDownloaded)} | ||
> | ||
<OsdsCheckboxButton color={ODS_THEME_COLOR_INTENT.primary}> | ||
<span slot="end"> | ||
<OsdsText color={ODS_THEME_COLOR_INTENT.text}> | ||
{t( | ||
'key_management_service_credential_create_confirmation_private-key_checkbox_label', | ||
)} | ||
</OsdsText> | ||
</span> | ||
</OsdsCheckboxButton> | ||
</OsdsCheckbox> | ||
</div> | ||
</OsdsTile> | ||
); | ||
}; | ||
|
||
export default CreateCredentialConfirmationPrivateKey; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.