diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2019-08-29 15:39:18 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-09-24 20:21:16 +0200 |
commit | 7243267d22b36aea1ea6614f4dff11b58aba5e12 (patch) | |
tree | b42975b4af2ba1e44576b28e1094b12b2b6905f0 /server | |
parent | 0cb53fe7d87b78dab98775ac94d9da87b561ce99 (diff) | |
download | sonarqube-7243267d22b36aea1ea6614f4dff11b58aba5e12.tar.gz sonarqube-7243267d22b36aea1ea6614f4dff11b58aba5e12.zip |
SONAR-12420 Prevent setting baseline from project branches page
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx | 32 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.tsx | 101 |
2 files changed, 1 insertions, 132 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx index b35f229419a..288ad320587 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx @@ -20,7 +20,6 @@ import * as classNames from 'classnames'; import * as React from 'react'; import ActionsDropdown, { - ActionsDropdownDivider, ActionsDropdownItem } from 'sonar-ui-common/components/controls/ActionsDropdown'; import { translate } from 'sonar-ui-common/helpers/l10n'; @@ -29,13 +28,11 @@ import BranchIcon from '../../../components/icons-components/BranchIcon'; import DateFromNow from '../../../components/intl/DateFromNow'; import { getBranchLikeDisplayName, - isLongLivingBranch, isMainBranch, isPullRequest, isShortLivingBranch } from '../../../helpers/branches'; import DeleteBranchModal from './DeleteBranchModal'; -import LeakPeriodForm from './LeakPeriodForm'; import RenameBranchModal from './RenameBranchModal'; interface Props { @@ -46,14 +43,13 @@ interface Props { } interface State { - changingLeak: boolean; deleting: boolean; renaming: boolean; } export default class BranchRow extends React.PureComponent<Props, State> { mounted = false; - state: State = { changingLeak: false, deleting: false, renaming: false }; + state: State = { deleting: false, renaming: false }; componentDidMount() { this.mounted = true; @@ -86,29 +82,11 @@ export default class BranchRow extends React.PureComponent<Props, State> { this.setState({ renaming: false }); }; - handleChangeLeakClick = () => { - this.setState({ changingLeak: true }); - }; - - handleChangingLeakStop = () => { - if (this.mounted) { - this.setState({ changingLeak: false }); - } - }; - renderActions() { const { branchLike, component } = this.props; return ( <td className="thin nowrap text-right"> <ActionsDropdown className="ig-spacer-left"> - {isLongLivingBranch(branchLike) && ( - <ActionsDropdownItem - className="js-change-leak-period" - onClick={this.handleChangeLeakClick}> - {translate('branches.set_new_code_period')} - </ActionsDropdownItem> - )} - {isLongLivingBranch(branchLike) && <ActionsDropdownDivider />} {isMainBranch(branchLike) ? ( <ActionsDropdownItem className="js-rename" onClick={this.handleRenameClick}> {translate('branches.rename')} @@ -142,14 +120,6 @@ export default class BranchRow extends React.PureComponent<Props, State> { onRename={this.handleChange} /> )} - - {this.state.changingLeak && isLongLivingBranch(branchLike) && ( - <LeakPeriodForm - branch={branchLike.name} - onClose={this.handleChangingLeakStop} - project={component} - /> - )} </td> ); } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.tsx deleted file mode 100644 index 5861698439a..00000000000 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.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 Modal from 'sonar-ui-common/components/controls/Modal'; -import { translate } from 'sonar-ui-common/helpers/l10n'; -import { getValues } from '../../../api/settings'; -import SettingForm from './SettingForm'; - -interface Props { - branch: string; - onClose: () => void; - project: string; -} - -interface State { - loading: boolean; - setting?: T.SettingValue; - submitting: boolean; - value?: string; -} - -const LEAK_PERIOD = 'sonar.leak.period'; - -export default class LeakPeriodForm extends React.PureComponent<Props, State> { - mounted = false; - state: State = { loading: true, submitting: false }; - - componentDidMount() { - this.mounted = true; - this.fetchSetting(); - } - - componentWillUnmount() { - this.mounted = false; - } - - fetchSetting() { - this.setState({ loading: true }); - getValues({ keys: LEAK_PERIOD, component: this.props.project, branch: this.props.branch }).then( - settings => { - if (this.mounted) { - this.setState({ loading: false, setting: settings[0] }); - } - }, - () => { - if (this.mounted) { - this.setState({ loading: false }); - } - } - ); - } - - handleCancelClick = (event: React.SyntheticEvent<HTMLAnchorElement>) => { - event.preventDefault(); - this.props.onClose(); - }; - - render() { - const { setting } = this.state; - const header = translate('branches.set_new_code_period'); - - return ( - <Modal contentLabel={header} onRequestClose={this.props.onClose}> - <header className="modal-head"> - <h2>{header}</h2> - </header> - {this.state.loading && ( - <div className="modal-body"> - <i className="spinner" /> - </div> - )} - {setting && ( - <SettingForm - branch={this.props.branch} - onChange={this.props.onClose} - onClose={this.props.onClose} - project={this.props.project} - setting={setting} - /> - )} - </Modal> - ); - } -} |