readOnly={readOnly}
value={formData.appId}
/>
+ <AlmBindingDefinitionFormField
+ id="client_id"
+ maxLength={80}
+ onFieldChange={onFieldChange}
+ propKey="clientId"
+ readOnly={readOnly}
+ value={formData.clientId}
+ />
+ <AlmBindingDefinitionFormField
+ id="client_secret"
+ maxLength={80}
+ onFieldChange={onFieldChange}
+ propKey="clientSecret"
+ readOnly={readOnly}
+ value={formData.clientSecret}
+ />
<AlmBindingDefinitionFormField
id="private_key"
isTextArea={true}
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import { translate } from 'sonar-ui-common/helpers/l10n';
+import { FormattedMessage } from 'react-intl';
+import WarningIcon from 'sonar-ui-common/components/icons/WarningIcon';
+import { Alert } from 'sonar-ui-common/components/ui/Alert';
+import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
import { createGithubConfiguration, updateGithubConfiguration } from '../../../../api/alm-settings';
import { AlmKeys, GithubBindingDefinition } from '../../../../types/alm-settings';
import { ALM_INTEGRATION } from '../AdditionalCategoryKeys';
translate('settings.almintegration.table.column.app_id')
]}
additionalColumnsKeys={['url', 'appId']}
+ additionalTableInfo={
+ <Alert className="big-spacer-bottom width-50" variant="info">
+ <FormattedMessage
+ defaultMessage={translate(
+ 'settings.almintegration.feature.alm_repo_import.disabled_if_multiple_github_instances'
+ )}
+ id="settings.almintegration.feature.alm_repo_import.disabled_if_multiple_github_instances"
+ values={{
+ feature: (
+ <em>{translate('settings.almintegration.feature.alm_repo_import.title')}</em>
+ )
+ }}
+ />
+ </Alert>
+ }
alm={AlmKeys.GitHub}
createConfiguration={createGithubConfiguration}
- defaultBinding={{ key: '', appId: '', url: '', privateKey: '' }}
+ defaultBinding={{
+ key: '',
+ appId: '',
+ clientId: '',
+ clientSecret: '',
+ url: '',
+ privateKey: ''
+ }}
definitions={definitions}
features={[
{
active: definitions.length > 0,
description: translate('settings.almintegration.feature.pr_decoration.description'),
inactiveReason: translate('settings.almintegration.feature.need_at_least_1_binding')
+ },
+ {
+ name: translate('settings.almintegration.feature.alm_repo_import.title'),
+ active:
+ definitions.length === 1 &&
+ !!definitions[0].clientId &&
+ !!definitions[0].clientSecret,
+ description: translate(
+ 'settings.almintegration.feature.alm_repo_import.description'
+ ),
+ inactiveReason:
+ definitions.length === 1 ? (
+ <>
+ <WarningIcon className="little-spacer-right" />
+ <FormattedMessage
+ id="settings.almintegration.feature.alm_repo_import.github.requires_fields"
+ defaultMessage={translate(
+ 'settings.almintegration.feature.alm_repo_import.github.requires_fields'
+ )}
+ values={{
+ clientId: <strong>clientId</strong>,
+ clientSecret: <strong>clientSecret</strong>
+ }}
+ />
+ </>
+ ) : (
+ translateWithParameters(
+ 'settings.almintegration.feature.alm_repo_import.github.too_many_instances_x',
+ definitions.length
+ )
+ )
}
]}
form={childProps => <GithubForm {...childProps} />}
key: 'github - example',
url: 'http://github.com',
appId: '34812568251',
+ clientId: 'cid',
+ clientSecret: 'csecret',
privateKey: 'gs7df9g7d9fsg7x9df7g9xdg'
};
wrapper.instance().handleFieldChange('key', formData.key);
wrapper.instance().handleFieldChange('url', formData.url);
wrapper.instance().handleFieldChange('appId', formData.appId);
+ wrapper.instance().handleFieldChange('clientId', formData.clientId);
+ wrapper.instance().handleFieldChange('clientSecret', formData.clientSecret);
wrapper.instance().handleFieldChange('privateKey', formData.privateKey);
expect(wrapper.state().formData).toEqual(formData);
});
const onSubmit = jest.fn();
const wrapper = shallowRender({
onSubmit,
- bindingDefinition: { key: 'originalKey', appId: '', privateKey: '', url: '' }
+ bindingDefinition: {
+ key: 'originalKey',
+ appId: '',
+ clientId: '',
+ clientSecret: '',
+ privateKey: '',
+ url: ''
+ }
});
const formData = {
key: 'github instance',
url: 'http://github.enterprise.com',
appId: '34812568251',
+ clientId: 'client1234',
+ clientSecret: 'secret',
privateKey: 'gs7df9g7d9fsg7x9df7g9xdg'
};
wrapper.setState({ formData });
const onCancel = jest.fn();
const bindingDefinition = {
appId: 'foo',
+ clientId: 'cid',
+ clientSecret: 'cs',
key: 'bar',
privateKey: 'baz',
url: 'http://github.enterprise.com'
) {
return shallow<AlmBindingDefinitionForm<GithubBindingDefinition>>(
<AlmBindingDefinitionForm
- bindingDefinition={{ appId: '', key: '', privateKey: '', url: '' }}
+ bindingDefinition={{
+ appId: '',
+ clientId: '',
+ clientSecret: '',
+ key: '',
+ privateKey: '',
+ url: ''
+ }}
onCancel={jest.fn()}
onSubmit={jest.fn()}
{...props}>
function shallowRender(props: Partial<GithubFormProps> = {}) {
return shallow(
<GithubForm
- formData={{ key: '', appId: '', privateKey: '', url: '' }}
+ formData={{ key: '', appId: '', clientId: '', clientSecret: '', privateKey: '', url: '' }}
onFieldChange={jest.fn()}
{...props}
/>
bindingDefinition={
Object {
"appId": "123456",
+ "clientId": "client1",
+ "clientSecret": "**clientsecret**",
"key": "key",
"privateKey": "asdf1234",
"url": "http://github.enterprise.com",
bindingDefinition={
Object {
"appId": "123456",
+ "clientId": "client1",
+ "clientSecret": "**clientsecret**",
"key": "key",
"privateKey": "asdf1234",
"url": "http://github.enterprise.com",
bindingDefinition={
Object {
"appId": "123456",
+ "clientId": "client1",
+ "clientSecret": "**clientsecret**",
"key": "key",
"privateKey": "asdf1234",
"url": "http://github.enterprise.com",
bindingDefinition={
Object {
"appId": "123456",
+ "clientId": "client1",
+ "clientSecret": "**clientsecret**",
"key": "key",
"privateKey": "asdf1234",
"url": "http://github.enterprise.com",
propKey="appId"
value=""
/>
+ <AlmBindingDefinitionFormField
+ id="client_id"
+ maxLength={80}
+ onFieldChange={[MockFunction]}
+ propKey="clientId"
+ value=""
+ />
+ <AlmBindingDefinitionFormField
+ id="client_secret"
+ maxLength={80}
+ onFieldChange={[MockFunction]}
+ propKey="clientSecret"
+ value=""
+ />
<AlmBindingDefinitionFormField
id="private_key"
isTextArea={true}
propKey="appId"
value="123456"
/>
+ <AlmBindingDefinitionFormField
+ id="client_id"
+ maxLength={80}
+ onFieldChange={[MockFunction]}
+ propKey="clientId"
+ value="client1"
+ />
+ <AlmBindingDefinitionFormField
+ id="client_secret"
+ maxLength={80}
+ onFieldChange={[MockFunction]}
+ propKey="clientSecret"
+ value="**clientsecret**"
+ />
<AlmBindingDefinitionFormField
id="private_key"
isTextArea={true}
"appId",
]
}
+ additionalTableInfo={
+ <Alert
+ className="big-spacer-bottom width-50"
+ variant="info"
+ >
+ <FormattedMessage
+ defaultMessage="settings.almintegration.feature.alm_repo_import.disabled_if_multiple_github_instances"
+ id="settings.almintegration.feature.alm_repo_import.disabled_if_multiple_github_instances"
+ values={
+ Object {
+ "feature": <em>
+ settings.almintegration.feature.alm_repo_import.title
+ </em>,
+ }
+ }
+ />
+ </Alert>
+ }
alm="github"
createConfiguration={[Function]}
defaultBinding={
Object {
"appId": "",
+ "clientId": "",
+ "clientSecret": "",
"key": "",
"privateKey": "",
"url": "",
Array [
Object {
"appId": "123456",
+ "clientId": "client1",
+ "clientSecret": "**clientsecret**",
"key": "key",
"privateKey": "asdf1234",
"url": "http://github.enterprise.com",
"inactiveReason": "settings.almintegration.feature.need_at_least_1_binding",
"name": "settings.almintegration.feature.pr_decoration.title",
},
+ Object {
+ "active": true,
+ "description": "settings.almintegration.feature.alm_repo_import.description",
+ "inactiveReason": <React.Fragment>
+ <WarningIcon
+ className="little-spacer-right"
+ />
+ <FormattedMessage
+ defaultMessage="settings.almintegration.feature.alm_repo_import.github.requires_fields"
+ id="settings.almintegration.feature.alm_repo_import.github.requires_fields"
+ values={
+ Object {
+ "clientId": <strong>
+ clientId
+ </strong>,
+ "clientSecret": <strong>
+ clientSecret
+ </strong>,
+ }
+ }
+ />
+ </React.Fragment>,
+ "name": "settings.almintegration.feature.alm_repo_import.title",
+ },
]
}
form={[Function]}
key: 'key',
url: 'http://github.enterprise.com',
appId: '123456',
+ clientId: 'client1',
+ clientSecret: '**clientsecret**',
privateKey: 'asdf1234',
...overrides
};
export interface GithubBindingDefinition extends AlmBindingDefinition {
appId: string;
+ clientId: string;
+ clientSecret: string;
privateKey: string;
url: string;
}
settings.almintegration.form.url.gitlab.help1=You do not have to provide this value if you're using GitLab CI.
settings.almintegration.form.url.gitlab.help2=If you're using another CI, provide the GitLab API URL. For example:
settings.almintegration.form.app_id=GitHub App ID
+settings.almintegration.form.client_id=GitHub Client ID
+settings.almintegration.form.client_secret=GitHub Client Secret
settings.almintegration.form.private_key=Private Key
settings.almintegration.form.personal_access_token=Personal Access token
settings.almintegration.form.personal_access_token.azure.help=Token of the user that will be used to decorate the Pull Requests. Needs authorized scope: "Code (read and write)".
settings.almintegration.feature.alm_repo_import.title=Import repositories from your ALM
settings.almintegration.feature.alm_repo_import.description=Select repositories from your ALM, and import them into SonarQube.
settings.almintegration.feature.alm_repo_import.disabled_if_multiple_bbs_instances=Connecting to multiple Bitbucket Server instances will deactivate the {feature} feature. Projects will have to be set up manually.
+settings.almintegration.feature.alm_repo_import.disabled_if_multiple_github_instances=Connecting to multiple GitHub Enterprise instances will deactivate the {feature} feature. Projects will have to be set up manually.
+settings.almintegration.feature.alm_repo_import.github.too_many_instances_x=You must have exactly 1 GitHub Enterprise instance configured in order to use this method. You currently have {0}.
+settings.almintegration.feature.alm_repo_import.github.requires_fields=Your configured instance must be provided with the App's {clientId} and {clientSecret}.
+
settings.pr_decoration.binding.category=Pull Request Decoration
settings.pr_decoration.binding.no_bindings=This feature must first be enabled in the global settings. {link}