Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Master dev (#96)
Browse files Browse the repository at this point in the history
* Create CONTRIBUTING.md

* Update README.md

* Update CONTRIBUTING.md

* Fix overflow

* Publish package to NPM

* Fix for CI and publish

* Remove Redux (#71)

* package bump

* remove redux packages

* remove redux logic

* remove actions, reducers and store

* update spec imports

* Trigger github action on both push and PR

* Test with jest (#73)

* package bump

* remove redux packages

* remove redux logic

* remove actions, reducers and store

* update spec imports

* replace enzyme with jest

* delete old specs and restructure code

* add test structure

* zero binds for local functions

* refactor and debug tests

* act on clicks

* delete old layers folder

* delete old layer spec

* rewrite sidebaar to functional component

* rewrite App as a functional component

* Remove nodejs 8 from CI workflow

* move seed data to consts

* rewrite sidebar as fucntional component

* rewrite menu as functional component

* ref to loaded driver

* rewrite map component as function

* review map and add test data

* sequence full map operations

* mock out leaflet

* usable test data, pause ut on map

* rewrite color picker as functional component

* singleton neo4j driver and service

* formalise error and result api on neo4jservice

* use error and result apiin layer ui

* fix map reinstantiation error

* format leaflet mock

* fix result filters

* optimise create driver

* dry session runner

* scaffold neo4j service tests

* tests and service refactors

* fix token fetch for driver init

* fix records query

* Fix several bugs (#88)

* Make the app work again...

* Enhanced master fix (#89)

* enhanced master fix

* map and layer pane fixes

* update layer tests

* class => className

* Do not force name (for now)

Co-authored-by: Konuko Jodom <[email protected]>

* Several fixes, including #81 and #82

* Fix tests (?)

* re-generate lock file

Co-authored-by: Konuko Jodom <[email protected]>
Co-authored-by: nikita <[email protected]>
  • Loading branch information
3 people authored Sep 17, 2021
1 parent b6471c5 commit 1138e4e
Show file tree
Hide file tree
Showing 36 changed files with 5,244 additions and 5,808 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Node CI

on: [push]
on: [push, pull_request]

jobs:
build:
Expand All @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
registry=https://neo.jfrog.io/neo/api/npm/npm/
registry=https://neo.jfrog.io/neo/api/npm/npm/
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contribution guide (WIP)

All contributions are currently welcome. Some tasks that are in our priority list right now include:
- Code review and improvements using latest React release and standard (hooks) https://github.com/stellasia/neomap/issues/55
- Write real covering tests https://github.com/stellasia/neomap/issues/62
- Map: feature request: https://github.com/stellasia/neomap/issues/51
- UI needs to be checked by someone with more experience in UI/UX

## Issue contribution

Open an issue if:
- You encounter problems installing or using neomap
- You find something that looks like a bug (even if you are unsure)
- You would like us to include a new feature


## Documentation contribution

Right now the documentation is hosted on GitHub wiki: https://github.com/stellasia/neomap/wiki. Contact me if you would like to help improving it.


## Code contribution

1. Let the others know you are working on the topic:
- comment on an existing issue or
- create a new issue if the topic is new. It will also allow us to make sure we are all aligned with the direction we want to push the project to.
2. Clone the repo and start a new branch on your local clone
3. Develop on your branch
4. Make sure you are not breaking tests and potentially add new ones (ok, given the state of the tests right now, this is not a big constraint)
5. Open a PR againt the dev branch referencing the issue

34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ A Neo4J Desktop (React-based) application to visualize nodes with geographical a

### Add the app to Neo4jDesktop

#### From NPM package URL (Recommended)

1. Open neo4j desktop and go to "Graph Applications" view:

![](img/desktop_graphapp_install.png)

2. Paste the following link in the text input:

https://registry.npmjs.org/neomap


#### From tarball

1. Go to the repository [releases](https://github.com/stellasia/neomap/releases)
2. Download the `neomap-<version>.tar.gz`
3. Open neo4j desktop and go to "Graph Applications" view:

![](img/desktop_graphapp_install.png)

3. Open neo4j desktop and go to "Graph Applications" view (see image in previous section)
4. Drag and drop the tarball you downloaded earlier below "Install Graph Application"
5. Trust the application
6. The application is now available and you can add it to your projects:
Expand All @@ -32,12 +40,15 @@ A Neo4J Desktop (React-based) application to visualize nodes with geographical a

![](img/desktop_graphapp_add_2.png)


## Usage

Read the [tutorial](https://github.com/stellasia/neomap/wiki/NeoMap-Tutorial/) or the [FAQ](https://github.com/stellasia/neomap/wiki/FAQ).

## Want to contribute?

See [CONTRIBUTING.md](CONTRIBUTING.md).

### WARNING

I am a data scientist, not a front-end developer. If someone with expertise with React wants to take a look and suggest improvements, that would be very welcome!
Expand All @@ -62,3 +73,18 @@ I am a data scientist, not a front-end developer. If someone with expertise with
5. Run tests: install dev dependencies and

npm run test

### Build for release (TODO: add this to CI?)

1. Make sure the version in package.json is correct
2. Build:

npm run build

3. Create tgz package:

npm pack

4. Publish to NPM: (after npm login):

npm publish neomap-<VERSION>.tgz # --registry=https://registry.npmjs.org
170 changes: 170 additions & 0 deletions __mocks__/leaflet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/**
* This is a copy of the very nice jest leaflet mock from
* [react-leaflet](https://github.com/PaulLeCam/react-leaflet/blob/master/__mocks__/leaflet.js).
*
* Consider contributing back to the package :)
*/

import { L } from 'leaflet';
const LeafletMock = jest.createMockFromModule('leaflet')

class ControlMock extends LeafletMock.Control {
constructor(options) {
super()
this.options = { ...L.Control.prototype.options, ...options }
}

getPosition() {
return this.options.position
}

setPosition(position) {
this.options.position = position
return this
}
}

const controlMock = (options) => new ControlMock(options)

class LayersControlMock extends ControlMock {
constructor(baseLayers = [], overlays = [], options) {
super(options)
this._layers = []

baseLayers.forEach((layer, i) => {
this._addLayer(layer, i)
})
overlays.forEach((layer, i) => {
this._addLayer(layer, i, true)
})
}

_addLayer(layer, name, overlay) {
this._layers.push({ layer, name, overlay })
}

addBaseLayer(layer, name) {
this._addLayer(layer, name)
return this
}

addOverlay(layer, name) {
this._addLayer(layer, name, true)
return this
}

removeLayer(obj) {
this._layers.splice(this._layers.indexOf(obj), 1)
}
}

ControlMock.Layers = LayersControlMock
controlMock.layers = (baseLayers, overlays, options) => {
return new LayersControlMock(baseLayers, overlays, options)
}

class MapMock extends LeafletMock.Map {
constructor(id, options = {}) {
super()
Object.assign(this, L.Evented.prototype)

this.options = { ...L.Map.prototype.options, ...options }
this._container = id

if (options.bounds) {
this.fitBounds(options.bounds, options.boundsOptions)
}

if (options.maxBounds) {
this.setMaxBounds(options.maxBounds)
}

if (options.center && options.zoom !== undefined) {
this.setView(L.latLng(options.center), options.zoom)
}
}

_limitZoom(zoom) {
const min = this.getMinZoom()
const max = this.getMaxZoom()
return Math.max(min, Math.min(max, zoom))
}

_resetView(center, zoom) {
this._initialCenter = center
this._zoom = zoom
}

fitBounds(bounds, options) {
this._bounds = bounds
this._boundsOptions = options
}

getBounds() {
return this._bounds
}

getCenter() {
return this._initialCenter
}

getMaxZoom() {
return this.options.maxZoom === undefined ? Infinity : this.options.maxZoom
}

getMinZoom() {
return this.options.minZoom === undefined ? 0 : this.options.minZoom
}

getZoom() {
return this._zoom
}

setMaxBounds(bounds) {
bounds = L.latLngBounds(bounds)
this.options.maxBounds = bounds
return this
}

setView(center, zoom) {
zoom = zoom === undefined ? this.getZoom() : zoom
this._resetView(L.latLng(center), this._limitZoom(zoom))
return this
}

setZoom(zoom) {
return this.setView(this.getCenter(), zoom)
}
}

class PopupMock extends LeafletMock.Popup {
constructor(options, source) {
super()
Object.assign(this, L.Evented.prototype)

this.options = { ...L.Popup.prototype.options, ...options }
this._source = source
}

getContent() {
return this._content
}

setContent(content) {
this._content = content
}
}

module.exports = {
...LeafletMock,
Control: ControlMock,
control: controlMock,
LatLng: L.LatLng,
latLng: L.latLng,
LatLngBounds: L.LatLngBounds,
latLngBounds: L.latLngBounds,
Map: MapMock,
map: (id, options) => new MapMock(id, options),
Popup: PopupMock,
popup: (options, source) => new PopupMock(options, source),
}
33 changes: 33 additions & 0 deletions __mocks__/neo4jDesktopApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Object.defineProperty(window, 'neo4jDesktopApi', {
writable: true,
value: {
getContext: jest.fn().mockImplementation(() => {
const mockGraph = {
name: 'mock graph',
description: 'mock graph for testing',
status: 'ACTIVE',
connection: {
configuration: {
protocols: {
bolt: {
url: '',
username: '',
password: ''
}
}
}
}
}

const mockProject = {
graphs: [mockGraph]
}

const mockContext = {
projects: [mockProject]
}

return Promise.resolve(mockContext);
})
}
});
Loading

0 comments on commit 1138e4e

Please sign in to comment.