*/
import { getJSON, post, postJSON } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Condition, Metric, QualityGate } from '../app/types';
+import { Condition, Metric, QualityGate, Omit } from '../app/types';
export function fetchQualityGates(data: {
organization?: string;
data: {
gateId: number;
organization?: string;
- } & Condition
+ } & Omit<Condition, 'id'>
): Promise<Condition> {
return postJSON('/api/qualitygates/create_condition', data);
}
export interface Condition {
error: string;
- id?: number;
+ id: number;
metric: string;
op?: string;
period?: number;
};
removeCondition = (condition: ICondition) => {
- if (condition.id !== undefined) {
- deleteCondition({ id: condition.id, organization: this.props.organization }).then(
- () => this.props.onRemoveCondition(condition),
- () => {}
- );
- }
+ deleteCondition({ id: condition.id, organization: this.props.organization }).then(
+ () => this.props.onRemoveCondition(condition),
+ () => {}
+ );
};
render() {
import ThresholdInput from './ThresholdInput';
import Period from './Period';
import { translate, getLocalizedMetricName } from '../../../helpers/l10n';
-import { Metric, QualityGate, Condition } from '../../../app/types';
+import { Metric, QualityGate, Condition, Omit } from '../../../app/types';
import { createCondition, updateCondition } from '../../../api/quality-gates';
import { isDiffMetric } from '../../../helpers/measures';
import { parseError } from '../../../helpers/request';
};
getUpdatedCondition = (metric: Metric) => {
- const data: Condition = {
+ const data: Omit<Condition, 'id'> = {
metric: metric.key,
op: metric.type === 'RATING' ? 'GT' : this.state.op,
warning: this.state.warning,