diff options
author | Michal Duda <michal.duda@sonarsource.com> | 2019-11-14 13:43:53 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-12-09 20:46:16 +0100 |
commit | 9e9d0ad028680e6fc4ef28f1d5985f74e411af95 (patch) | |
tree | 6516e58d838c1675beb717455dec610b12c10a00 /server/sonar-web/src | |
parent | 39f7a382198e93e0b818b34e1aa98da6c3a79f69 (diff) | |
download | sonarqube-9e9d0ad028680e6fc4ef28f1d5985f74e411af95.tar.gz sonarqube-9e9d0ad028680e6fc4ef28f1d5985f74e411af95.zip |
SONAR-12628 remove configuration setting "sonar.branch.longLivedBranches.regex"
Diffstat (limited to 'server/sonar-web/src')
12 files changed, 1 insertions, 638 deletions
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__/LongBranchesPatternForm-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx deleted file mode 100644 index ce4508257f1..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/LongBranchesPatternForm-test.tsx +++ /dev/null @@ -1,35 +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 LongBranchesPatternForm from '../LongBranchesPatternForm'; - -it('renders', () => { - expect( - shallow( - <LongBranchesPatternForm - onChange={jest.fn()} - onClose={jest.fn()} - project="project" - setting={{ key: 'foo', value: 'bar' }} - /> - ) - ).toMatchSnapshot(); -}); 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)); }); }; |