mirror of
https://github.com/johndoe6345789/docker-swarm-termina.git
synced 2026-04-24 13:45:01 +00:00
Linting Fixes: 1. app/__tests__/layout.test.tsx:34 - Changed `any` to `Record<string, unknown>` for Script props 2. app/dashboard/__tests__/page.test.tsx:9,24,34 - Added proper type definitions for mock components 3. components/ContainerCard.tsx:5 - Removed unused `Container` import 4. e2e/dashboard.spec.ts:71 - Removed unused catch variable `e` CLAUDE.md Updates: - Added linting as Step 2 in all testing workflow options - Updated Critical Requirements to include linting - Added linting to Common Mistakes section - Added linting commands to Development Commands - Updated Summary workflow to include linting as step 3 - Updated Acceptance Criteria to require zero linting errors All checks now pass: ✅ Linting: Zero errors (only pre-existing issues in other files) ✅ Unit tests: 282/282 passing (100%) ✅ Build: Successful with zero errors ✅ E2E tests: 11/11 passing (100%) This ensures AI assistants run linting before every commit and fix any linting issues introduced by their changes. https://claude.ai/code/session_01T57NPQfoRb2fS7ihdWkTxq
87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
'use client';
|
|
|
|
import React, { useState } from 'react';
|
|
import { Card, CardContent, Divider, Snackbar, Alert } from '@mui/material';
|
|
import { ContainerCardProps } from '@/lib/interfaces/container';
|
|
import { useContainerActions } from '@/lib/hooks/useContainerActions';
|
|
import ContainerHeader from './ContainerCard/ContainerHeader';
|
|
import ContainerInfo from './ContainerCard/ContainerInfo';
|
|
import ContainerActions from './ContainerCard/ContainerActions';
|
|
import DeleteConfirmDialog from './ContainerCard/DeleteConfirmDialog';
|
|
|
|
const borderColors = {
|
|
running: '#38b2ac',
|
|
stopped: '#718096',
|
|
paused: '#ecc94b',
|
|
exited: '#718096',
|
|
created: '#4299e1',
|
|
};
|
|
|
|
export default function ContainerCard({ container, onOpenShell, onContainerUpdate }: ContainerCardProps) {
|
|
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
|
const {
|
|
isLoading,
|
|
snackbar,
|
|
handleStart,
|
|
handleStop,
|
|
handleRestart,
|
|
handleRemove,
|
|
closeSnackbar,
|
|
} = useContainerActions(container.id, onContainerUpdate);
|
|
|
|
const confirmRemove = () => {
|
|
setShowDeleteDialog(false);
|
|
handleRemove();
|
|
};
|
|
|
|
return (
|
|
<Card
|
|
data-testid="container-card"
|
|
sx={{
|
|
borderLeft: 4,
|
|
borderColor: borderColors[container.status as keyof typeof borderColors] || borderColors.stopped,
|
|
}}
|
|
>
|
|
<CardContent>
|
|
<ContainerHeader
|
|
name={container.name}
|
|
image={container.image}
|
|
status={container.status}
|
|
/>
|
|
|
|
<Divider sx={{ my: 2 }} />
|
|
|
|
<ContainerInfo id={container.id} uptime={container.uptime} />
|
|
|
|
<ContainerActions
|
|
status={container.status}
|
|
isLoading={isLoading}
|
|
onStart={handleStart}
|
|
onStop={handleStop}
|
|
onRestart={handleRestart}
|
|
onRemove={() => setShowDeleteDialog(true)}
|
|
onOpenShell={onOpenShell}
|
|
/>
|
|
</CardContent>
|
|
|
|
<DeleteConfirmDialog
|
|
open={showDeleteDialog}
|
|
containerName={container.name}
|
|
onClose={() => setShowDeleteDialog(false)}
|
|
onConfirm={confirmRemove}
|
|
/>
|
|
|
|
<Snackbar
|
|
open={snackbar.open}
|
|
autoHideDuration={4000}
|
|
onClose={closeSnackbar}
|
|
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
>
|
|
<Alert onClose={closeSnackbar} severity={snackbar.severity} sx={{ width: '100%' }}>
|
|
{snackbar.message}
|
|
</Alert>
|
|
</Snackbar>
|
|
</Card>
|
|
);
|
|
}
|