From 6a6c62f9b3c0e01bdef5f481f1e89c02091aae51 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Mon, 1 Jul 2024 19:09:53 +0000 Subject: [PATCH] feat: [code-2061]: add ssh support in gitness (#2140) --- .../CloneButtonTooltip/CloneButtonTooltip.tsx | 72 +++++--- web/src/framework/strings/stringTypes.ts | 13 ++ web/src/i18n/strings.en.yaml | 15 ++ web/src/icons/sshKey.svg | 1 + .../pages/UserProfile/NewSshKey/NewSshKey.tsx | 142 +++++++++++++++ .../pages/UserProfile/UserProfile.module.scss | 44 +++++ .../UserProfile/UserProfile.module.scss.d.ts | 5 + web/src/pages/UserProfile/UserProfile.tsx | 170 ++++++++++++++++-- web/src/utils/Utils.ts | 12 ++ 9 files changed, 438 insertions(+), 36 deletions(-) create mode 100644 web/src/icons/sshKey.svg create mode 100644 web/src/pages/UserProfile/NewSshKey/NewSshKey.tsx diff --git a/web/src/components/CloneButtonTooltip/CloneButtonTooltip.tsx b/web/src/components/CloneButtonTooltip/CloneButtonTooltip.tsx index 1f4a073129..0ac8e501d0 100644 --- a/web/src/components/CloneButtonTooltip/CloneButtonTooltip.tsx +++ b/web/src/components/CloneButtonTooltip/CloneButtonTooltip.tsx @@ -17,7 +17,7 @@ import React, { useState } from 'react' import { Render } from 'react-jsx-match' import cx from 'classnames' -import { Button, ButtonVariation, Container, FlexExpander, Layout, Text } from '@harnessio/uicore' +import { Button, ButtonVariation, Container, FlexExpander, Layout, PillToggle, Text } from '@harnessio/uicore' import { Color, FontVariation } from '@harnessio/design-system' import { Classes } from '@blueprintjs/core' import { Icon } from '@harnessio/icons' @@ -32,11 +32,16 @@ interface CloneButtonTooltipProps { httpsURL: string sshURL: string } +enum CloneType { + HTTPS = 'https', + SSH = 'ssh' +} export function CloneButtonTooltip({ httpsURL, sshURL }: CloneButtonTooltipProps) { const { getString } = useStrings() const [flag, setFlag] = useState(false) const { isCurrentSessionPublic } = useAppContext() + const [type, setType] = useState(CloneType.HTTPS) return ( @@ -53,30 +58,51 @@ export function CloneButtonTooltip({ httpsURL, sshURL }: CloneButtonTooltipProps /> {getString('cloneHTTPS')} - - { - // TODO: replace with data from config api - sshURL && {getString('http')} - } - - {httpsURL} + {sshURL ? ( + + + + { + setType(typeClicked as CloneType) + }} + options={[ + { label: CloneType.HTTPS.toUpperCase(), value: 'https' }, + { label: CloneType.SSH.toUpperCase(), value: 'ssh' } + ]} + /> + + {type === CloneType.HTTPS ? ( + + {httpsURL} - - - - { - // TODO: replace with data from config api - sshURL && ( - - {getString('ssh')} - - {sshURL} + + + ) : ( + + {sshURL} + + + + )} + + + ) : ( + + + {httpsURL} + + + + + )} - - - - ) - }