interface State {
deleteFormOpen: boolean;
- error: string;
modal: boolean;
- op?: string;
- period?: number;
- warning: string;
}
export default class Condition extends React.PureComponent<Props, State> {
super(props);
this.state = {
deleteFormOpen: false,
- error: props.condition.error || '',
- modal: false,
- op: props.condition.op,
- period: props.condition.period,
- warning: props.condition.warning || ''
+ modal: false
};
}
<ConditionOperator canEdit={false} metric={metric} op={condition.op} />
</td>
- <td className="thin text-middle nowrap">{formatMeasure(condition.warning, metric.type)}</td>
-
<td className="thin text-middle nowrap">{formatMeasure(condition.error, metric.type)}</td>
{canEdit && (
metric?: T.Metric;
op?: string;
period: boolean;
- warning: string;
}
export default class ConditionModal extends React.PureComponent<Props, State> {
this.state = {
error: props.condition ? props.condition.error : '',
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
};
const data: T.Omit<T.Condition, 'id'> = {
metric: metric.key,
op: metric.type === 'RATING' ? 'GT' : this.state.op,
- warning: this.state.warning,
error: this.state.error
};
this.setState({ op });
};
- handleWarningChange = (warning: string) => {
- this.setState({ warning });
- };
-
handleErrorChange = (error: string) => {
this.setState({ error });
};
render() {
const { header, metrics, onClose } = this.props;
- const { period, op, warning, error, metric } = this.state;
+ const { period, op, error, metric } = this.state;
return (
<ConfirmModal
confirmButtonText={header}
op={op}
/>
</div>
- <div className="modal-field">
- <label>{translate('quality_gates.conditions.warning')}</label>
- <ThresholdInput
- metric={metric}
- name="warning"
- onChange={this.handleWarningChange}
- value={warning}
- />
- </div>
<div className="modal-field">
<label>{translate('quality_gates.conditions.error')}</label>
<ThresholdInput