Skip to content

Commit

Permalink
edit correlation Alert Trigger fix
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Oct 9, 2024
1 parent c725ac4 commit 41eab22
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
23 changes: 11 additions & 12 deletions public/pages/Correlations/containers/CreateCorrelationRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface CreateCorrelationRuleProps extends DataSourceProps {
history: RouteComponentProps<
any,
any,
{ rule: CorrelationRuleModel; isReadOnly: boolean }
{ rule: CorrelationRule; isReadOnly: boolean }
>['history'];
notifications: NotificationsStart | null;
notificationsService: NotificationsService;
Expand Down Expand Up @@ -234,20 +234,20 @@ export const CreateCorrelationRule: React.FC<CreateCorrelationRuleProps> = (
setNotificationChannels(parsedChannels);
setLoadingNotifications(false);
};
const setInitialRuleValues = async (ruleId: string) => {
const ruleRes = await correlationStore.getCorrelationRule(ruleId);
if (ruleRes) {
setInitialValues(ruleRes);
}
};

if (props.history.location.state?.rule) {
setAction('Edit');
setInitialValues(props.history.location.state?.rule);
setInitialRuleValues(props.history.location.state?.rule.id);
} else if (params.ruleId) {
const setInitialRuleValues = async () => {
const ruleRes = await correlationStore.getCorrelationRule(params.ruleId);
if (ruleRes) {
setInitialValues(ruleRes);
}
};

setAction('Edit');
setInitialRuleValues();
setInitialRuleValues(params.ruleId);
}

const setupLogTypeOptions = async () => {
const options = await getLogTypeOptions();
setLogTypeOptions(options);
Expand Down Expand Up @@ -388,7 +388,6 @@ export const CreateCorrelationRule: React.FC<CreateCorrelationRuleProps> = (
query.field = '';
});
}

// Modify or set default values for trigger if present
if (values.trigger) {
// Set default values for ids
Expand Down
1 change: 1 addition & 0 deletions public/store/CorrelationsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class CorrelationsStore implements ICorrelationsStore {
name: hit._source.name,
time_window: hit._source.time_window || 300000,
queries,
trigger: hit._source?.trigger
};
}

Expand Down
4 changes: 2 additions & 2 deletions types/Correlations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface CorrelationRuleModel {
name: string;
time_window: number; // Time in milliseconds
queries: CorrelationRuleQuery[];
trigger: CorrelationRuleTrigger | undefined;
trigger?: CorrelationRuleTrigger;
}

export interface CorrelationRule extends CorrelationRuleModel {
Expand All @@ -76,7 +76,7 @@ export interface CorrelationRuleSource {
name: string;
time_window: number;
correlate: CorrelationRuleSourceQueries[];
trigger?: CorrelationRuleTrigger | undefined;
trigger?: CorrelationRuleTrigger;
}

export interface CorrelationRuleHit {
Expand Down

0 comments on commit 41eab22

Please sign in to comment.