in public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.tsx [165:225]
_next() {
let currentStep = this.state.currentStep;
let error = false;
//Verification here
if (currentStep == 1) {
const { rollupId, sourceIndex, targetIndex } = this.state;
if (!rollupId) {
this.setState({ submitError: "Job name is required.", rollupIdError: "Job name is required." });
error = true;
}
if (sourceIndex.length == 0) {
this.setState({ submitError: "Source index is required.", sourceIndexError: "Source index is required." });
error = true;
}
if (targetIndex.length == 0) {
this.setState({ submitError: "Target index is required.", targetIndexError: "Target index is required." });
error = true;
}
} else if (currentStep == 2) {
const { timestamp, selectedMetrics } = this.state;
if (timestamp.length == 0) {
this.setState({ submitError: "Timestamp is required.", timestampError: "Timestamp is required." });
error = true;
}
if (selectedMetrics.length != 0) {
//Check if there's any metric item with no method selected.
//TODO: Could Probably store all invalid fields in an array and highlight them in table.
let invalidMetric = false;
selectedMetrics.map((metric) => {
if (!(metric.min || metric.max || metric.sum || metric.avg || metric.value_count)) {
const errorMsg = "Must specify at least one metric to aggregate on for: " + metric.source_field.label;
this.setState({ submitError: errorMsg, metricError: errorMsg });
invalidMetric = true;
error = true;
}
});
//If nothing invalid found, clear error.
if (!invalidMetric) this.setState({ metricError: "" });
}
} else if (currentStep == 3) {
//Check if interval is a valid value and is specified.
const { intervalError, continuousDefinition } = this.state;
if (continuousDefinition == "fixed") {
if (intervalError != "") {
const intervalErrorMsg = "Interval value is required.";
this.setState({ submitError: intervalErrorMsg, intervalError: intervalErrorMsg });
error = true;
}
}
}
if (error) return;
currentStep = currentStep >= 3 ? 4 : currentStep + 1;
this.setState({
submitError: "",
currentStep: currentStep,
});
}