Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: runbooks queried from GitHub and Gitlab #2104

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
b88145f
progress 1
Sep 21, 2024
85fd3f5
Merge branch 'main' into Runbooks-queried-by-github-and-gitlb
Mubashirshariq Sep 21, 2024
e1e5fcf
Merge branch 'main' into Runbooks-queried-by-github-and-gitlb
talboren Sep 24, 2024
d2e90fd
made some changes
Mubashirshariq Sep 29, 2024
e062dfd
Merge branch 'main' into Runbooks-queried-by-github-and-gitlb
rajesh-jonnalagadda Sep 30, 2024
2e9bc5d
fix: access token issue on frontend. but need to move the fetching lo…
rajesh-jonnalagadda Oct 1, 2024
8d1c443
chore:remvoed unwanted logs
rajesh-jonnalagadda Oct 1, 2024
17d9d85
Merge pull request #1 from rajeshj11/feat-1780-runbooks-intergation
Mubashirshariq Oct 1, 2024
546a0bd
refactor: moved the entire runbook fetching logic to backend and adde…
rajesh-jonnalagadda Oct 2, 2024
9c99c29
chore: clean up the code
rajesh-jonnalagadda Oct 2, 2024
a871262
chore: resolved the lint issues
rajesh-jonnalagadda Oct 2, 2024
8e87f9c
Merge pull request #2 from rajeshj11/feat-1780-runbooks-intergation
rajesh-jonnalagadda Oct 2, 2024
6775426
Merge branch 'main' into Runbooks-queried-by-github-and-gitlb
rajesh-jonnalagadda Oct 2, 2024
25cd6e8
fix: minor drop down issue
rajesh-jonnalagadda Oct 2, 2024
67772e0
Merge pull request #3 from rajeshj11/feat-1780-runbooks-intergation
rajesh-jonnalagadda Oct 2, 2024
a7e4cd3
refactor: modified the styles of the runbook page
rajesh-jonnalagadda Oct 2, 2024
c1ee5e1
Merge pull request #4 from rajeshj11/feat-1780-runbooks-intergation
rajesh-jonnalagadda Oct 2, 2024
bc61c4c
Merge branch 'main' into Runbooks-queried-by-github-and-gitlb
rajesh-jonnalagadda Oct 2, 2024
f3504c1
chore: fix the corrupted code
rajesh-jonnalagadda Oct 2, 2024
402cad8
Merge pull request #5 from rajeshj11/feat-1780-runbooks-intergation
rajesh-jonnalagadda Oct 2, 2024
27d38cf
Merge branch 'keephq:main' into Runbooks-queried-by-github-and-gitlb
Mubashirshariq Oct 6, 2024
6d6f865
Merge branch 'main' into Runbooks-queried-by-github-and-gitlb
rajesh-jonnalagadda Oct 6, 2024
12bdd12
moved runbook endpoints to runbook.py
Mubashirshariq Oct 7, 2024
2988810
Merge branch 'main' into Feat/runbook
Mubashirshariq Oct 7, 2024
6138c03
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 7, 2024
d5a37e5
Merge branch 'Feat/runbook' of github.com:Mubashirshariq/keep into fe…
rajesh-jonnalagadda Oct 7, 2024
9f1fabe
feat: add runbook data into db. to do: incident link needs to be done.
rajesh-jonnalagadda Oct 8, 2024
99c0226
Merge pull request #6 from rajeshj11/feat-1780-runbooks-intergation
Mubashirshariq Oct 8, 2024
51fcfd1
Merge branch 'main' into Feat/runbook
Mubashirshariq Oct 8, 2024
1c3f04d
Revert "Feat 1780 runbooks intergation"
rajesh-jonnalagadda Oct 8, 2024
e86b705
Merge pull request #8 from Mubashirshariq/revert-6-feat-1780-runbooks…
rajesh-jonnalagadda Oct 8, 2024
061c6d6
feat: add runbook schema and show real runbook data. to do: incident …
rajesh-jonnalagadda Oct 8, 2024
c5cf2c6
Merge pull request #9 from rajeshj11/feat/runbook-1780-main-final
Mubashirshariq Oct 9, 2024
40bad4a
Merge branch 'main' into Feat/runbook
Mubashirshariq Oct 9, 2024
5130224
feat: add realtion link between runbook and incident
rajesh-jonnalagadda Oct 9, 2024
74bc7d6
Merge branch 'Feat/runbook' into feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 9, 2024
e7afd8e
chore: fix lint issues
rajesh-jonnalagadda Oct 9, 2024
e0d9228
Merge branch 'feat/runbook-1780-main-final' of github.com:rajeshj11/k…
rajesh-jonnalagadda Oct 9, 2024
84f406c
chore: fixed circular issue
rajesh-jonnalagadda Oct 9, 2024
74e586e
chore: removed the incidents relation ship in runbook
rajesh-jonnalagadda Oct 9, 2024
10aaefb
chore: removed the runbooks key in incidents schema
rajesh-jonnalagadda Oct 9, 2024
2c65037
chore:minor ui change and backend change
rajesh-jonnalagadda Oct 9, 2024
76a9527
Merge pull request #10 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 9, 2024
dd57ffb
feat:fix the multiple files issue and add pagination logic to the table
rajesh-jonnalagadda Oct 9, 2024
1029b2e
chore: fix lint issues
rajesh-jonnalagadda Oct 9, 2024
a49eaa0
fix: gitlab file content issue
rajesh-jonnalagadda Oct 9, 2024
5fb1a26
Merge branch 'main' into Feat/runbook
Mubashirshariq Oct 9, 2024
7c9041a
Merge pull request #11 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 9, 2024
2a72a7c
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 10, 2024
c3b6697
Merge branch 'main' into Feat/runbook
Mubashirshariq Oct 10, 2024
b5b91d9
chore: handle modal close on runbook creation and minor style changes
rajesh-jonnalagadda Oct 10, 2024
b47e310
chore:minor style change
rajesh-jonnalagadda Oct 10, 2024
3d11c66
Merge pull request #12 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 10, 2024
d2e3d0d
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 10, 2024
61afa4e
Merge branch 'mubashir-main' into feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 10, 2024
24a4ae5
chore:fix migration [atch issue
rajesh-jonnalagadda Oct 10, 2024
3edb87e
Merge pull request #13 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 10, 2024
9b38bed
Merge branch 'main' into Feat/runbook
Matvey-Kuk Oct 13, 2024
051e676
chore: remove unwanted code and comments
rajesh-jonnalagadda Oct 13, 2024
4696517
Merge remote-tracking branch 'mubashir-main/main' into feat/runbook-1…
rajesh-jonnalagadda Oct 13, 2024
815df21
refactor: merged the runbook patches into signle one and remov the pr…
rajesh-jonnalagadda Oct 13, 2024
410c4b6
Merge pull request #14 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 13, 2024
4277e26
chore: move the db related function to db core and minor ui effect ch…
rajesh-jonnalagadda Oct 13, 2024
4cd16c9
chore: clean up the code
rajesh-jonnalagadda Oct 13, 2024
41d17fb
Merge pull request #15 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 13, 2024
30d1635
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 13, 2024
6f1d730
chore: more clean up
rajesh-jonnalagadda Oct 13, 2024
b5c5b70
Merge pull request #16 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 13, 2024
767b5e2
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 14, 2024
35b3a6c
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 14, 2024
311179f
made changes to next-env
Mubashirshariq Oct 15, 2024
484df95
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 15, 2024
e51782c
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 15, 2024
81cbd3c
Merge branch 'main' into Feat/runbook
talboren Oct 16, 2024
055085a
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 17, 2024
980d6a2
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 18, 2024
c68f7ab
updated the migration patch
rajesh-jonnalagadda Oct 18, 2024
5163630
Merge pull request #17 from rajeshj11/feat/runbook-1780-main-final
rajesh-jonnalagadda Oct 18, 2024
91ee73f
Merge branch 'main' into Feat/runbook
Matvey-Kuk Oct 20, 2024
a7dceb9
Merge branch 'main' into Feat/runbook
Mubashirshariq Oct 20, 2024
76ebde0
removed duplicate runbook title and path at provider level
Mubashirshariq Oct 20, 2024
a0a8c79
chore: merge the schema change
rajesh-jonnalagadda Oct 20, 2024
3e8cb56
Merge pull request #18 from rajeshj11/feat/runbook-1780-main-final
Mubashirshariq Oct 20, 2024
72c8f2f
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 20, 2024
880e0f2
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 22, 2024
7a3a2bd
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 22, 2024
92aa4b8
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 22, 2024
fe41979
change runbook title to actual markdown file name
Mubashirshariq Oct 22, 2024
c9cef6c
Merge branch 'main' into Feat/runbook
talboren Oct 22, 2024
f1a1194
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 23, 2024
3ba71bc
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 23, 2024
4186d81
runbook title progress 1
Mubashirshariq Oct 24, 2024
7482b57
Merge pull request #19 from Mubashirshariq/dev-runbook-file-title
rajesh-jonnalagadda Oct 24, 2024
19844e8
feat: handle the folder case and content title issue
rajesh-jonnalagadda Oct 24, 2024
fc231b9
chore: remove unwanted comment
rajesh-jonnalagadda Oct 24, 2024
12333af
chore: fix the patch issue
rajesh-jonnalagadda Oct 24, 2024
7d90431
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 25, 2024
46ced51
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 25, 2024
4f778ec
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 25, 2024
bb87a56
Merge pull request #20 from rajeshj11/feat/runbook-1780-main-final
Mubashirshariq Oct 25, 2024
de861bb
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 27, 2024
beacbe1
Merge branch 'main' into Feat/runbook
rajesh-jonnalagadda Oct 28, 2024
132ee65
Merge branch 'main' into Feat/runbook
Mubashirshariq Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api-ref/actions/add-actions.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
openapi: post /actions
title: Add Actions
---
1 change: 1 addition & 0 deletions keep-ui/app/providers/filter-context/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const PROVIDER_LABELS: Record<TProviderLabels, string> = {
ticketing: 'Ticketing',
data: 'Data',
queue: 'Queue',
runbook: 'Runbook',
}

export const PROVIDER_LABELS_KEYS = Object.keys(PROVIDER_LABELS);
4 changes: 3 additions & 1 deletion keep-ui/app/providers/provider-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import "./provider-tile.css";
import moment from "moment";
import ImageWithFallback from "@/components/ImageWithFallback";
import { FaCode } from "react-icons/fa";
import { FaCode, FaMarkdown } from "react-icons/fa";

interface Props {
provider: Provider;
Expand Down Expand Up @@ -101,6 +101,8 @@ function getIconForTag(tag: TProviderLabels) {
return QueueListIcon;
case "topology":
return MapIcon;
case "runbook":
return FaMarkdown
default:
return ChatBubbleBottomCenterIcon;
}
Expand Down
10 changes: 3 additions & 7 deletions keep-ui/app/providers/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ interface AlertDistritbuionData {
number: number;
}

export type TProviderLabels =
| "alert"
| "topology"
| "messaging"
| "ticketing"
| "data"
| "queue";

export type TProviderLabels = 'alert' | 'topology' | 'messaging' | 'ticketing' | 'data' | 'queue' | 'runbook';


export interface Provider {
// key value pair of auth method name and auth method config
Expand Down
22 changes: 22 additions & 0 deletions keep-ui/app/runbooks/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export interface ContentDto {
id: string;
content: string;
link: string;
encoding: string | null;
file_name: string;
title: string | null;
}
export interface RunbookDto {
id: number;
title: string;
contents: ContentDto[];
provider_type: string;
provider_id: string;
repo_id: string;
file_path: string;
}

export type RunbookResponse = {
runbooks: RunbookDto[];
total_count: number;
};
7 changes: 7 additions & 0 deletions keep-ui/app/runbooks/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import RunbookIncidentTable from './runbook-table';

export default function RunbookPage() {
return (
<RunbookIncidentTable />
);
}
57 changes: 57 additions & 0 deletions keep-ui/app/runbooks/runbook-actions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useState } from "react";
import { Button } from "@tremor/react";
import { RunbookDto } from "./models";
import { PlusIcon } from "@radix-ui/react-icons";
import RunbookAssociateIncidentModal from "./runbook-associate-incident-modal";

interface Props {
selectedRowIds: string[];
runbooks: RunbookDto[];
clearRowSelection: () => void;
}

export default function RunbookActions({
selectedRowIds,
runbooks,
clearRowSelection,
}: Props) {
const [isIncidentSelectorOpen, setIsIncidentSelectorOpen] =
useState<boolean>(false);

const selectedRunbooks = runbooks.filter((_runbook, index) =>
selectedRowIds.includes(index.toString())
);

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

const handleSuccessfulRunbooksAssociation = () => {
hideIncidentSelector();
clearRowSelection();
};

return (
<div className="w-full flex justify-end items-center">
<Button
icon={PlusIcon}
size="xs"
color="orange"
className="ml-2.5"
onClick={showIncidentSelector}
tooltip="Associate events with incident"
>
Associate with incident
</Button>
<RunbookAssociateIncidentModal
isOpen={isIncidentSelectorOpen}
runbooks={selectedRunbooks}
handleSuccess={handleSuccessfulRunbooksAssociation}
handleClose={hideIncidentSelector}
/>
</div>
);
}
195 changes: 195 additions & 0 deletions keep-ui/app/runbooks/runbook-associate-incident-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
import Modal from "@/components/ui/Modal";
import { Button, Divider, SelectItem, Title } from "@tremor/react";
import Select from "@/components/ui/Select";
import CreateOrUpdateIncident from "app/incidents/create-or-update-incident";
import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation";
import { FormEvent, useCallback, useEffect, useState } from "react";
import { toast } from "react-toastify";
import { getApiURL } from "../../utils/apiUrl";
import { useIncidents, usePollIncidents } from "../../utils/hooks/useIncidents";
import Loading from "../loading";
import { RunbookDto } from "./models";

interface AlertAssociateIncidentModalProps {
isOpen: boolean;
handleSuccess: () => void;
handleClose: () => void;
runbooks: Array<RunbookDto>;
}

const RunbookAssociateIncidentModal = ({
isOpen,
handleSuccess,
handleClose,
runbooks,
}: AlertAssociateIncidentModalProps) => {
const [createIncident, setCreateIncident] = useState(false);

const { data: incidents, isLoading, mutate } = useIncidents(true, 100);
usePollIncidents(mutate);

const [selectedIncident, setSelectedIncident] = useState<
string | undefined
>();
// get the token
const { data: session } = useSession();
const router = useRouter();
console.log("Associating runbooks is outside", runbooks.map(({ id }) => id));

const associateRunbooksHandler = async (incidentId: string) => {
const apiUrl = getApiURL();
console.log("Associating runbooks with incident", incidentId);
console.log("Associating runbooks is", runbooks.map(({ id }) => id));
console.log("Associating session?.accessToken", session?.accessToken);

const response = await fetch(`${apiUrl}/incidents/${incidentId}/runbooks`, {
method: "POST",
headers: {
Authorization: `Bearer ${session?.accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify(runbooks.map(({ id }) => id)),
});
if (response.ok) {
handleSuccess();
await mutate();
toast.success("Runbooks associated with incident successfully");
} else {
toast.error(
"Failed to associated runbooks with incident, please contact us if this issue persists."
);
}
};

const handleAssociateRunbooks = (e: FormEvent) => {
e.preventDefault();
if (selectedIncident) associateRunbooksHandler(selectedIncident);
};

const showCreateIncidentForm = useCallback(() => setCreateIncident(true), []);

const hideCreateIncidentForm = useCallback(
() => setCreateIncident(false),
[]
);

const onIncidentCreated = useCallback(
(incidentId: string) => {
hideCreateIncidentForm();
handleClose();
associateRunbooksHandler(incidentId);
},
[associateRunbooksHandler, handleClose, hideCreateIncidentForm]
);

// reset modal state after closing
useEffect(() => {
if (!isOpen) {
hideCreateIncidentForm();
setSelectedIncident(undefined);
}
}, [hideCreateIncidentForm, isOpen]);

// if this modal should not be open, do nothing
if (!runbooks) return null;

return (
<Modal
isOpen={isOpen}
onClose={handleClose}
title="Choose Incident"
className="w-[600px]"
>
<div className="relative bg-white p-6 rounded-lg">
{isLoading ? (
<Loading />
) : createIncident ? (
<CreateOrUpdateIncident
incidentToEdit={null}
createCallback={onIncidentCreated}
exitCallback={hideCreateIncidentForm}
/>
) : incidents && incidents.items.length > 0 ? (
<div className="h-full justify-center">
<Select
className="my-2.5"
placeholder="Select incident"
value={
selectedIncident
? {
value: selectedIncident,
label:
incidents.items.find(
(incident) => incident.id === selectedIncident
)?.user_generated_name ||
incidents.items.find(
(incident) => incident.id === selectedIncident
)?.ai_generated_name ||
"",
}
: null
}
onChange={(selectedOption) =>
setSelectedIncident(selectedOption?.value)
}
options={incidents.items?.map((incident) => ({
value: incident.id,
label:
incident.user_generated_name ||
incident.ai_generated_name ||
"",
}))}
/>
<Divider />
<div className="flex items-center justify-between gap-6">
<Button
className="flex-1"
color="orange"
onClick={handleAssociateRunbooks}
disabled={selectedIncident === null}
>
Associate {runbooks.length} Runbook{runbooks.length > 1 ? "s" : ""}
</Button>

<Button
className="flex-1"
color="orange"
variant="secondary"
onClick={showCreateIncidentForm}
>
Create a new incident
</Button>
</div>
</div>
) : (
<div className="flex flex-col items-center justify-center gap-y-8 h-full">
<div className="text-center space-y-3">
<Title className="text-2xl">No Incidents Yet</Title>
</div>

<div className="flex items-center justify-between w-full gap-6">
<Button
className="flex-1"
color="orange"
onClick={() => router.push("/incidents")}
>
Incidents page
</Button>

<Button
className="flex-1"
color="green"
onClick={showCreateIncidentForm}
>
Create a new incident
</Button>
</div>
</div>
)}
</div>
</Modal>
);
};

export default RunbookAssociateIncidentModal;
Loading
Loading