Fix httpx.Timeout configuration in PyPI proxy
This commit is contained in:
1117
frontend/package-lock.json
generated
1117
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -12,9 +12,12 @@
|
||||
"test:coverage": "vitest run --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/dagre": "^0.7.53",
|
||||
"dagre": "^0.8.5",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "6.28.0"
|
||||
"react-router-dom": "6.28.0",
|
||||
"reactflow": "^11.11.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^6.4.2",
|
||||
@@ -34,6 +37,15 @@
|
||||
"ufo": "1.5.4",
|
||||
"rollup": "4.52.4",
|
||||
"caniuse-lite": "1.0.30001692",
|
||||
"baseline-browser-mapping": "2.9.5"
|
||||
"baseline-browser-mapping": "2.9.5",
|
||||
"lodash": "4.17.21",
|
||||
"electron-to-chromium": "1.5.72",
|
||||
"@babel/core": "7.26.0",
|
||||
"@babel/traverse": "7.26.4",
|
||||
"@babel/types": "7.26.3",
|
||||
"@babel/compat-data": "7.26.3",
|
||||
"@babel/parser": "7.26.3",
|
||||
"@babel/generator": "7.26.3",
|
||||
"@babel/code-frame": "7.26.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import {
|
||||
Project,
|
||||
Package,
|
||||
Tag,
|
||||
TagDetail,
|
||||
Artifact,
|
||||
ArtifactDetail,
|
||||
PackageArtifact,
|
||||
UploadResponse,
|
||||
PaginatedResponse,
|
||||
ListParams,
|
||||
TagListParams,
|
||||
PackageListParams,
|
||||
ArtifactListParams,
|
||||
ProjectListParams,
|
||||
@@ -78,7 +75,13 @@ export class ForbiddenError extends ApiError {
|
||||
async function handleResponse<T>(response: Response): Promise<T> {
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ detail: 'Unknown error' }));
|
||||
const message = error.detail || `HTTP ${response.status}`;
|
||||
// Handle detail as string or object (backend may return structured errors)
|
||||
let message: string;
|
||||
if (typeof error.detail === 'object') {
|
||||
message = JSON.stringify(error.detail);
|
||||
} else {
|
||||
message = error.detail || `HTTP ${response.status}`;
|
||||
}
|
||||
|
||||
if (response.status === 401) {
|
||||
throw new UnauthorizedError(message);
|
||||
@@ -234,32 +237,6 @@ export async function createPackage(projectName: string, data: { name: string; d
|
||||
return handleResponse<Package>(response);
|
||||
}
|
||||
|
||||
// Tag API
|
||||
export async function listTags(projectName: string, packageName: string, params: TagListParams = {}): Promise<PaginatedResponse<TagDetail>> {
|
||||
const query = buildQueryString(params as Record<string, unknown>);
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/tags${query}`);
|
||||
return handleResponse<PaginatedResponse<TagDetail>>(response);
|
||||
}
|
||||
|
||||
export async function listTagsSimple(projectName: string, packageName: string, params: TagListParams = {}): Promise<TagDetail[]> {
|
||||
const data = await listTags(projectName, packageName, params);
|
||||
return data.items;
|
||||
}
|
||||
|
||||
export async function getTag(projectName: string, packageName: string, tagName: string): Promise<TagDetail> {
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/tags/${tagName}`);
|
||||
return handleResponse<TagDetail>(response);
|
||||
}
|
||||
|
||||
export async function createTag(projectName: string, packageName: string, data: { name: string; artifact_id: string }): Promise<Tag> {
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/tags`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return handleResponse<Tag>(response);
|
||||
}
|
||||
|
||||
// Artifact API
|
||||
export async function getArtifact(artifactId: string): Promise<ArtifactDetail> {
|
||||
const response = await fetch(`${API_BASE}/artifact/${artifactId}`);
|
||||
@@ -270,10 +247,10 @@ export async function listPackageArtifacts(
|
||||
projectName: string,
|
||||
packageName: string,
|
||||
params: ArtifactListParams = {}
|
||||
): Promise<PaginatedResponse<Artifact & { tags: string[] }>> {
|
||||
): Promise<PaginatedResponse<PackageArtifact>> {
|
||||
const query = buildQueryString(params as Record<string, unknown>);
|
||||
const response = await fetch(`${API_BASE}/project/${projectName}/${packageName}/artifacts${query}`);
|
||||
return handleResponse<PaginatedResponse<Artifact & { tags: string[] }>>(response);
|
||||
return handleResponse<PaginatedResponse<PackageArtifact>>(response);
|
||||
}
|
||||
|
||||
// Upload
|
||||
@@ -281,14 +258,10 @@ export async function uploadArtifact(
|
||||
projectName: string,
|
||||
packageName: string,
|
||||
file: File,
|
||||
tag?: string,
|
||||
version?: string
|
||||
): Promise<UploadResponse> {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
if (tag) {
|
||||
formData.append('tag', tag);
|
||||
}
|
||||
if (version) {
|
||||
formData.append('version', version);
|
||||
}
|
||||
@@ -746,3 +719,4 @@ export async function testUpstreamSource(id: string): Promise<UpstreamSourceTest
|
||||
});
|
||||
return handleResponse<UpstreamSourceTestResult>(response);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,10 @@
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.missing-count {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
@@ -72,171 +76,115 @@
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.dependency-graph-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 20px;
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.zoom-level {
|
||||
margin-left: auto;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-muted);
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
}
|
||||
|
||||
.dependency-graph-container {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background:
|
||||
linear-gradient(90deg, var(--border-primary) 1px, transparent 1px),
|
||||
linear-gradient(var(--border-primary) 1px, transparent 1px);
|
||||
background-size: 20px 20px;
|
||||
background-position: center center;
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
.graph-canvas {
|
||||
padding: 40px;
|
||||
min-width: 100%;
|
||||
min-height: 100%;
|
||||
transform-origin: center center;
|
||||
transition: transform 0.1s ease-out;
|
||||
/* React Flow Customization */
|
||||
.react-flow__background {
|
||||
background-color: var(--bg-primary) !important;
|
||||
}
|
||||
|
||||
/* Graph Nodes */
|
||||
.graph-node-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
.react-flow__controls {
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.graph-node {
|
||||
.react-flow__controls-button {
|
||||
background: var(--bg-tertiary);
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
color: var(--text-secondary);
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.react-flow__controls-button:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.react-flow__controls-button:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.react-flow__controls-button svg {
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.react-flow__attribution {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.react-flow__attribution a {
|
||||
color: var(--text-muted) !important;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
/* Custom Flow Nodes */
|
||||
.flow-node {
|
||||
background: var(--bg-tertiary);
|
||||
border: 2px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 12px 16px;
|
||||
min-width: 200px;
|
||||
min-width: 160px;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition-fast);
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.graph-node:hover {
|
||||
.flow-node:hover {
|
||||
border-color: var(--accent-primary);
|
||||
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
|
||||
}
|
||||
|
||||
.graph-node--root {
|
||||
.flow-node--root {
|
||||
background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.15) 100%);
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.graph-node--hovered {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.graph-node__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.graph-node__name {
|
||||
.flow-node__name {
|
||||
font-weight: 600;
|
||||
color: var(--accent-primary);
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-size: 0.875rem;
|
||||
font-size: 0.8125rem;
|
||||
margin-bottom: 4px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.graph-node__toggle {
|
||||
background: var(--bg-hover);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: 4px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
.flow-node__details {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary);
|
||||
font-weight: 600;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.graph-node__toggle:hover {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.graph-node__details {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
font-size: 0.75rem;
|
||||
gap: 8px;
|
||||
font-size: 0.6875rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.graph-node__version {
|
||||
.flow-node__version {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.graph-node__size {
|
||||
.flow-node__size {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Graph Children / Tree Structure */
|
||||
.graph-children {
|
||||
display: flex;
|
||||
padding-left: 24px;
|
||||
margin-top: 8px;
|
||||
position: relative;
|
||||
/* Flow Handles (connection points) */
|
||||
.flow-handle {
|
||||
width: 8px !important;
|
||||
height: 8px !important;
|
||||
background: var(--border-primary) !important;
|
||||
border: 2px solid var(--bg-tertiary) !important;
|
||||
}
|
||||
|
||||
.graph-connector {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
top: 0;
|
||||
bottom: 50%;
|
||||
width: 12px;
|
||||
border-left: 2px solid var(--border-primary);
|
||||
border-bottom: 2px solid var(--border-primary);
|
||||
border-bottom-left-radius: 8px;
|
||||
}
|
||||
|
||||
.graph-children-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.graph-children-list::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -12px;
|
||||
top: 20px;
|
||||
bottom: 20px;
|
||||
border-left: 2px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.graph-children-list > .graph-node-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.graph-children-list > .graph-node-container::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -12px;
|
||||
top: 20px;
|
||||
width: 12px;
|
||||
border-top: 2px solid var(--border-primary);
|
||||
.flow-node:hover .flow-handle {
|
||||
background: var(--accent-primary) !important;
|
||||
}
|
||||
|
||||
/* Loading, Error, Empty States */
|
||||
@@ -279,39 +227,76 @@
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* Tooltip */
|
||||
.graph-tooltip {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 12px 16px;
|
||||
font-size: 0.8125rem;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
|
||||
z-index: 1001;
|
||||
.graph-warning {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
background: rgba(245, 158, 11, 0.1);
|
||||
border-top: 1px solid rgba(245, 158, 11, 0.3);
|
||||
color: var(--warning-color, #f59e0b);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.graph-tooltip strong {
|
||||
display: block;
|
||||
color: var(--accent-primary);
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
margin-bottom: 4px;
|
||||
.graph-warning svg {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.graph-tooltip div {
|
||||
color: var(--text-secondary);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.tooltip-hint {
|
||||
margin-top: 8px;
|
||||
padding-top: 8px;
|
||||
/* Missing Dependencies */
|
||||
.missing-dependencies {
|
||||
border-top: 1px solid var(--border-primary);
|
||||
color: var(--text-muted);
|
||||
padding: 16px 20px;
|
||||
background: rgba(245, 158, 11, 0.05);
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.missing-dependencies h3 {
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.missing-hint {
|
||||
margin: 0 0 12px 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.missing-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.missing-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid rgba(245, 158, 11, 0.3);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 4px 8px;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.missing-name {
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.missing-constraint {
|
||||
color: var(--text-muted);
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
}
|
||||
|
||||
.missing-required-by {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.6875rem;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import ReactFlow, {
|
||||
Node,
|
||||
Edge,
|
||||
Controls,
|
||||
Background,
|
||||
useNodesState,
|
||||
useEdgesState,
|
||||
MarkerType,
|
||||
NodeProps,
|
||||
Handle,
|
||||
Position,
|
||||
} from 'reactflow';
|
||||
import dagre from 'dagre';
|
||||
import 'reactflow/dist/style.css';
|
||||
import { ResolvedArtifact, DependencyResolutionResponse, Dependency } from '../types';
|
||||
import { resolveDependencies, getArtifactDependencies } from '../api';
|
||||
import './DependencyGraph.css';
|
||||
@@ -11,15 +25,14 @@ interface DependencyGraphProps {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface GraphNode {
|
||||
id: string;
|
||||
interface NodeData {
|
||||
label: string;
|
||||
project: string;
|
||||
package: string;
|
||||
version: string | null;
|
||||
size: number;
|
||||
depth: number;
|
||||
children: GraphNode[];
|
||||
isRoot?: boolean;
|
||||
isRoot: boolean;
|
||||
onNavigate: (project: string, pkg: string) => void;
|
||||
}
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
@@ -30,84 +43,185 @@ function formatBytes(bytes: number): string {
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
// Custom node component
|
||||
function DependencyNode({ data }: NodeProps<NodeData>) {
|
||||
return (
|
||||
<div
|
||||
className={`flow-node ${data.isRoot ? 'flow-node--root' : ''}`}
|
||||
onClick={() => data.onNavigate(data.project, data.package)}
|
||||
>
|
||||
<Handle type="target" position={Position.Top} className="flow-handle" />
|
||||
<div className="flow-node__name">{data.package}</div>
|
||||
<div className="flow-node__details">
|
||||
{data.version && <span className="flow-node__version">{data.version}</span>}
|
||||
<span className="flow-node__size">{formatBytes(data.size)}</span>
|
||||
</div>
|
||||
<Handle type="source" position={Position.Bottom} className="flow-handle" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const nodeTypes = { dependency: DependencyNode };
|
||||
|
||||
// Dagre layout function
|
||||
function getLayoutedElements(
|
||||
nodes: Node<NodeData>[],
|
||||
edges: Edge[],
|
||||
direction: 'TB' | 'LR' = 'TB'
|
||||
) {
|
||||
const dagreGraph = new dagre.graphlib.Graph();
|
||||
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
||||
|
||||
const nodeWidth = 180;
|
||||
const nodeHeight = 60;
|
||||
|
||||
dagreGraph.setGraph({ rankdir: direction, nodesep: 50, ranksep: 80 });
|
||||
|
||||
nodes.forEach((node) => {
|
||||
dagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });
|
||||
});
|
||||
|
||||
edges.forEach((edge) => {
|
||||
dagreGraph.setEdge(edge.source, edge.target);
|
||||
});
|
||||
|
||||
dagre.layout(dagreGraph);
|
||||
|
||||
const layoutedNodes = nodes.map((node) => {
|
||||
const nodeWithPosition = dagreGraph.node(node.id);
|
||||
return {
|
||||
...node,
|
||||
position: {
|
||||
x: nodeWithPosition.x - nodeWidth / 2,
|
||||
y: nodeWithPosition.y - nodeHeight / 2,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
return { nodes: layoutedNodes, edges };
|
||||
}
|
||||
|
||||
function DependencyGraph({ projectName, packageName, tagName, onClose }: DependencyGraphProps) {
|
||||
const navigate = useNavigate();
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [warning, setWarning] = useState<string | null>(null);
|
||||
const [resolution, setResolution] = useState<DependencyResolutionResponse | null>(null);
|
||||
const [graphRoot, setGraphRoot] = useState<GraphNode | null>(null);
|
||||
const [hoveredNode, setHoveredNode] = useState<GraphNode | null>(null);
|
||||
const [zoom, setZoom] = useState(1);
|
||||
const [pan, setPan] = useState({ x: 0, y: 0 });
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
|
||||
const [collapsedNodes, setCollapsedNodes] = useState<Set<string>>(new Set());
|
||||
const [nodes, setNodes, onNodesChange] = useNodesState<NodeData>([]);
|
||||
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
|
||||
|
||||
const handleNavigate = useCallback((project: string, pkg: string) => {
|
||||
navigate(`/project/${project}/${pkg}`);
|
||||
onClose();
|
||||
}, [navigate, onClose]);
|
||||
|
||||
// Build graph structure from resolution data
|
||||
const buildGraph = useCallback(async (resolutionData: DependencyResolutionResponse) => {
|
||||
const buildFlowGraph = useCallback(async (
|
||||
resolutionData: DependencyResolutionResponse,
|
||||
onNavigate: (project: string, pkg: string) => void
|
||||
) => {
|
||||
const artifactMap = new Map<string, ResolvedArtifact>();
|
||||
resolutionData.resolved.forEach(artifact => {
|
||||
artifactMap.set(artifact.artifact_id, artifact);
|
||||
});
|
||||
|
||||
// Fetch dependencies for each artifact to build the tree
|
||||
// Fetch dependencies for each artifact
|
||||
const depsMap = new Map<string, Dependency[]>();
|
||||
const failedFetches: string[] = [];
|
||||
|
||||
for (const artifact of resolutionData.resolved) {
|
||||
try {
|
||||
const deps = await getArtifactDependencies(artifact.artifact_id);
|
||||
depsMap.set(artifact.artifact_id, deps.dependencies);
|
||||
} catch {
|
||||
} catch (err) {
|
||||
console.warn(`Failed to fetch dependencies for ${artifact.package}:`, err);
|
||||
failedFetches.push(artifact.package);
|
||||
depsMap.set(artifact.artifact_id, []);
|
||||
}
|
||||
}
|
||||
|
||||
// Find the root artifact (the requested one)
|
||||
// Report warning if some fetches failed
|
||||
if (failedFetches.length > 0) {
|
||||
setWarning(`Could not load dependency details for: ${failedFetches.slice(0, 3).join(', ')}${failedFetches.length > 3 ? ` and ${failedFetches.length - 3} more` : ''}`);
|
||||
}
|
||||
|
||||
// Find the root artifact
|
||||
const rootArtifact = resolutionData.resolved.find(
|
||||
a => a.project === resolutionData.requested.project &&
|
||||
a.package === resolutionData.requested.package
|
||||
);
|
||||
|
||||
if (!rootArtifact) {
|
||||
return null;
|
||||
return { nodes: [], edges: [] };
|
||||
}
|
||||
|
||||
// Build tree recursively
|
||||
const flowNodes: Node<NodeData>[] = [];
|
||||
const flowEdges: Edge[] = [];
|
||||
const visited = new Set<string>();
|
||||
const nodeIdMap = new Map<string, string>(); // artifact_id -> node id
|
||||
|
||||
// Build nodes and edges recursively
|
||||
const processNode = (artifact: ResolvedArtifact, isRoot: boolean) => {
|
||||
if (visited.has(artifact.artifact_id)) {
|
||||
return nodeIdMap.get(artifact.artifact_id);
|
||||
}
|
||||
|
||||
const buildNode = (artifact: ResolvedArtifact, depth: number): GraphNode => {
|
||||
const nodeId = `${artifact.project}/${artifact.package}`;
|
||||
visited.add(artifact.artifact_id);
|
||||
const nodeId = `node-${flowNodes.length}`;
|
||||
nodeIdMap.set(artifact.artifact_id, nodeId);
|
||||
|
||||
flowNodes.push({
|
||||
id: nodeId,
|
||||
type: 'dependency',
|
||||
position: { x: 0, y: 0 }, // Will be set by dagre
|
||||
data: {
|
||||
label: `${artifact.project}/${artifact.package}`,
|
||||
project: artifact.project,
|
||||
package: artifact.package,
|
||||
version: artifact.version,
|
||||
size: artifact.size,
|
||||
isRoot,
|
||||
onNavigate,
|
||||
},
|
||||
});
|
||||
|
||||
const deps = depsMap.get(artifact.artifact_id) || [];
|
||||
const children: GraphNode[] = [];
|
||||
|
||||
for (const dep of deps) {
|
||||
// Find the resolved artifact for this dependency
|
||||
const childArtifact = resolutionData.resolved.find(
|
||||
a => a.project === dep.project && a.package === dep.package
|
||||
);
|
||||
|
||||
if (childArtifact && !visited.has(childArtifact.artifact_id)) {
|
||||
children.push(buildNode(childArtifact, depth + 1));
|
||||
if (childArtifact) {
|
||||
const childNodeId = processNode(childArtifact, false);
|
||||
if (childNodeId) {
|
||||
flowEdges.push({
|
||||
id: `edge-${nodeId}-${childNodeId}`,
|
||||
source: nodeId,
|
||||
target: childNodeId,
|
||||
markerEnd: {
|
||||
type: MarkerType.ArrowClosed,
|
||||
width: 15,
|
||||
height: 15,
|
||||
color: 'var(--accent-primary)',
|
||||
},
|
||||
style: {
|
||||
stroke: 'var(--border-primary)',
|
||||
strokeWidth: 2,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: nodeId,
|
||||
project: artifact.project,
|
||||
package: artifact.package,
|
||||
version: artifact.version || artifact.tag,
|
||||
size: artifact.size,
|
||||
depth,
|
||||
children,
|
||||
isRoot: depth === 0,
|
||||
};
|
||||
return nodeId;
|
||||
};
|
||||
|
||||
return buildNode(rootArtifact, 0);
|
||||
processNode(rootArtifact, true);
|
||||
|
||||
// Apply dagre layout
|
||||
return getLayoutedElements(flowNodes, flowEdges);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -117,13 +231,21 @@ function DependencyGraph({ projectName, packageName, tagName, onClose }: Depende
|
||||
|
||||
try {
|
||||
const result = await resolveDependencies(projectName, packageName, tagName);
|
||||
|
||||
// If only the root package (no dependencies) and no missing deps, close the modal
|
||||
const hasDeps = result.artifact_count > 1 || (result.missing && result.missing.length > 0);
|
||||
if (!hasDeps) {
|
||||
onClose();
|
||||
return;
|
||||
}
|
||||
|
||||
setResolution(result);
|
||||
|
||||
const graph = await buildGraph(result);
|
||||
setGraphRoot(graph);
|
||||
const { nodes: layoutedNodes, edges: layoutedEdges } = await buildFlowGraph(result, handleNavigate);
|
||||
setNodes(layoutedNodes);
|
||||
setEdges(layoutedEdges);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
// Check if it's a resolution error
|
||||
try {
|
||||
const errorData = JSON.parse(err.message);
|
||||
if (errorData.error === 'circular_dependency') {
|
||||
@@ -145,95 +267,9 @@ function DependencyGraph({ projectName, packageName, tagName, onClose }: Depende
|
||||
}
|
||||
|
||||
loadData();
|
||||
}, [projectName, packageName, tagName, buildGraph]);
|
||||
}, [projectName, packageName, tagName, buildFlowGraph, handleNavigate, onClose, setNodes, setEdges]);
|
||||
|
||||
const handleNodeClick = (node: GraphNode) => {
|
||||
navigate(`/project/${node.project}/${node.package}`);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleNodeToggle = (node: GraphNode, e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
setCollapsedNodes(prev => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(node.id)) {
|
||||
next.delete(node.id);
|
||||
} else {
|
||||
next.add(node.id);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const handleWheel = (e: React.WheelEvent) => {
|
||||
e.preventDefault();
|
||||
const delta = e.deltaY > 0 ? -0.1 : 0.1;
|
||||
setZoom(z => Math.max(0.25, Math.min(2, z + delta)));
|
||||
};
|
||||
|
||||
const handleMouseDown = (e: React.MouseEvent) => {
|
||||
if (e.target === containerRef.current || (e.target as HTMLElement).classList.contains('graph-canvas')) {
|
||||
setIsDragging(true);
|
||||
setDragStart({ x: e.clientX - pan.x, y: e.clientY - pan.y });
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent) => {
|
||||
if (isDragging) {
|
||||
setPan({ x: e.clientX - dragStart.x, y: e.clientY - dragStart.y });
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseUp = () => {
|
||||
setIsDragging(false);
|
||||
};
|
||||
|
||||
const resetView = () => {
|
||||
setZoom(1);
|
||||
setPan({ x: 0, y: 0 });
|
||||
};
|
||||
|
||||
const renderNode = (node: GraphNode, index: number = 0): JSX.Element => {
|
||||
const isCollapsed = collapsedNodes.has(node.id);
|
||||
const hasChildren = node.children.length > 0;
|
||||
|
||||
return (
|
||||
<div key={`${node.id}-${index}`} className="graph-node-container">
|
||||
<div
|
||||
className={`graph-node ${node.isRoot ? 'graph-node--root' : ''} ${hoveredNode?.id === node.id ? 'graph-node--hovered' : ''}`}
|
||||
onClick={() => handleNodeClick(node)}
|
||||
onMouseEnter={() => setHoveredNode(node)}
|
||||
onMouseLeave={() => setHoveredNode(null)}
|
||||
>
|
||||
<div className="graph-node__header">
|
||||
<span className="graph-node__name">{node.project}/{node.package}</span>
|
||||
{hasChildren && (
|
||||
<button
|
||||
className="graph-node__toggle"
|
||||
onClick={(e) => handleNodeToggle(node, e)}
|
||||
title={isCollapsed ? 'Expand' : 'Collapse'}
|
||||
>
|
||||
{isCollapsed ? '+' : '-'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="graph-node__details">
|
||||
{node.version && <span className="graph-node__version">@ {node.version}</span>}
|
||||
<span className="graph-node__size">{formatBytes(node.size)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{hasChildren && !isCollapsed && (
|
||||
<div className="graph-children">
|
||||
<div className="graph-connector"></div>
|
||||
<div className="graph-children-list">
|
||||
{node.children.map((child, i) => renderNode(child, i))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
const defaultViewport = useMemo(() => ({ x: 50, y: 50, zoom: 0.8 }), []);
|
||||
|
||||
return (
|
||||
<div className="dependency-graph-modal" onClick={onClose}>
|
||||
@@ -244,7 +280,11 @@ function DependencyGraph({ projectName, packageName, tagName, onClose }: Depende
|
||||
<span>{projectName}/{packageName} @ {tagName}</span>
|
||||
{resolution && (
|
||||
<span className="graph-stats">
|
||||
{resolution.artifact_count} packages • {formatBytes(resolution.total_size)} total
|
||||
{resolution.artifact_count} cached
|
||||
{resolution.missing && resolution.missing.length > 0 && (
|
||||
<span className="missing-count"> • {resolution.missing.length} not cached</span>
|
||||
)}
|
||||
• {formatBytes(resolution.total_size)} total
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -256,28 +296,7 @@ function DependencyGraph({ projectName, packageName, tagName, onClose }: Depende
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="dependency-graph-toolbar">
|
||||
<button className="btn btn-secondary btn-small" onClick={() => setZoom(z => Math.min(2, z + 0.25))}>
|
||||
Zoom In
|
||||
</button>
|
||||
<button className="btn btn-secondary btn-small" onClick={() => setZoom(z => Math.max(0.25, z - 0.25))}>
|
||||
Zoom Out
|
||||
</button>
|
||||
<button className="btn btn-secondary btn-small" onClick={resetView}>
|
||||
Reset View
|
||||
</button>
|
||||
<span className="zoom-level">{Math.round(zoom * 100)}%</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="dependency-graph-container"
|
||||
onWheel={handleWheel}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseUp={handleMouseUp}
|
||||
onMouseLeave={handleMouseUp}
|
||||
>
|
||||
<div className="dependency-graph-container">
|
||||
{loading ? (
|
||||
<div className="graph-loading">
|
||||
<div className="spinner"></div>
|
||||
@@ -292,27 +311,52 @@ function DependencyGraph({ projectName, packageName, tagName, onClose }: Depende
|
||||
</svg>
|
||||
<p>{error}</p>
|
||||
</div>
|
||||
) : graphRoot ? (
|
||||
<div
|
||||
className="graph-canvas"
|
||||
style={{
|
||||
transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoom})`,
|
||||
cursor: isDragging ? 'grabbing' : 'grab',
|
||||
}}
|
||||
) : nodes.length > 0 ? (
|
||||
<ReactFlow
|
||||
nodes={nodes}
|
||||
edges={edges}
|
||||
onNodesChange={onNodesChange}
|
||||
onEdgesChange={onEdgesChange}
|
||||
nodeTypes={nodeTypes}
|
||||
defaultViewport={defaultViewport}
|
||||
fitView
|
||||
fitViewOptions={{ padding: 0.2 }}
|
||||
minZoom={0.1}
|
||||
maxZoom={2}
|
||||
attributionPosition="bottom-left"
|
||||
>
|
||||
{renderNode(graphRoot)}
|
||||
</div>
|
||||
<Controls />
|
||||
<Background color="var(--border-primary)" gap={20} />
|
||||
</ReactFlow>
|
||||
) : (
|
||||
<div className="graph-empty">No dependencies to display</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{hoveredNode && (
|
||||
<div className="graph-tooltip">
|
||||
<strong>{hoveredNode.project}/{hoveredNode.package}</strong>
|
||||
{hoveredNode.version && <div>Version: {hoveredNode.version}</div>}
|
||||
<div>Size: {formatBytes(hoveredNode.size)}</div>
|
||||
<div className="tooltip-hint">Click to navigate</div>
|
||||
{warning && (
|
||||
<div className="graph-warning">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
|
||||
<line x1="12" y1="9" x2="12" y2="13"></line>
|
||||
<line x1="12" y1="17" x2="12.01" y2="17"></line>
|
||||
</svg>
|
||||
<span>{warning}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{resolution && resolution.missing && resolution.missing.length > 0 && (
|
||||
<div className="missing-dependencies">
|
||||
<h3>Not Cached ({resolution.missing.length})</h3>
|
||||
<p className="missing-hint">These dependencies are referenced but not yet cached on the server.</p>
|
||||
<ul className="missing-list">
|
||||
{resolution.missing.map((dep, i) => (
|
||||
<li key={i} className="missing-item">
|
||||
<span className="missing-name">{dep.project}/{dep.package}</span>
|
||||
{dep.constraint && <span className="missing-constraint">@{dep.constraint}</span>}
|
||||
{dep.required_by && <span className="missing-required-by">← {dep.required_by}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -290,20 +290,25 @@
|
||||
color: var(--error-color, #dc3545);
|
||||
}
|
||||
|
||||
/* Progress Bar */
|
||||
.progress-bar {
|
||||
/* Progress Bar - scoped to upload component */
|
||||
.drag-drop-upload .progress-bar,
|
||||
.upload-queue .progress-bar {
|
||||
height: 8px;
|
||||
background: var(--border-color, #ddd);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.progress-bar--small {
|
||||
.drag-drop-upload .progress-bar--small,
|
||||
.upload-queue .progress-bar--small {
|
||||
height: 4px;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.progress-bar__fill {
|
||||
.drag-drop-upload .progress-bar__fill,
|
||||
.upload-queue .progress-bar__fill {
|
||||
height: 100%;
|
||||
background: var(--accent-color, #007bff);
|
||||
border-radius: 4px;
|
||||
|
||||
@@ -504,42 +504,4 @@ describe('DragDropUpload', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Tag Support', () => {
|
||||
it('includes tag in upload request', async () => {
|
||||
let capturedFormData: FormData | null = null;
|
||||
|
||||
class MockXHR {
|
||||
status = 200;
|
||||
responseText = JSON.stringify({ artifact_id: 'abc123', size: 100 });
|
||||
timeout = 0;
|
||||
upload = { addEventListener: vi.fn() };
|
||||
addEventListener = vi.fn((event: string, handler: () => void) => {
|
||||
if (event === 'load') setTimeout(handler, 10);
|
||||
});
|
||||
open = vi.fn();
|
||||
send = vi.fn((data: FormData) => {
|
||||
capturedFormData = data;
|
||||
});
|
||||
}
|
||||
vi.stubGlobal('XMLHttpRequest', MockXHR);
|
||||
|
||||
render(<DragDropUpload {...defaultProps} tag="v1.0.0" />);
|
||||
|
||||
const input = document.querySelector('input[type="file"]') as HTMLInputElement;
|
||||
const file = createMockFile('test.txt', 100, 'text/plain');
|
||||
|
||||
Object.defineProperty(input, 'files', {
|
||||
value: Object.assign([file], { item: (i: number) => [file][i] }),
|
||||
});
|
||||
|
||||
fireEvent.change(input);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(100);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(capturedFormData?.get('tag')).toBe('v1.0.0');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,6 @@ interface StoredUploadState {
|
||||
completedParts: number[];
|
||||
project: string;
|
||||
package: string;
|
||||
tag?: string;
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
@@ -87,7 +86,6 @@ export interface DragDropUploadProps {
|
||||
maxFileSize?: number; // in bytes
|
||||
maxConcurrentUploads?: number;
|
||||
maxRetries?: number;
|
||||
tag?: string;
|
||||
className?: string;
|
||||
disabled?: boolean;
|
||||
disabledReason?: string;
|
||||
@@ -230,7 +228,6 @@ export function DragDropUpload({
|
||||
maxFileSize,
|
||||
maxConcurrentUploads = 3,
|
||||
maxRetries = 3,
|
||||
tag,
|
||||
className = '',
|
||||
disabled = false,
|
||||
disabledReason,
|
||||
@@ -368,7 +365,6 @@ export function DragDropUpload({
|
||||
expected_hash: fileHash,
|
||||
filename: item.file.name,
|
||||
size: item.file.size,
|
||||
tag: tag || undefined,
|
||||
}),
|
||||
}
|
||||
);
|
||||
@@ -392,7 +388,6 @@ export function DragDropUpload({
|
||||
completedParts: [],
|
||||
project: projectName,
|
||||
package: packageName,
|
||||
tag: tag || undefined,
|
||||
createdAt: Date.now(),
|
||||
});
|
||||
|
||||
@@ -438,7 +433,6 @@ export function DragDropUpload({
|
||||
completedParts,
|
||||
project: projectName,
|
||||
package: packageName,
|
||||
tag: tag || undefined,
|
||||
createdAt: Date.now(),
|
||||
});
|
||||
|
||||
@@ -459,7 +453,7 @@ export function DragDropUpload({
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ tag: tag || undefined }),
|
||||
body: JSON.stringify({}),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -475,18 +469,15 @@ export function DragDropUpload({
|
||||
size: completeData.size,
|
||||
deduplicated: false,
|
||||
};
|
||||
}, [projectName, packageName, tag, isOnline]);
|
||||
}, [projectName, packageName, isOnline]);
|
||||
|
||||
const uploadFileSimple = useCallback((item: UploadItem): Promise<UploadResult> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhrMapRef.current.set(item.id, xhr);
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', item.file);
|
||||
if (tag) {
|
||||
formData.append('tag', tag);
|
||||
}
|
||||
|
||||
let lastLoaded = 0;
|
||||
let lastTime = Date.now();
|
||||
@@ -549,13 +540,13 @@ export function DragDropUpload({
|
||||
xhr.timeout = 300000;
|
||||
xhr.send(formData);
|
||||
|
||||
setUploadQueue(prev => prev.map(u =>
|
||||
u.id === item.id
|
||||
setUploadQueue(prev => prev.map(u =>
|
||||
u.id === item.id
|
||||
? { ...u, status: 'uploading' as UploadStatus, startTime: Date.now() }
|
||||
: u
|
||||
));
|
||||
});
|
||||
}, [projectName, packageName, tag]);
|
||||
}, [projectName, packageName]);
|
||||
|
||||
const uploadFile = useCallback((item: UploadItem): Promise<UploadResult> => {
|
||||
if (item.file.size >= CHUNKED_UPLOAD_THRESHOLD) {
|
||||
|
||||
@@ -233,7 +233,7 @@ export function GlobalSearch() {
|
||||
const flatIndex = results.projects.length + results.packages.length + index;
|
||||
return (
|
||||
<button
|
||||
key={artifact.tag_id}
|
||||
key={artifact.artifact_id}
|
||||
className={`global-search__result ${selectedIndex === flatIndex ? 'selected' : ''}`}
|
||||
onClick={() => navigateToResult({ type: 'artifact', item: artifact })}
|
||||
onMouseEnter={() => setSelectedIndex(flatIndex)}
|
||||
@@ -243,7 +243,7 @@ export function GlobalSearch() {
|
||||
<line x1="7" y1="7" x2="7.01" y2="7" />
|
||||
</svg>
|
||||
<div className="global-search__result-content">
|
||||
<span className="global-search__result-name">{artifact.tag_name}</span>
|
||||
<span className="global-search__result-name">{artifact.version}</span>
|
||||
<span className="global-search__result-path">
|
||||
{artifact.project_name} / {artifact.package_name}
|
||||
</span>
|
||||
|
||||
@@ -84,29 +84,6 @@ function Layout({ children }: LayoutProps) {
|
||||
</svg>
|
||||
Projects
|
||||
</Link>
|
||||
<Link to="/dashboard" className={location.pathname === '/dashboard' ? 'active' : ''}>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<rect x="3" y="3" width="7" height="7" rx="1"/>
|
||||
<rect x="14" y="3" width="7" height="7" rx="1"/>
|
||||
<rect x="3" y="14" width="7" height="7" rx="1"/>
|
||||
<rect x="14" y="14" width="7" height="7" rx="1"/>
|
||||
</svg>
|
||||
Dashboard
|
||||
</Link>
|
||||
{user && userTeams.length > 0 && (
|
||||
<Link
|
||||
to={userTeams.length === 1 ? `/teams/${userTeams[0].slug}` : '/teams'}
|
||||
className={location.pathname.startsWith('/teams') ? 'active' : ''}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
|
||||
<circle cx="9" cy="7" r="4"/>
|
||||
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
|
||||
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
|
||||
</svg>
|
||||
{userTeams.length === 1 ? 'Team' : 'Teams'}
|
||||
</Link>
|
||||
)}
|
||||
<a href="/docs" className="nav-link-muted">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
|
||||
@@ -148,6 +125,35 @@ function Layout({ children }: LayoutProps) {
|
||||
)}
|
||||
</div>
|
||||
<div className="user-menu-divider"></div>
|
||||
<NavLink
|
||||
to="/dashboard"
|
||||
className="user-menu-item"
|
||||
onClick={() => setShowUserMenu(false)}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<rect x="3" y="3" width="7" height="7" rx="1"/>
|
||||
<rect x="14" y="3" width="7" height="7" rx="1"/>
|
||||
<rect x="3" y="14" width="7" height="7" rx="1"/>
|
||||
<rect x="14" y="14" width="7" height="7" rx="1"/>
|
||||
</svg>
|
||||
Dashboard
|
||||
</NavLink>
|
||||
{userTeams.length > 0 && (
|
||||
<NavLink
|
||||
to={userTeams.length === 1 ? `/teams/${userTeams[0].slug}` : '/teams'}
|
||||
className="user-menu-item"
|
||||
onClick={() => setShowUserMenu(false)}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
|
||||
<circle cx="9" cy="7" r="4"/>
|
||||
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
|
||||
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
|
||||
</svg>
|
||||
{userTeams.length === 1 ? 'Team' : 'Teams'}
|
||||
</NavLink>
|
||||
)}
|
||||
<div className="user-menu-divider"></div>
|
||||
<NavLink
|
||||
to="/settings/api-keys"
|
||||
className="user-menu-item"
|
||||
|
||||
@@ -132,6 +132,12 @@
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.coming-soon-badge {
|
||||
color: #9e9e9e;
|
||||
font-style: italic;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
.actions-cell {
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -12,6 +12,7 @@ import { UpstreamSource, SourceType, AuthType } from '../types';
|
||||
import './AdminCachePage.css';
|
||||
|
||||
const SOURCE_TYPES: SourceType[] = ['npm', 'pypi', 'maven', 'docker', 'helm', 'nuget', 'deb', 'rpm', 'generic'];
|
||||
const SUPPORTED_SOURCE_TYPES: Set<SourceType> = new Set(['pypi', 'generic']);
|
||||
const AUTH_TYPES: AuthType[] = ['none', 'basic', 'bearer', 'api_key'];
|
||||
|
||||
function AdminCachePage() {
|
||||
@@ -285,7 +286,12 @@ function AdminCachePage() {
|
||||
<span className="env-badge" title="Defined via environment variable">ENV</span>
|
||||
)}
|
||||
</td>
|
||||
<td>{source.source_type}</td>
|
||||
<td>
|
||||
{source.source_type}
|
||||
{!SUPPORTED_SOURCE_TYPES.has(source.source_type) && (
|
||||
<span className="coming-soon-badge"> (coming soon)</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="url-cell" title={source.url}>{source.url}</td>
|
||||
<td>{source.priority}</td>
|
||||
<td>
|
||||
@@ -359,7 +365,7 @@ function AdminCachePage() {
|
||||
>
|
||||
{SOURCE_TYPES.map((type) => (
|
||||
<option key={type} value={type}>
|
||||
{type}
|
||||
{type}{!SUPPORTED_SOURCE_TYPES.has(type) ? ' (coming soon)' : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
@@ -249,7 +249,7 @@ function Home() {
|
||||
key: 'created_by',
|
||||
header: 'Owner',
|
||||
className: 'cell-owner',
|
||||
render: (project) => project.created_by,
|
||||
render: (project) => project.team_name || project.created_by,
|
||||
},
|
||||
...(user
|
||||
? [
|
||||
|
||||
@@ -185,56 +185,6 @@ h2 {
|
||||
color: var(--warning-color, #f59e0b);
|
||||
}
|
||||
|
||||
/* Usage Section */
|
||||
.usage-section {
|
||||
margin-top: 32px;
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.usage-section h3 {
|
||||
margin-bottom: 12px;
|
||||
color: var(--text-primary);
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.usage-section p {
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 12px;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.usage-section pre {
|
||||
background: #0d0d0f;
|
||||
border: 1px solid var(--border-primary);
|
||||
padding: 16px 20px;
|
||||
border-radius: var(--radius-md);
|
||||
overflow-x: auto;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.usage-section code {
|
||||
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
|
||||
font-size: 0.8125rem;
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
/* Syntax highlighting for code blocks */
|
||||
.usage-section pre {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.usage-section pre::before {
|
||||
content: 'bash';
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 12px;
|
||||
font-size: 0.6875rem;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
/* Copy button for code blocks (optional enhancement) */
|
||||
.code-block {
|
||||
position: relative;
|
||||
@@ -642,6 +592,11 @@ tr:hover .copy-btn {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* Ensure file modal needs higher z-index when opened from deps modal */
|
||||
.modal-overlay:has(.ensure-file-modal) {
|
||||
z-index: 1100;
|
||||
}
|
||||
|
||||
.ensure-file-modal {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
@@ -793,4 +748,194 @@ tr:hover .copy-btn {
|
||||
.ensure-file-modal {
|
||||
max-height: 90vh;
|
||||
}
|
||||
|
||||
.action-menu-dropdown {
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* Header upload button */
|
||||
.header-upload-btn {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* Tag/Version cell */
|
||||
.tag-version-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.tag-version-cell .version-badge {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Icon buttons */
|
||||
.btn-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
transition: all var(--transition-fast);
|
||||
}
|
||||
|
||||
.btn-icon:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Action menu */
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.action-menu {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Action menu backdrop for click-outside */
|
||||
.action-menu-backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.action-menu-dropdown {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
min-width: 180px;
|
||||
padding: 4px 0;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.action-menu-dropdown button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
text-align: left;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-primary);
|
||||
cursor: pointer;
|
||||
transition: background var(--transition-fast);
|
||||
}
|
||||
|
||||
.action-menu-dropdown button:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
/* Upload Modal */
|
||||
.upload-modal,
|
||||
.create-tag-modal {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: var(--radius-lg);
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
max-height: 90vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
margin: 0;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.modal-description {
|
||||
margin-bottom: 16px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
margin-top: 20px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
/* Dependencies Modal */
|
||||
.deps-modal {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: var(--radius-lg);
|
||||
width: 90%;
|
||||
max-width: 600px;
|
||||
max-height: 80vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.deps-modal .modal-body {
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.deps-modal-controls {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
/* Artifact ID Modal */
|
||||
.artifact-id-modal {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: var(--radius-lg);
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.artifact-id-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.artifact-id-display code {
|
||||
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text-primary);
|
||||
word-break: break-all;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.artifact-id-display .copy-btn {
|
||||
opacity: 1;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -214,7 +214,7 @@ function ProjectPage() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="page-header__actions">
|
||||
{canAdmin && !project.team_id && (
|
||||
{canAdmin && !project.team_id && !project.is_system && (
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
onClick={() => navigate(`/project/${projectName}/settings`)}
|
||||
@@ -227,11 +227,11 @@ function ProjectPage() {
|
||||
Settings
|
||||
</button>
|
||||
)}
|
||||
{canWrite ? (
|
||||
{canWrite && !project.is_system ? (
|
||||
<button className="btn btn-primary" onClick={() => setShowForm(!showForm)}>
|
||||
{showForm ? 'Cancel' : '+ New Package'}
|
||||
</button>
|
||||
) : user ? (
|
||||
) : user && !project.is_system ? (
|
||||
<span className="text-muted" title="You have read-only access to this project">
|
||||
Read-only access
|
||||
</span>
|
||||
@@ -294,18 +294,20 @@ function ProjectPage() {
|
||||
placeholder="Filter packages..."
|
||||
className="list-controls__search"
|
||||
/>
|
||||
<select
|
||||
className="list-controls__select"
|
||||
value={format}
|
||||
onChange={(e) => handleFormatChange(e.target.value)}
|
||||
>
|
||||
<option value="">All formats</option>
|
||||
{FORMAT_OPTIONS.map((f) => (
|
||||
<option key={f} value={f}>
|
||||
{f}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{!project?.is_system && (
|
||||
<select
|
||||
className="list-controls__select"
|
||||
value={format}
|
||||
onChange={(e) => handleFormatChange(e.target.value)}
|
||||
>
|
||||
<option value="">All formats</option>
|
||||
{FORMAT_OPTIONS.map((f) => (
|
||||
<option key={f} value={f}>
|
||||
{f}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{hasActiveFilters && (
|
||||
@@ -341,19 +343,19 @@ function ProjectPage() {
|
||||
className: 'cell-description',
|
||||
render: (pkg) => pkg.description || '—',
|
||||
},
|
||||
{
|
||||
...(!project?.is_system ? [{
|
||||
key: 'format',
|
||||
header: 'Format',
|
||||
render: (pkg) => <Badge variant="default">{pkg.format}</Badge>,
|
||||
},
|
||||
{
|
||||
key: 'tag_count',
|
||||
header: 'Tags',
|
||||
render: (pkg) => pkg.tag_count ?? '—',
|
||||
},
|
||||
render: (pkg: Package) => <Badge variant="default">{pkg.format}</Badge>,
|
||||
}] : []),
|
||||
...(!project?.is_system ? [{
|
||||
key: 'version_count',
|
||||
header: 'Versions',
|
||||
render: (pkg: Package) => pkg.version_count ?? '—',
|
||||
}] : []),
|
||||
{
|
||||
key: 'artifact_count',
|
||||
header: 'Artifacts',
|
||||
header: project?.is_system ? 'Versions' : 'Artifacts',
|
||||
render: (pkg) => pkg.artifact_count ?? '—',
|
||||
},
|
||||
{
|
||||
@@ -362,12 +364,12 @@ function ProjectPage() {
|
||||
render: (pkg) =>
|
||||
pkg.total_size !== undefined && pkg.total_size > 0 ? formatBytes(pkg.total_size) : '—',
|
||||
},
|
||||
{
|
||||
key: 'latest_tag',
|
||||
...(!project?.is_system ? [{
|
||||
key: 'latest_version',
|
||||
header: 'Latest',
|
||||
render: (pkg) =>
|
||||
pkg.latest_tag ? <strong style={{ color: 'var(--accent-primary)' }}>{pkg.latest_tag}</strong> : '—',
|
||||
},
|
||||
render: (pkg: Package) =>
|
||||
pkg.latest_version ? <strong style={{ color: 'var(--accent-primary)' }}>{pkg.latest_version}</strong> : '—',
|
||||
}] : []),
|
||||
{
|
||||
key: 'created_at',
|
||||
header: 'Created',
|
||||
|
||||
@@ -19,12 +19,6 @@ export interface Project {
|
||||
team_name?: string | null;
|
||||
}
|
||||
|
||||
export interface TagSummary {
|
||||
name: string;
|
||||
artifact_id: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Package {
|
||||
id: string;
|
||||
project_id: string;
|
||||
@@ -35,12 +29,11 @@ export interface Package {
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
// Aggregated fields (from PackageDetailResponse)
|
||||
tag_count?: number;
|
||||
artifact_count?: number;
|
||||
version_count?: number;
|
||||
total_size?: number;
|
||||
latest_tag?: string | null;
|
||||
latest_upload_at?: string | null;
|
||||
recent_tags?: TagSummary[];
|
||||
latest_version?: string | null;
|
||||
}
|
||||
|
||||
export interface Artifact {
|
||||
@@ -53,22 +46,19 @@ export interface Artifact {
|
||||
ref_count: number;
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
export interface PackageArtifact {
|
||||
id: string;
|
||||
package_id: string;
|
||||
name: string;
|
||||
artifact_id: string;
|
||||
sha256: string;
|
||||
size: number;
|
||||
content_type: string | null;
|
||||
original_name: string | null;
|
||||
checksum_md5?: string | null;
|
||||
checksum_sha1?: string | null;
|
||||
s3_etag?: string | null;
|
||||
created_at: string;
|
||||
created_by: string;
|
||||
}
|
||||
|
||||
export interface TagDetail extends Tag {
|
||||
artifact_size: number;
|
||||
artifact_content_type: string | null;
|
||||
artifact_original_name: string | null;
|
||||
artifact_created_at: string;
|
||||
artifact_format_metadata: Record<string, unknown> | null;
|
||||
version: string | null;
|
||||
format_metadata?: Record<string, unknown> | null;
|
||||
version?: string | null; // Version from PackageVersion if exists
|
||||
}
|
||||
|
||||
export interface PackageVersion {
|
||||
@@ -83,20 +73,9 @@ export interface PackageVersion {
|
||||
size?: number;
|
||||
content_type?: string | null;
|
||||
original_name?: string | null;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
export interface ArtifactTagInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
package_id: string;
|
||||
package_name: string;
|
||||
project_name: string;
|
||||
}
|
||||
|
||||
export interface ArtifactDetail extends Artifact {
|
||||
tags: ArtifactTagInfo[];
|
||||
}
|
||||
export interface ArtifactDetail extends Artifact {}
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
items: T[];
|
||||
@@ -116,8 +95,6 @@ export interface ListParams {
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export interface TagListParams extends ListParams {}
|
||||
|
||||
export interface PackageListParams extends ListParams {
|
||||
format?: string;
|
||||
platform?: string;
|
||||
@@ -142,7 +119,6 @@ export interface UploadResponse {
|
||||
size: number;
|
||||
project: string;
|
||||
package: string;
|
||||
tag: string | null;
|
||||
version: string | null;
|
||||
version_source: string | null;
|
||||
}
|
||||
@@ -165,9 +141,8 @@ export interface SearchResultPackage {
|
||||
}
|
||||
|
||||
export interface SearchResultArtifact {
|
||||
tag_id: string;
|
||||
tag_name: string;
|
||||
artifact_id: string;
|
||||
version: string | null;
|
||||
package_id: string;
|
||||
package_name: string;
|
||||
project_name: string;
|
||||
@@ -390,8 +365,7 @@ export interface Dependency {
|
||||
artifact_id: string;
|
||||
project: string;
|
||||
package: string;
|
||||
version: string | null;
|
||||
tag: string | null;
|
||||
version: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
@@ -405,7 +379,6 @@ export interface DependentInfo {
|
||||
project: string;
|
||||
package: string;
|
||||
version: string | null;
|
||||
constraint_type: 'version' | 'tag';
|
||||
constraint_value: string;
|
||||
}
|
||||
|
||||
@@ -428,11 +401,17 @@ export interface ResolvedArtifact {
|
||||
project: string;
|
||||
package: string;
|
||||
version: string | null;
|
||||
tag: string | null;
|
||||
size: number;
|
||||
download_url: string;
|
||||
}
|
||||
|
||||
export interface MissingDependency {
|
||||
project: string;
|
||||
package: string;
|
||||
constraint: string | null;
|
||||
required_by: string | null;
|
||||
}
|
||||
|
||||
export interface DependencyResolutionResponse {
|
||||
requested: {
|
||||
project: string;
|
||||
@@ -440,6 +419,7 @@ export interface DependencyResolutionResponse {
|
||||
ref: string;
|
||||
};
|
||||
resolved: ResolvedArtifact[];
|
||||
missing: MissingDependency[];
|
||||
total_size: number;
|
||||
artifact_count: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user