Skip to content

Commit

Permalink
Added hotfix for race condition in Neo4j Desktop (#230) (#231)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nielsdejong authored Oct 10, 2022
1 parent 57cfd19 commit 5c64c35
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_USERNAME }}/neodash:2.1.8
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/neodash:latest,${{ secrets.DOCKER_HUB_USERNAME }}/neodash:2.1.9
build-npm:
needs: build-test
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ RUN chown -R nginx:nginx /usr/share/nginx/html/
USER nginx
EXPOSE 5005
HEALTHCHECK cmd curl --fail http://localhost:5005 || exit 1
LABEL version="2.1.8"
LABEL version="2.1.9"
4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## NeoDash 2.1.8
## NeoDash 2.1.8 & 2.1.9
New features:
- Added the [Dashboard Gallery](https://neodash-gallery.graphapp.io), a live gallery of example NeoDash dashboards.
- Added **Gauge Charts**, a contribution of the [BlueHound](https://github.com/zeronetworks/BlueHound) fork.
Expand All @@ -10,7 +10,7 @@ Bug fixes:
- Fixed issue preventing dashboards to be shared with a non-standard database name.
- Fixed table chart breaking when returning a property called 'id' with a null value.
- Fixed bug not allowing users to select a different database when loading/saving a dashboard.

- **Added error handler for database list race condition in Neo4j Desktop**.


## NeoDash 2.1.6 & 2.1.7
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neodash",
"version": "2.1.8",
"version": "2.1.9",
"description": "NeoDash - Neo4j Dashboard Builder",
"neo4jDesktop": {
"apiVersion": "^1.2.0"
Expand Down
4 changes: 2 additions & 2 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## NeoDash 2.1.8
## NeoDash 2.1.8 & 2.1.9
New features:
- Added the [Dashboard Gallery](https://neodash-gallery.graphapp.io), a live gallery of example NeoDash dashboards.
- Added **Gauge Charts**, a contribution of the [BlueHound](https://github.com/zeronetworks/BlueHound) fork.
Expand All @@ -10,6 +10,6 @@ Bug fixes:
- Fixed issue preventing dashboards to be shared with a non-standard database name.
- Fixed table chart breaking when returning a property called 'id' with a null value.
- Fixed bug not allowing users to select a different database when loading/saving a dashboard.

- **Added error handler for database list race condition in Neo4j Desktop**.

For a complete version history, see the [Changelog](https://github.com/neo4j-labs/neodash/blob/master/changelog.md).
4 changes: 2 additions & 2 deletions src/application/ApplicationActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ export const setShareDetailsFromUrl = (type: string, id: string, standalone: boo
});

export const SET_STANDALONE_ENABLED = 'APPLICATION/SET_STANDALONE_ENABLED';
export const setStandaloneEnabled = (standalone: boolean, standaloneProtocol: string, standaloneHost: string, standalonePort: string, standaloneDatabase: string, standaloneDashboardName: string, standaloneDashboardDatabase: string, standaloneDashboardURL: string ) => ({
export const setStandaloneEnabled = (standalone: boolean, standaloneProtocol: string, standaloneHost: string, standalonePort: string, standaloneDatabase: string, standaloneDashboardName: string, standaloneDashboardDatabase: string, standaloneDashboardURL: string, standaloneUsername: string, standalonePassword: string) => ({
type: SET_STANDALONE_ENABLED,
payload: { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL },
payload: { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL, standaloneUsername, standalonePassword },
});

export const SET_STANDALONE_MODE = 'APPLICATION/SET_STANDALONE_MODE';
Expand Down
6 changes: 4 additions & 2 deletions src/application/ApplicationReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
}

case SET_STANDALONE_ENABLED: {
const { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL } = payload;
const { standalone, standaloneProtocol, standaloneHost, standalonePort, standaloneDatabase, standaloneDashboardName, standaloneDashboardDatabase, standaloneDashboardURL, standaloneUsername, standalonePassword } = payload;
state = update(state, {
standalone: standalone,
standaloneProtocol: standaloneProtocol,
Expand All @@ -112,7 +112,9 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
standaloneDatabase: standaloneDatabase,
standaloneDashboardName: standaloneDashboardName,
standaloneDashboardDatabase: standaloneDashboardDatabase,
standaloneDashboardURL: standaloneDashboardURL
standaloneDashboardURL: standaloneDashboardURL,
standaloneUsername: standaloneUsername,
standalonePassword: standalonePassword
})
return state;
}
Expand Down
4 changes: 3 additions & 1 deletion src/application/ApplicationSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export const applicationGetStandaloneSettings = (state: any) => {
"standaloneDatabase": state.application.standaloneDatabase,
"standaloneDashboardName": state.application.standaloneDashboardName,
"standaloneDashboardDatabase": state.application.standaloneDashboardDatabase,
"standaloneDashboardURL": state.application.standaloneDashboardURL
"standaloneDashboardURL": state.application.standaloneDashboardURL,
"standaloneUsername": state.application.standaloneUsername,
"standalonePassword": state.application.standalonePassword
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/application/ApplicationThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
dispatch(setSSOEnabled(config['ssoEnabled'], config["ssoDiscoveryUrl"]));
const state = getState();
const standalone = config['standalone'];// || (state.application.shareDetails !== undefined && state.application.shareDetails.standalone);
dispatch(setStandaloneEnabled(standalone, config['standaloneProtocol'], config['standaloneHost'], config['standalonePort'], config['standaloneDatabase'], config['standaloneDashboardName'], config['standaloneDashboardDatabase'], config["standaloneDashboardURL"]))
dispatch(setStandaloneEnabled(standalone, config['standaloneProtocol'], config['standaloneHost'], config['standalonePort'], config['standaloneDatabase'], config['standaloneDashboardName'], config['standaloneDashboardDatabase'], config["standaloneDashboardURL"], config['standaloneUsername'], config['standalonePassword']))
dispatch(setConnectionModalOpen(false));

// Auto-upgrade the dashboard version if an old version is cached.
Expand Down
20 changes: 12 additions & 8 deletions src/card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,20 @@ const NeoCard = ({
const {driver} = useContext<Neo4jContextState>(Neo4jContext);

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

// fetching the list of databases from neo4j, filtering out the 'system' db
useEffect(() => {
loadDatabaseListFromNeo4j(driver, (result) => {
let index = result.indexOf("system")
if (index > -1) { // only splice array when item is found
result.splice(index, 1); // 2nd parameter means remove one item only
}
setDatabaseList(result)
});
if(!databaseListLoaded){
loadDatabaseListFromNeo4j(driver, (result) => {
let index = result.indexOf("system")
if (index > -1) { // only splice array when item is found
result.splice(index, 1); // 2nd parameter means remove one item only
}
setDatabaseList(result)
});
setDatabaseListLoaded(true);
}
}, [report.query]);

const [settingsOpen, setSettingsOpen] = React.useState(false);
Expand Down Expand Up @@ -204,7 +208,7 @@ const NeoCard = ({
const mapStateToProps = (state, ownProps) => ({
report: getReportState(state, ownProps.index),
editable: getDashboardIsEditable(state),
database: getDatabase(state, ownProps.dashboardSettings.pagenumber, ownProps.index),
database: getDatabase(state, ownProps && ownProps.dashboardSettings ? ownProps.dashboardSettings.pagenumber : undefined, ownProps.index),
globalParameters: getGlobalParameters(state)
});

Expand Down
10 changes: 7 additions & 3 deletions src/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Container from '@material-ui/core/Container';
import NeoDrawer from './drawer/DashboardDrawer';
import NeoDashboardHeader from './header/DashboardHeader';
import { createDriver, Neo4jProvider, useConnection } from 'use-neo4j';
import { applicationGetConnection, applicationHasAboutModalOpen } from '../application/ApplicationSelectors';
import { applicationGetConnection, applicationGetStandaloneSettings, applicationHasAboutModalOpen } from '../application/ApplicationSelectors';
import { connect } from 'react-redux';
import NeoDashboardConnectionUpdateHandler from '../component/misc/DashboardConnectionUpdateHandler';
import { forceRefreshPage } from '../page/PageActions';
Expand All @@ -15,7 +15,7 @@ import { downloadComponentAsImage } from '../chart/ChartUtils';



const Dashboard = ({ pagenumber, connection, onConnectionUpdate, onDownloadDashboardAsImage }) => {
const Dashboard = ({ pagenumber, connection, applicationSettings, onConnectionUpdate, onDownloadDashboardAsImage }) => {
const [drawerOpen, setDrawerOpen] = React.useState(false);
const driver = createDriver(connection.protocol, connection.url, connection.port, connection.username, connection.password);

Expand Down Expand Up @@ -43,6 +43,9 @@ const Dashboard = ({ pagenumber, connection, onConnectionUpdate, onDownloadDashb
></NeoDashboardHeader>
<main style={{ flexGrow: 1, height: '100vh', overflow: 'auto', backgroundColor: "#fafafa" }}>
<Container maxWidth="xl" style={{ marginTop: "60px" }}>
{applicationSettings.standalonePassword ? <div style={{textAlign: "center", color: "red", zIndex: 999, paddingTop: 60, marginBottom: -50}}>
Warning: NeoDash is running with a plaintext password in config.json.
</div> : <></>}
<NeoPage></NeoPage>
</Container>
</main>
Expand All @@ -52,7 +55,8 @@ const Dashboard = ({ pagenumber, connection, onConnectionUpdate, onDownloadDashb

const mapStateToProps = state => ({
connection: applicationGetConnection(state),
pagenumber: getPageNumber(state)
pagenumber: getPageNumber(state),
applicationSettings: applicationGetStandaloneSettings(state)
});

const mapDispatchToProps = dispatch => ({
Expand Down
2 changes: 1 addition & 1 deletion src/modal/AboutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import BugReportIcon from '@material-ui/icons/BugReport';

export const NeoAboutModal = ({ open, handleClose, getDebugState }) => {
const app = "NeoDash - Neo4j Dashboard Builder";
const version = "2.1.8";
const version = "2.1.9";

const downloadDebugFile = () => {
const element = document.createElement("a");
Expand Down
4 changes: 0 additions & 4 deletions src/report/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ export const NeoReport = ({

// Determine the set of fields from the configurations.
var numericFields = (REPORT_TYPES[type].selection && fields) ? Object.keys(REPORT_TYPES[type].selection).filter(field => REPORT_TYPES[type].selection[field].type == SELECTION_TYPES.NUMBER && !REPORT_TYPES[type].selection[field].multiple) : [];
var numericOrDatetimeFields = (REPORT_TYPES[type].selection && fields) ? Object.keys(REPORT_TYPES[type].selection).filter(field => REPORT_TYPES[type].selection[field].type == SELECTION_TYPES.NUMBER_OR_DATETIME && !REPORT_TYPES[type].selection[field].multiple) : [];
var textFields = (REPORT_TYPES[type].selection && fields) ? Object.keys(REPORT_TYPES[type].selection).filter(field => REPORT_TYPES[type].selection[field].type == SELECTION_TYPES.TEXT && !REPORT_TYPES[type].selection[field].multiple) : [];
var optionalFields = (REPORT_TYPES[type].selection && fields) ? Object.keys(REPORT_TYPES[type].selection).filter(field => REPORT_TYPES[type].selection[field].optional == true) : [];

// Take care of multi select fields, they need to be added to the numeric fields too.
if (REPORT_TYPES[type].selection) {
Expand All @@ -69,7 +66,6 @@ export const NeoReport = ({
});
}

const defaultKeyField = (REPORT_TYPES[type].selection) ? Object.keys(REPORT_TYPES[type].selection).find(field => REPORT_TYPES[type].selection[field].key == true) : undefined;
const useNodePropsAsFields = REPORT_TYPES[type].useNodePropsAsFields == true;
const useReturnValuesAsFields = REPORT_TYPES[type].useReturnValuesAsFields == true;

Expand Down
14 changes: 11 additions & 3 deletions src/settings/SettingsSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ The database related to a card is, at its start, the same as the one defined ins
a user can modify the database that is used by a card with a new option inside the card itself.
*/
export const getDatabase = (state: any, pageNumber:number, cardIndex:number) => {
let reportDatabase = state.dashboard.pages[pageNumber].reports[cardIndex].database
if (reportDatabase != undefined) {
if(state == undefined || pageNumber == undefined || cardIndex == undefined){
// TODO - use DMBS default database instead of neo4j.
return "neo4j";
}
if( state.dashboard.pages[pageNumber] == undefined || state.dashboard.pages[pageNumber].reports[cardIndex] == undefined){
// TODO - use DMBS default database instead of neo4j.
return "neo4j";
}
let reportDatabase = state.dashboard.pages[pageNumber].reports[cardIndex].database;
if (reportDatabase !== undefined) {
return reportDatabase
}
return state.application.connection.database.length > 0 ? state.application.connection.database : "neo4j"
return state.application.connection.database ? state.application.connection.database : "neo4j";
}

0 comments on commit 5c64c35

Please sign in to comment.