Skip to content

Commit 4126aaf

Browse files
committed
feat: show integration name when not configured on block
1 parent c3eb62a commit 4126aaf

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

src/notebooks/deepnote/sqlCellStatusBarProvider.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,19 @@ export class SqlCellStatusBarProvider implements NotebookCellStatusBarItemProvid
202202

203203
// Get integration configuration to display the name
204204
const config = await this.integrationStorage.getProjectIntegrationConfig(projectId, integrationId);
205-
const displayName = config?.name || l10n.t('Unknown integration (configure)');
205+
206+
// Determine the display name
207+
let displayName: string;
208+
if (config?.name) {
209+
// Integration is configured, use the config name
210+
displayName = config.name;
211+
} else {
212+
// Integration is not configured, try to get the name from the project's integration list
213+
const project = this.notebookManager.getOriginalProject(projectId);
214+
const projectIntegration = project?.project.integrations?.find((i) => i.id === integrationId);
215+
const baseName = projectIntegration?.name || l10n.t('Unknown integration');
216+
displayName = l10n.t('{0} (configure)', baseName);
217+
}
206218

207219
// Create a status bar item that opens the integration picker
208220
return {

src/notebooks/deepnote/sqlCellStatusBarProvider.unit.test.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ suite('SqlCellStatusBarProvider', () => {
158158
assert.strictEqual(variableItem.priority, 90);
159159
});
160160

161-
test('shows "Unknown integration (configure)" when config not found', async () => {
161+
test('shows "Unknown integration (configure)" when config not found and not in project list', async () => {
162162
const integrationId = 'postgres-123';
163163
const cell = createMockCell(
164164
'sql',
@@ -171,6 +171,11 @@ suite('SqlCellStatusBarProvider', () => {
171171
);
172172

173173
when(integrationStorage.getProjectIntegrationConfig(anything(), anything())).thenResolve(undefined);
174+
when(notebookManager.getOriginalProject('project-1')).thenReturn({
175+
project: {
176+
integrations: []
177+
}
178+
} as any);
174179

175180
const result = await provider.provideCellStatusBarItems(cell, cancellationToken);
176181

@@ -188,6 +193,47 @@ suite('SqlCellStatusBarProvider', () => {
188193
assert.strictEqual(items[1].priority, 90);
189194
});
190195

196+
test('shows integration name from project list with (configure) suffix when config not found but integration is in project', async () => {
197+
const integrationId = 'postgres-123';
198+
const cell = createMockCell(
199+
'sql',
200+
{
201+
sql_integration_id: integrationId
202+
},
203+
{
204+
deepnoteProjectId: 'project-1'
205+
}
206+
);
207+
208+
when(integrationStorage.getProjectIntegrationConfig(anything(), anything())).thenResolve(undefined);
209+
when(notebookManager.getOriginalProject('project-1')).thenReturn({
210+
project: {
211+
integrations: [
212+
{
213+
id: integrationId,
214+
name: 'Production Database',
215+
type: 'pgsql'
216+
}
217+
]
218+
}
219+
} as any);
220+
221+
const result = await provider.provideCellStatusBarItems(cell, cancellationToken);
222+
223+
assert.isDefined(result);
224+
assert.isArray(result);
225+
const items = result as any[];
226+
assert.strictEqual(items.length, 2);
227+
assert.strictEqual(items[0].text, '$(database) Production Database (configure)');
228+
assert.strictEqual(items[0].alignment, 1);
229+
assert.strictEqual(items[0].command.command, 'deepnote.switchSqlIntegration');
230+
assert.deepStrictEqual(items[0].command.arguments, [cell]);
231+
assert.strictEqual(items[1].text, 'Variable: df');
232+
assert.strictEqual(items[1].alignment, 1);
233+
assert.strictEqual(items[1].command.command, 'deepnote.updateSqlVariableName');
234+
assert.strictEqual(items[1].priority, 90);
235+
});
236+
191237
test('returns only variable item when notebook has no project ID', async () => {
192238
const integrationId = 'postgres-123';
193239
const cell = createMockCell('sql', {

0 commit comments

Comments
 (0)