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

Update :server connect form to pick database #1194

Merged
merged 21 commits into from
Oct 5, 2020

Conversation

OskarDamkjaer
Copy link
Contributor

@OskarDamkjaer OskarDamkjaer commented Sep 15, 2020

Introduces a db url param for selecting a database and dbms as an alternative param to connectURL.

Prefills form from the url like so:
bild

@@ -156,7 +167,11 @@ export const discoveryOnStartupEpic = (some$, store) => {
getAllowedBoltSchemes(store.getState()),
host
)
store.dispatch(updateDiscoveryConnection({ host })) // Update discovery host in redux
const supportsMultiDb =
parseInt((result.neo4j_version || '0').charAt(0)) >= 4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking there's a better way to get version number? Or is this fine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not the whole truth, I think. Some Aura editions has version 4 but do not support multi-db.
Better check with them what version they expose in the discovery endpoint.
Ugly things like

if (['4.0-aura', '4.0-AuraProfessional'].includes(serverInfo.version)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do you suggest we check that the version starts with 4 and is not running on aura?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, good catch!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some aura editions do support multi-db, so it's tricky. I suggest you talk to Aura and ask which editions that has multi-db support and what version string those editions expose in the discovery endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asked just now!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems aura only supports the system + 1 other database at this moment. I think it'd make sense to disable the field for aura, WDYT?

@OskarDamkjaer OskarDamkjaer marked this pull request as ready for review September 16, 2020 09:39
Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, well done!

I have a few comments on naming and UI.

Connect frame UI

I don't think this looks particularly good to be honest. The form looks very unusual.
Screen Shot 2020-09-18 at 15 05 12

Auto-connect on refresh

It looks like the auto-connect doesn't work anymore. Successfully connect. Refresh page. You should auto-connect.

Continuously trying to :use

In the scenario of connecting successfully but using a db that doesn't exist for some reason, it looks like it's running :use on every dbmeta-tick.
Screen Shot 2020-09-18 at 15 14 24

@@ -156,7 +167,11 @@ export const discoveryOnStartupEpic = (some$, store) => {
getAllowedBoltSchemes(store.getState()),
host
)
store.dispatch(updateDiscoveryConnection({ host })) // Update discovery host in redux
const supportsMultiDb =
parseInt((result.neo4j_version || '0').charAt(0)) >= 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not the whole truth, I think. Some Aura editions has version 4 but do not support multi-db.
Better check with them what version they expose in the discovery endpoint.
Ugly things like

if (['4.0-aura', '4.0-AuraProfessional'].includes(serverInfo.version)) {

data-testid="database"
onChange={props.onDatabaseChange}
value={props.database}
placeholder="default database"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change this to "Database to use" or something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the label? I think the current placeholder makes sense

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't :)
It's not a default db the users enters, it's the target db that the user wants to use when a connection is made.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah and that's why the place holder is there to show what happens if you leave the field empty! Right now it think it makes sense to have a field titled "Database to use" and the default/placeholder being "default database". Having both be "database to use" I think would lead to me thinking the field was required

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your reasoning, but placeholders are hints on what the users should enter, not to indicate value if left blank.
The label could suggest "leave empty for default)" or something to let the users know what happens if it's left empty.

@OskarDamkjaer
Copy link
Contributor Author

Good catches, didn't see the screen shots you sent! Thanks a lot! :))

@OskarDamkjaer
Copy link
Contributor Author

Updated the form styling when I was thinking we'd always show the db field. Then it got really tall, but now when I know that's not the case I reverted to the older styling because it was simpler code wise and familiar.

@OskarDamkjaer
Copy link
Contributor Author

Not 100% sure the aura check works. What would be the best way to try it out? Not sure where to find the discovery response object

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good changes!

Still has a few more issues though:

  1. When choosing something other than the default db, there's a delay until next dbMeta to update the meta items in the sidebar. See gif.
    CleanShot 2020-10-01 at 08 46 30

  2. Same thing when entering a db that doesn't exist for the user. It takes until next dbmeta tick to update the UI with the correct info.
    CleanShot 2020-10-01 at 08 51 25

Also, would it be possible to add e2e test for checking so browser actually switches to use the entered db?
And maybe the error case as well?


const isAura = getEnv(store.getState()) === CLOUD
const supportsMultiDb =
!isAura && parseInt((result.neo4j_version || '0').charAt(0)) >= 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there Aura editions that support multi-db?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From asking there's only editions with proper support for multi-db. At most they support the system-db in addition to the default one. So I think if it's important there, you'll have to use the url param

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to behave as expected now, well done!
You just need to be extra cautious to make sure one failure in the forkJoin doesn't cancel the other ones + cancels the whole listener.

But other than that, 👍

Ping me to review when you're catching any errors and I'll approve it

@@ -105,5 +111,68 @@ describe('Connect form', () => {
cy.connect('neo4j', Cypress.config('password'), boltUrl)
cy.executeCommand(':server disconnect')
})

if (isEnterpriseEdition()) {
it.only('shows correct metadata when using db field', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No .only please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll set up an on commit hook for this so I won't forget it again

Comment on lines +487 to +490
return Rx.Observable.forkJoin([
getLabelsAndTypes(store),
clusterRole(store),
databaseList(store)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if one of these errors we'll need to keep the stream going, so I'f like to see some error catching here

Copy link
Member

@oskarhane oskarhane Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if I remember correctly, if one fail the other ones are cancelled as well, so I think you need to catch on each one of the inner ones.

Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌮 Merge on green tests 🌮

@OskarDamkjaer OskarDamkjaer merged commit 6eb5201 into neo4j:master Oct 5, 2020
@OskarDamkjaer OskarDamkjaer deleted the db_form branch October 5, 2020 14:44
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.

3 participants