-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: query bookmarks feedback changes #1295
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
94ad850
fix: show contact us for enabling bookmarks
saravmajestic 2ee987e
fix: errors when test added for new column
saravmajestic ecc654d
fix: allow jinja autocompletions for new sql file
saravmajestic c6f895f
fix: open code in editor
saravmajestic 99ca9d7
fix: cleanup
saravmajestic 8179f06
fix: add title for e2e tests
saravmajestic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -539,77 +539,81 @@ export class VSCodeCommands implements Disposable { | |
this.dbtTerminal.logLine(`Error=${e}`); | ||
} | ||
}), | ||
commands.registerCommand("dbtPowerUser.createSqlFile", async () => { | ||
try { | ||
const project = | ||
await this.queryManifestService.getOrPickProjectFromWorkspace(); | ||
if (!project) { | ||
window.showErrorMessage("No dbt project selected."); | ||
return; | ||
} | ||
commands.registerCommand( | ||
"dbtPowerUser.createSqlFile", | ||
async ({ code, fileName }: { code?: string; fileName?: string }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added these 2 arguments to display selected code from bookmark or history details and with filename |
||
try { | ||
const project = | ||
await this.queryManifestService.getOrPickProjectFromWorkspace(); | ||
if (!project) { | ||
window.showErrorMessage("No dbt project selected."); | ||
return; | ||
} | ||
|
||
const uri = Uri.parse( | ||
`${project.projectRoot}/poweruser-${getFormattedDateTime()}.sql`, | ||
).with({ scheme: "untitled" }); | ||
const annotationDecoration: TextEditorDecorationType = | ||
window.createTextEditorDecorationType({ | ||
rangeBehavior: DecorationRangeBehavior.OpenOpen, | ||
}); | ||
const fileNamePrefix = fileName || "poweruser"; | ||
const uri = Uri.parse( | ||
`${project.projectRoot}/${fileNamePrefix}-${getFormattedDateTime()}.sql`, | ||
).with({ scheme: "untitled" }); | ||
const annotationDecoration: TextEditorDecorationType = | ||
window.createTextEditorDecorationType({ | ||
rangeBehavior: DecorationRangeBehavior.OpenOpen, | ||
}); | ||
|
||
const contentText = | ||
"Enter your query here and execute it just like any dbt model file. This file is unsaved, you can either save it to your project or save it as a bookmark for later usage or share it with your team members."; | ||
const contentText = | ||
"Enter your query here and execute it just like any dbt model file. This file is unsaved, you can either save it to your project or save it as a bookmark for later usage or share it with your team members."; | ||
|
||
const decorations = [ | ||
{ | ||
renderOptions: { | ||
before: { | ||
color: "#666666", | ||
contentText, | ||
// hacking to add more css properties | ||
width: "90%;display: block;white-space: pre-line;", | ||
const decorations = [ | ||
{ | ||
renderOptions: { | ||
before: { | ||
color: "#666666", | ||
contentText, | ||
// hacking to add more css properties | ||
width: "90%;display: block;white-space: pre-line;", | ||
}, | ||
}, | ||
range: new Range(2, 0, 2, 0), | ||
}, | ||
range: new Range(2, 0, 2, 0), | ||
}, | ||
]; | ||
]; | ||
|
||
workspace.openTextDocument(uri).then((doc) => { | ||
// set this to sql language so we can bind codelens and other features | ||
languages.setTextDocumentLanguage(doc, "sql"); | ||
window.showTextDocument(doc).then((editor) => { | ||
editor.edit((editBuilder) => { | ||
const entireDocumentRange = new Range( | ||
doc.positionAt(0), | ||
doc.positionAt(doc.getText().length), | ||
); | ||
editBuilder.replace(entireDocumentRange, "\n"); | ||
workspace.openTextDocument(uri).then((doc) => { | ||
// set this to sql language so we can bind codelens and other features | ||
languages.setTextDocumentLanguage(doc, "jinja-sql"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use jinja-sql language |
||
window.showTextDocument(doc).then((editor) => { | ||
editor.edit((editBuilder) => { | ||
const entireDocumentRange = new Range( | ||
doc.positionAt(0), | ||
doc.positionAt(doc.getText().length), | ||
); | ||
editBuilder.replace(entireDocumentRange, code || "\n"); | ||
|
||
editor.setDecorations(annotationDecoration, decorations); | ||
setTimeout(() => { | ||
commands.executeCommand("cursorMove", { | ||
to: "up", | ||
by: "line", | ||
value: 1, | ||
}); | ||
}, 0); | ||
const disposable = workspace.onDidChangeTextDocument((e) => { | ||
const activeEditor = window.activeTextEditor; | ||
if (activeEditor && e.document === editor.document) { | ||
if (activeEditor.document.getText().trim()) { | ||
activeEditor.setDecorations(annotationDecoration, []); | ||
disposable.dispose(); | ||
editor.setDecorations(annotationDecoration, decorations); | ||
setTimeout(() => { | ||
commands.executeCommand("cursorMove", { | ||
to: "up", | ||
by: "line", | ||
value: 1, | ||
}); | ||
}, 0); | ||
const disposable = workspace.onDidChangeTextDocument((e) => { | ||
const activeEditor = window.activeTextEditor; | ||
if (activeEditor && e.document === editor.document) { | ||
if (activeEditor.document.getText().trim()) { | ||
activeEditor.setDecorations(annotationDecoration, []); | ||
disposable.dispose(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} catch (e) { | ||
const message = (e as Error).message; | ||
this.dbtTerminal.error("createSqlFile", message, e, true); | ||
window.showErrorMessage(message); | ||
} | ||
}), | ||
} catch (e) { | ||
const message = (e as Error).message; | ||
this.dbtTerminal.error("createSqlFile", message, e, true); | ||
window.showErrorMessage(message); | ||
} | ||
}, | ||
), | ||
commands.registerCommand("dbtPowerUser.sqlLineage", async () => { | ||
window.withProgress( | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converted the new query sql file from sql language to jinja-sql so we can use jinja autocompletes