aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMichal Duda <michal.duda@sonarsource.com>2019-11-14 13:43:53 +0100
committerSonarTech <sonartech@sonarsource.com>2019-12-09 20:46:16 +0100
commit9e9d0ad028680e6fc4ef28f1d5985f74e411af95 (patch)
tree6516e58d838c1675beb717455dec610b12c10a00 /server
parent39f7a382198e93e0b818b34e1aa98da6c3a79f69 (diff)
downloadsonarqube-9e9d0ad028680e6fc4ef28f1d5985f74e411af95.tar.gz
sonarqube-9e9d0ad028680e6fc4ef28f1d5985f74e411af95.zip
SONAR-12628 remove configuration setting "sonar.branch.longLivedBranches.regex"
Diffstat (limited to 'server')
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java6
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java (renamed from server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx)35
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java86
-rw-r--r--server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql11
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx101
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx43
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx140
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx68
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx87
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap3
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap17
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap27
-rw-r--r--server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap109
-rw-r--r--server/sonar-web/src/main/js/apps/settings/store/actions.ts7
16 files changed, 123 insertions, 621 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java
index e51407ffd2f..912861e3c6f 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java
@@ -28,13 +28,15 @@ public class DbVersion81 implements DbVersion {
registry
.add(3100, "Create ALM_SETTINGS table", CreateAlmSettingsTable.class)
.add(3101, "Create PROJECT_ALM_SETTINGS table", CreateProjectAlmSettingsTable.class)
- .add(3102, "Migrate property 'sonar.alm.github.app.privateKey.secured' to 'sonar.alm.github.app.privateKeyContent.secured'", MigrateDeprecatedGithubPrivateKeyToNewKey.class)
+ .add(3102, "Migrate property 'sonar.alm.github.app.privateKey.secured' to 'sonar.alm.github.app.privateKeyContent.secured'",
+ MigrateDeprecatedGithubPrivateKeyToNewKey.class)
.add(3103, "Migrate GitHub ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateGithubAlmSettings.class)
.add(3104, "Migrate Bitbucket ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateBitbucketAlmSettings.class)
.add(3105, "Migrate Azure ALM settings from PROPERTIES to ALM_SETTINGS tables", MigrateAzureAlmSettings.class)
.add(3106, "Delete 'sonar.pullrequest.provider' property", DeleteSonarPullRequestProviderProperty.class)
.add(3107, "Migrate default branches to keep global setting", MigrateDefaultBranchesToKeepSetting.class)
.add(3108, "Add EXCLUDE_FROM_PURGE column", AddExcludeBranchFromPurgeColumn.class)
- .add(3109, "Populate EXCLUDE_FROM_PURGE column", PopulateExcludeBranchFromPurgeColumn.class);
+ .add(3109, "Populate EXCLUDE_FROM_PURGE column", PopulateExcludeBranchFromPurgeColumn.class)
+ .add(3110, "Remove 'sonar.branch.longLivedBranches.regex'", RemoveLLBRegexSetting.class);
}
}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java
index ce4508257f1..e0fcaea9aab 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSetting.java
@@ -17,19 +17,24 @@
* 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 LongBranchesPatternForm from '../LongBranchesPatternForm';
+package org.sonar.server.platform.db.migration.version.v81;
-it('renders', () => {
- expect(
- shallow(
- <LongBranchesPatternForm
- onChange={jest.fn()}
- onClose={jest.fn()}
- project="project"
- setting={{ key: 'foo', value: 'bar' }}
- />
- )
- ).toMatchSnapshot();
-});
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.SupportsBlueGreen;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+@SupportsBlueGreen
+public class RemoveLLBRegexSetting extends DataChange {
+
+ public RemoveLLBRegexSetting(Database db) {
+ super(db);
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ context.prepareUpsert("delete from properties where prop_key='sonar.branch.longLivedBranches.regex'")
+ .execute()
+ .commit();
+ }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java
index 45f8522bf48..cb64c2f6f88 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java
@@ -37,7 +37,7 @@ public class DbVersion81Test {
@Test
public void verify_migration_count() {
- verifyMigrationCount(underTest, 10);
+ verifyMigrationCount(underTest, 11);
}
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java
new file mode 100644
index 00000000000..86a9a337c25
--- /dev/null
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+package org.sonar.server.platform.db.migration.version.v81;
+
+import java.sql.SQLException;
+import java.time.Instant;
+import javax.annotation.Nullable;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+
+public class RemoveLLBRegexSettingTest {
+
+ private static final String PROPERTIES_TABLE_NAME = "properties";
+ private static final int TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES = 10;
+
+ @Rule
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveLLBRegexSettingTest.class, "schema.sql");
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private RemoveLLBRegexSetting underTest = new RemoveLLBRegexSetting(dbTester.database());
+
+ @Before
+ public void setup() {
+ insertProperty(null, "xyz");
+ for (long i = 1; i <= TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES; i++) {
+ insertProperty(i, format("xyz-%s", i));
+ }
+
+ int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME);
+ assertEquals(TOTAL_NUMBER_OF_PROJECT_LEVEL_PROPERTIES + 1, propertiesCount);
+ }
+
+ @Test
+ public void remove_llb_regex_property() throws SQLException {
+ underTest.execute();
+
+ verifyResult();
+ }
+
+ @Test
+ public void migration_is_re_entrant() throws SQLException {
+ underTest.execute();
+ underTest.execute();
+
+ verifyResult();
+ }
+
+ private void verifyResult() {
+ int propertiesCount = dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME);
+ assertEquals(0, propertiesCount);
+ }
+
+ private void insertProperty(@Nullable Long projectId, String propertyValue) {
+ dbTester.executeInsert(PROPERTIES_TABLE_NAME,
+ "prop_key", "sonar.branch.longLivedBranches.regex",
+ "resource_id", projectId,
+ "is_empty", false,
+ "text_value", propertyValue,
+ "created_at", Instant.now().toEpochMilli());
+ }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql
new file mode 100644
index 00000000000..367029ea6ba
--- /dev/null
+++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveLLBRegexSettingTest/schema.sql
@@ -0,0 +1,11 @@
+CREATE TABLE "PROPERTIES" (
+ "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1),
+ "PROP_KEY" VARCHAR(512) NOT NULL,
+ "RESOURCE_ID" INTEGER,
+ "USER_ID" INTEGER,
+ "IS_EMPTY" BOOLEAN NOT NULL,
+ "TEXT_VALUE" VARCHAR(4000),
+ "CLOB_VALUE" CLOB,
+ "CREATED_AT" BIGINT
+);
+CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY");
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx
index 83a78038dcd..ade615895f2 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx
@@ -31,7 +31,6 @@ import {
sortBranchesAsTree
} from '../../../helpers/branches';
import BranchRow from './BranchRow';
-import LongBranchesPattern from './LongBranchesPattern';
interface Props {
branchLikes: T.BranchLike[];
@@ -126,7 +125,6 @@ export default class App extends React.PureComponent<Props, State> {
<div className="page page-limited">
<header className="page-header">
<h1 className="page-title">{translate('project_branches.page')}</h1>
- <LongBranchesPattern project={component.key} />
<p className="page-description">{translate('project_branches.page.description')}</p>
{this.renderBranchLifeTime()}
</header>
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx
deleted file mode 100644
index 0199d201ead..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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 { EditButton } from 'sonar-ui-common/components/controls/buttons';
-import { translate } from 'sonar-ui-common/helpers/l10n';
-import { getValues } from '../../../api/settings';
-import LongBranchesPatternForm from './LongBranchesPatternForm';
-
-interface Props {
- project: string;
-}
-
-interface State {
- formOpen: boolean;
- setting?: T.SettingValue;
-}
-
-export const LONG_BRANCH_PATTERN = 'sonar.branch.longLivedBranches.regex';
-
-export default class LongBranchesPattern extends React.PureComponent<Props, State> {
- mounted = false;
- state: State = { formOpen: false };
-
- componentDidMount() {
- this.mounted = true;
- this.fetchSetting();
- }
-
- componentWillUnmount() {
- this.mounted = false;
- }
-
- fetchSetting() {
- return getValues({ keys: LONG_BRANCH_PATTERN, component: this.props.project }).then(
- settings => {
- if (this.mounted) {
- this.setState({ setting: settings[0] });
- }
- },
- () => {}
- );
- }
-
- closeForm = () => {
- if (this.mounted) {
- this.setState({ formOpen: false });
- }
- };
-
- handleChangeClick = () => {
- this.setState({ formOpen: true });
- };
-
- handleChange = () => {
- if (this.mounted) {
- this.fetchSetting().then(this.closeForm, this.closeForm);
- }
- };
-
- render() {
- const { setting } = this.state;
-
- if (!setting) {
- return null;
- }
-
- return (
- <div className="pull-right text-right">
- {translate('branches.long_living_branches_pattern')}
- {': '}
- <strong>{setting.value}</strong>
- <EditButton className="button-small spacer-left" onClick={this.handleChangeClick} />
- {this.state.formOpen && (
- <LongBranchesPatternForm
- onChange={this.handleChange}
- onClose={this.closeForm}
- project={this.props.project}
- setting={setting}
- />
- )}
- </div>
- );
- }
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx
deleted file mode 100644
index a0d6816dc21..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 Modal from 'sonar-ui-common/components/controls/Modal';
-import { translate } from 'sonar-ui-common/helpers/l10n';
-import SettingForm from './SettingForm';
-
-interface Props {
- onChange: () => void;
- onClose: () => void;
- project: string;
- setting: T.SettingValue;
-}
-
-export default function LongBranchesPatternForm(props: Props) {
- const header = translate('branches.detection_of_long_living_branches');
-
- return (
- <Modal contentLabel={header} onRequestClose={props.onClose}>
- <header className="modal-head">
- <h2>{header}</h2>
- </header>
- <SettingForm {...props} />
- </Modal>
- );
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx
deleted file mode 100644
index 8ea209f8ad8..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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 { Button, ResetButtonLink, SubmitButton } from 'sonar-ui-common/components/controls/buttons';
-import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
-import { resetSettingValue, setSimpleSettingValue } from '../../../api/settings';
-import { sanitizeTranslation } from '../../settings/utils';
-
-interface Props {
- branch?: string;
- onClose: () => void;
- onChange: () => void;
- project: string;
- setting: T.SettingValue;
-}
-
-interface State {
- submitting: boolean;
- value?: string;
-}
-
-export default class SettingForm extends React.PureComponent<Props, State> {
- mounted = false;
-
- constructor(props: Props) {
- super(props);
- this.state = { submitting: false, value: props.setting.value };
- }
-
- componentDidMount() {
- this.mounted = true;
- }
-
- componentWillUnmount() {
- this.mounted = false;
- }
-
- stopLoading = () => {
- if (this.mounted) {
- this.setState({ submitting: false });
- }
- };
-
- handleSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => {
- event.preventDefault();
-
- const { value } = this.state;
- if (!value) {
- return;
- }
-
- this.setState({ submitting: true });
- setSimpleSettingValue({
- branch: this.props.branch,
- component: this.props.project,
- key: this.props.setting.key,
- value
- }).then(this.props.onChange, this.stopLoading);
- };
-
- handleValueChange = (event: React.SyntheticEvent<HTMLInputElement>) => {
- this.setState({ value: event.currentTarget.value });
- };
-
- handleResetClick = () => {
- this.setState({ submitting: true });
- resetSettingValue({
- keys: this.props.setting.key,
- component: this.props.project,
- branch: this.props.branch
- }).then(this.props.onChange, this.stopLoading);
- };
-
- render() {
- const { setting } = this.props;
- const submitDisabled = this.state.submitting || this.state.value === setting.value;
-
- return (
- <form onSubmit={this.handleSubmit}>
- <div className="modal-body">
- <div
- className="big-spacer-bottom markdown"
- dangerouslySetInnerHTML={{
- __html: sanitizeTranslation(translate(`property.${setting.key}.description`))
- }}
- />
- <div className="modal-field">
- <input
- autoFocus={true}
- className="input-super-large"
- onChange={this.handleValueChange}
- required={true}
- type="text"
- value={this.state.value}
- />
- {setting.inherited && (
- <div className="modal-field-description">{translate('settings._default')}</div>
- )}
- {!setting.inherited && setting.parentValue && (
- <div className="modal-field-description">
- {translateWithParameters('settings.default_x', setting.parentValue)}
- </div>
- )}
- </div>
- </div>
- <footer className="modal-foot">
- {!setting.inherited && setting.parentValue && (
- <Button
- className="pull-left"
- disabled={this.state.submitting}
- onClick={this.handleResetClick}
- type="reset">
- {translate('reset_to_default')}
- </Button>
- )}
- {this.state.submitting && <i className="spinner spacer-right" />}
- <SubmitButton disabled={submitDisabled}>{translate('save')}</SubmitButton>
- <ResetButtonLink onClick={this.props.onClose}>{translate('cancel')}</ResetButtonLink>
- </footer>
- </form>
- );
- }
-}
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx
deleted file mode 100644
index 3bc76e06f47..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPattern-test.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 { click } from 'sonar-ui-common/helpers/testUtils';
-import LongBranchesPattern from '../LongBranchesPattern';
-
-jest.mock('../../../../api/settings', () => ({
- getValues: jest.fn(() => Promise.resolve([]))
-}));
-
-const getValues = require('../../../../api/settings').getValues as jest.Mock<any>;
-
-beforeEach(() => {
- getValues.mockClear();
-});
-
-it('renders', () => {
- const wrapper = shallow(<LongBranchesPattern project="project" />);
- wrapper.setState({ loading: false, setting: { value: 'release-.*' } });
- expect(wrapper).toMatchSnapshot();
-});
-
-it('opens form', () => {
- const wrapper = shallow(<LongBranchesPattern project="project" />);
- wrapper.setState({ loading: false, setting: { value: 'release-.*' } });
-
- click(wrapper.find('EditButton'));
- expect(wrapper.find('LongBranchesPatternForm').exists()).toBeTruthy();
-
- wrapper.find('LongBranchesPatternForm').prop<Function>('onClose')();
- wrapper.update();
- expect(wrapper.find('LongBranchesPatternForm').exists()).toBeFalsy();
-});
-
-it('fetches setting value on mount', () => {
- shallow(<LongBranchesPattern project="project" />);
- expect(getValues).lastCalledWith({
- keys: 'sonar.branch.longLivedBranches.regex',
- component: 'project'
- });
-});
-
-it('fetches new setting value after change', () => {
- const wrapper = shallow(<LongBranchesPattern project="project" />);
- expect(getValues).toHaveBeenCalledTimes(1);
-
- (wrapper.instance() as LongBranchesPattern).handleChange();
- expect(getValues).toHaveBeenCalledTimes(2);
-});
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx
deleted file mode 100644
index 77b44a94311..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/SettingForm-test.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.
- */
-/* eslint-disable import/first */
-jest.mock('../../../../api/settings', () => ({
- setSimpleSettingValue: jest.fn(() => Promise.resolve()),
- resetSettingValue: jest.fn(() => Promise.resolve())
-}));
-
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import { change, click, submit } from 'sonar-ui-common/helpers/testUtils';
-import SettingForm from '../SettingForm';
-
-const setSimpleSettingValue = require('../../../../api/settings')
- .setSimpleSettingValue as jest.Mock<any>;
-
-const resetSettingValue = require('../../../../api/settings').resetSettingValue as jest.Mock<any>;
-
-beforeEach(() => {
- setSimpleSettingValue.mockClear();
- resetSettingValue.mockClear();
-});
-
-it('changes value', async () => {
- const onChange = jest.fn();
- const wrapper = shallow(
- <SettingForm
- onChange={onChange}
- onClose={jest.fn()}
- project="project"
- setting={{ inherited: true, key: 'foo', value: 'release-.*' }}
- />
- );
- expect(wrapper).toMatchSnapshot();
-
- change(wrapper.find('input'), 'branch-.*');
- submit(wrapper.find('form'));
- expect(setSimpleSettingValue).toBeCalledWith({
- branch: undefined,
- component: 'project',
- key: 'foo',
- value: 'branch-.*'
- });
-
- await new Promise(setImmediate);
- expect(onChange).toBeCalled();
-});
-
-it('resets value', async () => {
- const onChange = jest.fn();
- const wrapper = shallow(
- <SettingForm
- onChange={onChange}
- onClose={jest.fn()}
- project="project"
- setting={{ inherited: false, key: 'foo', parentValue: 'branch-.*', value: 'release-.*' }}
- />
- );
- expect(wrapper).toMatchSnapshot();
-
- click(wrapper.find('Button'));
- expect(resetSettingValue).toBeCalledWith({
- keys: 'foo',
- component: 'project',
- branch: undefined
- });
-
- await new Promise(setImmediate);
- expect(onChange).toBeCalled();
-});
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap
index 94ea8832c73..72cdbbb0068 100644
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/App-test.tsx.snap
@@ -12,9 +12,6 @@ exports[`renders sorted list of branches 1`] = `
>
project_branches.page
</h1>
- <LongBranchesPattern
- project="foo"
- />
<p
className="page-description"
>
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap
deleted file mode 100644
index 8d1c83d3003..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPattern-test.tsx.snap
+++ /dev/null
@@ -1,17 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<div
- className="pull-right text-right"
->
- branches.long_living_branches_pattern
- :
- <strong>
- release-.*
- </strong>
- <EditButton
- className="button-small spacer-left"
- onClick={[Function]}
- />
-</div>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap
deleted file mode 100644
index 07725582cdf..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/LongBranchesPatternForm-test.tsx.snap
+++ /dev/null
@@ -1,27 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renders 1`] = `
-<Modal
- contentLabel="branches.detection_of_long_living_branches"
- onRequestClose={[MockFunction]}
->
- <header
- className="modal-head"
- >
- <h2>
- branches.detection_of_long_living_branches
- </h2>
- </header>
- <SettingForm
- onChange={[MockFunction]}
- onClose={[MockFunction]}
- project="project"
- setting={
- Object {
- "key": "foo",
- "value": "bar",
- }
- }
- />
-</Modal>
-`;
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap
deleted file mode 100644
index 45cb96b4022..00000000000
--- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/__snapshots__/SettingForm-test.tsx.snap
+++ /dev/null
@@ -1,109 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`changes value 1`] = `
-<form
- onSubmit={[Function]}
->
- <div
- className="modal-body"
- >
- <div
- className="big-spacer-bottom markdown"
- dangerouslySetInnerHTML={
- Object {
- "__html": "property.foo.description",
- }
- }
- />
- <div
- className="modal-field"
- >
- <input
- autoFocus={true}
- className="input-super-large"
- onChange={[Function]}
- required={true}
- type="text"
- value="release-.*"
- />
- <div
- className="modal-field-description"
- >
- settings._default
- </div>
- </div>
- </div>
- <footer
- className="modal-foot"
- >
- <SubmitButton
- disabled={true}
- >
- save
- </SubmitButton>
- <ResetButtonLink
- onClick={[MockFunction]}
- >
- cancel
- </ResetButtonLink>
- </footer>
-</form>
-`;
-
-exports[`resets value 1`] = `
-<form
- onSubmit={[Function]}
->
- <div
- className="modal-body"
- >
- <div
- className="big-spacer-bottom markdown"
- dangerouslySetInnerHTML={
- Object {
- "__html": "property.foo.description",
- }
- }
- />
- <div
- className="modal-field"
- >
- <input
- autoFocus={true}
- className="input-super-large"
- onChange={[Function]}
- required={true}
- type="text"
- value="release-.*"
- />
- <div
- className="modal-field-description"
- >
- settings.default_x.branch-.*
- </div>
- </div>
- </div>
- <footer
- className="modal-foot"
- >
- <Button
- className="pull-left"
- disabled={false}
- onClick={[Function]}
- type="reset"
- >
- reset_to_default
- </Button>
- <SubmitButton
- disabled={true}
- >
- save
- </SubmitButton>
- <ResetButtonLink
- onClick={[MockFunction]}
- >
- cancel
- </ResetButtonLink>
- </footer>
-</form>
-`;
diff --git a/server/sonar-web/src/main/js/apps/settings/store/actions.ts b/server/sonar-web/src/main/js/apps/settings/store/actions.ts
index dd0b1e51316..52c3cf82a90 100644
--- a/server/sonar-web/src/main/js/apps/settings/store/actions.ts
+++ b/server/sonar-web/src/main/js/apps/settings/store/actions.ts
@@ -46,12 +46,7 @@ import { receiveValues } from './values';
export function fetchSettings(component?: string) {
return (dispatch: Dispatch) => {
return getDefinitions(component).then(definitions => {
- const filtered = definitions
- .filter(definition => definition.type !== 'LICENSE')
- // do not display this setting on project level
- .filter(
- definition => !component || definition.key !== 'sonar.branch.longLivedBranches.regex'
- );
+ const filtered = definitions.filter(definition => definition.type !== 'LICENSE');
dispatch(receiveDefinitions(filtered));
});
};