diff options
Diffstat (limited to 'server/sonar-web/src/main/js')
6 files changed, 5 insertions, 38 deletions
diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts index b7eb009e7f1..10bc60cea6c 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.ts +++ b/server/sonar-web/src/main/js/api/quality-gates.ts @@ -74,10 +74,6 @@ export function setQualityGateAsDefault(id: string): Promise<void | Response> { return post('/api/qualitygates/set_as_default', { id }).catch(throwGlobalError); } -export function unsetQualityGateAsDefault(id: string): Promise<void | Response> { - return post('/api/qualitygates/unset_default', { id }).catch(throwGlobalError); -} - export function createCondition(gateId: string, condition: RequestData): Promise<any> { return postJSON('/api/qualitygates/create_condition', { ...condition, gateId }); } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js index 97249bf6532..2d3a5ad3beb 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js @@ -20,11 +20,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Helmet from 'react-helmet'; -import { - fetchQualityGate, - setQualityGateAsDefault, - unsetQualityGateAsDefault -} from '../../../api/quality-gates'; +import { fetchQualityGate, setQualityGateAsDefault } from '../../../api/quality-gates'; import DetailsHeader from './DetailsHeader'; import DetailsContent from './DetailsContent'; import RenameView from '../views/rename-view'; @@ -77,11 +73,9 @@ export default class Details extends React.PureComponent { }; handleSetAsDefaultClick = () => { - const { qualityGate, onSetAsDefault, onUnsetAsDefault } = this.props; - if (qualityGate.isDefault) { - unsetQualityGateAsDefault(qualityGate.id).then(() => onUnsetAsDefault(qualityGate)); - } else { - setQualityGateAsDefault(qualityGate.id).then(() => onSetAsDefault(qualityGate)); + const { qualityGate, onSetAsDefault } = this.props; + if (!qualityGate.isDefault) { + setQualityGateAsDefault(qualityGate.id).then(() => onSetAsDefault(qualityGate), () => {}); } }; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js index dc878e83e39..2ac134c5275 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js @@ -73,9 +73,7 @@ export default class DetailsHeader extends React.PureComponent { className="little-spacer-left" id="quality-gate-toggle-default" onClick={this.handleSetAsDefaultClick}> - {qualityGate.isDefault - ? translate('unset_as_default') - : translate('set_as_default')} + {translate('set_as_default')} </button> )} {actions.edit && ( diff --git a/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js b/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js index c5eddfe37f9..5ac0a656b9d 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js @@ -24,7 +24,6 @@ import { renameQualityGate, copyQualityGate, setQualityGateAsDefault, - unsetQualityGateAsDefault, addCondition, deleteCondition, saveCondition @@ -44,7 +43,6 @@ const mapDispatchToProps = dispatch => ({ onRename: (qualityGate, newName) => dispatch(renameQualityGate(qualityGate, newName)), onCopy: qualityGate => dispatch(copyQualityGate(qualityGate)), onSetAsDefault: qualityGate => dispatch(setQualityGateAsDefault(qualityGate)), - onUnsetAsDefault: qualityGate => dispatch(unsetQualityGateAsDefault(qualityGate)), onAddCondition: metric => dispatch(addCondition(metric)), onSaveCondition: (oldCondition, newCondition) => dispatch(saveCondition(oldCondition, newCondition)), diff --git a/server/sonar-web/src/main/js/apps/quality-gates/store/actions.js b/server/sonar-web/src/main/js/apps/quality-gates/store/actions.js index 0dcea3223d1..ad94c833969 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/store/actions.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/store/actions.js @@ -74,14 +74,6 @@ export function setQualityGateAsDefault(qualityGate) { }; } -export const UNSET_AS_DEFAULT = 'qualityGates/UNSET_AS_DEFAULT'; -export function unsetQualityGateAsDefault(qualityGate) { - return { - type: UNSET_AS_DEFAULT, - qualityGate - }; -} - export const ADD_CONDITION = 'qualityGates/ADD_CONDITION'; export function addCondition(metric) { return { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/store/rootReducer.js b/server/sonar-web/src/main/js/apps/quality-gates/store/rootReducer.js index 05fc9df3e65..56078fc6518 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/store/rootReducer.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/store/rootReducer.js @@ -25,7 +25,6 @@ import { RENAME, COPY, SET_AS_DEFAULT, - UNSET_AS_DEFAULT, ADD_CONDITION, DELETE_CONDITION, SAVE_CONDITION @@ -75,16 +74,6 @@ export default function rootReducer(state = initialState, action = {}) { isDefault: state.qualityGate.id === action.qualityGate.id } }; - case UNSET_AS_DEFAULT: - return { - ...state, - qualityGates: state.qualityGates.map(candidate => { - return candidate.id === action.qualityGate.id - ? { ...candidate, isDefault: false } - : candidate; - }), - qualityGate: { ...state.qualityGate, isDefault: false } - }; case ADD_CONDITION: return { ...state, |