Skip to content

Commit

Permalink
Include config path in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMcNeil committed Feb 26, 2025
1 parent 62deeb8 commit 8c2ea01
Showing 7 changed files with 27 additions and 348 deletions.
2 changes: 0 additions & 2 deletions src/extension/ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -3,9 +3,7 @@ import AddIcon from '@mui/icons-material/Add';
import { createDockerDesktopClient } from '@docker/extension-api-client';
import { Stack, Typography, Button, ButtonGroup, Grid, debounce, Card, CardContent, IconButton, Alert, DialogTitle, Dialog, DialogContent, FormControlLabel, Checkbox, CircularProgress, Paper, DialogActions, Box } from '@mui/material';
import { CatalogItemWithName } from './components/PromptCard';
import { RegistrySyncStatus } from './components/RegistrySyncStatus';
import { getRegistry } from './Registry';
import { ClaudeConfigSyncStatus, setNeverShowAgain } from './components/ClaudeConfigSyncStatus';
import { Close, FolderOpenRounded, } from '@mui/icons-material';
import { ExecResult } from '@docker/extension-api-client-types/dist/v0';
import { CatalogGrid } from './components/CatalogGrid';
6 changes: 3 additions & 3 deletions src/extension/ui/src/Constants.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ export const DOCKER_MCP_CONFIG = {
export type MCPClient = {
name: string;
url: string;
readFile: (client: v1.DockerDesktopClient) => Promise<string | undefined | null>;
readFile: (client: v1.DockerDesktopClient) => Promise<{ content: string | null | undefined, path: string }>;
connect: (client: v1.DockerDesktopClient) => Promise<void>;
disconnect: (client: v1.DockerDesktopClient) => Promise<void>;
validateConfig: (content: string) => boolean;
@@ -47,9 +47,9 @@ export const SUPPORTED_MCP_CLIENTS: MCPClient[] = [
path = path.replace('$USER', user)
try {
const result = await client.docker.cli.exec('run', ['--rm', '--mount', `type=bind,source="${path}",target=/config.json`, 'alpine:latest', 'sh', '-c', `"cat /config.json"`])
return result.stdout || undefined;
return { content: result.stdout || undefined, path: path };
} catch (e) {
return null;
return { content: null, path: path };
}
},
connect: async (client: v1.DockerDesktopClient) => {
13 changes: 7 additions & 6 deletions src/extension/ui/src/MCPClients.ts
Original file line number Diff line number Diff line change
@@ -4,19 +4,20 @@ import { MCPClient, SUPPORTED_MCP_CLIENTS } from "./Constants";
export interface MCPClientState extends MCPClient {
exists: boolean;
configured: boolean;
path: string;
}

export const getMCPClientStates = async (ddClient: v1.DockerDesktopClient) => {
const mcpClientStates: { [name: string]: MCPClientState } = {};
for (const mcpClient of SUPPORTED_MCP_CLIENTS) {
const file = await mcpClient.readFile(ddClient);
if (file === null) {
mcpClientStates[mcpClient.name] = { exists: false, configured: false, ...mcpClient };
} else if (file === undefined) {
mcpClientStates[mcpClient.name] = { exists: true, configured: false, ...mcpClient };
const { path, content } = await mcpClient.readFile(ddClient);
if (content === null) {
mcpClientStates[mcpClient.name] = { exists: false, configured: false, path, ...mcpClient };
} else if (content === undefined) {
mcpClientStates[mcpClient.name] = { exists: true, configured: false, path, ...mcpClient };
}
else {
mcpClientStates[mcpClient.name] = { exists: true, configured: mcpClient.validateConfig(file), ...mcpClient };
mcpClientStates[mcpClient.name] = { exists: true, configured: mcpClient.validateConfig(content), path: path, ...mcpClient };
}
}
return mcpClientStates;
204 changes: 0 additions & 204 deletions src/extension/ui/src/components/ClaudeConfigSyncStatus.tsx

This file was deleted.

Loading
Oops, something went wrong.

0 comments on commit 8c2ea01

Please sign in to comment.