Skip to content

Commit

Permalink
update: [code-1826] upgrade to harness code from gitness (#2009)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkapoor10 authored and Harness committed Apr 29, 2024
1 parent 1916b30 commit 8c18a93
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 34 deletions.
4 changes: 4 additions & 0 deletions web/src/framework/strings/stringTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,14 @@ export interface StringsMap {
'exportSpace.accesstokenReq': string
'exportSpace.entitiesLabel': string
'exportSpace.exportCompleted': string
'exportSpace.exportFailed': string
'exportSpace.exportRepo': string
'exportSpace.exportRepoCompleted': string
'exportSpace.harness': string
'exportSpace.newProject': string
'exportSpace.orgIdPlaceholder': string
'exportSpace.organization': string
'exportSpace.projectIdPlaceholder': string
'exportSpace.projectName': string
'exportSpace.projectOrg': string
'exportSpace.repoToConvert': string
Expand All @@ -317,6 +320,7 @@ export interface StringsMap {
'exportSpace.upgrade': string
'exportSpace.upgradeConfirmation': string
'exportSpace.upgradeContent': string
'exportSpace.upgradeFailed': string
'exportSpace.upgradeHarness': string
'exportSpace.upgradeProgress': string
'exportSpace.upgradeTitle': string
Expand Down
24 changes: 14 additions & 10 deletions web/src/i18n/strings.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -861,26 +861,30 @@ exportSpace:
harness: Harness
accIdRequired: Account ID is required
accesstokenReq: Access token is required
accIdLabel: 'Harness Account Id'
accIdLabel: 'Harness Account ID'
accIdPlaceholder: 'Enter the Harness Account ID'
tokenLabel: 'Account Token'
tokenLabel: 'Harness Account Token'
tokenPlaceholder: 'Enter the access token here'
organization: Organization
projectName: Project Name
organization: Organization ID
orgIdPlaceholder: Enter the organization ID here
projectName: Project ID
projectIdPlaceholder: Enter the project ID here
entitiesLabel: Entities to upgrade
projectOrg: Project Organization
repoToConvert: '{{length}} repositories to be upgraded'
repoToConvert: '{length} {length|1:repository,repositories} to be upgraded'
startUpgrade: Start Upgrade
upgradeHarness: Upgrade to Harness
newProject: New Project Details
newProject: Harness Project Details
upgradeConfirmation: Upgrade Confirmation
upgradeTitle: Upgrade this project to the Harness Software Delivery platform
upgrade: Upgrade (Coming Soon)
upgradeContent: Upgrade this project to Harness. By upgrading to Harness, you will create a new project in your Harness account and migrate all repositories to the new project. Learn more about Harness.
upgrade: Upgrade to Harness
upgradeContent: The upgrade will import all repositories into an existing organization and project in Harness Code. Learn more about Harness Code here.
upgradeProgress: 'Upgrading in progress'
upgradeFailed: 'Upgrade Failed! Please validate your credentials and try again.'
exportCompleted: Upgrade Completed
exportRepoCompleted: Upgraded {{repoCount}} repositories
exportRepo: Upgrading {{repoCount}} repositories
exportFailed: Upgrade Failed
exportRepoCompleted: Upgraded {repoCount} {repoCount|1:repository,repositories}
exportRepo: Upgrading {repoCount} {repoCount|1:repository,repositories}
spaceUpdate: Project Updated
generate: Generate
generateHelptext: Let Gitness build your Pipeline for you.
Expand Down
42 changes: 29 additions & 13 deletions web/src/pages/SpaceSettings/ExportForm/ExportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import React, { useState } from 'react'
import React from 'react'
import { Intent } from '@blueprintjs/core'
import * as yup from 'yup'
import { useGet } from 'restful-react'
Expand All @@ -24,15 +24,15 @@ import { Color } from '@harnessio/design-system'
import {
Button,
Container,
Label,
Layout,
FlexExpander,
Formik,
FormikForm,
FormInput,
Text,
ButtonSize,
ButtonVariation
ButtonVariation,
stringSubstitute
} from '@harnessio/uicore'
import { Icon } from '@harnessio/icons'
import type { TypesRepository } from 'services/code'
Expand All @@ -55,7 +55,7 @@ interface ExportFormProps {
const ExportForm = (props: ExportFormProps) => {
const { handleSubmit, loading, hideModal, step, setStep, space } = props
const { getString } = useStrings()
const [auth, setAuth] = useState(false)
// const [auth, setAuth] = useState(false)
const formInitialValues: ExportFormDataExtended = {
accountId: '',
token: '',
Expand Down Expand Up @@ -129,7 +129,17 @@ const ExportForm = (props: ExportFormProps) => {
) : null}
<FormInput.Text
name="token"
label={getString('exportSpace.tokenLabel')}
label={
<>
{getString('exportSpace.tokenLabel')}
<a
target="_blank"
rel="noreferrer"
href="https://developer.harness.io/docs/platform/automation/api/add-and-manage-api-keys/">
<Icon padding={{ left: 'small' }} className={css.icon} name="code-info" size={16} />
</a>
</>
}
placeholder={getString('exportSpace.tokenPlaceholder')}
tooltipProps={{
dataTooltipId: 'tokenTextField'
Expand All @@ -154,7 +164,7 @@ const ExportForm = (props: ExportFormProps) => {
<FormInput.Text
name="organization"
label={getString('exportSpace.organization')}
placeholder={getString('importSpace.orgNamePlaceholder')}
placeholder={getString('exportSpace.orgIdPlaceholder')}
tooltipProps={{
dataTooltipId: 'importSpaceOrgName'
}}
Expand All @@ -172,7 +182,7 @@ const ExportForm = (props: ExportFormProps) => {
<FormInput.Text
name="name"
label={getString('exportSpace.projectName')}
placeholder={getString('enterName')}
placeholder={getString('exportSpace.projectIdPlaceholder')}
tooltipProps={{
dataTooltipId: 'exportProjectName'
}}
Expand All @@ -187,12 +197,14 @@ const ExportForm = (props: ExportFormProps) => {
</Text>
) : null}
</Container>
<Layout.Horizontal>
{/* <Layout.Horizontal>
<Label>{getString('exportSpace.entitiesLabel')}</Label>
<Icon padding={{ left: 'small' }} className={css.icon} name="code-info" size={16} />
</Layout.Horizontal>
<a href="">
<Icon padding={{ left: 'small' }} className={css.icon} name="code-info" size={16} />
</a>
</Layout.Horizontal> */}

<Container className={css.importContainer} padding={'medium'}>
{/* <Container className={css.importContainer} padding={'medium'}>
<Layout.Horizontal>
<FormInput.CheckBox
name="repositories"
Expand Down Expand Up @@ -221,7 +233,7 @@ const ExportForm = (props: ExportFormProps) => {
/>
</Container>
</Layout.Horizontal>
</Container>
</Container> */}
</Container>
</>
) : null}
Expand Down Expand Up @@ -266,7 +278,11 @@ const ExportForm = (props: ExportFormProps) => {
font={{
variation: FontVariation.BODY2
}}>
{getString('exportSpace.repoToConvert', { length: repositories?.length })}
{
stringSubstitute(getString('exportSpace.repoToConvert'), {
length: repositories?.length
}) as string
}
</Text>
</Container>
</Container>
Expand Down
47 changes: 36 additions & 11 deletions web/src/pages/SpaceSettings/SpaceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
FlexExpander,
useToaster,
Heading,
TextInput
TextInput,
stringSubstitute
} from '@harnessio/uicore'
import cx from 'classnames'
import { noop } from 'lodash-es'
Expand All @@ -36,6 +37,7 @@ import { Intent, Color, FontVariation } from '@harnessio/design-system'
import { useHistory } from 'react-router-dom'
import { Dialog } from '@blueprintjs/core'
import { ProgressBar, Intent as IntentCore } from '@blueprintjs/core'
import { Icon } from '@harnessio/icons'
import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata'
import { JobProgress, useGetSpace } from 'services/code'
import { useAppContext } from 'AppContext'
Expand Down Expand Up @@ -97,6 +99,7 @@ export default function SpaceSettings() {
if (exportProgressSpace?.repos && checkExportIsRunning()) {
setUpgrading(true)
setRepoCount(exportProgressSpace?.repos.length)
setExportDone(false)
} else if (exportProgressSpace?.repos && checkReposState()) {
setRepoCount(countFinishedRepos)
setExportDone(true)
Expand All @@ -114,6 +117,10 @@ export default function SpaceSettings() {
if (exportProgressSpace && checkReposState()) {
setRepoCount(countFinishedRepos)
setExportDone(true)
} else if (exportProgressSpace?.repos && checkExportIsRunning()) {
setUpgrading(true)
setRepoCount(exportProgressSpace?.repos.length)
setExportDone(false)
}
}
})
Expand All @@ -139,6 +146,7 @@ export default function SpaceSettings() {
.then(_ => {
hideModal()
setUpgrading(true)
refetchExport()
})
.catch(_error => {
showError(getErrorMessage(_error), 0, getString('failedToImportSpace'))
Expand Down Expand Up @@ -238,23 +246,34 @@ export default function SpaceSettings() {
padding={{ left: 'small' }}
font={{ variation: FontVariation.CARD_TITLE, size: 'medium' }}>
{exportDone
? getString('exportSpace.exportCompleted')
? repoCount
? getString('exportSpace.exportCompleted')
: getString('exportSpace.exportFailed')
: getString('exportSpace.upgradeProgress')}
</Text>
</Layout.Horizontal>
<Container padding={'xxlarge'}>
<Layout.Vertical spacing="large">
{exportDone ? null : <ProgressBar intent={IntentCore.PRIMARY} className={css.progressBar} />}
<Container padding={{ top: 'medium' }}>
<Container padding={{ top: 'small' }}>
{exportDone ? (
<Text
icon={'execution-success'}
icon={repoCount ? 'execution-success' : 'cross'}
iconProps={{
size: 16,
color: Color.GREEN_500
color: repoCount ? Color.GREEN_500 : Color.RED_500
}}>
<Text padding={{ left: 'large' }}>
{getString('exportSpace.exportRepoCompleted', { repoCount })}
<Text padding={{ left: 'small' }}>
{repoCount
? (stringSubstitute(getString('exportSpace.exportRepoCompleted'), {
repoCount
}) as string)
: getString('exportSpace.upgradeFailed')}
{!repoCount && (
<a target="_blank" rel="noreferrer" href="https://docs.gitness.com/support">
<Icon className={css.icon} name="code-info" size={16} />
</a>
)}
</Text>
</Text>
) : (
Expand All @@ -264,8 +283,12 @@ export default function SpaceSettings() {
size: 16,
color: Color.GREY_300
}}>
<Text padding={{ left: 'large' }}>
{getString('exportSpace.exportRepo', { repoCount })}
<Text padding={{ left: 'small' }}>
{
stringSubstitute(getString('exportSpace.exportRepo'), {
repoCount
}) as string
}
</Text>
</Text>
)}
Expand All @@ -292,7 +315,6 @@ export default function SpaceSettings() {
<Button
className={css.button}
variation={ButtonVariation.PRIMARY}
disabled
onClick={() => {
openModal()
}}
Expand All @@ -308,12 +330,15 @@ export default function SpaceSettings() {
</Text>
</Layout.Horizontal>
}
// intent="success"
intent="success"
size={ButtonSize.MEDIUM}
/>
</Layout.Horizontal>
<Text padding={{ top: 'large', left: 'xlarge' }} color={Color.GREY_500} font={{ size: 'small' }}>
{getString('exportSpace.upgradeContent')}
<a target="_blank" rel="noreferrer" href="https://developer.harness.io/docs/code-repository">
<Icon className={css.icon} name="code-info" size={16} />
</a>
</Text>
</Container>
)}
Expand Down

0 comments on commit 8c18a93

Please sign in to comment.