-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'code-213' of _OKE5H2PQKOUfzFFDuD4FA/default/CODE/gitness (
#38)
- Loading branch information
Showing
12 changed files
with
285 additions
and
8 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
25 changes: 25 additions & 0 deletions
25
web/src/components/CloneCredentialDialog/CloneCredentialDialog.module.scss
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,25 @@ | ||
.layout { | ||
height: 33px; | ||
display: inline-flex; | ||
justify-content: center; | ||
align-items: center; | ||
border: 1px solid var(--grey-200); | ||
background-color: var(--grey-50) !important; | ||
border-radius: 4px; | ||
padding-left: var(--spacing-small) !important; | ||
max-width: 100%; | ||
.url { | ||
// width: 80%; | ||
white-space: nowrap !important; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
font-size: var(--font-size-small) !important; | ||
} | ||
|
||
button#cloneCopyButton { | ||
--button-height: 24px !important; | ||
border-radius: 0 !important; | ||
border-left: 1px solid var(--grey-200) !important; | ||
margin-left: var(--spacing-small) !important; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
web/src/components/CloneCredentialDialog/CloneCredentialDialog.module.scss.d.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,8 @@ | ||
/* eslint-disable */ | ||
// this is an auto-generated file | ||
declare const styles: { | ||
readonly layout: string | ||
readonly url: string | ||
readonly cloneCopyButton: string | ||
} | ||
export default styles |
97 changes: 97 additions & 0 deletions
97
web/src/components/CloneCredentialDialog/CloneCredentialDialog.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,97 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { | ||
Button, | ||
ButtonVariation, | ||
Container, | ||
Dialog, | ||
FlexExpander, | ||
FontVariation, | ||
Layout, | ||
Text, | ||
useToaster | ||
} from '@harness/uicore' | ||
import { useStrings } from 'framework/strings' | ||
import { CopyButton } from 'components/CopyButton/CopyButton' | ||
import { CodeIcon } from 'utils/GitUtils' | ||
import { useAppContext } from 'AppContext' | ||
import { generateAlphaNumericHash } from 'utils/Utils' | ||
import css from './CloneCredentialDialog.module.scss' | ||
import { useHistory } from 'react-router-dom' | ||
|
||
interface CloneCredentialDialogProps { | ||
setFlag: (val: boolean) => void | ||
flag: boolean | ||
} | ||
|
||
const CloneCredentialDialog = (props: CloneCredentialDialogProps) => { | ||
const { setFlag, flag } = props | ||
const history = useHistory() | ||
const { getString } = useStrings() | ||
const { hooks, currentUser,currentUserProfileURL } = useAppContext() | ||
const [token, setToken] = useState('') | ||
const { showError } = useToaster() | ||
const hash = generateAlphaNumericHash(6) | ||
|
||
const tokenData = hooks?.useGenerateToken(hash, currentUser.uid, flag) | ||
useEffect(() => { | ||
if (tokenData) { | ||
if (tokenData && tokenData?.status !== 400) { | ||
setToken(tokenData?.data) | ||
} else if (tokenData?.status === 400 && flag) { | ||
setToken('N/A') | ||
showError(tokenData?.data?.message || tokenData?.message) | ||
} | ||
} | ||
}, [flag, tokenData]) | ||
return ( | ||
<Dialog | ||
isOpen={flag} | ||
enforceFocus={false} | ||
onClose={() => { | ||
setFlag(false) | ||
}} | ||
title={ | ||
<Text font={{ variation: FontVariation.H3 }} icon={'success-tick'} iconProps={{ size: 26 }}> | ||
{getString('getMyCloneTitle')} | ||
</Text> | ||
} | ||
style={{ width: 490, maxHeight: '95vh', overflow: 'auto' }}> | ||
<Layout.Vertical width={380}> | ||
<Text padding={{ bottom: 'small' }} font={{ variation: FontVariation.FORM_LABEL, size: 'small' }}> | ||
{getString('userName')} | ||
</Text> | ||
<Container padding={{ bottom: 'medium' }}> | ||
<Layout.Horizontal className={css.layout}> | ||
<Text className={css.url}>{currentUser.display_name}</Text> | ||
<FlexExpander /> | ||
<CopyButton | ||
content={currentUser.display_name} | ||
id={css.cloneCopyButton} | ||
icon={CodeIcon.Copy} | ||
iconProps={{ size: 14 }} | ||
/> | ||
</Layout.Horizontal> | ||
</Container> | ||
<Text padding={{ bottom: 'small' }} font={{ variation: FontVariation.FORM_LABEL, size: 'small' }}> | ||
{getString('passwordApi')} | ||
</Text> | ||
|
||
<Container padding={{ bottom: 'medium' }}> | ||
<Layout.Horizontal className={css.layout}> | ||
<Text className={css.url}>{token}</Text> | ||
<FlexExpander /> | ||
<CopyButton content={token} id={css.cloneCopyButton} icon={CodeIcon.Copy} iconProps={{ size: 14 }} /> | ||
</Layout.Horizontal> | ||
</Container> | ||
<Text padding={{ bottom: 'medium' }} font={{ variation: FontVariation.BODY2_SEMI, size: 'small' }}> | ||
{getString('cloneText')} | ||
</Text> | ||
<Button onClick={()=>{ | ||
history.push(currentUserProfileURL) | ||
}} variation={ButtonVariation.TERTIARY} text={getString('manageApiToken')} /> | ||
</Layout.Vertical> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default CloneCredentialDialog |
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.