Skip to content

Commit e7d7d98

Browse files
merging with develop
1 parent 6ca2e4b commit e7d7d98

File tree

6 files changed

+93
-119
lines changed

6 files changed

+93
-119
lines changed

src/chart/parameter/ParameterSelectCardSettings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ParameterSelectCardSettings = ({ query, database, settings, onReportSettin
2323

2424
const [queryText, setQueryText] = React.useState(query);
2525
const debouncedQueryUpdate = useCallback(debounce(onQueryUpdate, 250), []);
26-
const debouncedRunCypherQuery = useCallback(debounce(connectionModule.runQuery, RUN_QUERY_DELAY_MS), []);
26+
const debouncedRunQuery = useCallback(debounce(connectionModule.runQuery, RUN_QUERY_DELAY_MS), []);
2727

2828
const { manualPropertyNameSpecification } = settings;
2929
const [labelInputText, setLabelInputText] = React.useState(settings.entityType);
@@ -82,7 +82,7 @@ const ParameterSelectCardSettings = ({ query, database, settings, onReportSettin
8282
setSchema: () => {},
8383
};
8484

85-
debouncedRunCypherQuery(driver, queryParams, queryCallback);
85+
debouncedRunQuery(driver, queryParams, queryCallback);
8686
},
8787
[database]
8888
);

src/dashboard/sidebar/modal/DashboardSidebarAccessModal.tsx

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { IconButton, Button, Dialog, TextInput } from '@neo4j-ndl/react';
33
import { Menu, MenuItem, Chip } from '@mui/material';
44
import { Neo4jContext, Neo4jContextState } from 'use-neo4j/dist/neo4j.context';
55
import { PlusCircleIconOutline } from '@neo4j-ndl/react/icons';
6-
import { QueryStatus, runCypherQuery } from '../../../report/ReportQueryRunner';
76
import { createNotificationThunk } from '../../../page/PageThunks';
87
import { 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
*/
1617
export 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 (

src/extensions/forms/chart/NeoForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const NeoForm = (props: ChartProps) => {
3030
const [submitButtonActive, setSubmitButtonActive] = React.useState(true);
3131
const [status, setStatus] = React.useState(FormStatus.DATA_ENTRY);
3232
const [formResults, setFormResults] = React.useState([]);
33-
const debouncedRunCypherQuery = useCallback(debounce(props.queryCallback, RUN_QUERY_DELAY_MS), []);
33+
const debouncedRunQuery = useCallback(debounce(props.queryCallback, RUN_QUERY_DELAY_MS), []);
3434

3535
// Helper function to force a refresh on all reports that depend on the form.
3636
// All reports that use one or more parameters used in the form will be refreshed.
@@ -87,7 +87,7 @@ const NeoForm = (props: ChartProps) => {
8787
return;
8888
}
8989
setStatus(FormStatus.RUNNING);
90-
debouncedRunCypherQuery(props.query, props.parameters, (records) => {
90+
debouncedRunQuery(props.query, props.parameters, (records) => {
9191
setFormResults(records);
9292
if (records && records[0] && records[0].error) {
9393
setStatus(FormStatus.ERROR);

src/extensions/rbac/RBACManagementMenu.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, { useEffect, useState, useContext } from 'react';
22
import { Menu, MenuItem, MenuItems } from '@neo4j-ndl/react';
33
import { UserIconOutline } from '@neo4j-ndl/react/icons';
44
import { Neo4jContext, Neo4jContextState } from 'use-neo4j/dist/neo4j.context';
5-
import { QueryStatus, runCypherQuery } from '../../report/ReportQueryRunner';
65
import RBACManagementModal from './RBACManagementModal';
6+
import { runCypherQuery } from '../../connection/neo4j/runCypherQuery';
77

88
/**
99
* Component for providing a menu of all the roles in the neo4j database to the user whenever they press on the
@@ -20,22 +20,20 @@ export const RBACManagementMenu = ({ anchorEl, MenuOpen, handleClose, createNoti
2020
return;
2121
}
2222
const query = `SHOW PRIVILEGES YIELD role, action WHERE role <> "PUBLIC" RETURN role, 'dbms_actions' in collect(action)`;
23-
runCypherQuery(
23+
runCypherQuery({
2424
driver,
25-
'system',
25+
database: 'system',
2626
query,
27-
{},
28-
1000,
29-
() => {},
30-
(records) => {
27+
28+
setRecords: (records) => {
3129
if (records[0].error) {
3230
createNotification('Unable to retrieve roles', records[0].error);
3331
return;
3432
}
3533
// Only display roles which are not able to do 'dbms_actions', i.e. they are not admins.
3634
setRoles(records.filter((r) => r._fields[1] == false).map((record) => record._fields[0]));
37-
}
38-
);
35+
},
36+
});
3937
}, [MenuOpen]);
4038

4139
if (roles.length == 0) {

0 commit comments

Comments
 (0)