Skip to content

Commit

Permalink
better formatting for cmd_shift_s schema tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisclark committed Aug 20, 2024
1 parent add806c commit 357089e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions explorer/src/js/codemirror-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,21 @@ const hideTooltipOnEsc = EditorView.domEventHandlers({
}
});

function displaySchemaTooltip(editor, content) {
function displaySchemaTooltip(content) {
let tooltip = document.getElementById('schema_tooltip');
if (tooltip) {
tooltip.classList.remove('d-none');
tooltip.classList.add('d-block');
tooltip.textContent = content;

// Clear existing content
tooltip.textContent = '';

content.forEach(item => {
let column = document.createElement('span');
column.textContent = item;
column.classList.add('mx-1')
tooltip.appendChild(column);
});
}
}

Expand All @@ -58,11 +67,11 @@ function fetchAndShowSchema(view) {
SchemaSvc.get().then(schema => {
let formattedSchema;
if (schema.hasOwnProperty(tableName)) {
formattedSchema = JSON.stringify(schema[tableName], null, 2);
displaySchemaTooltip(schema[tableName]);
} else {
formattedSchema = `Table '${tableName}' not found in schema for connection`;
const errorMsg = [`Table '${tableName}' not found in schema for connection`];
displaySchemaTooltip(errorMsg);
}
displaySchemaTooltip(view, formattedSchema);
});
}
return true;
Expand Down

0 comments on commit 357089e

Please sign in to comment.