diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2021-01-26 09:30:35 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-02-08 20:07:44 +0000 |
commit | eaa3c931777204492328dc49c93e2cfca3d9c307 (patch) | |
tree | f07933edc99213209b7c84fac80e938ada68f955 /server/sonar-web/src/main/js/apps/create | |
parent | 3bb16bc1523169ff3eba97c9ccc98efc90b6c068 (diff) | |
download | sonarqube-eaa3c931777204492328dc49c93e2cfca3d9c307.tar.gz sonarqube-eaa3c931777204492328dc49c93e2cfca3d9c307.zip |
SONAR-14393 Add admin form for Bitbucket Cloud integration
Diffstat (limited to 'server/sonar-web/src/main/js/apps/create')
10 files changed, 27 insertions, 17 deletions
diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectCreateRenderer.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectCreateRenderer.tsx index a256fc3202e..0f71610155b 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectCreateRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketProjectCreateRenderer.tsx @@ -101,7 +101,7 @@ export default function BitbucketProjectCreateRenderer(props: BitbucketProjectCr {loading && <i className="spinner" />} {!loading && !bitbucketSetting && ( - <WrongBindingCountAlert alm={AlmKeys.Bitbucket} canAdmin={!!canAdmin} /> + <WrongBindingCountAlert alm={AlmKeys.BitbucketServer} canAdmin={!!canAdmin} /> )} {!loading && diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx index 136fb393e5f..e14ba173049 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx @@ -29,7 +29,12 @@ import { ALM_INTEGRATION } from '../../settings/components/AdditionalCategoryKey import { CreateProjectModes } from './types'; export interface CreateProjectModeSelectionProps { - almCounts: { [key in AlmKeys]: number }; + almCounts: { + [AlmKeys.Azure]: number; + [AlmKeys.BitbucketServer]: number; + [AlmKeys.GitLab]: number; + [AlmKeys.GitHub]: number; + }; appState: Pick<T.AppState, 'canAdmin'>; loadingBindings: boolean; onSelectMode: (mode: CreateProjectModes) => void; @@ -37,7 +42,7 @@ export interface CreateProjectModeSelectionProps { function renderAlmOption( props: CreateProjectModeSelectionProps, - alm: AlmKeys, + alm: AlmKeys.Azure | AlmKeys.BitbucketServer | AlmKeys.GitHub | AlmKeys.GitLab, mode: CreateProjectModes ) { const { @@ -145,7 +150,7 @@ export function CreateProjectModeSelection(props: CreateProjectModeSelectionProp </button> {renderAlmOption(props, AlmKeys.Azure, CreateProjectModes.AzureDevOps)} - {renderAlmOption(props, AlmKeys.Bitbucket, CreateProjectModes.BitbucketServer)} + {renderAlmOption(props, AlmKeys.BitbucketServer, CreateProjectModes.BitbucketServer)} {renderAlmOption(props, AlmKeys.GitHub, CreateProjectModes.GitHub)} {renderAlmOption(props, AlmKeys.GitLab, CreateProjectModes.GitLab)} </div> diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx index c2bdfd909e2..45feaadb2ad 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx @@ -75,7 +75,7 @@ export class CreateProjectPage extends React.PureComponent<Props, State> { if (this.mounted) { this.setState({ azureSettings: almSettings.filter(s => s.alm === AlmKeys.Azure), - bitbucketSettings: almSettings.filter(s => s.alm === AlmKeys.Bitbucket), + bitbucketSettings: almSettings.filter(s => s.alm === AlmKeys.BitbucketServer), githubSettings: almSettings.filter(s => s.alm === AlmKeys.GitHub), gitlabSettings: almSettings.filter(s => s.alm === AlmKeys.GitLab), loading: false @@ -171,7 +171,7 @@ export class CreateProjectPage extends React.PureComponent<Props, State> { default: { const almCounts = { [AlmKeys.Azure]: azureSettings.length, - [AlmKeys.Bitbucket]: bitbucketSettings.length, + [AlmKeys.BitbucketServer]: bitbucketSettings.length, [AlmKeys.GitHub]: githubSettings.length, [AlmKeys.GitLab]: gitlabSettings.length }; diff --git a/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx b/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx index 9062a7e84ac..51811a40ac1 100644 --- a/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx @@ -36,7 +36,7 @@ export interface PersonalAccessTokenFormProps { } function getPatUrl(alm: AlmKeys, url: string) { - if (alm === AlmKeys.Bitbucket) { + if (alm === AlmKeys.BitbucketServer) { return `${url.replace(/\/$/, '')}/plugins/servlet/access-tokens/add`; } else { // GitLab @@ -132,7 +132,7 @@ export default function PersonalAccessTokenForm(props: PersonalAccessTokenFormPr </p> <ul> - {alm === AlmKeys.Bitbucket && ( + {alm === AlmKeys.BitbucketServer && ( <> <li> <FormattedMessage diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreate-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreate-test.tsx index 43f47357a90..e1317528df6 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreate-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreate-test.tsx @@ -163,7 +163,7 @@ function shallowRender(props: Partial<BitbucketProjectCreate['props']> = {}) { return shallow<BitbucketProjectCreate>( <BitbucketProjectCreate canAdmin={false} - bitbucketSettings={[mockAlmSettingsInstance({ alm: AlmKeys.Bitbucket, key: 'foo' })]} + bitbucketSettings={[mockAlmSettingsInstance({ alm: AlmKeys.BitbucketServer, key: 'foo' })]} loadingBindings={false} location={mockLocation()} onProjectCreate={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreateRenderer-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreateRenderer-test.tsx index 2d8990bba1e..127da7584f4 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreateRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/BitbucketProjectCreateRenderer-test.tsx @@ -48,7 +48,7 @@ it('should render correctly', () => { function shallowRender(props: Partial<BitbucketProjectCreateRendererProps> = {}) { return shallow<BitbucketProjectCreateRendererProps>( <BitbucketProjectCreateRenderer - bitbucketSetting={mockAlmSettingsInstance({ alm: AlmKeys.Bitbucket })} + bitbucketSetting={mockAlmSettingsInstance({ alm: AlmKeys.BitbucketServer })} importing={false} loading={false} onImportRepository={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx index 642a92aba77..33dfbd45215 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectModeSelection-test.tsx @@ -30,11 +30,14 @@ import { CreateProjectModes } from '../types'; it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot('default'); expect(shallowRender({ loadingBindings: true })).toMatchSnapshot('loading instances'); - expect(shallowRender({}, { [AlmKeys.Bitbucket]: 0, [AlmKeys.GitHub]: 2 })).toMatchSnapshot( + expect(shallowRender({}, { [AlmKeys.BitbucketServer]: 0, [AlmKeys.GitHub]: 2 })).toMatchSnapshot( 'invalid configs, not admin' ); expect( - shallowRender({ appState: { canAdmin: true } }, { [AlmKeys.Bitbucket]: 0, [AlmKeys.GitHub]: 2 }) + shallowRender( + { appState: { canAdmin: true } }, + { [AlmKeys.BitbucketServer]: 0, [AlmKeys.GitHub]: 2 } + ) ).toMatchSnapshot('invalid configs, admin'); }); @@ -71,7 +74,7 @@ function shallowRender( ) { const almCounts = { [AlmKeys.Azure]: 0, - [AlmKeys.Bitbucket]: 1, + [AlmKeys.BitbucketServer]: 1, [AlmKeys.GitHub]: 0, [AlmKeys.GitLab]: 0, ...almCountOverrides diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx index e59baf2bb09..dd9682364f3 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx @@ -26,7 +26,7 @@ import { CreateProjectPage } from '../CreateProjectPage'; import { CreateProjectModes } from '../types'; jest.mock('../../../../api/alm-settings', () => ({ - getAlmSettings: jest.fn().mockResolvedValue([{ alm: AlmKeys.Bitbucket, key: 'foo' }]) + getAlmSettings: jest.fn().mockResolvedValue([{ alm: AlmKeys.BitbucketServer, key: 'foo' }]) })); beforeEach(jest.clearAllMocks); diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/PersonalAccessTokenForm-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/PersonalAccessTokenForm-test.tsx index 2f4ee698f96..5e7571a211b 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/PersonalAccessTokenForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/PersonalAccessTokenForm-test.tsx @@ -71,7 +71,7 @@ function shallowRender(props: Partial<PersonalAccessTokenFormProps> = {}) { return shallow<PersonalAccessTokenFormProps>( <PersonalAccessTokenForm almSetting={mockAlmSettingsInstance({ - alm: AlmKeys.Bitbucket, + alm: AlmKeys.BitbucketServer, url: 'http://www.example.com' })} onPersonalAccessTokenCreate={jest.fn()} diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/WrongBindingCountAlert-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/WrongBindingCountAlert-test.tsx index cc15f4311f0..3cc603af89c 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/WrongBindingCountAlert-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/WrongBindingCountAlert-test.tsx @@ -24,10 +24,12 @@ import WrongBindingCountAlert, { WrongBindingCountAlertProps } from '../WrongBin it('should render correctly', () => { expect(shallowRender({ canAdmin: true })).toMatchSnapshot('for admin'); - expect(shallowRender({ alm: AlmKeys.Bitbucket })).toMatchSnapshot('bitbucket'); + expect(shallowRender({ alm: AlmKeys.BitbucketServer })).toMatchSnapshot('bitbucket'); expect(shallowRender({ alm: AlmKeys.GitLab })).toMatchSnapshot('gitlab'); }); function shallowRender(props: Partial<WrongBindingCountAlertProps> = {}) { - return shallow(<WrongBindingCountAlert alm={AlmKeys.Bitbucket} canAdmin={false} {...props} />); + return shallow( + <WrongBindingCountAlert alm={AlmKeys.BitbucketServer} canAdmin={false} {...props} /> + ); } |