Squash
This commit is contained in:
+3
-1
@@ -6,4 +6,6 @@ venv
|
||||
.venv
|
||||
LOCAL.md
|
||||
.idea
|
||||
docker-compose.yml.tmp
|
||||
docker-compose.yml.tmp
|
||||
frontend/node_modules
|
||||
frontend/dist
|
||||
+17
-3
@@ -1,4 +1,16 @@
|
||||
# Use official Python image with uv pre-installed
|
||||
# Stage 1: Build React frontend
|
||||
FROM node:20-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY openapi.yaml /app/openapi.yaml
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Python backend
|
||||
FROM python:3.12.3-alpine
|
||||
|
||||
# Install uv (if not present)
|
||||
@@ -14,9 +26,11 @@ COPY requirements.txt ./
|
||||
RUN uv venv .venv && \
|
||||
uv pip install -r requirements.txt
|
||||
|
||||
# Copy backend and frontend
|
||||
# Copy backend
|
||||
COPY backend/ ./backend/
|
||||
COPY frontend/ ./frontend/
|
||||
|
||||
# Copy built frontend from Stage 1
|
||||
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
||||
|
||||
# Expose port for the web server
|
||||
EXPOSE 5001
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ app.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
FRONTEND_DIR = os.path.join(os.path.dirname(__file__), '../frontend')
|
||||
FRONTEND_DIR = os.path.join(os.path.dirname(__file__), '../frontend/dist')
|
||||
|
||||
# In-memory state
|
||||
environments: Dict[str, Environment] = {}
|
||||
|
||||
+8
-48
@@ -1,52 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Brencher - Branch Merger</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1>Brencher - Branch Merger</h1>
|
||||
<div id="status-bar" class="status-bar hidden">
|
||||
<span id="status-message"></span>
|
||||
<button id="close-status">×</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="branches-section">
|
||||
<h2 style="float: left;">Git Branches</h2>
|
||||
<div class="filter-section" style="float: left;">
|
||||
<input type="text" id="branch-filter"
|
||||
placeholder="Filter branches by name, commit ID, or commit message..." class="filter-input">
|
||||
</div>
|
||||
<div class="control-bar" style="float: left;">
|
||||
<button id="toggle-show-all" class="toggle-button">Show All</button>
|
||||
</div>
|
||||
<div class="control-bar" style="float: right;">
|
||||
<button id="refresh-branches" class="refresh-button">Refresh Branches</button>
|
||||
</div>
|
||||
<div class="apply-section" style="float: right;">
|
||||
<button id="apply-changes" class="apply-button hidden">Apply Changes</button>
|
||||
</div>
|
||||
<div style="clear: both;"/>
|
||||
<div class="branches-list" id="branches-list">
|
||||
<p class="loading">Loading branches...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="jobs-section">
|
||||
<h2>Jobs</h2>
|
||||
<div id="jobs-list" class="jobs-list">
|
||||
<p class="loading">Loading jobs...</p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Generated
+2137
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "brencher-frontend",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"generate-types": "openapi-typescript ../openapi.yaml -o src/types/api.ts",
|
||||
"prebuild": "npm run generate-types",
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"openapi-typescript": "^7.4.4",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
/* Base */
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f8f9fa;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 960px;
|
||||
margin: 40px auto;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
header h1 {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
/* Status bar */
|
||||
.status-bar {
|
||||
background: #e9ecef;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.close-status-btn {
|
||||
margin-left: auto;
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
color: #555;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.close-status-btn:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/* Branches section header */
|
||||
.branches-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.branches-header h2 {
|
||||
margin: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.branches-controls-left {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.branches-controls-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.refresh-button,
|
||||
.apply-button,
|
||||
.toggle-button {
|
||||
background: #28a745;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
padding: 8px 16px;
|
||||
cursor: pointer;
|
||||
font-size: 0.95rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.refresh-button:hover,
|
||||
.apply-button:hover,
|
||||
.toggle-button:hover {
|
||||
background: #218838;
|
||||
}
|
||||
|
||||
/* Filter */
|
||||
.filter-input {
|
||||
flex: 1;
|
||||
min-width: 220px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 4px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.filter-input:focus {
|
||||
outline: none;
|
||||
border-color: #007bff;
|
||||
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
|
||||
}
|
||||
|
||||
/* Branches list */
|
||||
.branches-list {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
color: #888;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* Environment block */
|
||||
.env-block {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.env-title {
|
||||
margin: 0 0 8px;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
/* Branches table */
|
||||
.branches-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.branches-table th {
|
||||
background: #f8f9fa;
|
||||
padding: 10px 8px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
color: #495057;
|
||||
border-bottom: 2px solid #dee2e6;
|
||||
}
|
||||
|
||||
.branches-table td {
|
||||
padding: 10px 8px;
|
||||
vertical-align: middle;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.branch-row:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.branch-name {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.desired-commit {
|
||||
margin-right: 6px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.commit-input {
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9em;
|
||||
width: 200px;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
input[type='checkbox'] {
|
||||
margin: 0;
|
||||
transform: scale(1.2);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Jobs section */
|
||||
.jobs-section {
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
.jobs-section h2 {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.jobs-list {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.env-jobs {
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.env-jobs h4 {
|
||||
margin: 0 0 8px;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.job-item {
|
||||
margin-bottom: 8px;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 4px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.job-header {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.job-header:hover {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.job-spoiler pre {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 4px;
|
||||
padding: 8px 12px;
|
||||
overflow-x: auto;
|
||||
font-size: 0.85em;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.job-spoiler a {
|
||||
color: #007bff;
|
||||
word-break: break-all;
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import './App.css';
|
||||
import { BranchesList } from './components/BranchesList';
|
||||
import type { BranchItem, ColumnsByEnv, SelectedBranches } from './components/BranchesList';
|
||||
import { JobsList } from './components/JobsList';
|
||||
import { StatusBar } from './components/StatusBar';
|
||||
import { useWebSocket } from './hooks/useWebSocket';
|
||||
import type { BranchCommitPair, EnvironmentDto } from './types/index';
|
||||
|
||||
export function App() {
|
||||
const { sendMessage, lastBranchesMessage, lastEnvironmentsMessage, lastError, connectionStatus } =
|
||||
useWebSocket();
|
||||
|
||||
const [branches, setBranches] = useState<BranchItem[]>([]);
|
||||
const [environments, setEnvironments] = useState<EnvironmentDto[]>([]);
|
||||
const [selectedBranchesByEnv, setSelectedBranchesByEnv] = useState<SelectedBranches>({});
|
||||
const [serverSelectedBranchesByEnv, setServerSelectedBranchesByEnv] = useState<SelectedBranches>({});
|
||||
const [columnsByEnv, setColumnsByEnv] = useState<ColumnsByEnv>({});
|
||||
const [filterText, setFilterText] = useState('');
|
||||
const [showAll, setShowAll] = useState(false);
|
||||
const [statusMessage, setStatusMessage] = useState<string | null>('Loading branches...');
|
||||
const [isStatusError, setIsStatusError] = useState(false);
|
||||
|
||||
const showStatus = useCallback((message: string, isError = false) => {
|
||||
setStatusMessage(message);
|
||||
setIsStatusError(isError);
|
||||
}, []);
|
||||
|
||||
// Handle incoming branches
|
||||
useEffect(() => {
|
||||
if (!lastBranchesMessage) return;
|
||||
const data = lastBranchesMessage;
|
||||
setBranches(() => {
|
||||
const next: BranchItem[] = Object.entries(data).flatMap(([envId, branchMap]) =>
|
||||
Object.entries(branchMap).map(([branchName, commitList]) => ({
|
||||
envId,
|
||||
branch: branchName,
|
||||
commits: commitList,
|
||||
}))
|
||||
);
|
||||
// Replace all branches with the latest data from the server
|
||||
return next;
|
||||
});
|
||||
showStatus('Branches updated.');
|
||||
}, [lastBranchesMessage, showStatus]);
|
||||
|
||||
// Handle incoming environments
|
||||
useEffect(() => {
|
||||
if (!lastEnvironmentsMessage) return;
|
||||
const payload = lastEnvironmentsMessage;
|
||||
const envList = Object.values(payload);
|
||||
setEnvironments(envList);
|
||||
|
||||
setSelectedBranchesByEnv((prevSelected) => {
|
||||
// We need server state inline to check pending changes; use functional update
|
||||
let nextSelected = prevSelected;
|
||||
setServerSelectedBranchesByEnv((prevServer) => {
|
||||
// Check if changes are pending before overwriting selections
|
||||
const hasPending = Object.keys(prevSelected).some((envId) => {
|
||||
const localSel = [...(prevSelected[envId] ?? [])].sort((a, b) =>
|
||||
JSON.stringify(a).localeCompare(JSON.stringify(b))
|
||||
);
|
||||
const serverSel = [...(prevServer[envId] ?? [])].sort((a, b) =>
|
||||
JSON.stringify(a).localeCompare(JSON.stringify(b))
|
||||
);
|
||||
return JSON.stringify(localSel) !== JSON.stringify(serverSel);
|
||||
});
|
||||
|
||||
const nextServerState = { ...prevServer };
|
||||
const updatedSelected = { ...prevSelected };
|
||||
|
||||
envList.forEach((envObj) => {
|
||||
const envId = envObj.id;
|
||||
if (!hasPending) {
|
||||
if (Array.isArray(envObj.branches) && envObj.branches.length > 0) {
|
||||
const pairs: BranchCommitPair[] = Array.isArray(envObj.branches[0])
|
||||
? (envObj.branches as BranchCommitPair[])
|
||||
: envObj.branches.map((b) => [b as unknown as string, 'HEAD'] as BranchCommitPair);
|
||||
updatedSelected[envId] = [...pairs];
|
||||
nextServerState[envId] = [...pairs];
|
||||
} else if (!updatedSelected[envId]) {
|
||||
updatedSelected[envId] = [];
|
||||
nextServerState[envId] = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
nextSelected = updatedSelected;
|
||||
return nextServerState;
|
||||
});
|
||||
|
||||
return nextSelected;
|
||||
});
|
||||
|
||||
// Extract column data from pipeline steps
|
||||
setColumnsByEnv((prev) => {
|
||||
const next = { ...prev };
|
||||
envList.forEach((envObj) => {
|
||||
const envId = envObj.id;
|
||||
next[envId] = {};
|
||||
const jobsArr = envObj.pipeline ?? [];
|
||||
jobsArr.forEach((job) => {
|
||||
if (job.status == null || job.error) return;
|
||||
const status = job.status;
|
||||
if (
|
||||
typeof status === 'object' &&
|
||||
!Array.isArray(status) &&
|
||||
status !== null &&
|
||||
'columns' in status
|
||||
) {
|
||||
const cols = (status as Record<string, unknown>).columns;
|
||||
if (cols && typeof cols === 'object' && !Array.isArray(cols)) {
|
||||
Object.entries(cols as Record<string, unknown>).forEach(([colName, colData]) => {
|
||||
if (colData && typeof colData === 'object' && !Array.isArray(colData)) {
|
||||
next[envId][colName] = colData as Record<string, string>;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return next;
|
||||
});
|
||||
|
||||
showStatus('Environments updated.');
|
||||
}, [lastEnvironmentsMessage, showStatus]);
|
||||
|
||||
// Handle incoming errors
|
||||
useEffect(() => {
|
||||
if (!lastError) return;
|
||||
showStatus(lastError.message || 'Unknown error', true);
|
||||
}, [lastError, showStatus]);
|
||||
|
||||
// Show connection status changes
|
||||
useEffect(() => {
|
||||
if (connectionStatus === 'disconnected') {
|
||||
showStatus('Disconnected from server.', true);
|
||||
}
|
||||
}, [connectionStatus, showStatus]);
|
||||
|
||||
const isChangesPending = useMemo(() => {
|
||||
return Object.keys(selectedBranchesByEnv).some((envId) => {
|
||||
const localSel = [...(selectedBranchesByEnv[envId] ?? [])].sort((a, b) =>
|
||||
JSON.stringify(a).localeCompare(JSON.stringify(b))
|
||||
);
|
||||
const serverSel = [...(serverSelectedBranchesByEnv[envId] ?? [])].sort((a, b) =>
|
||||
JSON.stringify(a).localeCompare(JSON.stringify(b))
|
||||
);
|
||||
return JSON.stringify(localSel) !== JSON.stringify(serverSel);
|
||||
});
|
||||
}, [selectedBranchesByEnv, serverSelectedBranchesByEnv]);
|
||||
|
||||
const filteredBranches = useMemo(() => {
|
||||
const text = filterText.toLowerCase().trim();
|
||||
return branches.filter(({ envId, branch, commits }) => {
|
||||
const selList = selectedBranchesByEnv[envId] ?? [];
|
||||
const isSelected = selList.some(([b]) => b === branch);
|
||||
|
||||
const envCols = columnsByEnv[envId] ?? {};
|
||||
const isInColumns = Object.values(envCols).some((colData) => branch in colData);
|
||||
|
||||
if (showAll) return true;
|
||||
if (isSelected || isInColumns) return true;
|
||||
if (!text) return false;
|
||||
|
||||
if (branch.toLowerCase().includes(text)) return true;
|
||||
return commits.some((c) => {
|
||||
const shortHash = c.hexsha ? c.hexsha.substring(0, 8).toLowerCase() : '';
|
||||
return (
|
||||
c.hexsha?.toLowerCase().includes(text) ||
|
||||
shortHash.includes(text) ||
|
||||
c.message?.toLowerCase().includes(text) ||
|
||||
c.author?.toLowerCase().includes(text)
|
||||
);
|
||||
});
|
||||
});
|
||||
}, [branches, filterText, showAll, selectedBranchesByEnv, columnsByEnv]);
|
||||
|
||||
const handleSelectionChange = useCallback((envId: string, updated: BranchCommitPair[]) => {
|
||||
setSelectedBranchesByEnv((prev) => ({ ...prev, [envId]: updated }));
|
||||
}, []);
|
||||
|
||||
const handleApplyChanges = useCallback(() => {
|
||||
Object.keys(selectedBranchesByEnv).forEach((envId) => {
|
||||
const localSel = [...(selectedBranchesByEnv[envId] ?? [])].sort((a, b) =>
|
||||
JSON.stringify(a).localeCompare(JSON.stringify(b))
|
||||
);
|
||||
const serverSel = [...(serverSelectedBranchesByEnv[envId] ?? [])].sort((a, b) =>
|
||||
JSON.stringify(a).localeCompare(JSON.stringify(b))
|
||||
);
|
||||
if (JSON.stringify(localSel) !== JSON.stringify(serverSel)) {
|
||||
sendMessage({ update: { id: envId, branches: selectedBranchesByEnv[envId] } });
|
||||
setServerSelectedBranchesByEnv((prev) => ({
|
||||
...prev,
|
||||
[envId]: [...(selectedBranchesByEnv[envId] ?? [])],
|
||||
}));
|
||||
}
|
||||
});
|
||||
setFilterText('');
|
||||
showStatus('Changes applied (pending server confirmation).');
|
||||
}, [selectedBranchesByEnv, serverSelectedBranchesByEnv, sendMessage, showStatus]);
|
||||
|
||||
const handleRefresh = useCallback(() => {
|
||||
sendMessage({ update: { id: '' } });
|
||||
showStatus('Refreshing...');
|
||||
}, [sendMessage, showStatus]);
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<header>
|
||||
<h1>Brencher - Branch Merger</h1>
|
||||
<StatusBar
|
||||
message={statusMessage}
|
||||
isError={isStatusError}
|
||||
onClose={() => setStatusMessage(null)}
|
||||
/>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div className="branches-section">
|
||||
<div className="branches-header">
|
||||
<h2>Git Branches</h2>
|
||||
<div className="branches-controls-left">
|
||||
<input
|
||||
type="text"
|
||||
className="filter-input"
|
||||
placeholder="Filter branches by name, commit ID, or commit message..."
|
||||
value={filterText}
|
||||
onChange={(e) => setFilterText(e.target.value)}
|
||||
/>
|
||||
<button
|
||||
className="toggle-button"
|
||||
onClick={() => setShowAll((v) => !v)}
|
||||
>
|
||||
{showAll ? 'Show Filtered' : 'Show All'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="branches-controls-right">
|
||||
{isChangesPending && (
|
||||
<button className="apply-button" onClick={handleApplyChanges}>
|
||||
Apply Changes
|
||||
</button>
|
||||
)}
|
||||
<button className="refresh-button" onClick={handleRefresh}>
|
||||
Refresh Branches
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="branches-list">
|
||||
<BranchesList
|
||||
branches={filteredBranches}
|
||||
environments={environments}
|
||||
selectedBranchesByEnv={selectedBranchesByEnv}
|
||||
columnsByEnv={columnsByEnv}
|
||||
onSelectionChange={handleSelectionChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="jobs-section">
|
||||
<h2>Jobs</h2>
|
||||
<JobsList environments={environments} />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
import type { BranchCommitPair, CommitInfo, EnvironmentDto } from '../types/index';
|
||||
|
||||
export interface BranchItem {
|
||||
envId: string;
|
||||
branch: string;
|
||||
commits: CommitInfo[];
|
||||
}
|
||||
|
||||
export type SelectedBranches = Record<string, BranchCommitPair[]>;
|
||||
export type ColumnsByEnv = Record<string, Record<string, Record<string, string>>>;
|
||||
|
||||
interface BranchesListProps {
|
||||
branches: BranchItem[];
|
||||
environments: EnvironmentDto[];
|
||||
selectedBranchesByEnv: SelectedBranches;
|
||||
columnsByEnv: ColumnsByEnv;
|
||||
onSelectionChange: (envId: string, branches: BranchCommitPair[]) => void;
|
||||
}
|
||||
|
||||
function getCommitOptions(commits: CommitInfo[], desiredCommit: string): { value: string; label: string; selected: boolean }[] {
|
||||
const opts: { value: string; label: string; selected: boolean }[] = [];
|
||||
|
||||
if (commits.length > 0) {
|
||||
const head = commits[0];
|
||||
const headShort = head.hexsha ? head.hexsha.substring(0, 8) : '';
|
||||
const headAuthor = (head.author || '').substring(0, 25);
|
||||
const headMsg = head.message
|
||||
? head.message.substring(0, 50) + (head.message.length > 50 ? '...' : '')
|
||||
: '';
|
||||
opts.push({
|
||||
value: 'HEAD',
|
||||
label: `HEAD (${headShort} - ${headAuthor} - ${headMsg})`,
|
||||
selected: desiredCommit === 'HEAD',
|
||||
});
|
||||
for (const c of commits) {
|
||||
const full = c.hexsha;
|
||||
const shortHash = full ? full.substring(0, 8) : '';
|
||||
const author = (c.author || '').substring(0, 25);
|
||||
const msg = c.message
|
||||
? c.message.substring(0, 50) + (c.message.length > 50 ? '...' : '')
|
||||
: '';
|
||||
opts.push({
|
||||
value: full,
|
||||
label: `${shortHash} - ${author} - ${msg}`,
|
||||
selected: desiredCommit === full || desiredCommit === shortHash,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
opts.push({ value: 'HEAD', label: 'HEAD (no commits)', selected: desiredCommit === 'HEAD' });
|
||||
}
|
||||
|
||||
const hasMatch = commits.some(
|
||||
(c) => desiredCommit === c.hexsha || desiredCommit === c.hexsha?.substring(0, 8) || desiredCommit === 'HEAD'
|
||||
);
|
||||
const isCustom = desiredCommit && desiredCommit !== 'HEAD' && !hasMatch;
|
||||
opts.push({ value: 'custom', label: 'Custom Commit', selected: isCustom });
|
||||
return opts;
|
||||
}
|
||||
|
||||
function branchHasCommit(commits: CommitInfo[], commit: string): boolean {
|
||||
if (commit === 'HEAD') return true;
|
||||
return commits.some((c) => c.hexsha === commit || c.hexsha?.substring(0, 8) === commit);
|
||||
}
|
||||
|
||||
interface BranchRowProps {
|
||||
envId: string;
|
||||
branch: string;
|
||||
commits: CommitInfo[];
|
||||
selectedBranches: BranchCommitPair[];
|
||||
colNames: string[];
|
||||
colData: Record<string, Record<string, string>>;
|
||||
onSelectionChange: (branches: BranchCommitPair[]) => void;
|
||||
}
|
||||
|
||||
function BranchRow({ envId, branch, commits, selectedBranches, colNames, colData, onSelectionChange }: BranchRowProps) {
|
||||
const pair = selectedBranches.find(([b]) => b === branch);
|
||||
const isChecked = !!pair;
|
||||
const desiredCommit = pair ? pair[1] : 'HEAD';
|
||||
const isCustom = desiredCommit !== 'HEAD' && !branchHasCommit(commits, desiredCommit);
|
||||
|
||||
const updateCommit = (commit: string) => {
|
||||
const updated = selectedBranches.map(([b, c]) => (b === branch ? [b, commit] as BranchCommitPair : [b, c] as BranchCommitPair));
|
||||
onSelectionChange(updated);
|
||||
};
|
||||
|
||||
const handleCheckbox = (checked: boolean) => {
|
||||
if (checked) {
|
||||
if (!selectedBranches.some(([b]) => b === branch)) {
|
||||
onSelectionChange([...selectedBranches, [branch, 'HEAD']]);
|
||||
}
|
||||
} else {
|
||||
onSelectionChange(selectedBranches.filter(([b]) => b !== branch));
|
||||
}
|
||||
};
|
||||
|
||||
const handleDropdownChange = (value: string) => {
|
||||
if (value === 'custom') {
|
||||
// show text input - handled via isCustom state derived from desiredCommit
|
||||
updateCommit('');
|
||||
} else if (value === 'HEAD') {
|
||||
updateCommit('HEAD');
|
||||
} else {
|
||||
updateCommit(value);
|
||||
}
|
||||
};
|
||||
|
||||
const dropdownValue = isCustom ? 'custom' : desiredCommit;
|
||||
const options = getCommitOptions(commits, desiredCommit);
|
||||
|
||||
return (
|
||||
<tr className="branch-row" data-env={envId} data-branch={branch}>
|
||||
<td>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={isChecked}
|
||||
onChange={(e) => handleCheckbox(e.target.checked)}
|
||||
/>
|
||||
</td>
|
||||
<td className="branch-name">{branch}</td>
|
||||
<td>
|
||||
<select
|
||||
className="desired-commit"
|
||||
value={dropdownValue}
|
||||
onChange={(e) => handleDropdownChange(e.target.value)}
|
||||
>
|
||||
{options.map((opt) => (
|
||||
<option key={opt.value} value={opt.value}>{opt.label}</option>
|
||||
))}
|
||||
</select>
|
||||
{isCustom && (
|
||||
<input
|
||||
type="text"
|
||||
className="commit-input"
|
||||
value={desiredCommit}
|
||||
placeholder="Enter commit ID"
|
||||
onChange={(e) => updateCommit(e.target.value)}
|
||||
onBlur={(e) => {
|
||||
const val = e.target.value.trim();
|
||||
updateCommit(val || 'HEAD');
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
{colNames.map((colName) => (
|
||||
<td key={colName}>{colData[colName]?.[branch] ?? ''}</td>
|
||||
))}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
export function BranchesList({
|
||||
branches,
|
||||
environments: _environments,
|
||||
selectedBranchesByEnv,
|
||||
columnsByEnv,
|
||||
onSelectionChange,
|
||||
}: BranchesListProps) {
|
||||
if (branches.length === 0) {
|
||||
return <p className="loading">No branches found.</p>;
|
||||
}
|
||||
|
||||
// Group branches by envId
|
||||
const groups = branches.reduce<Record<string, BranchItem[]>>((acc, b) => {
|
||||
acc[b.envId] = acc[b.envId] ?? [];
|
||||
acc[b.envId].push(b);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return (
|
||||
<>
|
||||
{Object.entries(groups).map(([envId, rows]) => {
|
||||
const envCols = columnsByEnv[envId] ?? {};
|
||||
const colNames = Object.keys(envCols);
|
||||
const selectedBranches = selectedBranchesByEnv[envId] ?? [];
|
||||
|
||||
return (
|
||||
<div key={envId} className="env-block">
|
||||
<h3 className="env-title">Environment: {envId}</h3>
|
||||
<table className="branches-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Deploy</th>
|
||||
<th>Branch</th>
|
||||
<th>Desired Commit</th>
|
||||
{colNames.map((n) => <th key={n}>{n}</th>)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map(({ branch, commits }) => (
|
||||
<BranchRow
|
||||
key={`${envId}-${branch}`}
|
||||
envId={envId}
|
||||
branch={branch}
|
||||
commits={commits}
|
||||
selectedBranches={selectedBranches}
|
||||
colNames={colNames}
|
||||
colData={envCols}
|
||||
onSelectionChange={(updated) => onSelectionChange(envId, updated)}
|
||||
/>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
import { useRef, useState } from 'react';
|
||||
import type { EnvironmentDto, PipelineStep } from '../types/index';
|
||||
|
||||
interface JobsListProps {
|
||||
environments: EnvironmentDto[];
|
||||
}
|
||||
|
||||
function extractUserLinks(obj: unknown): [string, string][] {
|
||||
if (!obj || typeof obj !== 'object') return [];
|
||||
const result: [string, string][] = [];
|
||||
const rec = obj as Record<string, unknown>;
|
||||
if (rec.userLinks && typeof rec.userLinks === 'object' && !Array.isArray(rec.userLinks)) {
|
||||
const links = rec.userLinks as Record<string, unknown>;
|
||||
for (const [title, url] of Object.entries(links)) {
|
||||
if (typeof url === 'string') result.push([title, url]);
|
||||
}
|
||||
}
|
||||
for (const key of Object.keys(rec)) {
|
||||
if (typeof rec[key] === 'object') {
|
||||
result.push(...extractUserLinks(rec[key]));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function escapeHtml(text: string): string {
|
||||
return text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function isValidHttpUrl(url: string): boolean {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function linkifyText(text: string): string {
|
||||
const escaped = escapeHtml(text);
|
||||
return escaped.replace(
|
||||
/(https?:\/\/[^\s&"'<>]+)/g,
|
||||
(url) => {
|
||||
// Decode HTML entities that may have been escaped (e.g. & → &)
|
||||
const rawUrl = url.replace(/&/g, '&');
|
||||
if (!isValidHttpUrl(rawUrl)) return url;
|
||||
const safeHref = escapeHtml(rawUrl);
|
||||
return `<a href="${safeHref}" target="_blank" rel="noopener noreferrer">${url}</a>`;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
interface JobItemProps {
|
||||
envId: string;
|
||||
job: PipelineStep;
|
||||
defaultOpen: boolean;
|
||||
}
|
||||
|
||||
function JobItem({ envId, job, defaultOpen }: JobItemProps) {
|
||||
const [open, setOpen] = useState(defaultOpen);
|
||||
const initialOpenRef = useRef(defaultOpen);
|
||||
|
||||
// Keep error jobs open by default (tracked via ref so it doesn't reset on re-render)
|
||||
const isOpen = job.error ? (initialOpenRef.current ? true : open) : open;
|
||||
|
||||
const statusJson = JSON.stringify(job.status, null, 2);
|
||||
const statusHtml = linkifyText(statusJson);
|
||||
|
||||
return (
|
||||
<div className="job-item">
|
||||
<div
|
||||
className="job-header"
|
||||
style={{ cursor: 'pointer', fontWeight: 'bold' }}
|
||||
onClick={() => setOpen((o) => !o)}
|
||||
>
|
||||
{job.error ? (
|
||||
<span style={{ color: '#dc3545', fontWeight: 'bold', marginRight: 6 }} title="Error">!</span>
|
||||
) : (
|
||||
<span style={{ color: '#28a745', fontWeight: 'bold', marginRight: 6 }} title="OK">✔</span>
|
||||
)}
|
||||
{envId} - {job.name}
|
||||
</div>
|
||||
{isOpen && (
|
||||
<div className="job-spoiler" style={{ marginTop: 8 }}>
|
||||
<pre dangerouslySetInnerHTML={{ __html: statusHtml }} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function JobsList({ environments }: JobsListProps) {
|
||||
if (environments.length === 0) {
|
||||
return (
|
||||
<div className="jobs-list">
|
||||
<p className="loading">No jobs found.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="jobs-list">
|
||||
{environments.map((envObj) => {
|
||||
const jobsArr = envObj.pipeline ?? [];
|
||||
|
||||
const allLinks: [string, string][] = jobsArr.flatMap((job) =>
|
||||
extractUserLinks(job.status)
|
||||
);
|
||||
|
||||
return (
|
||||
<div key={envObj.id} className="env-jobs">
|
||||
<h4>Environment: {envObj.id}</h4>
|
||||
{allLinks.length > 0 && (
|
||||
<div style={{ float: 'right' }}>
|
||||
{allLinks.map(([title, url], i) => (
|
||||
<span key={i}>
|
||||
{i > 0 && ' | '}
|
||||
<a href={url} target="_blank" rel="noopener noreferrer">{title}</a>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{jobsArr.length > 0 ? (
|
||||
jobsArr.map((job, idx) => (
|
||||
<JobItem
|
||||
key={`${envObj.id}::${job.name}::${idx}`}
|
||||
envId={envObj.id}
|
||||
job={job}
|
||||
defaultOpen={job.error === true}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<div className="job-item">No jobs found.</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
interface StatusBarProps {
|
||||
message: string | null;
|
||||
isError?: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function StatusBar({ message, isError = false, onClose }: StatusBarProps) {
|
||||
if (message === null) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="status-bar"
|
||||
style={{ background: isError ? '#f8d7da' : '#e9ecef' }}
|
||||
>
|
||||
<span style={{ color: isError ? '#721c24' : '#333' }}>{message}</span>
|
||||
<button className="close-status-btn" onClick={onClose}>×</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import type { BranchesData, EnvironmentsData, WsOutgoingMessage } from '../types/index';
|
||||
|
||||
export type ConnectionStatus = 'connecting' | 'connected' | 'disconnected';
|
||||
|
||||
export interface UseWebSocketReturn {
|
||||
sendMessage: (msg: WsOutgoingMessage) => void;
|
||||
lastBranchesMessage: BranchesData | null;
|
||||
lastEnvironmentsMessage: EnvironmentsData | null;
|
||||
lastError: { message: string } | null;
|
||||
connectionStatus: ConnectionStatus;
|
||||
}
|
||||
|
||||
export function useWebSocket(): UseWebSocketReturn {
|
||||
const wsRef = useRef<WebSocket | null>(null);
|
||||
const reconnectTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
const [lastBranchesMessage, setLastBranchesMessage] = useState<BranchesData | null>(null);
|
||||
const [lastEnvironmentsMessage, setLastEnvironmentsMessage] = useState<EnvironmentsData | null>(null);
|
||||
const [lastError, setLastError] = useState<{ message: string } | null>(null);
|
||||
const [connectionStatus, setConnectionStatus] = useState<ConnectionStatus>('connecting');
|
||||
|
||||
const connect = useCallback(() => {
|
||||
if (wsRef.current && wsRef.current.readyState !== WebSocket.CLOSED) {
|
||||
wsRef.current.onclose = null;
|
||||
wsRef.current.close();
|
||||
}
|
||||
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const host = window.location.host;
|
||||
const ws = new WebSocket(`${protocol}//${host}/ws`);
|
||||
wsRef.current = ws;
|
||||
setConnectionStatus('connecting');
|
||||
|
||||
ws.onopen = () => {
|
||||
setConnectionStatus('connected');
|
||||
};
|
||||
|
||||
ws.onmessage = (event: MessageEvent) => {
|
||||
try {
|
||||
const message: unknown = JSON.parse(event.data as string);
|
||||
if (message && typeof message === 'object') {
|
||||
const msg = message as Record<string, unknown>;
|
||||
if ('branches' in msg) {
|
||||
setLastBranchesMessage(msg.branches as BranchesData);
|
||||
} else if ('environments' in msg) {
|
||||
setLastEnvironmentsMessage(msg.environments as EnvironmentsData);
|
||||
} else if ('error' in msg) {
|
||||
setLastError(msg.error as { message: string });
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error processing WebSocket message:', e);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
setConnectionStatus('disconnected');
|
||||
reconnectTimerRef.current = setTimeout(() => connect(), 5000);
|
||||
};
|
||||
|
||||
ws.onerror = (error) => {
|
||||
console.error('WebSocket error:', error);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
connect();
|
||||
return () => {
|
||||
if (reconnectTimerRef.current) clearTimeout(reconnectTimerRef.current);
|
||||
if (wsRef.current) {
|
||||
wsRef.current.onclose = null;
|
||||
wsRef.current.close();
|
||||
}
|
||||
};
|
||||
}, [connect]);
|
||||
|
||||
const sendMessage = useCallback((msg: WsOutgoingMessage) => {
|
||||
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
||||
wsRef.current.send(JSON.stringify(msg));
|
||||
}
|
||||
}, []);
|
||||
|
||||
return { sendMessage, lastBranchesMessage, lastEnvironmentsMessage, lastError, connectionStatus };
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { StrictMode } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { App } from './App';
|
||||
|
||||
const rootEl = document.getElementById('root');
|
||||
if (!rootEl) throw new Error('Root element not found');
|
||||
|
||||
createRoot(rootEl).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>
|
||||
);
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* This file was auto-generated by openapi-typescript.
|
||||
* Do not make direct changes to the file.
|
||||
*/
|
||||
|
||||
export interface paths {
|
||||
"/state": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
/** Get current environment state */
|
||||
get: operations["getState"];
|
||||
put?: never;
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/branches": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
/** Get branches for all environments */
|
||||
get: operations["getBranches"];
|
||||
put?: never;
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
}
|
||||
export type webhooks = Record<string, never>;
|
||||
export interface components {
|
||||
schemas: {
|
||||
CommitInfo: {
|
||||
/** @description Full commit SHA */
|
||||
hexsha: string;
|
||||
/** @description Commit author name */
|
||||
author: string;
|
||||
/** @description Commit message */
|
||||
message: string;
|
||||
};
|
||||
/** @description Tuple of [branchName, commitHash] */
|
||||
BranchCommitPair: string[];
|
||||
PipelineStep: {
|
||||
/** @description Step name */
|
||||
name: string;
|
||||
/** @description Step status (any shape) */
|
||||
status: unknown;
|
||||
/** @description Whether this step has an error */
|
||||
error?: boolean;
|
||||
};
|
||||
EnvironmentDto: {
|
||||
/** @description Environment identifier */
|
||||
id: string;
|
||||
/** @description Array of [branchName, commitHash] pairs */
|
||||
branches: components["schemas"]["BranchCommitPair"][];
|
||||
/** @description Whether this is a dry-run environment */
|
||||
dry: boolean;
|
||||
/** @description Repository path or URL */
|
||||
repo: string;
|
||||
/** @description Pipeline steps with their statuses */
|
||||
pipeline: components["schemas"]["PipelineStep"][];
|
||||
};
|
||||
WsIncomingMessage: {
|
||||
branches?: components["schemas"]["BranchesData"];
|
||||
environments?: components["schemas"]["EnvironmentsData"];
|
||||
error?: {
|
||||
message?: string;
|
||||
};
|
||||
};
|
||||
WsUpdatePayload: {
|
||||
/** @description Environment ID (empty string to trigger refresh) */
|
||||
id: string;
|
||||
branches?: components["schemas"]["BranchCommitPair"][];
|
||||
};
|
||||
WsOutgoingMessage: {
|
||||
update: components["schemas"]["WsUpdatePayload"];
|
||||
};
|
||||
/** @description Dict[envId, Dict[branchName, CommitInfo[]]] */
|
||||
BranchesData: {
|
||||
[key: string]: {
|
||||
[key: string]: components["schemas"]["CommitInfo"][];
|
||||
};
|
||||
};
|
||||
/** @description Dict[envId, EnvironmentDto] */
|
||||
EnvironmentsData: {
|
||||
[key: string]: components["schemas"]["EnvironmentDto"];
|
||||
};
|
||||
StateResponse: components["schemas"]["EnvironmentsData"];
|
||||
BranchesResponse: components["schemas"]["BranchesData"];
|
||||
};
|
||||
responses: never;
|
||||
parameters: never;
|
||||
requestBodies: never;
|
||||
headers: never;
|
||||
pathItems: never;
|
||||
}
|
||||
export type $defs = Record<string, never>;
|
||||
export interface operations {
|
||||
getState: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description Current state of all environments */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["StateResponse"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
getBranches: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description Branches grouped by environment and branch name */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["BranchesResponse"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { components } from './api';
|
||||
|
||||
export type CommitInfo = components['schemas']['CommitInfo'];
|
||||
export type BranchCommitPair = [string, string];
|
||||
export type PipelineStep = components['schemas']['PipelineStep'];
|
||||
export type EnvironmentDto = components['schemas']['EnvironmentDto'];
|
||||
export type BranchesData = components['schemas']['BranchesData'];
|
||||
export type EnvironmentsData = components['schemas']['EnvironmentsData'];
|
||||
export type WsIncomingMessage = components['schemas']['WsIncomingMessage'];
|
||||
export type WsUpdatePayload = components['schemas']['WsUpdatePayload'];
|
||||
export type WsOutgoingMessage = components['schemas']['WsOutgoingMessage'];
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
const backendUrl = process.env.VITE_BACKEND_URL ?? 'http://localhost:5001';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: true,
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/ws': {
|
||||
target: backendUrl,
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api': {
|
||||
target: backendUrl,
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
openapi: 3.1.0
|
||||
info:
|
||||
title: Brencher API
|
||||
version: 1.0.0
|
||||
description: |
|
||||
Brencher branch merger API.
|
||||
|
||||
## WebSocket /ws
|
||||
|
||||
Connect to `/ws` for real-time updates.
|
||||
|
||||
### Incoming messages (server → client)
|
||||
|
||||
**Branches update:**
|
||||
```json
|
||||
{ "branches": { "<envId>": { "<branchName>": [CommitInfo, ...] } } }
|
||||
```
|
||||
|
||||
**Environments update:**
|
||||
```json
|
||||
{ "environments": { "<envId>": EnvironmentDto } }
|
||||
```
|
||||
|
||||
**Error:**
|
||||
```json
|
||||
{ "error": { "message": "string" } }
|
||||
```
|
||||
|
||||
### Outgoing messages (client → server)
|
||||
|
||||
**Update environment branches:**
|
||||
```json
|
||||
{ "update": { "id": "<envId>", "branches": [["<branchName>", "<commitHash>"], ...] } }
|
||||
```
|
||||
|
||||
**Refresh (send empty id to trigger refresh):**
|
||||
```json
|
||||
{ "update": { "id": "" } }
|
||||
```
|
||||
|
||||
paths:
|
||||
/state:
|
||||
get:
|
||||
operationId: getState
|
||||
summary: Get current environment state
|
||||
responses:
|
||||
"200":
|
||||
description: Current state of all environments
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/StateResponse"
|
||||
|
||||
/branches:
|
||||
get:
|
||||
operationId: getBranches
|
||||
summary: Get branches for all environments
|
||||
responses:
|
||||
"200":
|
||||
description: Branches grouped by environment and branch name
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/BranchesResponse"
|
||||
|
||||
components:
|
||||
schemas:
|
||||
CommitInfo:
|
||||
type: object
|
||||
required:
|
||||
- hexsha
|
||||
- author
|
||||
- message
|
||||
properties:
|
||||
hexsha:
|
||||
type: string
|
||||
description: Full commit SHA
|
||||
author:
|
||||
type: string
|
||||
description: Commit author name
|
||||
message:
|
||||
type: string
|
||||
description: Commit message
|
||||
|
||||
BranchCommitPair:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
minItems: 2
|
||||
maxItems: 2
|
||||
description: Tuple of [branchName, commitHash]
|
||||
|
||||
PipelineStep:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- status
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Step name
|
||||
status:
|
||||
description: Step status (any shape)
|
||||
error:
|
||||
type: boolean
|
||||
description: Whether this step has an error
|
||||
|
||||
EnvironmentDto:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- branches
|
||||
- dry
|
||||
- repo
|
||||
- pipeline
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Environment identifier
|
||||
branches:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/BranchCommitPair"
|
||||
description: Array of [branchName, commitHash] pairs
|
||||
dry:
|
||||
type: boolean
|
||||
description: Whether this is a dry-run environment
|
||||
repo:
|
||||
type: string
|
||||
description: Repository path or URL
|
||||
pipeline:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PipelineStep"
|
||||
description: Pipeline steps with their statuses
|
||||
|
||||
WsIncomingMessage:
|
||||
type: object
|
||||
properties:
|
||||
branches:
|
||||
$ref: "#/components/schemas/BranchesData"
|
||||
environments:
|
||||
$ref: "#/components/schemas/EnvironmentsData"
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
|
||||
WsUpdatePayload:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: Environment ID (empty string to trigger refresh)
|
||||
branches:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/BranchCommitPair"
|
||||
|
||||
WsOutgoingMessage:
|
||||
type: object
|
||||
required:
|
||||
- update
|
||||
properties:
|
||||
update:
|
||||
$ref: "#/components/schemas/WsUpdatePayload"
|
||||
|
||||
BranchesData:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/CommitInfo"
|
||||
description: "Dict[envId, Dict[branchName, CommitInfo[]]]"
|
||||
|
||||
EnvironmentsData:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: "#/components/schemas/EnvironmentDto"
|
||||
description: "Dict[envId, EnvironmentDto]"
|
||||
|
||||
StateResponse:
|
||||
$ref: "#/components/schemas/EnvironmentsData"
|
||||
|
||||
BranchesResponse:
|
||||
$ref: "#/components/schemas/BranchesData"
|
||||
Reference in New Issue
Block a user