Skip to content

Commit

Permalink
Merge branch 'main' into docs/1232
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Oct 22, 2024
2 parents 31bd356 + f32e342 commit 7fb83e6
Show file tree
Hide file tree
Showing 134 changed files with 3,553 additions and 1,336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
try {
const prCount = parseInt(process.env.PR_COUNT);
const author = process.env.AUTHOR;
const mention = 'talboren';
const prNumber = context.payload.pull_request.number;
const repo = process.env.REPO;
Expand All @@ -68,49 +67,41 @@ jobs:
return `${emoji} **Fantastic work @${author}!** Your very first PR to ${repo} has been merged! 🎉🥳\n\n` +
`You've just taken your first step into open-source, and we couldn't be happier to have you onboard. 🙌\n` +
`If you're feeling adventurous, why not dive into another issue and keep contributing? The community would love to see more from you! 🚀\n\n` +
`For any support, feel free to reach out to the developer onboarding lead: @${mention}. Happy coding! 👩‍💻👨‍💻`;
`For any support, feel free to reach out on the community: https://slack.keephq.dev. Happy coding! 👩‍💻👨‍💻`;
case 2:
return `${emoji} **Well done @${author}!** Two PRs merged already! 🎉🥳\n\n` +
`With your second PR, you're on a roll, and your contributions are already making a difference. 🌟\n` +
`Looking forward to seeing even more contributions from you. The developer onboarding lead: @${mention} is here if you need any help! Keep up the great work! 🚀`;
`Looking forward to seeing even more contributions from you. See you in Slack https://slack.keephq.dev 🚀`;
case 3:
return `${emoji} **You're on fire, @${author}!** Three PRs merged and counting! 🔥🎉\n\n` +
`Your consistent contributions are truly impressive. You're becoming a valued member of our community! 💖\n` +
`Have you considered taking on some more challenging issues? We'd love to see what you can do! 💪\n\n` +
`Remember, @${mention} is always here to support you. Keep blazing that trail! 🚀`;
`Remember, the team is always here to support you. Keep blazing that trail! 🚀`;
case 5:
return `${emoji} **High five, @${author}!** You've hit the incredible milestone of 5 merged PRs! 🖐️✨\n\n` +
`Your dedication to ${repo} is outstanding. You're not just contributing code; you're shaping the future of this project! 🌠\n` +
`We'd love to hear your thoughts on the project. Any ideas for new features or improvements? 🤔\n\n` +
`@${mention} and the whole team applaud your efforts. You're a superstar! 🌟`;
`The whole team applaud your efforts. You're a superstar! 🌟`;
case 10:
return `${emoji} **Double digits, @${author}!** 10 merged PRs is a massive achievement! 🏆🎊\n\n` +
`Your impact on ${repo} is undeniable. You've become a pillar of our community! 🏛️\n` +
`We'd be thrilled to have you take on a mentorship role for newer contributors. Interested? 🧑‍🏫\n\n` +
`@${mention} and everyone here are in awe of your contributions. You're an open source hero! 🦸‍♀️🦸‍♂️`;
`Everyone here are in awe of your contributions. You're an open source hero! 🦸‍♀️🦸‍♂️`;
default:
if (count > 10) {
return `${emoji} **Incredible, @${author}!** You've merged your ${count}th PR! 🎯🎊\n\n` +
`Your ongoing commitment to ${repo} is truly remarkable. You're a driving force in our community! 🚀\n` +
`Your contributions are helping to shape the future of this project. What exciting features or improvements do you envision next? 🔮\n\n` +
`@${mention} and the entire team are grateful for your dedication. You're an inspiration to us all! 💫`;
} else {
return `${emoji} **Great job, @${author}!** You've merged your ${count}th PR! 🎊\n\n` +
`Your contributions to ${repo} are making a real difference. Keep up the fantastic work! 💪\n` +
`Remember, every PR counts and helps improve the project. What will you tackle next? 🤔\n\n` +
`@${mention} is here if you need any guidance. Onward and upward! 🚀`;
}
return "";
}
}
const message = getMessage(prCount);
await github.rest.issues.createComment({
owner: process.env.OWNER,
repo: process.env.REPO,
issue_number: prNumber,
body: message
});
if (message) {
await github.rest.issues.createComment({
owner: process.env.OWNER,
repo: process.env.REPO,
issue_number: prNumber,
body: message
});
}
} catch (error) {
core.setFailed(`Error creating comment: ${error.message}`);
}
}
3 changes: 3 additions & 0 deletions examples/workflows/new_github_stars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ steps:
previous_stars_count:
default: 0
key: "{{ last_workflow_results.get-github-stars.0.stars }}"
last_stargazer:
default: ""
key: "{{ last_workflow_results.get-github-stars.0.last_stargazer }}"
repository: keephq/keep
actions:
- condition:
Expand Down
4 changes: 2 additions & 2 deletions keep-ui/app/ai/ai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Card, List, ListItem, Title, Subtitle } from "@tremor/react";
import { useAIStats, usePollAILogs } from "utils/hooks/useAI";
import { useSession } from "next-auth/react";
import { getApiURL } from "utils/apiUrl";
import { useApiUrl } from "utils/hooks/useConfig";
import { toast } from "react-toastify";
import { useEffect, useState, useRef, FormEvent } from "react";
import { AILogs } from "./model";
Expand All @@ -15,6 +15,7 @@ export default function Ai() {
const [newText, setNewText] = useState("Mine incidents");
const [animate, setAnimate] = useState(false);
const onlyOnce = useRef(false);
const apiUrl = useApiUrl();

const mutateAILogs = (logs: AILogs) => {
setBasicAlgorithmLog(logs.log);
Expand Down Expand Up @@ -42,7 +43,6 @@ export default function Ai() {
e.preventDefault();
setAnimate(true);
setNewText("Mining 🚀🚀🚀 ...");
const apiUrl = getApiURL();
const response = await fetch(`${apiUrl}/incidents/mine`, {
method: "POST",
headers: {
Expand Down
96 changes: 60 additions & 36 deletions keep-ui/app/alerts/ViewAlertModal.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
import { AlertDto } from "./models"; // Adjust the import path as needed
import Modal from "@/components/ui/Modal"; // Ensure this path matches your project structure
import {Button, Icon, Switch, Text} from "@tremor/react";
import { Button, Icon, Switch, Text } from "@tremor/react";
import { toast } from "react-toastify";
import { getApiURL } from "../../utils/apiUrl";
import { useApiUrl } from "utils/hooks/useConfig";
import { useSession } from "next-auth/react";
import { XMarkIcon } from "@heroicons/react/24/outline";
import "./ViewAlertModal.css";
import React, {useState} from "react";
import React, { useState } from "react";

interface ViewAlertModalProps {
alert: AlertDto | null | undefined;
handleClose: () => void;
mutate: () => void;
}

const objectToJSONLine = (obj: any) => {
const objectToJSONLine = (obj: any) => {
return JSON.stringify(obj, null, 2).slice(2, -2);
}
};

export const ViewAlertModal: React.FC<ViewAlertModalProps> = ({ alert, handleClose, mutate}) => {
export const ViewAlertModal: React.FC<ViewAlertModalProps> = ({
alert,
handleClose,
mutate,
}) => {
const isOpen = !!alert;
const [showHighlightedOnly, setShowHighlightedOnly] = useState(false);
const {data: session} = useSession();
const { data: session } = useSession();
const apiUrl = useApiUrl();

const unEnrichAlert = async (key: string) => {
if (confirm(`Are you sure you want to un-enrich ${key}?`)) {
Expand All @@ -30,7 +35,7 @@ export const ViewAlertModal: React.FC<ViewAlertModalProps> = ({ alert, handleClo
enrichments: [key],
fingerprint: alert!.fingerprint,
};
const response = await fetch(`${getApiURL()}/alerts/unenrich`, {
const response = await fetch(`${apiUrl}/alerts/unenrich`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -52,35 +57,46 @@ export const ViewAlertModal: React.FC<ViewAlertModalProps> = ({ alert, handleClo
toast.error("An unexpected error occurred");
}
}
}
};

const highlightKeys = (json: any, keys: string[]) => {

const lines = Object.keys(json).length;
const isLast = (index: number) => index == lines - 1
const isLast = (index: number) => index == lines - 1;

return Object.keys(json).map((key: string, index: number) => {
if (keys.includes(key)) {
return <p key={key} className="text-green-600 cursor-pointer line-container" onClick={() => unEnrichAlert(key)}>
<span className="un-enrich-icon">
<Icon
icon={XMarkIcon}
tooltip={`Click to un-enrich ${key}`}
size="xs"
color="red"
className="cursor-pointer px-0 py-0"
variant="outlined"
/>
</span>
{objectToJSONLine({[key]: json[key]})}{isLast(index) ? null : ","}
</p>
return (
<p
key={key}
className="text-green-600 cursor-pointer line-container"
onClick={() => unEnrichAlert(key)}
>
<span className="un-enrich-icon">
<Icon
icon={XMarkIcon}
tooltip={`Click to un-enrich ${key}`}
size="xs"
color="red"
className="cursor-pointer px-0 py-0"
variant="outlined"
/>
</span>
{objectToJSONLine({ [key]: json[key] })}
{isLast(index) ? null : ","}
</p>
);
} else {
if (!showHighlightedOnly || keys.length == 0) {
return <p key={key}>{objectToJSONLine({[key]: json[key]})}{isLast(index) ? null : ","}</p>
return (
<p key={key}>
{objectToJSONLine({ [key]: json[key] })}
{isLast(index) ? null : ","}
</p>
);
}
}
})
}
});
};

const handleCopy = async () => {
if (alert) {
Expand All @@ -94,23 +110,31 @@ export const ViewAlertModal: React.FC<ViewAlertModalProps> = ({ alert, handleClo
};

return (
<Modal onClose={handleClose} isOpen={isOpen} className="overflow-visible max-w-fit">
<Modal
onClose={handleClose}
isOpen={isOpen}
className="overflow-visible max-w-fit"
>
<div className="flex justify-between items-center mb-4 min-w-full">
<h2 className="text-lg font-semibold">Alert Details</h2>
<div className="flex gap-x-2"> {/* Adjust gap as needed */}
<div className="flex gap-x-2">
{" "}
{/* Adjust gap as needed */}
<div className="placeholder-resizing min-w-48"></div>
<div className="flex items-center space-x-2">
<Switch
color="orange"
id="showHighlightedOnly"
checked={showHighlightedOnly}
onChange={() => setShowHighlightedOnly(!showHighlightedOnly)}
/>
<label htmlFor="showHighlightedOnly" className="text-sm text-gray-500">
color="orange"
id="showHighlightedOnly"
checked={showHighlightedOnly}
onChange={() => setShowHighlightedOnly(!showHighlightedOnly)}
/>
<label
htmlFor="showHighlightedOnly"
className="text-sm text-gray-500"
>
<Text>Enriched Fields Only</Text>
</label>
</div>

<Button onClick={handleCopy} color="orange">
Copy to Clipboard
</Button>
Expand Down
24 changes: 13 additions & 11 deletions keep-ui/app/alerts/alert-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import { Button } from "@tremor/react";
import { getSession } from "next-auth/react";
import { getApiURL } from "utils/apiUrl";
import { useApiUrl } from "utils/hooks/useConfig";
import { AlertDto } from "./models";
import { PlusIcon } from "@radix-ui/react-icons";
import { toast } from "react-toastify";
Expand All @@ -23,14 +23,16 @@ export default function AlertActions({
alerts,
clearRowSelection,
setDismissModalAlert,
mutateAlerts
mutateAlerts,
}: Props) {
const router = useRouter();
const { useAllPresets } = usePresets();
const apiUrl = useApiUrl();
const { mutate: presetsMutator } = useAllPresets({
revalidateOnFocus: false,
});
const [isIncidentSelectorOpen, setIsIncidentSelectorOpen] = useState<boolean>(false);
const [isIncidentSelectorOpen, setIsIncidentSelectorOpen] =
useState<boolean>(false);

const selectedAlerts = alerts.filter((_alert, index) =>
selectedRowIds.includes(index.toString())
Expand All @@ -54,7 +56,6 @@ export default function AlertActions({
);
const options = [{ value: formattedCel, label: "CEL" }];
const session = await getSession();
const apiUrl = getApiURL();
const response = await fetch(`${apiUrl}/preset`, {
method: "POST",
headers: {
Expand Down Expand Up @@ -82,18 +83,18 @@ export default function AlertActions({

const showIncidentSelector = () => {
setIsIncidentSelectorOpen(true);
}
};
const hideIncidentSelector = () => {
setIsIncidentSelectorOpen(false);
}
};

const handleSuccessfulAlertsAssociation = () => {
hideIncidentSelector();
clearRowSelection();
if (mutateAlerts) {
mutateAlerts();
}
}
};

return (
<div className="w-full flex justify-end items-center">
Expand Down Expand Up @@ -130,10 +131,11 @@ export default function AlertActions({
Associate with incident
</Button>
<AlertAssociateIncidentModal
isOpen={isIncidentSelectorOpen}
alerts={selectedAlerts}
handleSuccess={handleSuccessfulAlertsAssociation}
handleClose={hideIncidentSelector}/>
isOpen={isIncidentSelectorOpen}
alerts={selectedAlerts}
handleSuccess={handleSuccessfulAlertsAssociation}
handleClose={hideIncidentSelector}
/>
</div>
);
}
13 changes: 5 additions & 8 deletions keep-ui/app/alerts/alert-assign-ticket-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PlusIcon } from "@heroicons/react/20/solid";
import { useForm, Controller, SubmitHandler } from "react-hook-form";
import { Providers } from "./../providers/providers";
import { useSession } from "next-auth/react";
import { getApiURL } from "utils/apiUrl";
import { useApiUrl } from "utils/hooks/useConfig";
import { AlertDto } from "./models";
import Modal from "@/components/ui/Modal";

Expand Down Expand Up @@ -45,6 +45,7 @@ const AlertAssignTicketModal = ({
} = useForm<FormData>();
// get the token
const { data: session } = useSession();
const apiUrl = useApiUrl();

// if this modal should not be open, do nothing
if (!alert) return null;
Expand All @@ -61,7 +62,7 @@ const AlertAssignTicketModal = ({
fingerprint: alert.fingerprint,
};

const response = await fetch(`${getApiURL()}/alerts/enrich`, {
const response = await fetch(`${apiUrl}/alerts/enrich`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -225,18 +226,14 @@ const AlertAssignTicketModal = ({
</div>
<div className="mt-6 flex gap-2">
<Button color="orange" type="submit">
<Text>
Assign Ticket
</Text>
<Text>Assign Ticket</Text>
</Button>
<Button
onClick={handleClose}
variant="secondary"
className="border border-orange-500 text-orange-500"
>
<Text>
Cancel
</Text>
<Text>Cancel</Text>
</Button>
</div>
</form>
Expand Down
Loading

0 comments on commit 7fb83e6

Please sign in to comment.