@@ -19,10 +19,11 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import AlmSettingsInstanceSelector from '../../../components/devops-platform/AlmSettingsInstanceSelector'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { AlmSettingsInstance } from '../../../types/alm-settings'; | |||
import { hasMessage, translate, translateWithParameters } from '../../../helpers/l10n'; | |||
import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; | |||
export interface AlmSettingsInstanceDropdownProps { | |||
almKey: AlmKeys; | |||
almInstances?: AlmSettingsInstance[]; | |||
selectedAlmInstance?: AlmSettingsInstance; | |||
onChangeConfig: (instance: AlmSettingsInstance) => void; | |||
@@ -31,14 +32,19 @@ export interface AlmSettingsInstanceDropdownProps { | |||
const MIN_SIZE_INSTANCES = 2; | |||
export default function AlmSettingsInstanceDropdown(props: AlmSettingsInstanceDropdownProps) { | |||
const { almInstances, selectedAlmInstance } = props; | |||
const { almKey, almInstances, selectedAlmInstance } = props; | |||
if (!almInstances || almInstances.length < MIN_SIZE_INSTANCES) { | |||
return null; | |||
} | |||
const almKeyTranslation = hasMessage(`alm.${almKey}.long`) | |||
? `alm.${almKey}.long` | |||
: `alm.${almKey}`; | |||
return ( | |||
<div className="display-flex-column huge-spacer-bottom"> | |||
<label htmlFor="alm-config-selector" className="spacer-bottom"> | |||
{translate('alm.configuration.selector.label')} | |||
{translateWithParameters('alm.configuration.selector.label', translate(almKeyTranslation))} | |||
</label> | |||
<AlmSettingsInstanceSelector | |||
instances={almInstances} |
@@ -116,6 +116,7 @@ export default function AzureProjectCreateRenderer(props: AzureProjectCreateRend | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey={AlmKeys.Azure} | |||
almInstances={almInstances} | |||
selectedAlmInstance={selectedAlmInstance} | |||
onChangeConfig={props.onSelectedAlmInstanceChange} |
@@ -83,6 +83,7 @@ export default function BitbucketCloudProjectCreateRenderer( | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey={AlmKeys.BitbucketCloud} | |||
almInstances={almInstances} | |||
selectedAlmInstance={selectedAlmInstance} | |||
onChangeConfig={props.onSelectedAlmInstanceChange} |
@@ -101,6 +101,7 @@ export default function BitbucketProjectCreateRenderer(props: BitbucketProjectCr | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey={AlmKeys.BitbucketServer} | |||
almInstances={almInstances} | |||
selectedAlmInstance={selectedAlmInstance} | |||
onChangeConfig={props.onSelectedAlmInstanceChange} |
@@ -26,7 +26,7 @@ import withAppStateContext from '../../../app/components/app-state/withAppStateC | |||
import ChevronsIcon from '../../../components/icons/ChevronsIcon'; | |||
import { translate } from '../../../helpers/l10n'; | |||
import { getBaseUrl } from '../../../helpers/system'; | |||
import { AlmKeys, AlmKeysUnion } from '../../../types/alm-settings'; | |||
import { AlmKeys } from '../../../types/alm-settings'; | |||
import { AppState } from '../../../types/appstate'; | |||
import { CreateProjectModes } from './types'; | |||
@@ -53,7 +53,7 @@ function getErrorMessage(hasConfig: boolean, canAdmin: boolean | undefined) { | |||
function renderAlmOption( | |||
props: CreateProjectModeSelectionProps, | |||
alm: AlmKeysUnion, | |||
alm: AlmKeys, | |||
mode: CreateProjectModes, | |||
last = false | |||
) { |
@@ -37,7 +37,7 @@ import { translate } from '../../../helpers/l10n'; | |||
import { getBaseUrl } from '../../../helpers/system'; | |||
import { getProjectUrl } from '../../../helpers/urls'; | |||
import { GithubOrganization, GithubRepository } from '../../../types/alm-integration'; | |||
import { AlmSettingsInstance } from '../../../types/alm-settings'; | |||
import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; | |||
import { ComponentQualifier } from '../../../types/component'; | |||
import { Paging } from '../../../types/types'; | |||
import AlmSettingsInstanceDropdown from './AlmSettingsInstanceDropdown'; | |||
@@ -220,6 +220,7 @@ export default function GitHubProjectCreateRenderer(props: GitHubProjectCreateRe | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey={AlmKeys.GitHub} | |||
almInstances={almInstances} | |||
selectedAlmInstance={selectedAlmInstance} | |||
onChangeConfig={props.onSelectedAlmInstanceChange} |
@@ -82,6 +82,7 @@ export default function GitlabProjectCreateRenderer(props: GitlabProjectCreateRe | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey={AlmKeys.GitLab} | |||
almInstances={almInstances} | |||
selectedAlmInstance={selectedAlmInstance} | |||
onChangeConfig={props.onSelectedAlmInstanceChange} |
@@ -41,7 +41,7 @@ const ui = { | |||
personalAccessTokenInput: byRole('textbox', { | |||
name: 'onboarding.create_project.enter_pat field_required', | |||
}), | |||
instanceSelector: byLabelText('alm.configuration.selector.label'), | |||
instanceSelector: byLabelText(/alm.configuration.selector.label/), | |||
}; | |||
beforeAll(() => { | |||
@@ -70,7 +70,7 @@ describe('Gitlab onboarding page', () => { | |||
await user.click(ui.gitlabCreateProjectButton.get()); | |||
expect(screen.getByText('onboarding.create_project.gitlab.title')).toBeInTheDocument(); | |||
expect(screen.getByText('alm.configuration.selector.label')).toBeInTheDocument(); | |||
expect(ui.instanceSelector.get()).toBeInTheDocument(); | |||
expect(screen.getByText('onboarding.create_project.enter_pat')).toBeInTheDocument(); | |||
expect(screen.getByText('onboarding.create_project.pat_help.title')).toBeInTheDocument(); | |||
@@ -120,11 +120,9 @@ describe('Github onboarding page', () => { | |||
await user.click(ui.githubCreateProjectButton.get()); | |||
expect(screen.getByText('onboarding.create_project.github.title')).toBeInTheDocument(); | |||
expect(screen.getByText('alm.configuration.selector.placeholder')).toBeInTheDocument(); | |||
expect(screen.getByText('alm.configuration.selector.label')).toBeInTheDocument(); | |||
expect(ui.instanceSelector.get()).toBeInTheDocument(); | |||
await selectEvent.select(screen.getByLabelText('alm.configuration.selector.label'), [ | |||
/conf-github-1/, | |||
]); | |||
await selectEvent.select(ui.instanceSelector.get(), [/conf-github-1/]); | |||
expect(window.location.replace).toHaveBeenCalled(); | |||
expect( |
@@ -27,6 +27,7 @@ exports[`should render correctly: loading 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="azure" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<i | |||
@@ -53,6 +54,7 @@ exports[`should render correctly: no settings 1`] = ` | |||
} | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey="azure" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<WrongBindingCountAlert | |||
@@ -111,6 +113,7 @@ exports[`should render correctly: project list 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="azure" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -186,6 +189,7 @@ exports[`should render correctly: setting missing url, admin 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="azure" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
</Fragment> | |||
@@ -217,6 +221,7 @@ exports[`should render correctly: setting missing url, not admin 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="azure" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
</Fragment> | |||
@@ -250,6 +255,7 @@ exports[`should render correctly: token form 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="azure" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
</Fragment> |
@@ -26,6 +26,7 @@ exports[`Should render correctly 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucketcloud" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -72,6 +73,7 @@ exports[`Should render correctly: Loading... 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucketcloud" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -112,6 +114,7 @@ exports[`Should render correctly: Need App password 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucketcloud" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -159,6 +162,7 @@ exports[`Should render correctly: Wrong config 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucketcloud" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<WrongBindingCountAlert |
@@ -43,6 +43,7 @@ exports[`should render correctly: default 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucket" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -127,6 +128,7 @@ exports[`should render correctly: importing 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucket" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -211,6 +213,7 @@ exports[`should render correctly: invalid config, admin user 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucket" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<WrongBindingCountAlert | |||
@@ -263,6 +266,7 @@ exports[`should render correctly: invalid config, regular user 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucket" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<WrongBindingCountAlert | |||
@@ -315,6 +319,7 @@ exports[`should render correctly: loading 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucket" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -356,6 +361,7 @@ exports[`should render correctly: pat form 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucket" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -420,6 +426,7 @@ exports[`should render correctly: selected repo 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="bitbucket" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { |
@@ -30,6 +30,7 @@ exports[`should render correctly: default 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="github" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<DeferredSpinner | |||
@@ -82,6 +83,7 @@ exports[`should render correctly: error 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="github" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
</div> | |||
@@ -117,6 +119,7 @@ exports[`should render correctly: error for admin 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="github" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
</div> | |||
@@ -171,6 +174,7 @@ exports[`should render correctly: no repositories 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="github" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<DeferredSpinner | |||
@@ -239,6 +243,7 @@ exports[`should render correctly: organizations 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="github" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<DeferredSpinner | |||
@@ -319,6 +324,7 @@ exports[`should render correctly: repositories 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="github" | |||
onChangeConfig={[MockFunction]} | |||
/> | |||
<DeferredSpinner |
@@ -18,6 +18,7 @@ exports[`should render correctly: invalid settings 1`] = ` | |||
} | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey="gitlab" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -57,6 +58,7 @@ exports[`should render correctly: invalid settings, admin user 1`] = ` | |||
} | |||
/> | |||
<AlmSettingsInstanceDropdown | |||
almKey="gitlab" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -112,6 +114,7 @@ exports[`should render correctly: loading 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="gitlab" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -160,6 +163,7 @@ exports[`should render correctly: pat form 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="gitlab" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { | |||
@@ -215,6 +219,7 @@ exports[`should render correctly: project selection form 1`] = ` | |||
}, | |||
] | |||
} | |||
almKey="gitlab" | |||
onChangeConfig={[MockFunction]} | |||
selectedAlmInstance={ | |||
Object { |
@@ -25,13 +25,6 @@ export const enum AlmKeys { | |||
GitLab = 'gitlab', | |||
} | |||
export type AlmKeysUnion = | |||
| AlmKeys.Azure | |||
| AlmKeys.BitbucketServer | |||
| AlmKeys.BitbucketCloud | |||
| AlmKeys.GitHub | |||
| AlmKeys.GitLab; | |||
export type AlmBindingDefinition = | |||
| AzureBindingDefinition | |||
| GithubBindingDefinition |
@@ -389,7 +389,7 @@ alm.github=GitHub | |||
alm.github.short=GitHub | |||
alm.gitlab=GitLab | |||
alm.gitlab.short=GitLab | |||
alm.configuration.selector.label=What DevOps platform configuration do you want to import projects from? | |||
alm.configuration.selector.label=What {0} configuration do you want to import projects from? | |||
alm.configuration.selector.placeholder=Select a configuration | |||
#------------------------------------------------------------------------------ |