@@ -3,9 +3,10 @@ import { IconButton, Button, Dialog, TextInput } from '@neo4j-ndl/react';
33import { Menu , MenuItem , Chip } from '@mui/material' ;
44import { Neo4jContext , Neo4jContextState } from 'use-neo4j/dist/neo4j.context' ;
55import { PlusCircleIconOutline } from '@neo4j-ndl/react/icons' ;
6- import { QueryStatus , runCypherQuery } from '../../../report/ReportQueryRunner' ;
76import { createNotificationThunk } from '../../../page/PageThunks' ;
87import { useDispatch } from 'react-redux' ;
8+ import { runCypherQuery } from '../../../connection/neo4j/runCypherQuery' ;
9+ import { QueryStatus } from '../../../connection/interfaces' ;
910/**
1011 * Configures setting the current Neo4j database connection for the dashboard.
1112 * @param open - Whether the modal is open or not.
@@ -15,8 +16,8 @@ import { useDispatch } from 'react-redux';
1516 */
1617export const NeoDashboardSidebarAccessModal = ( { open, database, dashboard, handleClose } ) => {
1718 const [ anchorEl , setAnchorEl ] = useState ( null ) ;
18- const [ selectedLabels , setSelectedLabels ] = useState ( [ ] ) ;
19- const [ allLabels , setAllLabels ] = useState ( [ ] ) ;
19+ const [ selectedLabels , setSelectedLabels ] = useState < string [ ] > ( [ ] ) ;
20+ const [ allLabels , setAllLabels ] = useState < string [ ] > ( [ ] ) ;
2021 const [ neo4jLabels , setNeo4jLabels ] = useState ( [ ] ) ;
2122 const [ newLabel , setNewLabel ] = useState ( '' ) ;
2223 const INITIAL_LABEL = '_Neodash_Dashboard' ;
@@ -28,35 +29,30 @@ export const NeoDashboardSidebarAccessModal = ({ open, database, dashboard, hand
2829 if ( ! open ) {
2930 return ;
3031 }
31- runCypherQuery (
32+ runCypherQuery ( {
3233 driver,
3334 database,
34- 'CALL db.labels()' ,
35- { } ,
36- 1000 ,
37- ( ) => { } ,
38- ( records ) => setNeo4jLabels ( records . map ( ( record ) => record . get ( 'label' ) ) )
39- ) ;
35+ query : 'CALL db.labels()' ,
36+ setRecords : ( records ) => setNeo4jLabels ( records . map ( ( record ) => record . get ( 'label' ) ) ) ,
37+ } ) ;
4038
4139 const query = `
4240 MATCH (d:${ INITIAL_LABEL } {uuid: "${ dashboard . uuid } "})
4341 RETURN labels(d) as labels
4442 ` ;
45- runCypherQuery (
43+ runCypherQuery ( {
4644 driver,
4745 database,
4846 query,
49- { } ,
50- 1000 ,
51- ( error ) => {
47+ setError : ( error ) => {
5248 console . error ( error ) ;
5349 } ,
54- ( records ) => {
50+ setRecords : ( records ) => {
5551 // Set the selectedLabels state to the labels of the dashboard
5652 setSelectedLabels ( records [ 0 ] . get ( 'labels' ) ) ;
5753 setAllLabels ( records [ 0 ] . get ( 'labels' ) ) ;
58- }
59- ) ;
54+ } ,
55+ } ) ;
6056 setFeedback ( '' ) ;
6157 setNewLabel ( '' ) ;
6258 } , [ open ] ) ;
@@ -114,13 +110,12 @@ export const NeoDashboardSidebarAccessModal = ({ open, database, dashboard, hand
114110 RETURN 1;
115111 ` ;
116112
117- runCypherQuery (
113+ runCypherQuery ( {
118114 driver,
119115 database,
120116 query,
121- { selectedLabels : selectedLabels } ,
122- 1000 ,
123- ( status ) => {
117+ parameters : { selectedLabels : selectedLabels } ,
118+ setStatus : ( status ) => {
124119 if ( status == QueryStatus . COMPLETE ) {
125120 dispatch (
126121 createNotificationThunk (
@@ -138,8 +133,7 @@ export const NeoDashboardSidebarAccessModal = ({ open, database, dashboard, hand
138133 ) ;
139134 }
140135 } ,
141- ( ) => { }
142- ) ;
136+ } ) ;
143137 } ;
144138
145139 return (
0 commit comments