- Added api.ts to handle API requests and define data models for Project, Image, Vulnerability, IgnoreRule, ScanJob, and DashboardStats. - Created Dashboard component to display statistics and initiate scans for projects and vulnerabilities. - Developed IgnoreRules component for managing ignore rules with filtering options. - Implemented Images component to list discovered Docker images. - Added Projects component to display monitored GitLab projects. - Created ScanJobs component to show history and status of scanning operations. - Developed Vulnerabilities component to report security vulnerabilities found in Docker images. - Removed BrowserRouter from main.tsx as routing is not currently implemented.
27 lines
749 B
TypeScript
27 lines
749 B
TypeScript
import { createContext, useContext, ReactNode } from 'react'
|
|
import { useWebSocket } from '@/hooks/useWebSocket'
|
|
|
|
interface WebSocketContextType {
|
|
isConnected: boolean
|
|
hasRunningScans: boolean
|
|
}
|
|
|
|
const WebSocketContext = createContext<WebSocketContextType | undefined>(undefined)
|
|
|
|
export function WebSocketProvider({ children }: { children: ReactNode }) {
|
|
const webSocketState = useWebSocket()
|
|
|
|
return (
|
|
<WebSocketContext.Provider value={webSocketState}>
|
|
{children}
|
|
</WebSocketContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useWebSocketContext() {
|
|
const context = useContext(WebSocketContext)
|
|
if (context === undefined) {
|
|
throw new Error('useWebSocketContext must be used within a WebSocketProvider')
|
|
}
|
|
return context
|
|
} |