Skip to content

Commit

Permalink
Use new desktop api
Browse files Browse the repository at this point in the history
Act on GRAPH_ACTIVE and GRAPH_INACTIVE rather than DATABASE_STARTED and DATABASE_STOPPED
  • Loading branch information
oskarhane committed Oct 17, 2017
1 parent 3daab6f commit 270d800
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"homepage": "https://neo4j.com",
"main": "dist/index.html",
"neo4jDesktop": {
"apiVersion": "1.1.0"
"apiVersion": "^1.2.0"
},
"scripts": {
"start":
Expand Down
11 changes: 5 additions & 6 deletions src/browser/modules/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class App extends Component {
<DesktopIntegration
integrationPoint={this.props.desktopIntegrationPoint}
onMount={this.props.setInitialConnectionData}
onDatabaseStarted={this.props.changeConnectionMaybe}
onDatabaseStopped={this.props.closeConnectionMaybe}
onGraphActive={this.props.switchConnection}
onGraphInactive={this.props.closeConnectionMaybe}
/>
<Render if={loadExternalScripts}>
<Intercom appID='lq70afwx' />
Expand Down Expand Up @@ -176,14 +176,13 @@ const mapDispatchToProps = dispatch => {
}

const mergeProps = (stateProps, dispatchProps, ownProps) => {
const changeConnectionMaybe = (event, newContext, oldContext) => {
const didChange = didChangeActiveGraph(newContext, oldContext)
if (!didChange) return
const switchConnection = (event, newContext, oldContext) => {
const creds = getActiveCredentials('bolt', newContext)
if (!creds) return // No conection. Ignore and let browser show connection lost msgs.
const connectionCreds = {
// Use current connections creds until we get new from API
...stateProps.defaultConnectionData,
...creds,
encrypted: creds.tlsLevel === 'REQUIRED',
host: `bolt://${creds.host}:${creds.port}`
}
Expand All @@ -209,7 +208,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
...stateProps,
...ownProps,
...dispatchProps,
changeConnectionMaybe,
switchConnection,
setInitialConnectionData,
closeConnectionMaybe
}
Expand Down
24 changes: 18 additions & 6 deletions src/browser/modules/Stream/Auth/ConnectedView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,34 @@ const ConnectedView = ({
host,
username,
storeCredentials,
hideStoreCredentials = false,
additionalFooter = null,
showHost = true
}) => {
return (
<StyledConnectionBody>
You are connected as user <StyledCode>{username}</StyledCode>
<br />
<Render if={username}>
<span>
You are connected as user <StyledCode>{username}</StyledCode>
<br />
</span>
</Render>
<Render if={!username}>You are connected </Render>
<Render if={showHost}>
<span>
to the server <StyledCode>{host}</StyledCode>
<br />
</span>
</Render>
<StyledConnectionFooter>
Connection credentials are {storeCredentials ? '' : 'not '}stored in
your web browser.
</StyledConnectionFooter>
<Render if={!hideStoreCredentials}>
<StyledConnectionFooter>
Connection credentials are {storeCredentials ? '' : 'not '}stored in
your web browser.
</StyledConnectionFooter>
</Render>
<Render if={additionalFooter}>
<StyledConnectionFooter>{additionalFooter}</StyledConnectionFooter>
</Render>
</StyledConnectionBody>
)
}
Expand Down
26 changes: 18 additions & 8 deletions src/browser/modules/Stream/Auth/ServerSwitchFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import ClickToCode from '../../ClickToCode'

class ServerStatusFrame extends Component {
render () {
const { frame } = this.props
const {
frame,
activeConnectionData: dynamicConnectionData = {}
} = this.props
const { activeConnectionData, storeCredentials } = frame
return (
<FrameTemplate
Expand All @@ -49,7 +52,8 @@ class ServerStatusFrame extends Component {
<StyledConnectionBodyContainer>
<Render if={frame.type === 'switch-fail'}>
<StyledConnectionBody>
The updated credentials was not correct.
The connection credentials provided could not be used to
connect.
<br />
You are now disconnected.
<br />
Expand All @@ -61,7 +65,8 @@ class ServerStatusFrame extends Component {
if={
frame.type === 'switch-success' &&
activeConnectionData &&
activeConnectionData.authEnabled
dynamicConnectionData &&
dynamicConnectionData.authEnabled
}
>
<ConnectedView
Expand All @@ -77,13 +82,18 @@ class ServerStatusFrame extends Component {
if={
frame.type === 'switch-success' &&
activeConnectionData &&
!activeConnectionData.authEnabled
dynamicConnectionData &&
!dynamicConnectionData.authEnabled
}
>
<StyledConnectionBody>
You have a working connection with the Neo4j database and
server auth is disabled.
</StyledConnectionBody>
<div>
<ConnectedView
host={activeConnectionData && activeConnectionData.host}
showHost
hideStoreCredentials
additionalFooter='You have a working connection with the Neo4j database and server auth is disabled.'
/>
</div>
</Render>
</StyledConnectionBodyContainer>
</StyledConnectionFrame>
Expand Down

0 comments on commit 270d800

Please sign in to comment.