* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { FormattedMessage } from 'react-intl';
+import Link from '../../../../components/common/Link';
import BoxedTabs from '../../../../components/controls/BoxedTabs';
+import { Alert } from '../../../../components/ui/Alert';
import { translate } from '../../../../helpers/l10n';
import { getBaseUrl } from '../../../../helpers/system';
import {
AlmSettingsBindingDefinitions,
AlmSettingsBindingStatus,
} from '../../../../types/alm-settings';
+import { SettingsKey } from '../../../../types/settings';
import { Dict } from '../../../../types/types';
+import { useGetValuesQuery } from '../../queries/settings';
import { AlmTabs } from './AlmIntegration';
import AlmTab from './AlmTab';
import DeleteModal from './DeleteModal';
[AlmKeys.BitbucketServer]: [...definitions.bitbucket, ...definitions.bitbucketcloud],
};
+ const { data, isLoading } = useGetValuesQuery([SettingsKey.ServerBaseUrl]);
+ const hasServerBaseUrl = data?.length === 1 && data[0].value !== undefined;
+
return (
<>
<header className="page-header">
<h1 className="page-title">{translate('settings.almintegration.title')}</h1>
</header>
- <div className="markdown small spacer-top big-spacer-bottom">
+ {!hasServerBaseUrl && !isLoading && branchesEnabled && (
+ <Alert variant="warning">
+ <FormattedMessage
+ id="settings.almintegration.empty.server_base_url"
+ defaultMessage={translate('settings.almintegration.empty.server_base_url')}
+ values={{
+ serverBaseUrl: (
+ <Link to="../settings?category=general#sonar.core.serverBaseURL">
+ {translate('settings.almintegration.empty.server_base_url.setting_link')}
+ </Link>
+ ),
+ }}
+ />
+ </Alert>
+ )}
+
+ <div className="markdown small big-spacer-top big-spacer-bottom">
{translate('settings.almintegration.description')}
</div>
import userEvent from '@testing-library/user-event';
import React from 'react';
import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock';
+import SettingsServiceMock from '../../../../../api/mocks/SettingsServiceMock';
import { AvailableFeaturesContext } from '../../../../../app/components/available-features/AvailableFeaturesContext';
import { renderComponent } from '../../../../../helpers/testReactTestingUtils';
import { byRole, byText } from '../../../../../helpers/testSelector';
import { AlmKeys } from '../../../../../types/alm-settings';
import { Feature } from '../../../../../types/features';
+import { SettingsKey } from '../../../../../types/settings';
import AlmIntegration from '../AlmIntegration';
jest.mock('../../../../../api/alm-settings');
+jest.mock('../../../../../api/settings');
let almSettings: AlmSettingsServiceMock;
+let settings: SettingsServiceMock;
beforeAll(() => {
almSettings = new AlmSettingsServiceMock();
+ settings = new SettingsServiceMock();
});
afterEach(() => {
almSettings.reset();
+ settings.reset();
+});
+
+it('should not display the serverBaseURL message when it is defined', async () => {
+ const { ui } = getPageObjects();
+ settings.set(SettingsKey.ServerBaseUrl, 'http://localhost:9000');
+ renderAlmIntegration([Feature.BranchSupport]);
+ expect(await ui.almHeading.find()).toBeInTheDocument();
+ expect(ui.serverBaseUrlMissingInformation.query()).not.toBeInTheDocument();
+});
+
+it('should not display the serverBaseURL message for Community edition', async () => {
+ const { ui } = getPageObjects();
+ renderAlmIntegration();
+ expect(await ui.almHeading.find()).toBeInTheDocument();
+ expect(ui.serverBaseUrlMissingInformation.query()).not.toBeInTheDocument();
+});
+
+it('should display the serverBaseURL message when it is not defined', async () => {
+ const { ui } = getPageObjects();
+ renderAlmIntegration([Feature.BranchSupport]);
+
+ expect(await ui.serverBaseUrlMissingInformation.find()).toBeInTheDocument();
});
describe('github tab', () => {
const ui = {
almHeading: byRole('heading', { name: 'settings.almintegration.title' }),
+ serverBaseUrlMissingInformation: byText('settings.almintegration.empty.server_base_url'),
emptyIntro: (almKey: AlmKeys) => byText(`settings.almintegration.empty.${almKey}`),
createConfigurationButton: byRole('button', { name: 'settings.almintegration.create' }),
tab: (almKey: AlmKeys) =>
settings.almintegration.title=DevOps Platform Integrations
settings.almintegration.description=DevOps Platform integrations allow SonarQube to interact with your DevOps Platform. This enables things like authentication, or providing analysis details and a Quality Gate to your Pull Requests directly in your DevOps Platform's interface.
+settings.almintegration.empty.server_base_url=You need to set the Server Base URL in General > {serverBaseUrl} to have correct links from the DevOps Platform to your SonarQube instance.
+settings.almintegration.empty.server_base_url.setting_link=Server Base URL
settings.almintegration.tab.github=GitHub
settings.almintegration.tab.bitbucket=Bitbucket
settings.almintegration.tab.azure=Azure DevOps