@@ -144,9 +144,8 @@ export const onConfirmLoadSharedDashboardThunk = () => (dispatch: any, getState:
144144 const shareDetails = state . application . shareDetails ;
145145 dispatch ( setWelcomeScreenOpen ( false ) ) ;
146146 dispatch ( setDashboardToLoadAfterConnecting ( shareDetails . id ) ) ;
147- if ( shareDetails . dashboardDatabase ) {
147+ if ( shareDetails . dashboardDatabase ) {
148148 dispatch ( setStandaloneDashboardDatabase ( shareDetails . dashboardDatabase ) ) ;
149-
150149 dispatch ( setStandaloneDashboardDatabase ( shareDetails . database ) ) ;
151150 }
152151 if ( shareDetails . url ) {
@@ -172,13 +171,13 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
172171 standaloneProtocol : "neo4j" ,
173172 standaloneHost : "localhost" ,
174173 standalonePort : "7687" ,
175- standaloneDatabase : "neo4j" ,
174+ standaloneDatabase : "neo4j" ,
176175 standaloneDashboardName : "My Dashboard" ,
177- standaloneDashboardDatabase : "dashboards"
176+ standaloneDashboardDatabase : "dashboards"
178177 }
179178 try {
180179 config = await ( await fetch ( "/config.json" ) ) . json ( ) ;
181- } catch ( e ) {
180+ } catch ( e ) {
182181 // Config may not be found, for example when we are in Neo4j Desktop.
183182 console . log ( "No config file detected. Setting to safe defaults." )
184183 }
@@ -188,13 +187,31 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
188187 const standalone = config [ 'standalone' ] ; // || (state.application.shareDetails !== undefined && state.application.shareDetails.standalone);
189188 dispatch ( setStandaloneEnabled ( standalone , config [ 'standaloneProtocol' ] , config [ 'standaloneHost' ] , config [ 'standalonePort' ] , config [ 'standaloneDatabase' ] , config [ 'standaloneDashboardName' ] , config [ 'standaloneDashboardDatabase' ] ) )
190189 if ( standalone ) {
191- dispatch ( setConnectionProperties ( config [ 'standaloneProtocol' ] , config [ 'standaloneHost' ] , config [ 'standalonePort' ] , config [ 'standaloneDatabase' ] , state . application . connection . username , state . application . connection . password ) ) ;
192- dispatch ( setConnectionModalOpen ( true ) ) ;
190+ // If we are running in standalone mode, auto-set the connection details that are configured.
191+ dispatch ( setConnectionProperties (
192+ config [ 'standaloneProtocol' ] ,
193+ config [ 'standaloneHost' ] ,
194+ config [ 'standalonePort' ] ,
195+ config [ 'standaloneDatabase' ] ,
196+ config [ 'standaloneUsername' ] ? config [ 'standaloneUsername' ] : state . application . connection . username ,
197+ config [ 'standalonePassword' ] ? config [ 'standalonePassword' ] : state . application . connection . password ) ) ;
198+
193199 dispatch ( setAboutModalOpen ( false ) ) ;
194200 dispatch ( setConnected ( false ) ) ;
195201 dispatch ( setWelcomeScreenOpen ( false ) ) ;
196202 dispatch ( setDashboardToLoadAfterConnecting ( "name:" + config [ 'standaloneDashboardName' ] ) ) ;
197203 dispatch ( clearNotification ( ) ) ;
204+ // Override for when username and password are specified in the config - automatically connect to the specified URL.
205+ if ( config [ 'standaloneUsername' ] && config [ 'standalonePassword' ] ) {
206+ dispatch ( createConnectionThunk ( config [ 'standaloneProtocol' ] ,
207+ config [ 'standaloneHost' ] ,
208+ config [ 'standalonePort' ] ,
209+ config [ 'standaloneDatabase' ] ,
210+ config [ 'standaloneUsername' ] ,
211+ config [ 'standalonePassword' ] ) ) ;
212+ } else {
213+ dispatch ( setConnectionModalOpen ( true ) ) ;
214+ }
198215 } else {
199216 dispatch ( clearDesktopConnectionProperties ( ) ) ;
200217 dispatch ( setDatabaseFromNeo4jDesktopIntegrationThunk ( ) ) ;
0 commit comments