Skip to content

Commit 56b91ca

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

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ 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

@@ -103,6 +104,8 @@ export class IntegrationWebviewProvider implements IIntegrationWebviewProvider {
103104
id,
104105
status: integration.status
105106
}));
107+
logger.debug(`IntegrationWebviewProvider: Sending ${integrationsData.length} integrations to webview`);
108+
logger.trace('IntegrationWebviewProvider: Integration data:', JSON.stringify(integrationsData, null, 2));
106109

107110
await this.currentPanel.webview.postMessage({
108111
integrations: integrationsData,

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)