Skip to content

Commit

Permalink
Fix Rule details/edit view with updated data
Browse files Browse the repository at this point in the history
We need to fix the other side of the equation to get these to work: the
timeline data was moved to a different step during creation, but when
viewing on the frontend we split the rule data back into the separate
"steps."
  • Loading branch information
rylnd committed Mar 20, 2020
1 parent 91a60b6 commit 3fd39a2
Showing 1 changed file with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ export const getStepsData = ({
return { aboutRuleData, modifiedAboutRuleDetailsData, defineRuleData, scheduleRuleData };
};

export const getDefineStepsData = (rule: Rule): DefineStepRule => {
return {
isNew: false,
ruleType: rule.type,
anomalyThreshold: rule.anomaly_threshold ?? 50,
machineLearningJobId: rule.machine_learning_job_id ?? '',
index: rule.index ?? [],
queryBar: {
query: { query: rule.query ?? '', language: rule.language ?? '' },
filters: (rule.filters ?? []) as Filter[],
saved_id: rule.saved_id,
},
};
};
export const getDefineStepsData = (rule: Rule): DefineStepRule => ({
isNew: false,
ruleType: rule.type,
anomalyThreshold: rule.anomaly_threshold ?? 50,
machineLearningJobId: rule.machine_learning_job_id ?? '',
index: rule.index ?? [],
queryBar: {
query: { query: rule.query ?? '', language: rule.language ?? '' },
filters: (rule.filters ?? []) as Filter[],
saved_id: rule.saved_id,
},
timeline: {
id: rule.timeline_id ?? null,
title: rule.timeline_title ?? null,
},
});

export const getScheduleStepsData = (rule: Rule): ScheduleStepRule => {
const { enabled, interval, from } = rule;
Expand Down Expand Up @@ -94,8 +96,6 @@ export const getAboutStepsData = (rule: Rule, detailsView: boolean): AboutStepRu
risk_score: riskScore,
tags,
threat,
timeline_id: timelineId,
timeline_title: timelineTitle,
} = rule;

return {
Expand All @@ -109,10 +109,6 @@ export const getAboutStepsData = (rule: Rule, detailsView: boolean): AboutStepRu
riskScore,
falsePositives,
threat: threat as IMitreEnterpriseAttack[],
timeline: {
id: timelineId ?? null,
title: timelineTitle ?? null,
},
};
};

Expand Down

0 comments on commit 3fd39a2

Please sign in to comment.