11import React , { useState , useEffect } from "react" ;
2- import { HTMLTable , Button , MenuItem , Spinner , Label } from "@blueprintjs/core" ;
2+ import {
3+ Button ,
4+ Checkbox ,
5+ HTMLTable ,
6+ Label ,
7+ MenuItem ,
8+ Spinner ,
9+ Tab ,
10+ TabId ,
11+ Tabs ,
12+ } from "@blueprintjs/core" ;
13+ import { OnloadArgs } from "roamjs-components/types" ;
14+ import Description from "roamjs-components/components/Description" ;
315import { Select } from "@blueprintjs/select" ;
416import {
517 getSupabaseContext ,
@@ -91,7 +103,8 @@ const NodeTable = ({ nodes }: { nodes: PConceptFull[] }) => {
91103 ) ;
92104} ;
93105
94- const AdminPanel = ( ) => {
106+ const AdminPanel = ( { onloadArgs } : { onloadArgs : OnloadArgs } ) => {
107+ const extensionAPI = onloadArgs . extensionAPI ;
95108 const [ context , setContext ] = useState < SupabaseContext | null > ( null ) ;
96109 const [ supabase , setSupabase ] = useState < DGSupabaseClient | null > ( null ) ;
97110 const [ schemas , setSchemas ] = useState < NodeSignature [ ] > ( [ ] ) ;
@@ -101,6 +114,7 @@ const AdminPanel = () => {
101114 const [ loading , setLoading ] = useState ( true ) ;
102115 const [ loadingNodes , setLoadingNodes ] = useState ( true ) ;
103116 const [ error , setError ] = useState < string | null > ( null ) ;
117+ const [ selectedTabId , setSelectedTabId ] = useState < TabId > ( "node-list" ) ;
104118
105119 useEffect ( ( ) => {
106120 let ignore = false ;
@@ -196,41 +210,87 @@ const AdminPanel = () => {
196210 }
197211
198212 return (
199- < >
200- < p >
201- Context:{ " " }
202- < code > { JSON . stringify ( { ...context , spacePassword : "****" } ) } </ code >
203- </ p >
204- { schemas . length > 0 ? (
205- < >
206- < Label >
207- Display:
208- < div className = "mx-2 inline-block" >
209- < Select
210- items = { schemas }
211- onItemSelect = { ( choice ) => {
212- setShowingSchema ( choice ) ;
213- } }
214- itemRenderer = { ( node , { handleClick, modifiers } ) => (
215- < MenuItem
216- active = { modifiers . active }
217- key = { node . sourceLocalId }
218- label = { node . name }
219- onClick = { handleClick }
220- text = { node . name }
213+ < Tabs
214+ onChange = { ( id ) => setSelectedTabId ( id ) }
215+ selectedTabId = { selectedTabId }
216+ renderActiveTabPanelOnly = { true }
217+ >
218+ < Tab
219+ id = "node-list"
220+ title = "Node list"
221+ panel = {
222+ < >
223+ < p >
224+ Context:{ " " }
225+ < code >
226+ { JSON . stringify ( { ...context , spacePassword : "****" } ) }
227+ </ code >
228+ </ p >
229+ { schemas . length > 0 ? (
230+ < >
231+ < Label >
232+ Display:
233+ < div className = "mx-2 inline-block" >
234+ < Select
235+ items = { schemas }
236+ onItemSelect = { ( choice ) => {
237+ setShowingSchema ( choice ) ;
238+ } }
239+ itemRenderer = { ( node , { handleClick, modifiers } ) => (
240+ < MenuItem
241+ active = { modifiers . active }
242+ key = { node . sourceLocalId }
243+ label = { node . name }
244+ onClick = { handleClick }
245+ text = { node . name }
246+ />
247+ ) }
248+ >
249+ < Button text = { showingSchema . name } />
250+ </ Select >
251+ </ div >
252+ </ Label >
253+ < div >
254+ { loadingNodes ? < Spinner /> : < NodeTable nodes = { nodes } /> }
255+ </ div >
256+ </ >
257+ ) : (
258+ < p > No node schemas found</ p >
259+ ) }
260+ </ >
261+ }
262+ />
263+ < Tab
264+ id = "experiments"
265+ title = "Experiments"
266+ panel = {
267+ < div className = "flex flex-col gap-4 p-1" >
268+ < Checkbox
269+ defaultChecked = {
270+ extensionAPI . settings . get ( "use-reified-relations" ) as boolean
271+ }
272+ onChange = { ( e ) => {
273+ const target = e . target as HTMLInputElement ;
274+ extensionAPI . settings . set (
275+ "use-reified-relations" ,
276+ target . checked ,
277+ ) ;
278+ } }
279+ labelElement = {
280+ < >
281+ Reified Relation Triples
282+ < Description
283+ description = {
284+ "When ON, relations are read/written as sourceUid:relationBlockUid:destinationUid in [[roam/js/discourse-graph/relations]]."
285+ }
221286 />
222- ) }
223- >
224- < Button text = { showingSchema . name } />
225- </ Select >
226- </ div >
227- </ Label >
228- < div > { loadingNodes ? < Spinner /> : < NodeTable nodes = { nodes } /> } </ div >
229- </ >
230- ) : (
231- < p > No node schemas found</ p >
232- ) }
233- </ >
287+ </ >
288+ }
289+ />
290+ </ div >
291+ }
292+ />
293+ </ Tabs >
234294 ) ;
235295} ;
236296
0 commit comments