Skip to content

Commit

Permalink
Temp button for toggling visualization render
Browse files Browse the repository at this point in the history
  • Loading branch information
alepbloyd committed Feb 4, 2025
1 parent f877eba commit 5abdf85
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions react/src/components/CustomQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ function CustomQueryPage() {
[]
);
const [openPanel, setOpenPanel] = useState(false);
const [renderVisualization, setRenderVisualization] = useState(true);

const handleRenderVisualizationToggle = () => {
setRenderVisualization(!renderVisualization);
};


const initialNodes = [];
const initialEdges = [];
Expand All @@ -377,7 +383,7 @@ function CustomQueryPage() {
}).then((response) => {
return response.json()
}).then(json => {
if (!json.data.hasOwnProperty("__schema")) { // only update response data if it's not a schema info response
if (!json.data.hasOwnProperty("__schema") && renderVisualization) { // only update response data if it's not a schema info response
// clearArray(initialEdges)
// clearArray(initialNodes)

Expand Down Expand Up @@ -407,10 +413,13 @@ function CustomQueryPage() {
<>
<div className="text-xl mb-2 text-white flex flex-row items-center justify-between sm:justify-around p-2 border-b-2 bg-green-800 sticky top-0">
<button className="absolute left-5 bg-green-600 hover:bg-green-300 text-gray-800 font-semibold py-1 px-1 border border-black rounded shadow" onClick={() => setOpenPanel(true)}>Open Query Panel</button>
πŸ“– πŸ› BookWorm
<button className={`absolute right-5 ${renderVisualization ? "bg-green-600" : "bg-red-400"} text-gray-800 font-semibold py-1 px-1 border border-black rounded shadow`}
onClick={handleRenderVisualizationToggle}> Render visualization? {renderVisualization ? 'βœ…' : '❌'}</button>
πŸ“– πŸ› BookWorm
</div>
<div>
<SlidingPanel type={'left'} isOpen={openPanel} size={70} >

<div style = {{textAlign:"left"}} className="graphiql-container">
<GraphiQL fetcher={gql_fetcher} />
<button onClick={() => setOpenPanel(false)}>Close Query Panel</button>
Expand Down

0 comments on commit 5abdf85

Please sign in to comment.