aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-11-28 13:55:57 +0100
committerEric Hartmann <hartmann.eric@gmail.Com>2017-12-04 13:44:55 +0100
commit1795cff89143b881f8d832a22d0dcec8a6abbc19 (patch)
tree725997140fa1ac0fb0764123b1b718c6fd04476d
parent000321a20f70cca96218ab4395324bf154203e05 (diff)
downloadsonarqube-1795cff89143b881f8d832a22d0dcec8a6abbc19.tar.gz
sonarqube-1795cff89143b881f8d832a22d0dcec8a6abbc19.zip
SONAR-10088 Prevent deleting default quality gate
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts4
-rw-r--r--server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.js25
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js2
6 files changed, 25 insertions, 16 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 10bc60cea6c..d2402fcdb46 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -33,7 +33,9 @@ export interface QualityGate {
actions?: {
associateProjects: boolean;
copy: boolean;
- edit: boolean;
+ delete: boolean;
+ manageConditions: boolean;
+ rename: boolean;
setAsDefault: boolean;
};
conditions?: Condition[];
diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.js
index ba4e5e1a32c..8149f8963f4 100644
--- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.js
+++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.js
@@ -69,16 +69,23 @@ export default class ApplicationQualityGate extends React.PureComponent {
fetchDetails = () => {
this.setState({ loading: true });
- getApplicationQualityGate(this.props.component.key).then(({ status, projects, metrics }) => {
- if (this.mounted) {
- this.setState({
- loading: false,
- metrics: keyBy(metrics, 'key'),
- status,
- projects
- });
+ getApplicationQualityGate(this.props.component.key).then(
+ ({ status, projects, metrics }) => {
+ if (this.mounted) {
+ this.setState({
+ loading: false,
+ metrics: keyBy(metrics, 'key'),
+ status,
+ projects
+ });
+ }
+ },
+ () => {
+ if (this.mounted) {
+ this.setState({ loading: false });
+ }
}
- });
+ );
};
render() {
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js
index e7021d78f0c..0489459a58c 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js
@@ -39,7 +39,7 @@ export default class DetailsContent extends React.PureComponent {
qualityGate={gate}
conditions={conditions}
metrics={metrics}
- edit={actions.edit}
+ edit={actions.manageConditions}
onAddCondition={onAddCondition}
onSaveCondition={onSaveCondition}
onDeleteCondition={onDeleteCondition}
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 b86e89a41b8..71ce93cf1c5 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
@@ -55,7 +55,7 @@ export default class DetailsHeader extends React.PureComponent {
</h2>
<div className="pull-right">
- {actions.edit && (
+ {actions.rename && (
<button id="quality-gate-rename" onClick={this.handleRenameClick}>
{translate('rename')}
</button>
@@ -76,7 +76,7 @@ export default class DetailsHeader extends React.PureComponent {
{translate('set_as_default')}
</button>
)}
- {actions.edit && (
+ {actions.delete && (
<button
id="quality-gate-delete"
className="little-spacer-left button-red"
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js b/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js
index 5e9d68b432c..2801cd954bb 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ListHeader.js
@@ -21,7 +21,7 @@ import React from 'react';
import CreateView from '../views/create-view';
import { translate } from '../../../helpers/l10n';
-export default function ListHeader({ canEdit, onAdd }) {
+export default function ListHeader({ canCreate, onAdd }) {
function handleAddClick(e) {
e.preventDefault();
new CreateView({ onAdd }).render();
@@ -30,7 +30,7 @@ export default function ListHeader({ canEdit, onAdd }) {
return (
<header className="page-header">
<h1 className="page-title">{translate('quality_gates.page')}</h1>
- {canEdit && (
+ {canCreate && (
<div className="page-actions">
<button id="quality-gate-add" onClick={handleAddClick}>
{translate('create')}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js
index a8b0b97d490..8d13fbae35e 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js
@@ -81,7 +81,7 @@ export default class QualityGatesApp extends Component {
<div className="layout-page-side" style={{ top }}>
<div className="layout-page-side-inner">
<div className="layout-page-filters">
- <ListHeader canEdit={actions && actions.create} onAdd={this.handleAdd} />
+ <ListHeader canCreate={actions && actions.create} onAdd={this.handleAdd} />
{qualityGates && <List organization={organization} qualityGates={qualityGates} />}
</div>
</div>