diff --git a/keep-ui/app/runbooks/runbook-table.tsx b/keep-ui/app/runbooks/runbook-table.tsx index aa3ad1933..8e6ec4877 100644 --- a/keep-ui/app/runbooks/runbook-table.tsx +++ b/keep-ui/app/runbooks/runbook-table.tsx @@ -1,19 +1,14 @@ "use client"; import React, { useState } from "react"; -import Modal from "react-modal"; // Add this import for react-modal +import Modal from "react-modal"; import { Button, Badge, - Table as TremorTable, - TableBody, - TableCell, - TableHead, - TableHeaderCell, - TableRow, } from "@tremor/react"; import { DisplayColumnDef } from "@tanstack/react-table"; -import { GenericTable } from "@/components/table/GenericTable"; +import { GenericTable } from "@/components/table/GenericTable"; +import { useSession } from "next-auth/react"; const customStyles = { @@ -95,6 +90,8 @@ function RunbookIncidentTable() { const [repositoryName, setRepositoryName] = useState(''); const [pathToMdFiles, setPathToMdFiles] = useState(''); + const { data: session } = useSession(); + const handlePaginationChange = (newLimit: number, newOffset: number) => { setLimit(newLimit); setOffset(newOffset); @@ -110,12 +107,28 @@ function RunbookIncidentTable() { setIsModalOpen(false); }; - // Handle save action from modal - const handleSave = () => { - // You can handle saving the data here (e.g., API call or updating state) - console.log('Repository:', repositoryName); - console.log('Path to MD Files:', pathToMdFiles); - closeModal(); + const handleQuerySettings = async ({ repositoryName, pathToMdFiles }) => { + try { + const [owner, repo] = repositoryName.split("/"); + const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/contents/${pathToMdFiles}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${session?.accessToken}`, + }, + }); + + if (!response.ok) { + throw new Error('Failed to query settings'); + } + + const data = await response.json(); + console.log('Settings queried successfully:', data); + + } catch (error) { + console.error('Error while querying settings:', error); + alert('An error occurred while querying settings'); + } }; return ( @@ -149,7 +162,7 @@ function RunbookIncidentTable() { type="text" value={repositoryName} onChange={(e) => setRepositoryName(e.target.value)} - placeholder="Enter repository name" + placeholder="Enter repository name (e.g., owner/repo)" style={{ width: '100%', padding: '8px', marginBottom: '10px' }} /> @@ -167,7 +180,7 @@ function RunbookIncidentTable() {
- +
diff --git a/keep/providers/github_provider/github_provider.py b/keep/providers/github_provider/github_provider.py index 7e9bdfaa1..7b495189e 100644 --- a/keep/providers/github_provider/github_provider.py +++ b/keep/providers/github_provider/github_provider.py @@ -25,21 +25,6 @@ class GithubProviderAuthConfig: "sensitive": True, } ) - repository: str = dataclasses.field( - metadata={ - "description": "GitHub Repository", - "sensitive": False, - }, - default=None, - ) - md_path: str = dataclasses.field( - metadata={ - "description": "Path to .md files in the repository", - "sensitive": False, - }, - default=None, - ) - class GithubProvider(BaseProvider): """ @@ -72,33 +57,6 @@ def validate_config(self): self.authentication_config = GithubProviderAuthConfig( **self.config.authentication ) - def query_runbook(self,query): - """Retrieve markdown files from the GitHub repository.""" - - if not query: - raise ValueError("Query is required") - - auth=None - if self.authentication_config.repository and self.authentication_config.md_path: - auth = HTTPBasicAuth( - self.authentication_config.repository, - self.authentication_config.md_path, - ) - - resp = requests.get( - f"{self.authentication_config.url}/api/v1/query", - params={"query": query}, - auth=( - auth - if self.authentication_config.repository and self.authentication_config.md_path - else None - ) - ) - if response.status_code != 200: - raise Exception(f"Runbook Query Failed: {response.content}") - - return response.json() - class GithubStarsProvider(GithubProvider): """ @@ -153,8 +111,6 @@ def _query( "test", ProviderConfig(authentication={ "access_token": os.environ.get("GITHUB_PAT"), - "repository": os.environ.get("GITHUB_REPOSITORY"), - "md_path": os.environ.get("MARKDOWN_PATH"), } ), )