Skip to content

Commit 476c344

Browse files
committed
Use new desktop api
Act on GRAPH_ACTIVE and GRAPH_INACTIVE rather than DATABASE_STARTED and DATABASE_STOPPED
1 parent 3daab6f commit 476c344

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"homepage": "https://neo4j.com",
1313
"main": "dist/index.html",
1414
"neo4jDesktop": {
15-
"apiVersion": "1.1.0"
15+
"apiVersion": "^1.2.0"
1616
},
1717
"scripts": {
1818
"start":

src/browser/modules/App/App.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import Render from 'browser-components/Render'
6464
import BrowserSyncInit from '../Sync/BrowserSyncInit'
6565
import DesktopIntegration from 'browser-components/DesktopIntegration'
6666
import {
67-
didChangeActiveGraph,
6867
getActiveCredentials,
6968
getActiveGraph
7069
} from 'browser-components/DesktopIntegration/helpers'
@@ -113,8 +112,8 @@ class App extends Component {
113112
<DesktopIntegration
114113
integrationPoint={this.props.desktopIntegrationPoint}
115114
onMount={this.props.setInitialConnectionData}
116-
onDatabaseStarted={this.props.changeConnectionMaybe}
117-
onDatabaseStopped={this.props.closeConnectionMaybe}
115+
onGraphActive={this.props.switchConnection}
116+
onGraphInactive={this.props.closeConnectionMaybe}
118117
/>
119118
<Render if={loadExternalScripts}>
120119
<Intercom appID='lq70afwx' />
@@ -176,14 +175,13 @@ const mapDispatchToProps = dispatch => {
176175
}
177176

178177
const mergeProps = (stateProps, dispatchProps, ownProps) => {
179-
const changeConnectionMaybe = (event, newContext, oldContext) => {
180-
const didChange = didChangeActiveGraph(newContext, oldContext)
181-
if (!didChange) return
178+
const switchConnection = (event, newContext, oldContext) => {
182179
const creds = getActiveCredentials('bolt', newContext)
183180
if (!creds) return // No conection. Ignore and let browser show connection lost msgs.
184181
const connectionCreds = {
185182
// Use current connections creds until we get new from API
186183
...stateProps.defaultConnectionData,
184+
...creds,
187185
encrypted: creds.tlsLevel === 'REQUIRED',
188186
host: `bolt://${creds.host}:${creds.port}`
189187
}
@@ -209,7 +207,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
209207
...stateProps,
210208
...ownProps,
211209
...dispatchProps,
212-
changeConnectionMaybe,
210+
switchConnection,
213211
setInitialConnectionData,
214212
closeConnectionMaybe
215213
}

src/browser/modules/Stream/Auth/ConnectedView.jsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,34 @@ const ConnectedView = ({
2929
host,
3030
username,
3131
storeCredentials,
32+
hideStoreCredentials = false,
33+
additionalFooter = null,
3234
showHost = true
3335
}) => {
3436
return (
3537
<StyledConnectionBody>
36-
You are connected as user <StyledCode>{username}</StyledCode>
37-
<br />
38+
<Render if={username}>
39+
<span>
40+
You are connected as user <StyledCode>{username}</StyledCode>
41+
<br />
42+
</span>
43+
</Render>
44+
<Render if={!username}>You are connected </Render>
3845
<Render if={showHost}>
3946
<span>
4047
to the server <StyledCode>{host}</StyledCode>
4148
<br />
4249
</span>
4350
</Render>
44-
<StyledConnectionFooter>
45-
Connection credentials are {storeCredentials ? '' : 'not '}stored in
46-
your web browser.
47-
</StyledConnectionFooter>
51+
<Render if={!hideStoreCredentials}>
52+
<StyledConnectionFooter>
53+
Connection credentials are {storeCredentials ? '' : 'not '}stored in
54+
your web browser.
55+
</StyledConnectionFooter>
56+
</Render>
57+
<Render if={additionalFooter}>
58+
<StyledConnectionFooter>{additionalFooter}</StyledConnectionFooter>
59+
</Render>
4860
</StyledConnectionBody>
4961
)
5062
}

src/browser/modules/Stream/Auth/ServerSwitchFrame.jsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ import ClickToCode from '../../ClickToCode'
3333

3434
class ServerStatusFrame extends Component {
3535
render () {
36-
const { frame } = this.props
36+
const {
37+
frame,
38+
activeConnectionData: dynamicConnectionData = {}
39+
} = this.props
3740
const { activeConnectionData, storeCredentials } = frame
3841
return (
3942
<FrameTemplate
@@ -49,7 +52,8 @@ class ServerStatusFrame extends Component {
4952
<StyledConnectionBodyContainer>
5053
<Render if={frame.type === 'switch-fail'}>
5154
<StyledConnectionBody>
52-
The updated credentials was not correct.
55+
The connection credentials provided could not be used to
56+
connect.
5357
<br />
5458
You are now disconnected.
5559
<br />
@@ -61,7 +65,8 @@ class ServerStatusFrame extends Component {
6165
if={
6266
frame.type === 'switch-success' &&
6367
activeConnectionData &&
64-
activeConnectionData.authEnabled
68+
dynamicConnectionData &&
69+
dynamicConnectionData.authEnabled
6570
}
6671
>
6772
<ConnectedView
@@ -77,13 +82,18 @@ class ServerStatusFrame extends Component {
7782
if={
7883
frame.type === 'switch-success' &&
7984
activeConnectionData &&
80-
!activeConnectionData.authEnabled
85+
dynamicConnectionData &&
86+
!dynamicConnectionData.authEnabled
8187
}
8288
>
83-
<StyledConnectionBody>
84-
You have a working connection with the Neo4j database and
85-
server auth is disabled.
86-
</StyledConnectionBody>
89+
<div>
90+
<ConnectedView
91+
host={activeConnectionData && activeConnectionData.host}
92+
showHost
93+
hideStoreCredentials
94+
additionalFooter='You have a working connection with the Neo4j database and server auth is disabled.'
95+
/>
96+
</div>
8797
</Render>
8898
</StyledConnectionBodyContainer>
8999
</StyledConnectionFrame>

0 commit comments

Comments
 (0)