From 878887d3f9ecd7c580c911b8d80e16871393b9f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Fri, 24 Nov 2017 11:55:03 +0100 Subject: [PATCH] SONAR-9962 Remove the "unset as default" action on Quality Gates --- server/sonar-web/src/main/js/api/quality-gates.ts | 4 ---- .../js/apps/quality-gates/components/Details.js | 14 ++++---------- .../apps/quality-gates/components/DetailsHeader.js | 4 +--- .../quality-gates/containers/DetailsContainer.js | 2 -- .../main/js/apps/quality-gates/store/actions.js | 8 -------- .../js/apps/quality-gates/store/rootReducer.js | 11 ----------- .../main/resources/org/sonar/l10n/core.properties | 1 - 7 files changed, 5 insertions(+), 39 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 { return post('/api/qualitygates/set_as_default', { id }).catch(throwGlobalError); } -export function unsetQualityGateAsDefault(id: string): Promise { - return post('/api/qualitygates/unset_default', { id }).catch(throwGlobalError); -} - export function createCondition(gateId: string, condition: RequestData): Promise { 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')} )} {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, diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index ddcfa8d7041..921ae0999d5 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -218,7 +218,6 @@ no_results_search.2=Try to change filters to get some results. no_results_search.favorites.2=Would you like to search among {url} projects? page_extension_failed=Page extension failed. set_as_default=Set as Default -unset_as_default=Unset as Default short_number_suffix.g=G short_number_suffix.k=k short_number_suffix.m=M -- 2.39.5