Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with desktop API #664

Merged
merged 14 commits into from
Oct 17, 2017
Merged

Conversation

oskarhane
Copy link
Member

@oskarhane oskarhane commented Oct 13, 2017

New component

We added the DesktopIntegration component which reads initial context and sets up a listener for events that the desktop att emits.
To react on events happening you attach props to the component in the form of EVENT_NAME -> onEventName.
Example on react on DATABASE_STARTED ->

<DesktopIntegration 
  integrationPoint={window.neo4jDesktopApi} 
  onDatabaseStarted={(event, newContext, oldConext) => alert(event.type)}  
/>

To get the initial context on app load, you attach the

onMount={(activeGraph, boltCredentials, fullContext) => alert(activeGraph.id)}

Features

In web env, no changes are expected.
In desktop env, this should be the behaviour:

When browser is opened when a graph already is running:

  • Get host + port from desktop api and populate the connection fields with those.
  • In the case of username and pw in browsers local storage not being correct, show :server connect and the host should be what the active graph has.
  • In the case of username and pw being correct, connect and show start frame.

When browser is open and connected and graph is shut down:

  • Show connect banner right away
  • Empty metadata
  • Keep username and pw in memory

When browser is open but not connected to a graph and a graph starts:

  • Get credentials (host and encryption mode) from desktop api and re-use stored username and pw and try to connect.
  • If successful
    • Show :server switch success frame and inform about the connection switch.
    • Update metadata
  • If unsuccessful
    • Show :server switch fail frame and inform about the failure
    • User clicks :server connect link to manually enter creds.

Worth mentions

  • To our mount function in testUtils.js we can now pass a second param with props to get to test the componentDidMount lifecycle method.
  • Environment detection added. In appDuck.js there are now selectors to check what environment the browser lives in. Useful for code branching.
  • The plan is that the functions in DesktopIntegration/helpers.js should be used by outside components to extract and compare data coming from the desktop api.

oskarhane-mbpt 2017-10-13 at 13 59 05

@oskarhane oskarhane force-pushed the 3.0-desktop-integration branch 2 times, most recently from 48db676 to 3a96a92 Compare October 13, 2017 14:44
@oskarhane oskarhane force-pushed the 3.0-desktop-integration branch from 3a96a92 to f360b9e Compare October 16, 2017 06:36
@oskarhane
Copy link
Member Author

Blocking this from merging now since we need to update it to adhere to the new api context format

@oskarhane
Copy link
Member Author

Updated to use new API version

Act on GRAPH_ACTIVE and GRAPH_INACTIVE rather than DATABASE_STARTED and DATABASE_STOPPED
@oskarhane oskarhane force-pushed the 3.0-desktop-integration branch from 270d800 to 476c344 Compare October 17, 2017 06:53
@pe4cey pe4cey merged commit 6ed2f11 into neo4j:3.0 Oct 17, 2017
@oskarhane oskarhane deleted the 3.0-desktop-integration branch October 17, 2017 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants