Skip to content
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: no error message when compiling without having file opened #98

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions media/js/sidePanel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function removeLoadingMessage() {
function removeLoadingMessage(errorMessage) {
var loadingMessage = document.getElementById("loadingMessage");
if (loadingMessage) {
if (loadingMessage && !errorMessage) {
loadingMessage.parentNode.removeChild(loadingMessage);
} else if (errorMessage){
loadingMessage.innerHTML = `<p>${errorMessage}<p>`;
}
}

Expand Down Expand Up @@ -103,8 +105,12 @@ function showCurrFileMetadataInSideBar(tables) {

window.addEventListener('message', event => {
const message = event.data;
let errorMessage = message.errorMessage;
if(errorMessage){
removeLoadingMessage(errorMessage);
return;
}
let tables = message.currFileMetadata.fileMetadata.tables;
showCurrFileMetadataInSideBar(tables);
removeLoadingMessage();
});

4 changes: 3 additions & 1 deletion src/views/register-preview-compiled-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ export class CompiledQueryPanel {
}

if(!curFileMeta){
await webview.postMessage({
"errorMessage": `File type not supported. Supported file types are sqlx, js`
});
return;
//TODO: show some error message in this case
}

if (curFileMeta.isDataformWorkspace===false){
Expand Down
6 changes: 5 additions & 1 deletion src/views/register-sidebar-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export async function registerWebViewProvider(context: ExtensionContext) {
let currFileMetadata = await getCurrentFileMetadata(false);
if (currFileMetadata) {
provider.view?.webview.postMessage({ "currFileMetadata": currFileMetadata });
} else {
provider.view?.webview.postMessage({
"errorMessage": `File type not supported. Supported file types are sqlx, js`
});
}
}));

Expand Down Expand Up @@ -91,7 +95,7 @@ export class SidebarWebViewProvider implements WebviewViewProvider {
<body>
<h1> Dataform </h1>
<br>
<h3 id="loadingMessage"> Loading metadata ... </h3>
<h3 id="loadingMessage"></h3>
<br>
<button type="button" class="load-dependancy-graph-button">Load dependancy graph</button><br>
<script nonce="${nonce}" src="${sidePanelScriptUri}"></script>
Expand Down