aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Mugnier <pascal.mugnier@sonarsource.com>2018-05-23 16:56:56 +0200
committerSonarTech <sonartech@sonarsource.com>2018-05-24 20:20:47 +0200
commit74fc9a991a81542cb51b3bbdcf9b364670e505aa (patch)
treead9935ffaba3bccb346c5104e139c125bf08b04e
parentb68330a93e71d9a2c3c6697213d78cdbcb99e739 (diff)
downloadsonarqube-74fc9a991a81542cb51b3bbdcf9b364670e505aa.tar.gz
sonarqube-74fc9a991a81542cb51b3bbdcf9b364670e505aa.zip
Fix after review
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx28
1 files changed, 12 insertions, 16 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx
index 536fe76f0d1..b5d8fbf5b89 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx
@@ -46,7 +46,6 @@ interface State {
metric?: Metric;
op?: string;
period: boolean;
- submitting: boolean;
warning: string;
}
@@ -60,8 +59,7 @@ export default class ConditionModal extends React.PureComponent<Props, State> {
period: props.condition ? props.condition.period === 1 : false,
warning: props.condition ? props.condition.warning : '',
metric: props.metric ? props.metric : undefined,
- op: props.condition ? props.condition.op : undefined,
- submitting: false
+ op: props.condition ? props.condition.op : undefined
};
}
@@ -74,16 +72,14 @@ export default class ConditionModal extends React.PureComponent<Props, State> {
}
handleError = (error: any) => {
- if (this.mounted) {
- parseError(error).then(
- message => {
- this.setState({ errorMessage: message, submitting: false });
- },
- () => {
- this.setState({ submitting: false });
+ parseError(error).then(
+ message => {
+ if (this.mounted) {
+ this.setState({ errorMessage: message });
}
- );
- }
+ },
+ () => {}
+ );
};
getUpdatedCondition = (metric: Metric) => {
@@ -107,13 +103,11 @@ export default class ConditionModal extends React.PureComponent<Props, State> {
handleConditionResponse = (newCondition: Condition) => {
this.props.onAddCondition(newCondition);
- this.props.onClose();
};
handleFormSubmit = () => {
if (this.state.metric) {
const { condition, qualityGate, organization } = this.props;
- this.setState({ submitting: true });
if (condition) {
const data: Condition = {
@@ -121,19 +115,20 @@ export default class ConditionModal extends React.PureComponent<Props, State> {
...this.getUpdatedCondition(this.state.metric)
};
- updateCondition({ organization, ...data }).then(
+ return updateCondition({ organization, ...data }).then(
this.handleConditionResponse,
this.handleError
);
} else {
const data = this.getUpdatedCondition(this.state.metric);
- createCondition({ gateId: qualityGate.id, organization, ...data }).then(
+ return createCondition({ gateId: qualityGate.id, organization, ...data }).then(
this.handleConditionResponse,
this.handleError
);
}
}
+ return Promise.resolve();
};
handleChooseType = (metric: Metric) => {
@@ -162,6 +157,7 @@ export default class ConditionModal extends React.PureComponent<Props, State> {
return (
<ConfirmModal
confirmButtonText={header}
+ confirmDisable={metric === undefined}
header={header}
onClose={onClose}
onConfirm={this.handleFormSubmit}>