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} + + + + + )} - - - - ) - }