Skip to content

Commit 6adc67f

Browse files
rename connection form (#1875)
1 parent 2814ccd commit 6adc67f

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

src/browser/modules/Stream/Auth/ChangePasswordFrame.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { connect } from 'react-redux'
2222

2323
import FrameBodyTemplate from '../../Frame/FrameBodyTemplate'
2424
import FrameError from '../../Frame/FrameError'
25-
import ConnectionForm from './ConnectionForm'
25+
import ConnectionFormController from './ConnectionFormController'
2626
import { StyledConnectionAside } from './styled'
2727
import { Lead } from 'browser-components/Text'
2828
import { H3 } from 'browser-components/headers'
@@ -71,7 +71,7 @@ class ChangePasswordFrame extends Component<any, ChangePasswordFrameState> {
7171
</StyledConnectionAside>
7272

7373
{this.props.activeConnection && (
74-
<ConnectionForm
74+
<ConnectionFormController
7575
{...this.props}
7676
error={this.error}
7777
onSuccess={this.onSuccess}

src/browser/modules/Stream/Auth/ConnectionForm.test.tsx renamed to src/browser/modules/Stream/Auth/ConnectionFormController.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { fireEvent, render } from '@testing-library/react'
2121
import React from 'react'
2222

23-
import { ConnectionForm } from './ConnectionForm'
23+
import { ConnectionFormController } from './ConnectionFormController'
2424
import { NATIVE, NO_AUTH } from 'services/bolt/boltHelpers'
2525

2626
test('should print correct state for retaining credentials', async () => {
@@ -41,7 +41,7 @@ test('should print correct state for retaining credentials', async () => {
4141

4242
// When
4343
const { rerender, getByText, getByTestId } = render(
44-
<ConnectionForm
44+
<ConnectionFormController
4545
frame={frame}
4646
error={error}
4747
bus={bus}
@@ -74,7 +74,7 @@ test('should print correct state for retaining credentials', async () => {
7474
authEnabled: true
7575
}
7676
rerender(
77-
<ConnectionForm
77+
<ConnectionFormController
7878
frame={frame}
7979
bus={bus}
8080
activeConnectionData={activeConnectionData}
@@ -99,7 +99,7 @@ test('should print correct state for retaining credentials', async () => {
9999
// When not storing credentials anymore
100100
storeCredentials = false
101101
rerender(
102-
<ConnectionForm
102+
<ConnectionFormController
103103
frame={frame}
104104
bus={bus}
105105
activeConnectionData={activeConnectionData}

src/browser/modules/Stream/Auth/ConnectionForm.tsx renamed to src/browser/modules/Stream/Auth/ConnectionFormController.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ import {
6464
stripScheme
6565
} from 'shared/services/boltscheme.utils'
6666
import { isCloudHost } from 'shared/services/utils'
67-
68-
type ConnectionFormState = any
67+
import { Neo4jError } from 'neo4j-driver'
68+
import { GlobalState } from 'shared/globalState'
6969

7070
const isAuraHost = (host: string) => isCloudHost(host, NEO4J_CLOUD_DOMAINS)
7171

@@ -76,7 +76,7 @@ function getAllowedAuthMethodsForHost(host: string): AuthenticationMethod[] {
7676
const getAllowedSchemesForHost = (host: string, allowedSchemes: string[]) =>
7777
isAuraHost(host) ? CLOUD_SCHEMES : allowedSchemes
7878

79-
export class ConnectionForm extends Component<any, ConnectionFormState> {
79+
export class ConnectionFormController extends Component<any, any> {
8080
constructor(props: any) {
8181
super(props)
8282
const connection = this.getConnection()
@@ -106,7 +106,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
106106
}
107107
}
108108

109-
componentDidMount() {
109+
componentDidMount(): void {
110110
const { authenticationMethod } = this.state
111111
if (authenticationMethod === NO_AUTH) {
112112
this.connect(() => this.setState({ connecting: false }))
@@ -269,11 +269,17 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
269269
this.props.error({})
270270
}
271271

272-
onChangePasswordChange() {
272+
onChangePasswordChange(): void {
273273
this.props.error({})
274274
}
275275

276-
onChangePassword({ newPassword, error }: any) {
276+
onChangePassword({
277+
newPassword,
278+
error
279+
}: {
280+
newPassword: string
281+
error?: Neo4jError
282+
}): void {
277283
this.setState({ isLoading: true })
278284
if (error && error.code) {
279285
this.setState({ isLoading: false })
@@ -332,7 +338,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
332338
)
333339
}
334340

335-
saveAndStart() {
341+
saveAndStart(): void {
336342
this.setState({ forcePasswordChange: false, used: true })
337343
this.state.successCallback()
338344
this.props.bus && this.props.bus.send(FOCUS)
@@ -344,7 +350,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
344350
}
345351
}
346352

347-
saveCredentials() {
353+
saveCredentials(): void {
348354
this.props.updateConnection({
349355
id: CONNECTION_ID,
350356
host: this.state.host,
@@ -440,7 +446,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
440446
}
441447
}
442448

443-
const mapStateToProps = (state: any) => {
449+
const mapStateToProps = (state: GlobalState) => {
444450
return {
445451
discoveredData: getConnectionData(state, CONNECTION_ID),
446452
initCmd: getInitCmd(state),
@@ -458,7 +464,7 @@ const mapDispatchToProps = (dispatch: any) => {
458464
updateConnection: (connection: any) => {
459465
dispatch(updateConnection(connection))
460466
},
461-
setActiveConnection: (id: any) => dispatch(setActiveConnection(id)),
467+
setActiveConnection: (id: string) => dispatch(setActiveConnection(id)),
462468
dispatchInitCmd: (initCmd: any) => dispatch(executeSystemCommand(initCmd))
463469
}
464470
}
@@ -481,5 +487,9 @@ const mergeProps = (stateProps: any, dispatchProps: any, ownProps: any) => {
481487
}
482488

483489
export default withBus(
484-
connect(mapStateToProps, mapDispatchToProps, mergeProps)(ConnectionForm)
490+
connect(
491+
mapStateToProps,
492+
mapDispatchToProps,
493+
mergeProps
494+
)(ConnectionFormController)
485495
)

src/browser/modules/Stream/Auth/ConnectionFrame.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@ import React, { Component } from 'react'
2121

2222
import FrameBodyTemplate from '../../Frame/FrameBodyTemplate'
2323
import FrameError from '../../Frame/FrameError'
24-
import ConnectionForm from './ConnectionForm'
24+
import ConnectionForm from './ConnectionFormController'
2525
import { StyledConnectionAside, StyledConnectionBodyContainer } from './styled'
2626
import { Lead } from 'browser-components/Text'
2727
import { H3 } from 'browser-components/headers'
28+
import { BaseFrameProps } from '../Stream'
29+
import { Neo4jError } from 'neo4j-driver'
2830

29-
type State = any
30-
31-
class ConnectionFrame extends Component<any, State> {
32-
constructor(props: {}) {
33-
super(props)
34-
this.state = {
35-
error: {}
36-
}
31+
type ConnectionFrameState = { error: Partial<Neo4jError>; success?: true }
32+
class ConnectionFrame extends Component<BaseFrameProps, ConnectionFrameState> {
33+
state: ConnectionFrameState = {
34+
error: {}
3735
}
3836

3937
error(e: any) {

0 commit comments

Comments
 (0)