Skip to content
Open
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
26 changes: 14 additions & 12 deletions graphiql_debug_toolbar/static/graphiql_debug_toolbar/js/parse.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
(function(JSON) {
const parse = JSON.parse;
const djDebug = document.getElementById("djDebug");

JSON.parse = function(text) {
const data = parse(text);

if (data === null || !data.hasOwnProperty("debugToolbar")) return data;
const stringify = JSON.stringify
JSON.stringify = function(data) {
if (data === null || !data.hasOwnProperty("debugToolbar")) return stringify(data);

Object.entries(data.debugToolbar.panels).map(([id, panel]) => {
if (panel.title) {
const sideContent = document.getElementById(`djdt-${id}`)
if (sideContent) {
const linkContent = sideContent.querySelector("a");
linkContent.innerHTML =
`${panel.title}
<br>
<small>${panel.subtitle}</small>`
}

const content = djDebug.querySelector(`#${id}`);

content
Expand All @@ -23,15 +30,10 @@
content.querySelector(".djDebugPanelContent").prepend(loader);
}
}
if (panel.subtitle) {
document
.getElementById(`djdt-${id}`)
.querySelector("small").textContent = panel.subtitle;
}
});
djDebug.setAttribute("data-store-id", data.debugToolbar.storeId);

delete data.debugToolbar;
return data;
};
return stringify(data, null, 2);
}
})(JSON);