Skip to content

Commit 2ee2100

Browse files
feat(knowledge): improve MCP import and tool selector dialogs
- Move Import button to DialogActions for consistency with other dialogs - Remove oversized Search button styling - Display tool name instead of provider type in dialog title - Replace Cancel with Back button that navigates to tool selector - Add provider-specific icons (Notion, GitHub, Atlassian) to tool list - Capitalize provider type names in tool selector
1 parent 59b251a commit 2ee2100

File tree

3 files changed

+61
-28
lines changed

3 files changed

+61
-28
lines changed

apps/frontend/src/app/(protected)/knowledge/components/MCPImportDialog.tsx

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import CloseIcon from '@mui/icons-material/Close';
2727
import SearchIcon from '@mui/icons-material/Search';
2828
import SaveIcon from '@mui/icons-material/Save';
2929
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
30+
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
3031
import { ApiClientFactory } from '@/utils/api-client/client-factory';
3132
import { useNotifications } from '@/components/common/NotificationContext';
3233
import { MCPItem } from '@/utils/api-client/services-client';
@@ -36,6 +37,7 @@ import { UUID } from 'crypto';
3637
interface MCPImportDialogProps {
3738
open: boolean;
3839
onClose: () => void;
40+
onBack?: () => void;
3941
onSuccess?: () => void;
4042
sessionToken: string;
4143
tool?: Tool | null;
@@ -44,6 +46,7 @@ interface MCPImportDialogProps {
4446
export default function MCPImportDialog({
4547
open,
4648
onClose,
49+
onBack,
4750
onSuccess,
4851
sessionToken,
4952
tool,
@@ -233,6 +236,20 @@ export default function MCPImportDialog({
233236
}
234237
};
235238

239+
const handleBack = () => {
240+
if (!searching && !importing) {
241+
setSearchQuery('');
242+
setSearchResults([]);
243+
setSelectedIds(new Set());
244+
setError(null);
245+
if (onBack) {
246+
onBack();
247+
} else {
248+
onClose();
249+
}
250+
}
251+
};
252+
236253
const handleKeyPress = (e: React.KeyboardEvent) => {
237254
if (e.key === 'Enter' && !searching) {
238255
handleSearch();
@@ -256,11 +273,7 @@ export default function MCPImportDialog({
256273
<Box display="flex" alignItems="center" gap={1}>
257274
<SearchIcon />
258275
<Typography variant="h6">
259-
Import from{' '}
260-
{tool?.tool_provider_type?.type_value
261-
? tool.tool_provider_type.type_value.charAt(0).toUpperCase() +
262-
tool.tool_provider_type.type_value.slice(1)
263-
: 'MCP'}
276+
Import from {tool?.name || 'MCP'}
264277
</Typography>
265278
</Box>
266279
<IconButton onClick={handleClose} disabled={isProcessing}>
@@ -303,7 +316,6 @@ export default function MCPImportDialog({
303316
startIcon={
304317
searching ? <CircularProgress size={20} /> : <SearchIcon />
305318
}
306-
sx={{ minWidth: '120px' }}
307319
>
308320
{searching ? 'Searching...' : 'Search'}
309321
</Button>
@@ -399,29 +411,33 @@ export default function MCPImportDialog({
399411
))}
400412
</List>
401413
</Paper>
402-
<Box sx={{ mt: 2, display: 'flex', justifyContent: 'flex-end' }}>
403-
<Button
404-
variant="contained"
405-
onClick={handleImportAsSources}
406-
disabled={selectedIds.size === 0 || importing}
407-
startIcon={
408-
importing ? <CircularProgress size={20} /> : <SaveIcon />
409-
}
410-
>
411-
{importing
412-
? 'Importing...'
413-
: `Import ${selectedIds.size} as Source${selectedIds.size !== 1 ? 's' : ''}`}
414-
</Button>
415-
</Box>
416414
</Box>
417415
)}
418416
</Box>
419417
</DialogContent>
420418

421-
<DialogActions sx={{ px: 3, pb: 2 }}>
422-
<Button onClick={handleClose} disabled={isProcessing}>
423-
Cancel
419+
<DialogActions sx={{ p: 3, pt: 1, justifyContent: 'space-between' }}>
420+
<Button
421+
onClick={handleBack}
422+
disabled={isProcessing}
423+
startIcon={<ArrowBackIcon />}
424+
>
425+
Back
424426
</Button>
427+
{searchResults.length > 0 && (
428+
<Button
429+
variant="contained"
430+
onClick={handleImportAsSources}
431+
disabled={selectedIds.size === 0 || importing}
432+
startIcon={
433+
importing ? <CircularProgress size={20} /> : <SaveIcon />
434+
}
435+
>
436+
{importing
437+
? 'Importing...'
438+
: `Import ${selectedIds.size} as Source${selectedIds.size !== 1 ? 's' : ''}`}
439+
</Button>
440+
)}
425441
</DialogActions>
426442
</Dialog>
427443
);

apps/frontend/src/app/(protected)/knowledge/components/MCPToolSelectorDialog.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import {
2121
} from '@mui/material';
2222
import CloseIcon from '@mui/icons-material/Close';
2323
import TerminalIcon from '@mui/icons-material/Terminal';
24+
import SmartToyIcon from '@mui/icons-material/SmartToy';
2425
import { ApiClientFactory } from '@/utils/api-client/client-factory';
2526
import { Tool } from '@/utils/api-client/interfaces/tool';
27+
import { MCP_PROVIDER_ICONS } from '@/config/mcp-providers';
2628

2729
interface MCPToolSelectorDialogProps {
2830
open: boolean;
@@ -111,6 +113,15 @@ export default function MCPToolSelectorDialog({
111113
}
112114
};
113115

116+
const getToolIcon = (tool: Tool) => {
117+
const providerName = tool.tool_provider_type?.type_value || 'custom';
118+
const providerIcon = MCP_PROVIDER_ICONS[providerName];
119+
if (providerIcon) {
120+
return providerIcon;
121+
}
122+
return <SmartToyIcon />;
123+
};
124+
114125
return (
115126
<Dialog open={open} onClose={handleClose} maxWidth="sm" fullWidth>
116127
<DialogTitle>
@@ -154,14 +165,16 @@ export default function MCPToolSelectorDialog({
154165
{index > 0 && <Divider />}
155166
<ListItem disablePadding>
156167
<ListItemButton onClick={() => handleSelectTool(tool)}>
157-
<ListItemIcon>
158-
<TerminalIcon />
159-
</ListItemIcon>
168+
<ListItemIcon>{getToolIcon(tool)}</ListItemIcon>
160169
<ListItemText
161170
primary={tool.name}
162171
secondary={
163-
tool.tool_provider_type?.type_value ||
164-
'Unknown provider'
172+
tool.tool_provider_type?.type_value
173+
? tool.tool_provider_type.type_value
174+
.charAt(0)
175+
.toUpperCase() +
176+
tool.tool_provider_type.type_value.slice(1)
177+
: 'Unknown provider'
165178
}
166179
primaryTypographyProps={{ fontWeight: 500 }}
167180
/>

apps/frontend/src/app/(protected)/knowledge/components/SourcesGrid.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,10 @@ export default function SourcesGrid({
582582
setMcpImportDialogOpen(false);
583583
setSelectedMCPTool(null);
584584
}}
585+
onBack={() => {
586+
setMcpImportDialogOpen(false);
587+
setMcpToolSelectorOpen(true);
588+
}}
585589
onSuccess={() => {
586590
fetchSources();
587591
setMcpImportDialogOpen(false);

0 commit comments

Comments
 (0)