@@ -14,7 +14,7 @@ import {
1414 FromDataExtensionsEditorMessage ,
1515 ToDataExtensionsEditorMessage ,
1616} from "../common/interface-types" ;
17- import { ProgressUpdate } from "../common/vscode/progress" ;
17+ import { ProgressUpdate , withProgress } from "../common/vscode/progress" ;
1818import { QueryRunner } from "../query-server" ;
1919import {
2020 showAndLogExceptionWithTelemetry ,
@@ -44,6 +44,7 @@ import { getAutoModelUsages } from "./auto-model-usages-query";
4444import { Mode } from "./shared/mode" ;
4545import { loadModeledMethods , saveModeledMethods } from "./modeled-method-fs" ;
4646import { join } from "path" ;
47+ import { pickExtensionPack } from "./extension-pack-picker" ;
4748
4849export class DataExtensionsEditorView extends AbstractWebview <
4950 ToDataExtensionsEditorMessage ,
@@ -140,6 +141,8 @@ export class DataExtensionsEditorView extends AbstractWebview<
140141
141142 break ;
142143 case "modelDependency" :
144+ await this . modelDependency ( ) ;
145+
143146 break ;
144147 case "switchMode" :
145148 this . mode = msg . mode ;
@@ -430,6 +433,61 @@ export class DataExtensionsEditorView extends AbstractWebview<
430433 await this . clearProgress ( ) ;
431434 }
432435
436+ private async modelDependency ( ) : Promise < void > {
437+ return withProgress ( async ( progress , token ) => {
438+ const selectedDatabase = this . databaseManager . currentDatabaseItem ;
439+
440+ // The external API methods are in the library source code, so we need to ask
441+ // the user to import the library database. We need to have the database
442+ // imported to the query server, so we need to register it to our workspace.
443+ const addedDatabase = await promptImportGithubDatabase (
444+ this . app . commands ,
445+ this . databaseManager ,
446+ this . app . workspaceStoragePath ?? this . app . globalStoragePath ,
447+ this . app . credentials ,
448+ progress ,
449+ this . cliServer ,
450+ this . databaseItem . language ,
451+ ) ;
452+ if ( ! addedDatabase ) {
453+ void this . app . logger . log ( "No database chosen" ) ;
454+ return ;
455+ }
456+
457+ // The library database was set as the current database by importing it,
458+ // but we need to set it back to the originally selected database.
459+ await this . databaseManager . setCurrentDatabaseItem ( selectedDatabase ) ;
460+
461+ if ( token . isCancellationRequested ) {
462+ return ;
463+ }
464+
465+ const modelFile = await pickExtensionPack (
466+ this . cliServer ,
467+ addedDatabase ,
468+ this . app . logger ,
469+ progress ,
470+ token ,
471+ ) ;
472+ if ( ! modelFile ) {
473+ return ;
474+ }
475+
476+ const view = new DataExtensionsEditorView (
477+ this . ctx ,
478+ this . app ,
479+ this . databaseManager ,
480+ this . cliServer ,
481+ this . queryRunner ,
482+ this . queryStorageDir ,
483+ addedDatabase ,
484+ modelFile ,
485+ Mode . Framework ,
486+ ) ;
487+ await view . openView ( ) ;
488+ } ) ;
489+ }
490+
433491 /*
434492 * Progress in this class is a bit weird. Most of the progress is based on running the query.
435493 * Query progress is always between 0 and 1000. However, we still have some steps that need
0 commit comments