@mhjuma/traverse 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +46 -0
- package/src/bootstrap.spec.tsx +290 -0
- package/src/bootstrap.tsx +195 -0
- package/src/colors.ts +23 -0
- package/src/components/ChartPanel/ChartPanel.logic.spec.ts +358 -0
- package/src/components/ChartPanel/ChartPanel.logic.ts +318 -0
- package/src/components/ChartPanel/ChartPanel.spec.tsx +331 -0
- package/src/components/ChartPanel/ChartPanel.styles.ts +14 -0
- package/src/components/ChartPanel/ChartPanel.tsx +151 -0
- package/src/components/ConnectionDialog/ConnectionDialog.spec.tsx +767 -0
- package/src/components/ConnectionDialog/ConnectionDialog.tsx +652 -0
- package/src/components/ConnectionDialog/ConnectionRow.spec.tsx +104 -0
- package/src/components/ConnectionDialog/ConnectionRow.tsx +177 -0
- package/src/components/EditorToolbar/EditorToolbar.spec.tsx +599 -0
- package/src/components/EditorToolbar/EditorToolbar.tsx +259 -0
- package/src/components/Explorer/Explorer.spec.tsx +615 -0
- package/src/components/Explorer/Explorer.tsx +49 -0
- package/src/components/ExplorerWorkspace/ExplorerWorkspace.logic.spec.ts +715 -0
- package/src/components/ExplorerWorkspace/ExplorerWorkspace.logic.ts +324 -0
- package/src/components/ExplorerWorkspace/ExplorerWorkspace.spec.tsx +450 -0
- package/src/components/ExplorerWorkspace/ExplorerWorkspace.styles.ts +478 -0
- package/src/components/ExplorerWorkspace/ExplorerWorkspace.tsx +648 -0
- package/src/components/ExplorerWorkspace/kqlLanguage.spec.ts +321 -0
- package/src/components/ExplorerWorkspace/kqlLanguage.ts +155 -0
- package/src/components/ResultsPanel/ElapsedTimer.spec.tsx +51 -0
- package/src/components/ResultsPanel/ElapsedTimer.tsx +15 -0
- package/src/components/ResultsPanel/HistoryItem.spec.tsx +123 -0
- package/src/components/ResultsPanel/HistoryItem.tsx +56 -0
- package/src/components/ResultsPanel/ResultSetTab.tsx +18 -0
- package/src/components/ResultsPanel/ResultsPanel.spec.tsx +1194 -0
- package/src/components/ResultsPanel/ResultsPanel.tsx +321 -0
- package/src/components/ResultsPanel/TabButton.tsx +11 -0
- package/src/components/ResultsTable/ColumnHeader.tsx +42 -0
- package/src/components/ResultsTable/ColumnPickerItem.tsx +16 -0
- package/src/components/ResultsTable/FilterCell.tsx +24 -0
- package/src/components/ResultsTable/ResultsTable.logic.spec.ts +655 -0
- package/src/components/ResultsTable/ResultsTable.logic.ts +264 -0
- package/src/components/ResultsTable/ResultsTable.spec.tsx +930 -0
- package/src/components/ResultsTable/ResultsTable.styles.ts +108 -0
- package/src/components/ResultsTable/ResultsTable.tsx +501 -0
- package/src/components/ResultsTable/VirtualCell.spec.tsx +55 -0
- package/src/components/ResultsTable/VirtualCell.tsx +32 -0
- package/src/components/ResultsTable/VirtualRow.tsx +55 -0
- package/src/components/SchemaSidebar/FolderRow.tsx +35 -0
- package/src/components/SchemaSidebar/SchemaColumnItem.tsx +41 -0
- package/src/components/SchemaSidebar/SchemaContextMenu.spec.tsx +148 -0
- package/src/components/SchemaSidebar/SchemaContextMenu.tsx +49 -0
- package/src/components/SchemaSidebar/SchemaSidebar.logic.spec.ts +230 -0
- package/src/components/SchemaSidebar/SchemaSidebar.logic.ts +74 -0
- package/src/components/SchemaSidebar/SchemaSidebar.spec.tsx +1111 -0
- package/src/components/SchemaSidebar/SchemaSidebar.tsx +244 -0
- package/src/components/SchemaSidebar/SchemaTableItem.tsx +77 -0
- package/src/components/TabBar/TabBar.logic.spec.ts +127 -0
- package/src/components/TabBar/TabBar.logic.ts +35 -0
- package/src/components/TabBar/TabBar.spec.tsx +929 -0
- package/src/components/TabBar/TabBar.tsx +284 -0
- package/src/components/TabBar/TabItem.tsx +166 -0
- package/src/components/VegaChart/VegaChart.spec.tsx +126 -0
- package/src/components/VegaChart/VegaChart.tsx +224 -0
- package/src/config.spec.ts +44 -0
- package/src/config.ts +47 -0
- package/src/context/ExplorerColorContext.ts +14 -0
- package/src/context/ExplorerStateContext.ts +49 -0
- package/src/context/KustoClientContext.ts +12 -0
- package/src/context/context.spec.tsx +183 -0
- package/src/index.ts +14 -0
- package/src/services/cache.spec.ts +31 -0
- package/src/services/cache.ts +16 -0
- package/src/services/concurrency.spec.ts +139 -0
- package/src/services/concurrency.ts +46 -0
- package/src/services/kusto.spec.ts +919 -0
- package/src/services/kusto.ts +472 -0
- package/src/services/queryHistory.spec.ts +287 -0
- package/src/services/queryHistory.ts +146 -0
- package/src/services/schema.spec.ts +618 -0
- package/src/services/schema.ts +294 -0
- package/src/services/state-service.spec.ts +670 -0
- package/src/services/state-service.ts +602 -0
- package/src/services/useKustoQuery.spec.ts +234 -0
- package/src/services/useKustoQuery.ts +124 -0
- package/src/state/actions.ts +50 -0
- package/src/state/index.ts +3 -0
- package/src/state/reducer.spec.ts +644 -0
- package/src/state/reducer.ts +207 -0
- package/src/state/types.ts +54 -0
- package/tsconfig.json +7 -0
- package/tsconfig.lint.json +4 -0
- package/tsconfig.spec.json +7 -0
- package/vitest.config.ts +34 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import { act } from 'react';
|
|
6
|
+
import { ConnectionRow } from './ConnectionRow';
|
|
7
|
+
|
|
8
|
+
vi.mock('@fluentui/react-components', () => ({
|
|
9
|
+
Button: (p: Record<string, unknown>) => React.createElement('button', { onClick: p['onClick'] as (() => void) | undefined, 'data-testid': 'btn' }, p['icon'] as React.ReactNode),
|
|
10
|
+
Input: (p: Record<string, unknown>) => {
|
|
11
|
+
const onChange = p['onChange'] as ((e: unknown, d: { value: string }) => void) | undefined;
|
|
12
|
+
return React.createElement('input', { value: p['value'] as string, onChange: (e: React.ChangeEvent<HTMLInputElement>) => onChange?.(e, { value: e.target.value }), readOnly: p['readOnly'] as boolean });
|
|
13
|
+
},
|
|
14
|
+
Dropdown: (p: Record<string, unknown>) => {
|
|
15
|
+
const onOpenChange = p['onOpenChange'] as ((e: unknown, d: { open: boolean }) => void) | undefined;
|
|
16
|
+
const onOptionSelect = p['onOptionSelect'] as ((e: unknown, d: { optionValue?: string }) => void) | undefined;
|
|
17
|
+
return React.createElement('select', { 'data-testid': 'dropdown', onFocus: () => onOpenChange?.(null, { open: true }), onChange: (e: React.ChangeEvent<HTMLSelectElement>) => onOptionSelect?.(e, { optionValue: e.target.value }) });
|
|
18
|
+
},
|
|
19
|
+
Option: (p: Record<string, unknown>) => React.createElement('option', { value: p['value'] as string }, p['children'] as string),
|
|
20
|
+
Spinner: () => React.createElement('span', null, 'Loading...'),
|
|
21
|
+
Tooltip: (p: Record<string, unknown>) => React.createElement('span', null, p['children'] as React.ReactNode),
|
|
22
|
+
tokens: new Proxy({}, { get: (_, p) => String(p) }),
|
|
23
|
+
makeStyles: () => () => new Proxy({}, { get: (_, p) => String(p) }),
|
|
24
|
+
}));
|
|
25
|
+
vi.mock('@fluentui/react-icons', () => ({
|
|
26
|
+
DeleteRegular: () => React.createElement('span', null, '🗑'),
|
|
27
|
+
ReOrderDotsVerticalRegular: () => React.createElement('span', null, '⋮'),
|
|
28
|
+
ArrowSyncRegular: () => React.createElement('span', null, '🔄'),
|
|
29
|
+
}));
|
|
30
|
+
vi.mock('../ExplorerWorkspace/ExplorerWorkspace.logic', () => ({
|
|
31
|
+
CONNECTION_COLORS: ['#aaa', '#bbb', '#ccc'],
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
let container: HTMLDivElement;
|
|
35
|
+
let root: ReturnType<typeof createRoot>;
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
39
|
+
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
40
|
+
container = document.createElement('div');
|
|
41
|
+
document.body.appendChild(container);
|
|
42
|
+
root = createRoot(container);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
act(() => { root.unmount(); });
|
|
47
|
+
container.remove();
|
|
48
|
+
vi.restoreAllMocks();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const baseConn = { id: 'c1', name: 'Test', clusterUrl: 'https://test.kusto.windows.net', database: 'DB1', color: '#aaa' };
|
|
52
|
+
const baseProps = {
|
|
53
|
+
conn: baseConn, idx: 0, canDelete: true, databases: ['DB1', 'DB2'], dbLoading: false, dbLoadFailed: false, isDragOver: false,
|
|
54
|
+
isNew: false, validationStatus: 'none' as const,
|
|
55
|
+
onUpdate: vi.fn(), onRemove: vi.fn(), onLoadDatabases: vi.fn(), onRefreshSchema: vi.fn(), onDragStart: vi.fn(), onDragOver: vi.fn(), onDragEnd: vi.fn(),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
describe('ConnectionRow', () => {
|
|
59
|
+
it('renders connection name and cluster URL', () => {
|
|
60
|
+
act(() => { root.render(React.createElement(ConnectionRow, baseProps)); });
|
|
61
|
+
const inputs = container.querySelectorAll('input');
|
|
62
|
+
expect(inputs.length).toBeGreaterThanOrEqual(2);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('calls onRemove when delete button clicked', () => {
|
|
66
|
+
const onRemove = vi.fn();
|
|
67
|
+
act(() => { root.render(React.createElement(ConnectionRow, { ...baseProps, onRemove })); });
|
|
68
|
+
const buttons = container.querySelectorAll('button[data-testid="btn"]');
|
|
69
|
+
const deleteBtn = buttons[buttons.length - 1];
|
|
70
|
+
act(() => { deleteBtn?.dispatchEvent(new MouseEvent('click', { bubbles: true })); });
|
|
71
|
+
expect(onRemove).toHaveBeenCalledWith('c1');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('cycles color on dot click', () => {
|
|
75
|
+
const onUpdate = vi.fn();
|
|
76
|
+
act(() => { root.render(React.createElement(ConnectionRow, { ...baseProps, onUpdate })); });
|
|
77
|
+
const dot = container.querySelector('[role="menuitem"]');
|
|
78
|
+
act(() => { dot?.dispatchEvent(new MouseEvent('click', { bubbles: true })); });
|
|
79
|
+
expect(onUpdate).toHaveBeenCalledWith('c1', 'color', '#bbb');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('cycles color on dot Enter key', () => {
|
|
83
|
+
const onUpdate = vi.fn();
|
|
84
|
+
act(() => { root.render(React.createElement(ConnectionRow, { ...baseProps, onUpdate })); });
|
|
85
|
+
const dot = container.querySelector('[role="menuitem"]');
|
|
86
|
+
act(() => { dot?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })); });
|
|
87
|
+
expect(onUpdate).toHaveBeenCalledWith('c1', 'color', '#bbb');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('shows spinner when dbLoading is true', () => {
|
|
91
|
+
act(() => { root.render(React.createElement(ConnectionRow, { ...baseProps, dbLoading: true, databases: [] })); });
|
|
92
|
+
expect(container.textContent).toContain('Loading...');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('calls onDragStart on drag handle', () => {
|
|
96
|
+
const onDragStart = vi.fn();
|
|
97
|
+
act(() => { root.render(React.createElement(ConnectionRow, { ...baseProps, onDragStart })); });
|
|
98
|
+
const handle = container.querySelector('[draggable]');
|
|
99
|
+
if (handle) {
|
|
100
|
+
act(() => { handle.dispatchEvent(new Event('dragstart', { bubbles: true })); });
|
|
101
|
+
expect(onDragStart).toHaveBeenCalledWith(0);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Button, Input, Dropdown, Option, Spinner, Tooltip, tokens, makeStyles } from '@fluentui/react-components';
|
|
2
|
+
import { DeleteRegular, ReOrderDotsVerticalRegular, ArrowSyncRegular } from '@fluentui/react-icons';
|
|
3
|
+
import React, { useCallback, useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { KustoConnection } from '../ExplorerWorkspace/ExplorerWorkspace.logic';
|
|
6
|
+
import { CONNECTION_COLORS } from '../ExplorerWorkspace/ExplorerWorkspace.logic';
|
|
7
|
+
|
|
8
|
+
export type ValidationStatus = 'none' | 'validating' | 'valid' | 'invalid';
|
|
9
|
+
|
|
10
|
+
const rowStyle = { display: 'flex', gap: '6px', alignItems: 'flex-end', padding: '6px 0', borderBottom: `1px solid ${tokens.colorNeutralStroke2}` } as const;
|
|
11
|
+
const dragHandleStyle = { cursor: 'grab', color: tokens.colorNeutralForeground4, marginBottom: '6px', flexShrink: 0 } as const;
|
|
12
|
+
const rowDragOverStyle = { display: 'flex', gap: '6px', alignItems: 'flex-end', padding: '6px 0', borderBottom: `1px solid ${tokens.colorNeutralStroke2}`, borderTop: `2px solid ${tokens.colorBrandForeground1}` } as const;
|
|
13
|
+
const labelStyle = { fontSize: '10px', color: tokens.colorNeutralForeground3, marginBottom: '1px' } as const;
|
|
14
|
+
const nameFieldStyle = { width: '140px', flexShrink: 0, display: 'flex', flexDirection: 'column' as const, gap: '2px' } as const;
|
|
15
|
+
const urlFieldStyle = { flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column' as const, gap: '2px' } as const;
|
|
16
|
+
const dbFieldStyle = { width: '200px', flexShrink: 0, display: 'flex', flexDirection: 'column' as const, gap: '2px', overflow: 'hidden' } as const;
|
|
17
|
+
const dbDropdownStyle = { minWidth: '180px', maxWidth: '200px' } as const;
|
|
18
|
+
|
|
19
|
+
const useDbDropdownStyles = makeStyles({
|
|
20
|
+
root: {},
|
|
21
|
+
listbox: {
|
|
22
|
+
width: 'auto !important' as unknown as string,
|
|
23
|
+
minWidth: '200px',
|
|
24
|
+
maxWidth: '400px',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const colorDotStyle = (color: string) => ({
|
|
28
|
+
width: '16px', height: '16px', borderRadius: '50%', backgroundColor: color, cursor: 'pointer',
|
|
29
|
+
border: `2px solid ${tokens.colorNeutralStroke1}`, flexShrink: 0, marginBottom: '6px',
|
|
30
|
+
}) as const;
|
|
31
|
+
const deleteButtonStyle = { minWidth: 'auto', marginBottom: '2px' } as const;
|
|
32
|
+
const dbLoadFailedButtonStyle = { width: '100%', justifyContent: 'flex-start', fontSize: '12px', color: tokens.colorPaletteRedForeground1 } as const;
|
|
33
|
+
const loadDbButtonStyle = { width: '100%', justifyContent: 'flex-start', fontSize: '12px', color: tokens.colorNeutralForeground3 } as const;
|
|
34
|
+
const readOnlyInputStyle = { opacity: 0.7 } as const;
|
|
35
|
+
const statusIndicatorStyle = { flexShrink: 0, marginBottom: '6px', fontSize: '14px', width: '18px', textAlign: 'center' as const } as const;
|
|
36
|
+
const statusValidStyle = { ...statusIndicatorStyle, color: tokens.colorPaletteGreenForeground1 } as const;
|
|
37
|
+
const statusInvalidStyle = { ...statusIndicatorStyle, color: tokens.colorPaletteRedForeground1 } as const;
|
|
38
|
+
const deleteIcon = <DeleteRegular />;
|
|
39
|
+
const refreshIcon = <ArrowSyncRegular />;
|
|
40
|
+
|
|
41
|
+
export interface ConnectionRowProps {
|
|
42
|
+
conn: KustoConnection;
|
|
43
|
+
idx: number;
|
|
44
|
+
isNew?: boolean;
|
|
45
|
+
canDelete: boolean;
|
|
46
|
+
databases: string[];
|
|
47
|
+
dbLoading: boolean;
|
|
48
|
+
dbLoadFailed: boolean;
|
|
49
|
+
isDragOver: boolean;
|
|
50
|
+
validationStatus?: ValidationStatus;
|
|
51
|
+
onUpdate: (id: string, field: keyof KustoConnection, value: string) => void;
|
|
52
|
+
onRemove: (id: string) => void;
|
|
53
|
+
onLoadDatabases: (clusterUrl: string) => void;
|
|
54
|
+
onRefreshSchema: (clusterUrl: string, database: string) => void;
|
|
55
|
+
onDragStart: (idx: number) => void;
|
|
56
|
+
onDragOver: (idx: number) => void;
|
|
57
|
+
onDragEnd: () => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function ConnectionRow({ conn, idx, isNew = false, canDelete, databases, dbLoading, dbLoadFailed, isDragOver, validationStatus = 'none', onUpdate, onRemove, onLoadDatabases, onRefreshSchema, onDragStart, onDragOver, onDragEnd }: ConnectionRowProps) {
|
|
61
|
+
const dbStyles = useDbDropdownStyles();
|
|
62
|
+
const listboxProp = useMemo(() => ({ className: dbStyles.listbox }), [dbStyles.listbox]);
|
|
63
|
+
const selectedDbOptions = useMemo(() => conn.database ? [conn.database] : [], [conn.database]);
|
|
64
|
+
const selectedDbSingle = useMemo(() => [conn.database], [conn.database]);
|
|
65
|
+
const handleNameChange = useCallback((_: unknown, d: { value: string }) => onUpdate(conn.id, 'name', d.value), [onUpdate, conn.id]);
|
|
66
|
+
const handleUrlChange = useCallback((_: unknown, d: { value: string }) => onUpdate(conn.id, 'clusterUrl', d.value), [onUpdate, conn.id]);
|
|
67
|
+
const handleRemove = useCallback(() => onRemove(conn.id), [onRemove, conn.id]);
|
|
68
|
+
const handleDragStart = useCallback(() => onDragStart(idx), [onDragStart, idx]);
|
|
69
|
+
const handleDragOver = useCallback((e: React.DragEvent) => { e.preventDefault(); onDragOver(idx); }, [onDragOver, idx]);
|
|
70
|
+
const handleColorCycle = useCallback(() => {
|
|
71
|
+
const idx2 = CONNECTION_COLORS.indexOf(conn.color);
|
|
72
|
+
const next = CONNECTION_COLORS[(idx2 + 1) % CONNECTION_COLORS.length];
|
|
73
|
+
onUpdate(conn.id, 'color', next);
|
|
74
|
+
}, [onUpdate, conn.id, conn.color]);
|
|
75
|
+
const handleColorKeyDown = useCallback((e: React.KeyboardEvent) => {
|
|
76
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
77
|
+
handleColorCycle();
|
|
78
|
+
}
|
|
79
|
+
}, [handleColorCycle]);
|
|
80
|
+
const handleDbSelect = useCallback((_: unknown, data: { optionValue?: string }) => {
|
|
81
|
+
if (data.optionValue) {
|
|
82
|
+
onUpdate(conn.id, 'database', data.optionValue);
|
|
83
|
+
}
|
|
84
|
+
}, [onUpdate, conn.id]);
|
|
85
|
+
const handleDbDropdownOpen = useCallback(() => {
|
|
86
|
+
onLoadDatabases(conn.clusterUrl);
|
|
87
|
+
}, [onLoadDatabases, conn.clusterUrl]);
|
|
88
|
+
|
|
89
|
+
const handleRefresh = useCallback(() => {
|
|
90
|
+
onRefreshSchema(conn.clusterUrl, conn.database);
|
|
91
|
+
}, [onRefreshSchema, conn.clusterUrl, conn.database]);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div style={isDragOver ? rowDragOverStyle : rowStyle}
|
|
95
|
+
draggable onDragStart={handleDragStart} onDragOver={handleDragOver} onDragEnd={onDragEnd}>
|
|
96
|
+
<ReOrderDotsVerticalRegular style={dragHandleStyle} />
|
|
97
|
+
<Tooltip content="Click to change color" relationship="label">
|
|
98
|
+
<div style={colorDotStyle(conn.color)} role="menuitem" tabIndex={0} onClick={handleColorCycle} onKeyDown={handleColorKeyDown} />
|
|
99
|
+
</Tooltip>
|
|
100
|
+
<div style={nameFieldStyle}>
|
|
101
|
+
<div style={labelStyle}>Name</div>
|
|
102
|
+
<Input size="small" value={conn.name} onChange={handleNameChange} />
|
|
103
|
+
</div>
|
|
104
|
+
<div style={urlFieldStyle}>
|
|
105
|
+
<div style={labelStyle}>Cluster URL</div>
|
|
106
|
+
{isNew ? (
|
|
107
|
+
<Input size="small" value={conn.clusterUrl} onChange={handleUrlChange}
|
|
108
|
+
placeholder="https://mycluster.kusto.windows.net" />
|
|
109
|
+
) : (
|
|
110
|
+
<Input size="small" value={conn.clusterUrl} readOnly style={readOnlyInputStyle} />
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
<div style={dbFieldStyle}>
|
|
114
|
+
<div style={labelStyle}>Database</div>
|
|
115
|
+
{dbLoading ? (
|
|
116
|
+
<Spinner size="tiny" />
|
|
117
|
+
) : databases.length > 0 ? (
|
|
118
|
+
<div className={dbStyles.root}>
|
|
119
|
+
<Dropdown size="small" style={dbDropdownStyle}
|
|
120
|
+
positioning="below-end"
|
|
121
|
+
listbox={listboxProp}
|
|
122
|
+
value={conn.database || 'Select…'}
|
|
123
|
+
selectedOptions={selectedDbOptions}
|
|
124
|
+
onOptionSelect={handleDbSelect}>
|
|
125
|
+
{databases.map((db) => (
|
|
126
|
+
<Option key={db} value={db} text={db}>{db}</Option>
|
|
127
|
+
))}
|
|
128
|
+
</Dropdown>
|
|
129
|
+
</div>
|
|
130
|
+
) : conn.database ? (
|
|
131
|
+
<div className={dbStyles.root}>
|
|
132
|
+
<Dropdown size="small" style={dbDropdownStyle}
|
|
133
|
+
positioning="below-end"
|
|
134
|
+
listbox={listboxProp}
|
|
135
|
+
value={conn.database}
|
|
136
|
+
selectedOptions={selectedDbSingle}
|
|
137
|
+
onOptionSelect={handleDbSelect}
|
|
138
|
+
onOpenChange={handleDbDropdownOpen}>
|
|
139
|
+
<Option key={conn.database} value={conn.database} text={conn.database}>{conn.database}</Option>
|
|
140
|
+
</Dropdown>
|
|
141
|
+
</div>
|
|
142
|
+
) : dbLoadFailed ? (
|
|
143
|
+
<Button appearance="subtle" size="small" onClick={handleDbDropdownOpen}
|
|
144
|
+
style={dbLoadFailedButtonStyle}>
|
|
145
|
+
Failed — retry
|
|
146
|
+
</Button>
|
|
147
|
+
) : (
|
|
148
|
+
<Button appearance="subtle" size="small" onClick={handleDbDropdownOpen}
|
|
149
|
+
style={loadDbButtonStyle}>
|
|
150
|
+
Load databases…
|
|
151
|
+
</Button>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
<div style={statusIndicatorStyle}>
|
|
155
|
+
{validationStatus === 'validating' && <Spinner size="tiny" />}
|
|
156
|
+
{validationStatus === 'valid' && <span style={statusValidStyle}>✓</span>}
|
|
157
|
+
{validationStatus === 'invalid' && (
|
|
158
|
+
<Tooltip content="Connection failed — unreachable or unauthorized" relationship="label">
|
|
159
|
+
<span style={statusInvalidStyle}>✗</span>
|
|
160
|
+
</Tooltip>
|
|
161
|
+
)}
|
|
162
|
+
</div>
|
|
163
|
+
{!isNew && conn.database && (
|
|
164
|
+
<Tooltip content="Refresh schema" relationship="label">
|
|
165
|
+
<Button appearance="subtle" icon={refreshIcon} size="small"
|
|
166
|
+
onClick={handleRefresh} style={deleteButtonStyle} />
|
|
167
|
+
</Tooltip>
|
|
168
|
+
)}
|
|
169
|
+
{canDelete && (
|
|
170
|
+
<Tooltip content="Remove" relationship="label">
|
|
171
|
+
<Button appearance="subtle" icon={deleteIcon} size="small"
|
|
172
|
+
onClick={handleRemove} style={deleteButtonStyle} />
|
|
173
|
+
</Tooltip>
|
|
174
|
+
)}
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|