Skip to content

Commit fdc914b

Browse files
committed
working button on sql block
1 parent 64f3aa8 commit fdc914b

File tree

4 files changed

+67
-8
lines changed

4 files changed

+67
-8
lines changed

src/notebooks/deepnote/integrations/integrationManager.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,26 @@ export class IntegrationManager implements IIntegrationManager {
2727
public activate(): void {
2828
// Register the manage integrations command
2929
// The command can optionally receive an integration ID to select/configure
30+
// Note: When invoked from a notebook cell status bar, VSCode passes context object first,
31+
// then the actual arguments from the command definition
3032
this.extensionContext.subscriptions.push(
31-
commands.registerCommand(Commands.ManageIntegrations, (integrationId?: string) =>
32-
this.showIntegrationsUI(integrationId)
33-
)
33+
commands.registerCommand(Commands.ManageIntegrations, (...args: unknown[]) => {
34+
logger.debug(`IntegrationManager: Command invoked with args:`, args);
35+
36+
// Find the integration ID from the arguments
37+
// It could be the first arg (if called directly) or in the args array (if called from UI)
38+
let integrationId: string | undefined;
39+
40+
for (const arg of args) {
41+
if (typeof arg === 'string') {
42+
integrationId = arg;
43+
break;
44+
}
45+
}
46+
47+
logger.debug(`IntegrationManager: Extracted integrationId: ${integrationId}`);
48+
return this.showIntegrationsUI(integrationId);
49+
})
3450
);
3551

3652
// Listen for active notebook changes to update context
@@ -129,6 +145,17 @@ export class IntegrationManager implements IIntegrationManager {
129145

130146
logger.debug(`IntegrationManager: Found ${integrations.size} integrations`);
131147

148+
// If a specific integration was requested (e.g., from status bar click),
149+
// ensure it's in the map even if not detected from the project
150+
if (selectedIntegrationId && !integrations.has(selectedIntegrationId)) {
151+
logger.debug(`IntegrationManager: Adding requested integration ${selectedIntegrationId} to the map`);
152+
const config = await this.integrationStorage.get(selectedIntegrationId);
153+
integrations.set(selectedIntegrationId, {
154+
config: config || null,
155+
status: config ? IntegrationStatus.Connected : IntegrationStatus.Disconnected
156+
});
157+
}
158+
132159
if (integrations.size === 0) {
133160
void window.showInformationMessage(`No integrations found in this project.`);
134161
return;

src/notebooks/deepnote/integrations/integrationWebview.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,42 @@ export class IntegrationWebviewProvider implements IIntegrationWebviewProvider {
9595
*/
9696
private async updateWebview(): Promise<void> {
9797
if (!this.currentPanel) {
98+
logger.debug('IntegrationWebviewProvider: No current panel, skipping update');
9899
return;
99100
}
100101

101-
const integrationsData = Array.from(this.integrations.entries()).map(([id, integration]) => ({
102-
config: integration.config,
103-
id,
104-
status: integration.status
105-
}));
102+
const integrationsData = Array.from(this.integrations.entries()).map(([id, integration]) => {
103+
// Ensure we're sending plain objects, not enums or other complex types
104+
const plainConfig = integration.config
105+
? {
106+
id: integration.config.id,
107+
name: integration.config.name,
108+
type: String(integration.config.type), // Convert enum to string
109+
...(integration.config.type === 'postgres'
110+
? {
111+
host: (integration.config as any).host,
112+
port: (integration.config as any).port,
113+
database: (integration.config as any).database,
114+
username: (integration.config as any).username,
115+
password: (integration.config as any).password,
116+
ssl: (integration.config as any).ssl
117+
}
118+
: {
119+
projectId: (integration.config as any).projectId,
120+
credentials: (integration.config as any).credentials
121+
})
122+
}
123+
: null;
124+
125+
return {
126+
id,
127+
config: plainConfig,
128+
status: String(integration.status) // Convert enum to string
129+
};
130+
});
131+
132+
logger.debug(`IntegrationWebviewProvider: Sending ${integrationsData.length} integrations to webview`);
133+
logger.trace('IntegrationWebviewProvider: Integration data:', JSON.stringify(integrationsData, null, 2));
106134

107135
await this.currentPanel.webview.postMessage({
108136
integrations: integrationsData,

src/webviews/webview-side/integrations/IntegrationItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const IntegrationItem: React.FC<IIntegrationItemProps> = ({ integration,
1212
const statusText = integration.status === 'connected' ? 'Connected' : 'Not Configured';
1313
const configureText = integration.config ? 'Reconfigure' : 'Configure';
1414
const displayName = integration.config?.name || integration.id;
15+
console.log('INTGGGG', integration);
1516

1617
return (
1718
<div className="integration-item">

src/webviews/webview-side/integrations/IntegrationPanel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ export const IntegrationPanel: React.FC<IIntegrationPanelProps> = ({ baseTheme,
3737
React.useEffect(() => {
3838
const handleMessage = (event: MessageEvent<WebviewMessage>) => {
3939
const msg = event.data;
40+
console.log('IntegrationPanel: Received message:', msg);
4041

4142
switch (msg.type) {
4243
case 'update':
44+
console.log('IntegrationPanel: Updating integrations:', msg.integrations);
4345
setIntegrations(msg.integrations);
4446
break;
4547

@@ -66,6 +68,7 @@ export const IntegrationPanel: React.FC<IIntegrationPanelProps> = ({ baseTheme,
6668
}
6769
};
6870

71+
console.log('IntegrationPanel: Component mounted, adding message listener');
6972
window.addEventListener('message', handleMessage);
7073
return () => window.removeEventListener('message', handleMessage);
7174
}, []);

0 commit comments

Comments
 (0)