Browse Source

SONAR-12514 UI for bitbucket PR decoration configuration

tags/8.1.0.31237
Jeremy Davis 4 years ago
parent
commit
144eddb106
19 changed files with 732 additions and 9 deletions
  1. 10
    0
      server/sonar-web/src/main/js/api/almSettings.ts
  2. 63
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketFormModal.tsx
  3. 94
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTab.tsx
  4. 61
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTabRenderer.tsx
  5. 74
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTable.tsx
  6. 13
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PRDecorationTabs.tsx
  7. 1
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PullRequestDecoration.tsx
  8. 38
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketFormModal-test.tsx
  9. 99
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTab-test.tsx
  10. 40
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTable-test.tsx
  11. 1
    1
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/PRDecorationTabs-test.tsx
  12. 103
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketFormModal-test.tsx.snap
  13. 13
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap
  14. 88
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTable-test.tsx.snap
  15. 1
    0
      server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/PullRequestDecoration-test.tsx.snap
  16. 2
    2
      server/sonar-web/src/main/js/apps/settings/utils.ts
  17. 12
    1
      server/sonar-web/src/main/js/helpers/testMocks.ts
  18. 12
    4
      server/sonar-web/src/main/js/types/alm-settings.d.ts
  19. 7
    1
      sonar-core/src/main/resources/org/sonar/l10n/core.properties

+ 10
- 0
server/sonar-web/src/main/js/api/almSettings.ts View File

@@ -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);
}

+ 63
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketFormModal.tsx View File

@@ -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 (
<>
<AlmDefinitionFormField
autoFocus={true}
formData={formData}
help={true}
id="name"
isTextArea={false}
maxLength={40}
onFieldChange={onFieldChange}
propKey="key"
/>
<AlmDefinitionFormField
formData={formData}
help={false}
id="url.bitbucket"
isTextArea={false}
maxLength={2000}
onFieldChange={onFieldChange}
propKey="url"
/>
<AlmDefinitionFormField
formData={formData}
help={false}
id="personal_access_token"
isTextArea={true}
maxLength={2000}
onFieldChange={onFieldChange}
propKey="personalAccessToken"
/>
</>
);
}

+ 94
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTab.tsx View File

@@ -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<Props, State> {
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 (
<BitbucketTabRenderer
definitions={definitions}
editedDefinition={editedDefinition}
loading={loading}
onCancel={this.handleCancel}
onCreate={this.handleCreate}
onDelete={this.props.onDelete}
onEdit={this.handleEdit}
onSubmit={this.handleSubmit}
/>
);
}
}

+ 61
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTabRenderer.tsx View File

@@ -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 (
<>
<TabHeader alm={ALM_KEYS.BITBUCKET} onCreate={props.onCreate} />

<BitbucketTable
definitions={definitions}
loading={loading}
onDelete={props.onDelete}
onEdit={props.onEdit}
/>

{editedDefinition && (
<AlmPRDecorationFormModal
bindingDefinition={editedDefinition}
onCancel={props.onCancel}
onSubmit={props.onSubmit}>
{childProps => <BitbucketFormModal {...childProps} />}
</AlmPRDecorationFormModal>
)}
</>
);
}

+ 74
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/BitbucketTable.tsx View File

@@ -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 <DeferredSpinner />;
}

return (
<table className="data zebra spacer-bottom">
<thead>
<tr>
<th>{translate('settings.pr_decoration.table.column.name')}</th>
<th>{translate(`settings.pr_decoration.table.column.bitbucket.url`)}</th>
<th className="thin">{translate('settings.pr_decoration.table.column.edit')}</th>
<th className="thin">{translate('settings.pr_decoration.table.column.delete')}</th>
</tr>
</thead>
<tbody>
{definitions.length < 1 ? (
<tr>
<td colSpan={4}>{translate('settings.pr_decoration.table.empty.bitbucket')}</td>
</tr>
) : (
definitions.map(definition => (
<tr key={definition.key}>
<td>{definition.key}</td>
<td>{definition.url}</td>
<td>
<ButtonIcon onClick={() => props.onEdit(definition)}>
<EditIcon />
</ButtonIcon>
</td>
<td>
<DeleteButton onClick={() => props.onDelete(definition.key)} />
</td>
</tr>
))
)}
</tbody>
</table>
);
}

+ 13
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PRDecorationTabs.tsx View File

@@ -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 && (
<BitbucketTab
definitions={definitions.bitbucket}
loading={loading}
onDelete={props.onDelete}
onUpdateDefinitions={props.onUpdateDefinitions}
/>
)}
{currentAlm === ALM_KEYS.GITHUB && (
<GithubTab
definitions={definitions.github}

+ 1
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/PullRequestDecoration.tsx View File

@@ -40,6 +40,7 @@ export default class PullRequestDecoration extends React.PureComponent<{}, State
currentAlm: ALM_KEYS.GITHUB,
definitions: {
[ALM_KEYS.AZURE]: [],
[ALM_KEYS.BITBUCKET]: [],
[ALM_KEYS.GITHUB]: []
},
loading: true

+ 38
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketFormModal-test.tsx View File

@@ -0,0 +1,38 @@
/*
* 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 BitbucketFormModal, { BitbucketFormModalProps } from '../BitbucketFormModal';

it('should render correctly', () => {
expect(shallowRender()).toMatchSnapshot();
expect(shallowRender({ formData: mockBitbucketDefinition() })).toMatchSnapshot();
});

function shallowRender(props: Partial<BitbucketFormModalProps> = {}) {
return shallow(
<BitbucketFormModal
formData={{ key: '', personalAccessToken: '', url: '' }}
onFieldChange={jest.fn()}
{...props}
/>
);
}

+ 99
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTab-test.tsx View File

@@ -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<BitbucketTab['props']> = {}) {
return shallow<BitbucketTab>(
<BitbucketTab
definitions={[]}
loading={false}
onDelete={jest.fn()}
onUpdateDefinitions={jest.fn()}
{...props}
/>
);
}

+ 40
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/BitbucketTable-test.tsx View File

@@ -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<BitbucketTableProps> = {}) {
return shallow(
<BitbucketTable
definitions={[]}
loading={false}
onDelete={jest.fn()}
onEdit={jest.fn()}
{...props}
/>
);
}

+ 1
- 1
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/PRDecorationTabs-test.tsx View File

@@ -33,7 +33,7 @@ function shallowRender(props: Partial<PRDecorationTabsProps> = {}) {
return shallow(
<PRDecorationTabs
currentAlm={ALM_KEYS.GITHUB}
definitions={{ azure: [], github: [] }}
definitions={{ azure: [], bitbucket: [], github: [] }}
loading={false}
onCancel={jest.fn()}
onConfirmDelete={jest.fn()}

+ 103
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketFormModal-test.tsx.snap View File

@@ -0,0 +1,103 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should render correctly 1`] = `
<Fragment>
<AlmDefinitionFormField
autoFocus={true}
formData={
Object {
"key": "",
"personalAccessToken": "",
"url": "",
}
}
help={true}
id="name"
isTextArea={false}
maxLength={40}
onFieldChange={[MockFunction]}
propKey="key"
/>
<AlmDefinitionFormField
formData={
Object {
"key": "",
"personalAccessToken": "",
"url": "",
}
}
help={false}
id="url.bitbucket"
isTextArea={false}
maxLength={2000}
onFieldChange={[MockFunction]}
propKey="url"
/>
<AlmDefinitionFormField
formData={
Object {
"key": "",
"personalAccessToken": "",
"url": "",
}
}
help={false}
id="personal_access_token"
isTextArea={true}
maxLength={2000}
onFieldChange={[MockFunction]}
propKey="personalAccessToken"
/>
</Fragment>
`;

exports[`should render correctly 2`] = `
<Fragment>
<AlmDefinitionFormField
autoFocus={true}
formData={
Object {
"key": "key",
"personalAccessToken": "asdf1234",
"url": "http://bbs.enterprise.com",
}
}
help={true}
id="name"
isTextArea={false}
maxLength={40}
onFieldChange={[MockFunction]}
propKey="key"
/>
<AlmDefinitionFormField
formData={
Object {
"key": "key",
"personalAccessToken": "asdf1234",
"url": "http://bbs.enterprise.com",
}
}
help={false}
id="url.bitbucket"
isTextArea={false}
maxLength={2000}
onFieldChange={[MockFunction]}
propKey="url"
/>
<AlmDefinitionFormField
formData={
Object {
"key": "key",
"personalAccessToken": "asdf1234",
"url": "http://bbs.enterprise.com",
}
}
help={false}
id="personal_access_token"
isTextArea={true}
maxLength={2000}
onFieldChange={[MockFunction]}
propKey="personalAccessToken"
/>
</Fragment>
`;

+ 13
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTab-test.tsx.snap View File

@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should render correctly 1`] = `
<BitbucketTabRenderer
definitions={Array []}
loading={false}
onCancel={[Function]}
onCreate={[Function]}
onDelete={[MockFunction]}
onEdit={[Function]}
onSubmit={[Function]}
/>
`;

+ 88
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/BitbucketTable-test.tsx.snap View File

@@ -0,0 +1,88 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should render correctly 1`] = `
<table
className="data zebra spacer-bottom"
>
<thead>
<tr>
<th>
settings.pr_decoration.table.column.name
</th>
<th>
settings.pr_decoration.table.column.bitbucket.url
</th>
<th
className="thin"
>
settings.pr_decoration.table.column.edit
</th>
<th
className="thin"
>
settings.pr_decoration.table.column.delete
</th>
</tr>
</thead>
<tbody>
<tr>
<td
colSpan={4}
>
settings.pr_decoration.table.empty.bitbucket
</td>
</tr>
</tbody>
</table>
`;

exports[`should render correctly 2`] = `
<table
className="data zebra spacer-bottom"
>
<thead>
<tr>
<th>
settings.pr_decoration.table.column.name
</th>
<th>
settings.pr_decoration.table.column.bitbucket.url
</th>
<th
className="thin"
>
settings.pr_decoration.table.column.edit
</th>
<th
className="thin"
>
settings.pr_decoration.table.column.delete
</th>
</tr>
</thead>
<tbody>
<tr
key="key"
>
<td>
key
</td>
<td>
http://bbs.enterprise.com
</td>
<td>
<ButtonIcon
onClick={[Function]}
>
<EditIcon />
</ButtonIcon>
</td>
<td>
<DeleteButton
onClick={[Function]}
/>
</td>
</tr>
</tbody>
</table>
`;

+ 1
- 0
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecoration/__tests__/__snapshots__/PullRequestDecoration-test.tsx.snap View File

@@ -6,6 +6,7 @@ exports[`should render correctly 1`] = `
definitions={
Object {
"azure": Array [],
"bitbucket": Array [],
"github": Array [],
}
}

+ 2
- 2
server/sonar-web/src/main/js/apps/settings/utils.ts View File

@@ -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'
};


+ 12
- 1
server/sonar-web/src/main/js/helpers/testMocks.ts View File

@@ -60,12 +60,23 @@ export function mockAzureDefinition(
};
}

export function mockBitbucketDefinition(
overrides: Partial<T.BitbucketBindingDefinition> = {}
): T.BitbucketBindingDefinition {
return {
key: 'key',
personalAccessToken: 'asdf1234',
url: 'http://bbs.enterprise.com',
...overrides
};
}

export function mockGithubDefinition(
overrides: Partial<T.GithubBindingDefinition> = {}
): T.GithubBindingDefinition {
return {
key: 'key',
url: 'http:alm.enterprise.com',
url: 'http://github.enterprise.com',
appId: '123456',
privateKey: 'asdf1234',
...overrides

+ 12
- 4
server/sonar-web/src/main/js/types/alm-settings.d.ts View File

@@ -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;

+ 7
- 1
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -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

Loading…
Cancel
Save