Skip to content

Commit

Permalink
fix: save alert when switching in multi project
Browse files Browse the repository at this point in the history
  • Loading branch information
saravmajestic committed May 17, 2024
1 parent 2a9db5e commit 73882d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/services/docGenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class DocGenService {
generated: false,
resource_type: currentNode.resource_type,
uniqueId: currentNode.uniqueId,
filePath,
columns: Object.values(docColumns).map((column) => {
return {
name: column.name,
Expand Down
21 changes: 16 additions & 5 deletions src/webview_provider/docsEditPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,16 @@ export class DocsEditViewPanel implements WebviewViewProvider {
},
async () => {
try {
const projectByFilePath =
this.dbtProjectContainer.findDBTProject(
Uri.file(message.filePath),
);
if (!projectByFilePath) {
throw new Error(
"Unable to find project for saving documentation",
);
}

if (!patchPath) {
switch (message.dialogType) {
case "Existing file":
Expand Down Expand Up @@ -630,7 +640,7 @@ export class DocsEditViewPanel implements WebviewViewProvider {
} else {
// the location comes from the manifest, parse it
patchPath = path.join(
project.projectRoot.fsPath,
projectByFilePath.projectRoot.fsPath,
patchPath.split("://")[1],
);
}
Expand Down Expand Up @@ -663,7 +673,7 @@ export class DocsEditViewPanel implements WebviewViewProvider {
columns: message.columns.map((column: any) => {
const name = getColumnNameByCase(
column.name,
project.getAdapterType(),
projectByFilePath.getAdapterType(),
);
return {
name,
Expand All @@ -672,7 +682,7 @@ export class DocsEditViewPanel implements WebviewViewProvider {
...this.getTestDataByColumn(message, column.name),
...(isQuotedIdentifier(
column.name,
project.getAdapterType(),
projectByFilePath.getAdapterType(),
)
? { quote: true }
: undefined),
Expand Down Expand Up @@ -714,7 +724,7 @@ export class DocsEditViewPanel implements WebviewViewProvider {
} else {
const name = getColumnNameByCase(
column.name,
project.getAdapterType(),
projectByFilePath.getAdapterType(),
);
return {
name,
Expand All @@ -726,7 +736,7 @@ export class DocsEditViewPanel implements WebviewViewProvider {
),
...(isQuotedIdentifier(
column.name,
project.getAdapterType(),
projectByFilePath.getAdapterType(),
)
? { quote: true }
: undefined),
Expand Down Expand Up @@ -767,6 +777,7 @@ export class DocsEditViewPanel implements WebviewViewProvider {
"saveDocumentationError",
`Could not save documentation to ${patchPath}`,
error,
true,
);
if (syncRequestId) {
this._panel!.webview.postMessage({
Expand Down

0 comments on commit 73882d5

Please sign in to comment.