From 144eddb106ad2a93c93a278e586bff807dcd1853 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Tue, 22 Oct 2019 11:16:59 +0200 Subject: [PATCH] SONAR-12514 UI for bitbucket PR decoration configuration --- .../sonar-web/src/main/js/api/almSettings.ts | 10 ++ .../BitbucketFormModal.tsx | 63 +++++++++++ .../pullRequestDecoration/BitbucketTab.tsx | 94 ++++++++++++++++ .../BitbucketTabRenderer.tsx | 61 +++++++++++ .../pullRequestDecoration/BitbucketTable.tsx | 74 +++++++++++++ .../PRDecorationTabs.tsx | 13 +++ .../PullRequestDecoration.tsx | 1 + .../__tests__/BitbucketFormModal-test.tsx | 38 +++++++ .../__tests__/BitbucketTab-test.tsx | 99 +++++++++++++++++ .../__tests__/BitbucketTable-test.tsx | 40 +++++++ .../__tests__/PRDecorationTabs-test.tsx | 2 +- .../BitbucketFormModal-test.tsx.snap | 103 ++++++++++++++++++ .../__snapshots__/BitbucketTab-test.tsx.snap | 13 +++ .../BitbucketTable-test.tsx.snap | 88 +++++++++++++++ .../PullRequestDecoration-test.tsx.snap | 1 + .../src/main/js/apps/settings/utils.ts | 4 +- .../src/main/js/helpers/testMocks.ts | 13 ++- .../src/main/js/types/alm-settings.d.ts | 16 ++- .../resources/org/sonar/l10n/core.properties | 8 +- 19 files changed, 732 insertions(+), 9 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketFormModal.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTab.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTabRenderer.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTable.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketFormModal-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTab-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTable-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketFormModal-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTable-test.tsx.snap diff --git a/server/sonar-web/src/main/js/api/almSettings.ts b/server/sonar-web/src/main/js/api/almSettings.ts index e7aaee50827..2d20b9f0511 100644 --- a/server/sonar-web/src/main/js/api/almSettings.ts +++ b/server/sonar-web/src/main/js/api/almSettings.ts @@ -46,6 +46,16 @@ export function updateAzureConfiguration(data: T.AzureBindingDefinition & { newK return post('/api/alm_settings/update_azure', data).catch(throwGlobalError); } +export function createBitbucketConfiguration(data: T.BitbucketBindingDefinition) { + return post('/api/alm_settings/create_bitbucket', data).catch(throwGlobalError); +} + +export function updateBitbucketConfiguration( + data: T.BitbucketBindingDefinition & { newKey: string } +) { + return post('/api/alm_settings/update_bitbucket', data).catch(throwGlobalError); +} + export function deleteConfiguration(key: string) { return post('/api/alm_settings/delete', { key }).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketFormModal.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketFormModal.tsx new file mode 100644 index 00000000000..0f34916731f --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketFormModal.tsx @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import { AlmDefinitionFormField } from './AlmDefinitionFormField'; + +export interface BitbucketFormModalProps { + formData: T.BitbucketBindingDefinition; + onFieldChange: (fieldId: keyof T.BitbucketBindingDefinition, value: string) => void; +} + +export default function BitbucketFormModal(props: BitbucketFormModalProps) { + const { formData, onFieldChange } = props; + + return ( + <> + + + + + ); +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTab.tsx new file mode 100644 index 00000000000..9f8af24d00e --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTab.tsx @@ -0,0 +1,94 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import { + createBitbucketConfiguration, + updateBitbucketConfiguration +} from '../../../../api/almSettings'; +import BitbucketTabRenderer from './BitbucketTabRenderer'; + +interface Props { + definitions: T.BitbucketBindingDefinition[]; + loading: boolean; + onDelete: (definitionKey: string) => void; + onUpdateDefinitions: () => void; +} + +interface State { + editedDefinition?: T.BitbucketBindingDefinition; + projectCount?: number; +} + +export default class BitbucketTab extends React.PureComponent { + mounted = false; + state: State = {}; + + componentDidMount() { + this.mounted = true; + } + + componentWillUnmount() { + this.mounted = false; + } + + handleCancel = () => { + this.setState({ + editedDefinition: undefined + }); + }; + + handleCreate = () => { + this.setState({ editedDefinition: { key: '', url: '', personalAccessToken: '' } }); + }; + + handleEdit = (config: T.BitbucketBindingDefinition) => { + this.setState({ editedDefinition: config }); + }; + + handleSubmit = (config: T.BitbucketBindingDefinition, originalKey: string) => { + const call = originalKey + ? updateBitbucketConfiguration({ newKey: config.key, ...config, key: originalKey }) + : createBitbucketConfiguration(config); + return call + .then(() => { + if (this.mounted) { + this.setState({ editedDefinition: undefined }); + } + }) + .then(this.props.onUpdateDefinitions); + }; + + render() { + const { definitions, loading } = this.props; + const { editedDefinition } = this.state; + return ( + + ); + } +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTabRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTabRenderer.tsx new file mode 100644 index 00000000000..52c14765e1c --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTabRenderer.tsx @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import { ALM_KEYS } from '../../utils'; +import AlmPRDecorationFormModal from './AlmPRDecorationFormModal'; +import BitbucketFormModal from './BitbucketFormModal'; +import BitbucketTable from './BitbucketTable'; +import TabHeader from './TabHeader'; + +export interface BitbucketTabRendererProps { + editedDefinition?: T.BitbucketBindingDefinition; + definitions: T.BitbucketBindingDefinition[]; + loading: boolean; + onCancel: () => void; + onCreate: () => void; + onDelete: (definitionKey: string) => void; + onEdit: (config: T.BitbucketBindingDefinition) => void; + onSubmit: (config: T.BitbucketBindingDefinition, originalKey: string) => void; +} + +export default function BitbucketTabRenderer(props: BitbucketTabRendererProps) { + const { definitions, editedDefinition, loading } = props; + return ( + <> + + + + + {editedDefinition && ( + + {childProps => } + + )} + + ); +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTable.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTable.tsx new file mode 100644 index 00000000000..1c49cb360e8 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTable.tsx @@ -0,0 +1,74 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import { ButtonIcon, DeleteButton } from 'sonar-ui-common/components/controls/buttons'; +import EditIcon from 'sonar-ui-common/components/icons/EditIcon'; +import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner'; +import { translate } from 'sonar-ui-common/helpers/l10n'; + +export interface BitbucketTableProps { + definitions: T.BitbucketBindingDefinition[]; + loading: boolean; + onDelete: (definitionKey: string) => void; + onEdit: (config: T.BitbucketBindingDefinition) => void; +} + +export default function BitbucketTable(props: BitbucketTableProps) { + const { definitions, loading } = props; + + if (loading) { + return ; + } + + return ( + + + + + + + + + + + {definitions.length < 1 ? ( + + + + ) : ( + definitions.map(definition => ( + + + + + + + )) + )} + +
{translate('settings.pr_decoration.table.column.name')}{translate(`settings.pr_decoration.table.column.bitbucket.url`)}{translate('settings.pr_decoration.table.column.edit')}{translate('settings.pr_decoration.table.column.delete')}
{translate('settings.pr_decoration.table.empty.bitbucket')}
{definition.key}{definition.url} + props.onEdit(definition)}> + + + + props.onDelete(definition.key)} /> +
+ ); +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PRDecorationTabs.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PRDecorationTabs.tsx index a10de20c8fe..ded107bd343 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PRDecorationTabs.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PRDecorationTabs.tsx @@ -22,6 +22,7 @@ import BoxedTabs from 'sonar-ui-common/components/controls/BoxedTabs'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { almName, ALM_KEYS } from '../../utils'; import AzureTab from './AzureTab'; +import BitbucketTab from './BitbucketTab'; import DeleteModal from './DeleteModal'; import GithubTab from './GithubTab'; @@ -58,6 +59,10 @@ export default function PRDecorationTabs(props: PRDecorationTabsProps) { key: ALM_KEYS.GITHUB, label: almName[ALM_KEYS.GITHUB] }, + { + key: ALM_KEYS.BITBUCKET, + label: almName[ALM_KEYS.BITBUCKET] + }, { key: ALM_KEYS.AZURE, label: almName[ALM_KEYS.AZURE] @@ -74,6 +79,14 @@ export default function PRDecorationTabs(props: PRDecorationTabsProps) { onUpdateDefinitions={props.onUpdateDefinitions} /> )} + {currentAlm === ALM_KEYS.BITBUCKET && ( + + )} {currentAlm === ALM_KEYS.GITHUB && ( { + expect(shallowRender()).toMatchSnapshot(); + expect(shallowRender({ formData: mockBitbucketDefinition() })).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTab-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTab-test.tsx new file mode 100644 index 00000000000..8aef4b21971 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTab-test.tsx @@ -0,0 +1,99 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { shallow } from 'enzyme'; +import * as React from 'react'; +import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; +import { + createBitbucketConfiguration, + updateBitbucketConfiguration +} from '../../../../../api/almSettings'; +import { mockBitbucketDefinition } from '../../../../../helpers/testMocks'; +import BitbucketTab from '../BitbucketTab'; + +jest.mock('../../../../../api/almSettings', () => ({ + countBindedProjects: jest.fn().mockResolvedValue(2), + createBitbucketConfiguration: jest.fn().mockResolvedValue({}), + deleteConfiguration: jest.fn().mockResolvedValue({}), + updateBitbucketConfiguration: jest.fn().mockResolvedValue({}) +})); + +beforeEach(() => { + jest.clearAllMocks(); +}); + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +it('should handle cancel', async () => { + const wrapper = shallowRender(); + + wrapper.setState({ + editedDefinition: mockBitbucketDefinition() + }); + + wrapper.instance().handleCancel(); + + await waitAndUpdate(wrapper); + + expect(wrapper.state().editedDefinition).toBeUndefined(); +}); + +it('should create config', async () => { + const onUpdateDefinitions = jest.fn(); + const config = mockBitbucketDefinition(); + const wrapper = shallowRender({ onUpdateDefinitions }); + wrapper.setState({ editedDefinition: config }); + + await wrapper.instance().handleSubmit(config, ''); + + expect(createBitbucketConfiguration).toBeCalledWith(config); + expect(onUpdateDefinitions).toBeCalled(); + expect(wrapper.state().editedDefinition).toBeUndefined(); +}); + +it('should update config', async () => { + const onUpdateDefinitions = jest.fn(); + const config = mockBitbucketDefinition(); + const wrapper = shallowRender({ onUpdateDefinitions }); + wrapper.setState({ editedDefinition: config }); + + await wrapper.instance().handleSubmit(config, 'originalKey'); + + expect(updateBitbucketConfiguration).toBeCalledWith({ + newKey: 'key', + ...config, + key: 'originalKey' + }); + expect(onUpdateDefinitions).toBeCalled(); + expect(wrapper.state().editedDefinition).toBeUndefined(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTable-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTable-test.tsx new file mode 100644 index 00000000000..37c0bc2350f --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTable-test.tsx @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { shallow } from 'enzyme'; +import * as React from 'react'; +import { mockBitbucketDefinition } from '../../../../../helpers/testMocks'; +import BitbucketTable, { BitbucketTableProps } from '../BitbucketTable'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); + expect(shallowRender({ definitions: [mockBitbucketDefinition()] })).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/PRDecorationTabs-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/PRDecorationTabs-test.tsx index ef4fb6cd72e..1f34d682137 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/PRDecorationTabs-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/PRDecorationTabs-test.tsx @@ -33,7 +33,7 @@ function shallowRender(props: Partial = {}) { return shallow( + + + + +`; + +exports[`should render correctly 2`] = ` + + + + + +`; diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap new file mode 100644 index 00000000000..68fb3da0537 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + +`; diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTable-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTable-test.tsx.snap new file mode 100644 index 00000000000..95b21970235 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTable-test.tsx.snap @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + + + + + + + + + + + + + + +
+ settings.pr_decoration.table.column.name + + settings.pr_decoration.table.column.bitbucket.url + + settings.pr_decoration.table.column.edit + + settings.pr_decoration.table.column.delete +
+ settings.pr_decoration.table.empty.bitbucket +
+`; + +exports[`should render correctly 2`] = ` + + + + + + + + + + + + + + + + + +
+ settings.pr_decoration.table.column.name + + settings.pr_decoration.table.column.bitbucket.url + + settings.pr_decoration.table.column.edit + + settings.pr_decoration.table.column.delete +
+ key + + http://bbs.enterprise.com + + + + + + +
+`; diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/PullRequestDecoration-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/PullRequestDecoration-test.tsx.snap index c3fa031b26d..4f286f4d173 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/PullRequestDecoration-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/PullRequestDecoration-test.tsx.snap @@ -6,6 +6,7 @@ exports[`should render correctly 1`] = ` definitions={ Object { "azure": Array [], + "bitbucket": Array [], "github": Array [], } } diff --git a/server/sonar-web/src/main/js/apps/settings/utils.ts b/server/sonar-web/src/main/js/apps/settings/utils.ts index 8337e33e576..5e41638529d 100644 --- a/server/sonar-web/src/main/js/apps/settings/utils.ts +++ b/server/sonar-web/src/main/js/apps/settings/utils.ts @@ -24,13 +24,13 @@ export const DEFAULT_CATEGORY = 'general'; export enum ALM_KEYS { AZURE = 'azure', - // BITBUCKET = 'bitbucket', + BITBUCKET = 'bitbucket', GITHUB = 'github' } export const almName = { [ALM_KEYS.AZURE]: 'Azure DevOps Server', - // [ALM_KEYS.BITBUCKET]: 'Bitbucket Server', + [ALM_KEYS.BITBUCKET]: 'Bitbucket Server', [ALM_KEYS.GITHUB]: 'Github Enterprise' }; diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index 40ea08a4cfc..db978e76bee 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -60,12 +60,23 @@ export function mockAzureDefinition( }; } +export function mockBitbucketDefinition( + overrides: Partial = {} +): T.BitbucketBindingDefinition { + return { + key: 'key', + personalAccessToken: 'asdf1234', + url: 'http://bbs.enterprise.com', + ...overrides + }; +} + export function mockGithubDefinition( overrides: Partial = {} ): T.GithubBindingDefinition { return { key: 'key', - url: 'http:alm.enterprise.com', + url: 'http://github.enterprise.com', appId: '123456', privateKey: 'asdf1234', ...overrides diff --git a/server/sonar-web/src/main/js/types/alm-settings.d.ts b/server/sonar-web/src/main/js/types/alm-settings.d.ts index 16fd0be23da..17d7285bc57 100644 --- a/server/sonar-web/src/main/js/types/alm-settings.d.ts +++ b/server/sonar-web/src/main/js/types/alm-settings.d.ts @@ -30,18 +30,26 @@ declare namespace T { export interface AlmSettingsBindingDefinitions { azure: AzureBindingDefinition[]; + bitbucket: BitbucketBindingDefinition[]; github: GithubBindingDefinition[]; } - export interface GithubBindingDefinition extends AlmSettingsBinding { + export interface AzureBindingDefinition extends AlmSettingsBinding { + personalAccessToken: string; + } + + export interface BitbucketBindingDefinition extends AlmSettingsBinding { + personalAccessToken: string; url: string; + } + + export interface GithubBindingDefinition extends AlmSettingsBinding { appId: string; privateKey: string; + url: string; } - export interface AzureBindingDefinition extends AlmSettingsBinding { - personalAccessToken: string; - } + export interface ProjectAlmBinding { key: string; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 5ea5c4e3c74..73113f8f983 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -924,11 +924,16 @@ settings.pr_decoration.category=Pull Requests settings.pr_decoration.title=Pull Requests decoration settings.pr_decoration.description=When Pull Request decoration is enabled, SonarQube publishes the status of the analysis directly in your ALM Pull requests. settings.pr_decoration.manage_instances=Manage instances -settings.pr_decoration.azure.info=The account that will be used to decorate Pull Requests needs write permission. {link} +settings.pr_decoration.azure.info=Accounts that will be used to decorate Pull Requests needs Code: Read & Write permission. {link} +settings.pr_decoration.bitbucket.info=Accounts that will be used to decorate Pull Requests needs write permission. {link} settings.pr_decoration.github.info=You need to install a Github App with specific settings and permissions to enable Pull Request Decoration on your Organization or Repository. {link} settings.pr_decoration.table.title=Pull Request decoration configurations +settings.pr_decoration.table.empty.azure=Create your first Azure DevOps configuration to enable Pull Request decoration on your projects. +settings.pr_decoration.table.empty.bitbucket=Create your first Bitbucket configuration to enable Pull Request decoration on your projects. +settings.pr_decoration.table.empty.github=Create your first Github configuration to enable Pull Request decoration on your organization or repository. settings.pr_decoration.table.create=Create configuration settings.pr_decoration.table.column.name=Name +settings.pr_decoration.table.column.bitbucket.url=BitBucket server URL settings.pr_decoration.table.column.github.url=Github instance URL settings.pr_decoration.table.column.app_id=App ID settings.pr_decoration.table.column.edit=Edit @@ -941,6 +946,7 @@ settings.pr_decoration.form.header.create=Create a Pull Request decoration confi settings.pr_decoration.form.header.edit=Edit the Pull Request decoration configuration settings.pr_decoration.form.name=Configuration name settings.pr_decoration.form.name.help=Give your configuration a clear and succinct name. This name will be used at project level to identify the correct configured GitHub App for a project. +settings.pr_decoration.form.url.bitbucket=Bitbucket Server URL settings.pr_decoration.form.url.github=GitHub Enterprise URL settings.pr_decoration.form.app_id=GitHub App ID settings.pr_decoration.form.private_key=Private Key -- 2.39.5