Skip to content

Commit 7382903

Browse files
committed
Merge remote-tracking branch 'origin/main' into tk/fix-dataframe-renderer
Signed-off-by: Tomas Kislan <[email protected]>
2 parents 40cb432 + 065b4c0 commit 7382903

21 files changed

+1432
-155
lines changed

package-lock.json

Lines changed: 61 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/messageTypes.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ export type LocalizedMessages = {
182182
// Integration type labels
183183
integrationsPostgresTypeLabel: string;
184184
integrationsBigQueryTypeLabel: string;
185+
integrationsSnowflakeTypeLabel: string;
185186
// PostgreSQL form strings
186187
integrationsPostgresNameLabel: string;
187188
integrationsPostgresNamePlaceholder: string;
@@ -204,9 +205,36 @@ export type LocalizedMessages = {
204205
integrationsBigQueryCredentialsLabel: string;
205206
integrationsBigQueryCredentialsPlaceholder: string;
206207
integrationsBigQueryCredentialsRequired: string;
208+
// Snowflake form strings
209+
integrationsSnowflakeNameLabel: string;
210+
integrationsSnowflakeNamePlaceholder: string;
211+
integrationsSnowflakeAccountLabel: string;
212+
integrationsSnowflakeAccountPlaceholder: string;
213+
integrationsSnowflakeAuthMethodLabel: string;
214+
integrationsSnowflakeAuthMethodSubLabel: string;
215+
integrationsSnowflakeAuthMethodUsernamePassword: string;
216+
integrationsSnowflakeAuthMethodKeyPair: string;
217+
integrationsSnowflakeUnsupportedAuthMethod: string;
218+
integrationsSnowflakeUsernameLabel: string;
219+
integrationsSnowflakePasswordLabel: string;
220+
integrationsSnowflakePasswordPlaceholder: string;
221+
integrationsSnowflakeServiceAccountUsernameLabel: string;
222+
integrationsSnowflakeServiceAccountUsernameHelp: string;
223+
integrationsSnowflakePrivateKeyLabel: string;
224+
integrationsSnowflakePrivateKeyHelp: string;
225+
integrationsSnowflakePrivateKeyPlaceholder: string;
226+
integrationsSnowflakePrivateKeyPassphraseLabel: string;
227+
integrationsSnowflakePrivateKeyPassphraseHelp: string;
228+
integrationsSnowflakeDatabaseLabel: string;
229+
integrationsSnowflakeDatabasePlaceholder: string;
230+
integrationsSnowflakeRoleLabel: string;
231+
integrationsSnowflakeRolePlaceholder: string;
232+
integrationsSnowflakeWarehouseLabel: string;
233+
integrationsSnowflakeWarehousePlaceholder: string;
207234
// Common form strings
208235
integrationsRequiredField: string;
209236
integrationsOptionalField: string;
237+
integrationsUnnamedIntegration: string;
210238
};
211239
// Map all messages to specific payloads
212240
export class IInteractiveWindowMapping {

src/notebooks/deepnote/deepnoteSerializer.ts

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { l10n, workspace, type CancellationToken, type NotebookData, type Notebo
55
import { logger } from '../../platform/logging';
66
import { IDeepnoteNotebookManager } from '../types';
77
import { DeepnoteDataConverter } from './deepnoteDataConverter';
8-
import type { DeepnoteProject } from '../../platform/deepnote/deepnoteTypes';
8+
import type { DeepnoteFile, DeepnoteNotebook } from '../../platform/deepnote/deepnoteTypes';
99

1010
export { DeepnoteBlock, DeepnoteNotebook, DeepnoteOutput, DeepnoteFile } from '../../platform/deepnote/deepnoteTypes';
1111

@@ -44,20 +44,24 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
4444

4545
try {
4646
const contentString = new TextDecoder('utf-8').decode(content);
47-
const deepnoteProject = yaml.load(contentString) as DeepnoteProject;
47+
const deepnoteFile = yaml.load(contentString) as DeepnoteFile;
4848

49-
if (!deepnoteProject.project?.notebooks) {
49+
if (!deepnoteFile.project?.notebooks) {
5050
throw new Error('Invalid Deepnote file: no notebooks found');
5151
}
5252

53-
const projectId = deepnoteProject.project.id;
53+
const projectId = deepnoteFile.project.id;
5454
const notebookId = this.findCurrentNotebookId(projectId);
5555

5656
logger.debug(`DeepnoteSerializer: Project ID: ${projectId}, Selected notebook ID: ${notebookId}`);
5757

58+
if (deepnoteFile.project.notebooks.length === 0) {
59+
throw new Error('Deepnote project contains no notebooks.');
60+
}
61+
5862
const selectedNotebook = notebookId
59-
? deepnoteProject.project.notebooks.find((nb) => nb.id === notebookId)
60-
: deepnoteProject.project.notebooks[0];
63+
? deepnoteFile.project.notebooks.find((nb) => nb.id === notebookId)
64+
: this.findDefaultNotebook(deepnoteFile);
6165

6266
if (!selectedNotebook) {
6367
throw new Error(l10n.t('No notebook selected or found'));
@@ -67,17 +71,17 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
6771

6872
logger.debug(`DeepnoteSerializer: Converted ${cells.length} cells from notebook blocks`);
6973

70-
this.notebookManager.storeOriginalProject(deepnoteProject.project.id, deepnoteProject, selectedNotebook.id);
74+
this.notebookManager.storeOriginalProject(deepnoteFile.project.id, deepnoteFile, selectedNotebook.id);
7175
logger.debug(`DeepnoteSerializer: Stored project ${projectId} in notebook manager`);
7276

7377
return {
7478
cells,
7579
metadata: {
76-
deepnoteProjectId: deepnoteProject.project.id,
77-
deepnoteProjectName: deepnoteProject.project.name,
80+
deepnoteProjectId: deepnoteFile.project.id,
81+
deepnoteProjectName: deepnoteFile.project.name,
7882
deepnoteNotebookId: selectedNotebook.id,
7983
deepnoteNotebookName: selectedNotebook.name,
80-
deepnoteVersion: deepnoteProject.version,
84+
deepnoteVersion: deepnoteFile.version,
8185
name: selectedNotebook.name,
8286
display_name: selectedNotebook.name
8387
}
@@ -110,7 +114,7 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
110114
throw new Error('Missing Deepnote project ID in notebook metadata');
111115
}
112116

113-
const originalProject = this.notebookManager.getOriginalProject(projectId) as DeepnoteProject | undefined;
117+
const originalProject = this.notebookManager.getOriginalProject(projectId) as DeepnoteFile | undefined;
114118

115119
if (!originalProject) {
116120
throw new Error('Original Deepnote project not found. Cannot save changes.');
@@ -131,7 +135,7 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
131135
throw new Error(`Notebook with ID ${notebookId} not found in project`);
132136
}
133137

134-
const updatedProject = JSON.parse(JSON.stringify(originalProject)) as DeepnoteProject;
138+
const updatedProject = JSON.parse(JSON.stringify(originalProject)) as DeepnoteFile;
135139

136140
const updatedBlocks = this.converter.convertCellsToBlocks(data.cells);
137141

@@ -178,4 +182,26 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
178182

179183
return activeNotebook?.metadata?.deepnoteNotebookId;
180184
}
185+
186+
/**
187+
* Finds the default notebook to open when no selection is made.
188+
* @param file
189+
* @returns
190+
*/
191+
private findDefaultNotebook(file: DeepnoteFile): DeepnoteNotebook | undefined {
192+
if (file.project.notebooks.length === 0) {
193+
return undefined;
194+
}
195+
196+
const sortedNotebooks = file.project.notebooks.slice().sort((a, b) => a.name.localeCompare(b.name));
197+
const sortedNotebooksWithoutInit = file.project.initNotebookId
198+
? sortedNotebooks.filter((nb) => nb.id !== file.project.initNotebookId)
199+
: sortedNotebooks;
200+
201+
if (sortedNotebooksWithoutInit.length > 0) {
202+
return sortedNotebooksWithoutInit[0];
203+
}
204+
205+
return sortedNotebooks[0];
206+
}
181207
}

0 commit comments

Comments
 (0)