metric?: Metric;
op?: string;
period: boolean;
- submitting: boolean;
warning: string;
}
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
};
}
}
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) => {
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 = {
...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) => {
return (
<ConfirmModal
confirmButtonText={header}
+ confirmDisable={metric === undefined}
header={header}
onClose={onClose}
onConfirm={this.handleFormSubmit}>