Skip to content

Commit 4ce8162

Browse files
Merge branch 'main' into Feat/Workflow-secrets
2 parents 1947ff9 + fb84fb2 commit 4ce8162

File tree

28 files changed

+1377
-207
lines changed

28 files changed

+1377
-207
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
workflow:
2+
id: run-webhook-foreach
3+
description: Run a webhook for each alert
4+
name: Run webhook for each alert
5+
debug: true
6+
triggers:
7+
- type: manual
8+
9+
steps:
10+
- name: webhook-get
11+
provider:
12+
type: webhook
13+
config: "{{ providers.test }}"
14+
with:
15+
method: GET
16+
url: "http://localhost:8000"
17+
- name: get-alerts
18+
foreach: " {{ steps.webhook-get.results.body.ids }}"
19+
provider:
20+
type: keep
21+
with:
22+
version: 2
23+
filter: 'id=="{{ foreach.value }}"'
24+
actions:
25+
- name: echo
26+
foreach: " {{ steps.get-alerts.results }}"
27+
if: '{{ foreach.value.0.status }} == "firing"'
28+
provider:
29+
type: console
30+
with:
31+
logger: true
32+
message: "alert {{ foreach.value.0.id }} is {{ foreach.value.0.status }}"
33+
# actions:
34+
# - name: webhook-test
35+
# foreach: " {{ steps.get-alerts.results }}"
36+
# if: '{{ foreach.value.0.status }} == "firing"'
37+
# provider:
38+
# type: webhook
39+
# config: "{{ providers.test }}"
40+
# with:
41+
# body:
42+
# message: "Hello world"

keep-ui/app/(keep)/alerts/alert-table-utils.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,15 @@ export const useAlertTableCols = (
287287
const incidentString = String(value || "");
288288
const incidentSplit = incidentString.split(",");
289289
return incidentSplit.map((incidentId, index) => {
290-
const incidentName = incidents?.items.find(
290+
const incident = incidents?.items.find(
291291
(incident) => incident.id === incidentId
292-
)?.user_generated_name;
292+
);
293293
return (
294294
<>
295295
<Link href={`/incidents/${incidentId}`}>
296-
{incidentName || incidentId}
296+
{incident?.user_generated_name ||
297+
incident?.ai_generated_name ||
298+
incidentId}
297299
</Link>
298300
{index < incidentSplit.length - 1 && ", "}
299301
</>

keep-ui/app/(keep)/rules/CorrelationPlaceholder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Fragment, useState } from "react";
2-
import { Button, Card, Subtitle, Title } from "@tremor/react";
2+
import { Button } from "@tremor/react";
33
import { CorrelationSidebar } from "./CorrelationSidebar";
44
import { PlaceholderSankey } from "./ui/PlaceholderSankey";
55
import { PlusIcon } from "@heroicons/react/20/solid";

keep-ui/app/(keep)/rules/CorrelationSidebar/RuleFields.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useEffect, useState } from "react";
22
import {
33
Button,
44
SearchSelect,
@@ -21,6 +21,7 @@ import { useFormContext } from "react-hook-form";
2121
import { useSearchAlerts } from "utils/hooks/useSearchAlerts";
2222
import { CorrelationFormType } from "./types";
2323
import { TIMEFRAME_UNITS_TO_SECONDS } from "./timeframe-constants";
24+
import { useDeduplicationFields } from "@/utils/hooks/useDeduplicationRules";
2425

2526
const DEFAULT_OPERATORS = defaultOperators.filter((operator) =>
2627
[
@@ -67,6 +68,10 @@ const Field = ({
6768
const [searchValue, setSearchValue] = useState("");
6869
const [isValueEnabled, setIsValueEnabled] = useState(true);
6970

71+
useEffect(() => {
72+
setFields(avaliableFields);
73+
}, [avaliableFields]);
74+
7075
const onValueChange = (selectedValue: string) => {
7176
if (searchValue.length) {
7277
const doesSearchedValueExistInFields = fields.some(
@@ -190,9 +195,24 @@ export const RuleFields = ({
190195
[]
191196
);
192197

193-
const availableFields = DEFAULT_FIELDS.filter(
194-
({ name }) => selectedFields.includes(name) === false
195-
);
198+
const { data: deduplicationFields = {} } = useDeduplicationFields();
199+
200+
const uniqueDeduplicationFields = Object.values(deduplicationFields)
201+
.flat()
202+
.filter(
203+
(field) => DEFAULT_FIELDS.find((f) => f.name === field) === undefined
204+
) // remove duplicates
205+
.map((field) => ({
206+
label: field,
207+
name: field,
208+
datatype: "text",
209+
}));
210+
211+
const availableFields = DEFAULT_FIELDS.concat(
212+
uniqueDeduplicationFields
213+
).filter(({ name }) => selectedFields.includes(name) === false);
214+
215+
console.log(availableFields);
196216

197217
const onAddRuleFieldClick = () => {
198218
const nextAvailableField = availableFields.at(0);

keep-ui/app/(keep)/workflows/page.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
import React from "react";
22
import WorkflowsPage from "./workflows.client";
3+
import { FacetDto } from "@/features/filter";
4+
import { createServerApiClient } from "@/shared/api/server";
5+
import { getInitialFacets } from "@/features/filter/api";
36

4-
export default function Page() {
5-
return <WorkflowsPage />;
7+
export default async function Page() {
8+
let initialFacets: FacetDto[] | null = null;
9+
10+
try {
11+
const api = await createServerApiClient();
12+
initialFacets = await getInitialFacets(api, "workflows");
13+
} catch (error) {
14+
console.log(error);
15+
}
16+
return (
17+
<WorkflowsPage
18+
initialFacetsData={
19+
initialFacets
20+
? { facets: initialFacets, facetOptions: null }
21+
: undefined
22+
}
23+
/>
24+
);
625
}
726

827
export const metadata = {

0 commit comments

Comments
 (0)