Skip to content

Commit 5c64c35

Browse files
authored
Added hotfix for race condition in Neo4j Desktop (#230) (#231)
* Added hotfix for race condition in Neo4j Desktop * Bumped version number * Added check to ensure the database list doesn't get reloaded too often * Added TODOs
1 parent 57cfd19 commit 5c64c35

File tree

14 files changed

+48
-32
lines changed

14 files changed

+48
-32
lines changed

.github/workflows/master-deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
context: .
7979
file: ./Dockerfile
8080
push: true
81-
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_USERNAME }}/neodash:2.1.8
81+
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_USERNAME }}/neodash:2.1.9
8282
build-npm:
8383
needs: build-test
8484
runs-on: ubuntu-latest

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ RUN chown -R nginx:nginx /usr/share/nginx/html/
3838
USER nginx
3939
EXPOSE 5005
4040
HEALTHCHECK cmd curl --fail http://localhost:5005 || exit 1
41-
LABEL version="2.1.8"
41+
LABEL version="2.1.9"

changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## NeoDash 2.1.8
1+
## NeoDash 2.1.8 & 2.1.9
22
New features:
33
- Added the [Dashboard Gallery](https://neodash-gallery.graphapp.io), a live gallery of example NeoDash dashboards.
44
- Added **Gauge Charts**, a contribution of the [BlueHound](https://github.com/zeronetworks/BlueHound) fork.
@@ -10,7 +10,7 @@ Bug fixes:
1010
- Fixed issue preventing dashboards to be shared with a non-standard database name.
1111
- Fixed table chart breaking when returning a property called 'id' with a null value.
1212
- Fixed bug not allowing users to select a different database when loading/saving a dashboard.
13-
13+
- **Added error handler for database list race condition in Neo4j Desktop**.
1414

1515

1616
## NeoDash 2.1.6 & 2.1.7

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "neodash",
3-
"version": "2.1.8",
3+
"version": "2.1.9",
44
"description": "NeoDash - Neo4j Dashboard Builder",
55
"neo4jDesktop": {
66
"apiVersion": "^1.2.0"

release-notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## NeoDash 2.1.8
1+
## NeoDash 2.1.8 & 2.1.9
22
New features:
33
- Added the [Dashboard Gallery](https://neodash-gallery.graphapp.io), a live gallery of example NeoDash dashboards.
44
- Added **Gauge Charts**, a contribution of the [BlueHound](https://github.com/zeronetworks/BlueHound) fork.
@@ -10,6 +10,6 @@ Bug fixes:
1010
- Fixed issue preventing dashboards to be shared with a non-standard database name.
1111
- Fixed table chart breaking when returning a property called 'id' with a null value.
1212
- Fixed bug not allowing users to select a different database when loading/saving a dashboard.
13-
13+
- **Added error handler for database list race condition in Neo4j Desktop**.
1414

1515
For a complete version history, see the [Changelog](https://github.com/neo4j-labs/neodash/blob/master/changelog.md).

src/application/ApplicationActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export const setShareDetailsFromUrl = (type: string, id: string, standalone: boo
8888
});
8989

9090
export const SET_STANDALONE_ENABLED = 'APPLICATION/SET_STANDALONE_ENABLED';
91-
export const setStandaloneEnabled = (standalone: boolean, standaloneProtocol: string, standaloneHost: string, standalonePort: string, standaloneDatabase: string, standaloneDashboardName: string, standaloneDashboardDatabase: string, standaloneDashboardURL: string ) => ({
91+
export const setStandaloneEnabled = (standalone: boolean, standaloneProtocol: string, standaloneHost: string, standalonePort: string, standaloneDatabase: string, standaloneDashboardName: string, standaloneDashboardDatabase: string, standaloneDashboardURL: string, standaloneUsername: string, standalonePassword: string) => ({
9292
type: SET_STANDALONE_ENABLED,
93-
payload: { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL },
93+
payload: { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL, standaloneUsername, standalonePassword },
9494
});
9595

9696
export const SET_STANDALONE_MODE = 'APPLICATION/SET_STANDALONE_MODE';

src/application/ApplicationReducer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
103103
}
104104

105105
case SET_STANDALONE_ENABLED: {
106-
const { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL } = payload;
106+
const { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL, standaloneUsername, standalonePassword } = payload;
107107
state = update(state, {
108108
standalone: standalone,
109109
standaloneProtocol: standaloneProtocol,
@@ -112,7 +112,9 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
112112
standaloneDatabase: standaloneDatabase,
113113
standaloneDashboardName: standaloneDashboardName,
114114
standaloneDashboardDatabase: standaloneDashboardDatabase,
115-
standaloneDashboardURL: standaloneDashboardURL
115+
standaloneDashboardURL: standaloneDashboardURL,
116+
standaloneUsername: standaloneUsername,
117+
standalonePassword: standalonePassword
116118
})
117119
return state;
118120
}

src/application/ApplicationSelectors.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const applicationGetStandaloneSettings = (state: any) => {
7373
"standaloneDatabase": state.application.standaloneDatabase,
7474
"standaloneDashboardName": state.application.standaloneDashboardName,
7575
"standaloneDashboardDatabase": state.application.standaloneDashboardDatabase,
76-
"standaloneDashboardURL": state.application.standaloneDashboardURL
76+
"standaloneDashboardURL": state.application.standaloneDashboardURL,
77+
"standaloneUsername": state.application.standaloneUsername,
78+
"standalonePassword": state.application.standalonePassword
7779
}
7880
}
7981

src/application/ApplicationThunks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
272272
dispatch(setSSOEnabled(config['ssoEnabled'], config["ssoDiscoveryUrl"]));
273273
const state = getState();
274274
const standalone = config['standalone'];// || (state.application.shareDetails !== undefined && state.application.shareDetails.standalone);
275-
dispatch(setStandaloneEnabled(standalone, config['standaloneProtocol'], config['standaloneHost'], config['standalonePort'], config['standaloneDatabase'], config['standaloneDashboardName'], config['standaloneDashboardDatabase'], config["standaloneDashboardURL"]))
275+
dispatch(setStandaloneEnabled(standalone, config['standaloneProtocol'], config['standaloneHost'], config['standalonePort'], config['standaloneDatabase'], config['standaloneDashboardName'], config['standaloneDashboardDatabase'], config["standaloneDashboardURL"], config['standaloneUsername'], config['standalonePassword']))
276276
dispatch(setConnectionModalOpen(false));
277277

278278
// Auto-upgrade the dashboard version if an old version is cached.

src/card/Card.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,20 @@ const NeoCard = ({
5757
const {driver} = useContext<Neo4jContextState>(Neo4jContext);
5858

5959
const [databaseList, setDatabaseList] = React.useState([database])
60+
const [databaseListLoaded, setDatabaseListLoaded] = React.useState(false);
6061

6162
// fetching the list of databases from neo4j, filtering out the 'system' db
6263
useEffect(() => {
63-
loadDatabaseListFromNeo4j(driver, (result) => {
64-
let index = result.indexOf("system")
65-
if (index > -1) { // only splice array when item is found
66-
result.splice(index, 1); // 2nd parameter means remove one item only
67-
}
68-
setDatabaseList(result)
69-
});
64+
if(!databaseListLoaded){
65+
loadDatabaseListFromNeo4j(driver, (result) => {
66+
let index = result.indexOf("system")
67+
if (index > -1) { // only splice array when item is found
68+
result.splice(index, 1); // 2nd parameter means remove one item only
69+
}
70+
setDatabaseList(result)
71+
});
72+
setDatabaseListLoaded(true);
73+
}
7074
}, [report.query]);
7175

7276
const [settingsOpen, setSettingsOpen] = React.useState(false);
@@ -204,7 +208,7 @@ const NeoCard = ({
204208
const mapStateToProps = (state, ownProps) => ({
205209
report: getReportState(state, ownProps.index),
206210
editable: getDashboardIsEditable(state),
207-
database: getDatabase(state, ownProps.dashboardSettings.pagenumber, ownProps.index),
211+
database: getDatabase(state, ownProps && ownProps.dashboardSettings ? ownProps.dashboardSettings.pagenumber : undefined, ownProps.index),
208212
globalParameters: getGlobalParameters(state)
209213
});
210214

0 commit comments

Comments
 (0)