Skip to content

Commit 2351346

Browse files
committed
Change data flow generator for framework mode
1 parent d26d886 commit 2351346

File tree

2 files changed

+41
-31
lines changed

2 files changed

+41
-31
lines changed

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-view.ts

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -327,29 +327,35 @@ export class DataExtensionsEditorView extends AbstractWebview<
327327
protected async generateModeledMethods(): Promise<void> {
328328
const tokenSource = new CancellationTokenSource();
329329

330-
const selectedDatabase = this.databaseManager.currentDatabaseItem;
331-
332-
// The external API methods are in the library source code, so we need to ask
333-
// the user to import the library database. We need to have the database
334-
// imported to the query server, so we need to register it to our workspace.
335-
const database = await promptImportGithubDatabase(
336-
this.app.commands,
337-
this.databaseManager,
338-
this.app.workspaceStoragePath ?? this.app.globalStoragePath,
339-
this.app.credentials,
340-
(update) => this.showProgress(update),
341-
this.cliServer,
342-
);
343-
if (!database) {
344-
await this.clearProgress();
345-
void this.app.logger.log("No database chosen");
330+
let addedDatabase: DatabaseItem | undefined;
331+
332+
// In application mode, we need the database of a specific library to generate
333+
// the modeled methods. In framework mode, we'll use the current database.
334+
if (this.mode === Mode.Application) {
335+
const selectedDatabase = this.databaseManager.currentDatabaseItem;
336+
337+
// The external API methods are in the library source code, so we need to ask
338+
// the user to import the library database. We need to have the database
339+
// imported to the query server, so we need to register it to our workspace.
340+
addedDatabase = await promptImportGithubDatabase(
341+
this.app.commands,
342+
this.databaseManager,
343+
this.app.workspaceStoragePath ?? this.app.globalStoragePath,
344+
this.app.credentials,
345+
(update) => this.showProgress(update),
346+
this.cliServer,
347+
);
348+
if (!addedDatabase) {
349+
await this.clearProgress();
350+
void this.app.logger.log("No database chosen");
346351

347-
return;
348-
}
352+
return;
353+
}
349354

350-
// The library database was set as the current database by importing it,
351-
// but we need to set it back to the originally selected database.
352-
await this.databaseManager.setCurrentDatabaseItem(selectedDatabase);
355+
// The library database was set as the current database by importing it,
356+
// but we need to set it back to the originally selected database.
357+
await this.databaseManager.setCurrentDatabaseItem(selectedDatabase);
358+
}
353359

354360
await this.showProgress({
355361
step: 0,
@@ -362,7 +368,7 @@ export class DataExtensionsEditorView extends AbstractWebview<
362368
cliServer: this.cliServer,
363369
queryRunner: this.queryRunner,
364370
queryStorageDir: this.queryStorageDir,
365-
databaseItem: database,
371+
databaseItem: addedDatabase ?? this.databaseItem,
366372
onResults: async (results) => {
367373
const modeledMethodsByName: Record<string, ModeledMethod> = {};
368374

@@ -389,14 +395,16 @@ export class DataExtensionsEditorView extends AbstractWebview<
389395
);
390396
}
391397

392-
// After the flow model has been generated, we can remove the temporary database
393-
// which we used for generating the flow model.
394-
await this.showProgress({
395-
step: 3900,
396-
maxStep: 4000,
397-
message: "Removing temporary database",
398-
});
399-
await this.databaseManager.removeDatabaseItem(database);
398+
if (addedDatabase) {
399+
// After the flow model has been generated, we can remove the temporary database
400+
// which we used for generating the flow model.
401+
await this.showProgress({
402+
step: 3900,
403+
maxStep: 4000,
404+
message: "Removing temporary database",
405+
});
406+
await this.databaseManager.removeDatabaseItem(addedDatabase);
407+
}
400408

401409
await this.clearProgress();
402410
}

extensions/ql-vscode/src/view/data-extensions-editor/DataExtensionsEditor.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ export function DataExtensionsEditor({
220220
<ButtonsContainer>
221221
<VSCodeButton onClick={onApplyClick}>Apply</VSCodeButton>
222222
<VSCodeButton onClick={onGenerateClick}>
223-
Download and generate
223+
{viewState?.mode === Mode.Framework
224+
? "Generate"
225+
: "Download and generate"}
224226
</VSCodeButton>
225227
{viewState?.showLlmButton && (
226228
<>

0 commit comments

Comments
 (0)