Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/browser/modules/Stream/Auth/ChangePasswordFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { connect } from 'react-redux'

import FrameBodyTemplate from '../../Frame/FrameBodyTemplate'
import FrameError from '../../Frame/FrameError'
import ConnectionForm from './ConnectionForm'
import ConnectionFormController from './ConnectionFormController'
import { StyledConnectionAside } from './styled'
import { Lead } from 'browser-components/Text'
import { H3 } from 'browser-components/headers'
Expand Down Expand Up @@ -71,7 +71,7 @@ class ChangePasswordFrame extends Component<any, ChangePasswordFrameState> {
</StyledConnectionAside>

{this.props.activeConnection && (
<ConnectionForm
<ConnectionFormController
{...this.props}
error={this.error}
onSuccess={this.onSuccess}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { fireEvent, render } from '@testing-library/react'
import React from 'react'

import { ConnectionForm } from './ConnectionForm'
import { ConnectionFormController } from './ConnectionFormController'
import { NATIVE, NO_AUTH } from 'services/bolt/boltHelpers'

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

// When
const { rerender, getByText, getByTestId } = render(
<ConnectionForm
<ConnectionFormController
frame={frame}
error={error}
bus={bus}
Expand Down Expand Up @@ -74,7 +74,7 @@ test('should print correct state for retaining credentials', async () => {
authEnabled: true
}
rerender(
<ConnectionForm
<ConnectionFormController
frame={frame}
bus={bus}
activeConnectionData={activeConnectionData}
Expand All @@ -99,7 +99,7 @@ test('should print correct state for retaining credentials', async () => {
// When not storing credentials anymore
storeCredentials = false
rerender(
<ConnectionForm
<ConnectionFormController
frame={frame}
bus={bus}
activeConnectionData={activeConnectionData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ import {
stripScheme
} from 'shared/services/boltscheme.utils'
import { isCloudHost } from 'shared/services/utils'

type ConnectionFormState = any
import { Neo4jError } from 'neo4j-driver'
import { GlobalState } from 'shared/globalState'

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

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

export class ConnectionForm extends Component<any, ConnectionFormState> {
export class ConnectionFormController extends Component<any, any> {
constructor(props: any) {
super(props)
const connection = this.getConnection()
Expand Down Expand Up @@ -106,7 +106,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
}
}

componentDidMount() {
componentDidMount(): void {
const { authenticationMethod } = this.state
if (authenticationMethod === NO_AUTH) {
this.connect(() => this.setState({ connecting: false }))
Expand Down Expand Up @@ -269,11 +269,17 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
this.props.error({})
}

onChangePasswordChange() {
onChangePasswordChange(): void {
this.props.error({})
}

onChangePassword({ newPassword, error }: any) {
onChangePassword({
newPassword,
error
}: {
newPassword: string
error?: Neo4jError
}): void {
this.setState({ isLoading: true })
if (error && error.code) {
this.setState({ isLoading: false })
Expand Down Expand Up @@ -332,7 +338,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
)
}

saveAndStart() {
saveAndStart(): void {
this.setState({ forcePasswordChange: false, used: true })
this.state.successCallback()
this.props.bus && this.props.bus.send(FOCUS)
Expand All @@ -344,7 +350,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
}
}

saveCredentials() {
saveCredentials(): void {
this.props.updateConnection({
id: CONNECTION_ID,
host: this.state.host,
Expand Down Expand Up @@ -440,7 +446,7 @@ export class ConnectionForm extends Component<any, ConnectionFormState> {
}
}

const mapStateToProps = (state: any) => {
const mapStateToProps = (state: GlobalState) => {
return {
discoveredData: getConnectionData(state, CONNECTION_ID),
initCmd: getInitCmd(state),
Expand All @@ -458,7 +464,7 @@ const mapDispatchToProps = (dispatch: any) => {
updateConnection: (connection: any) => {
dispatch(updateConnection(connection))
},
setActiveConnection: (id: any) => dispatch(setActiveConnection(id)),
setActiveConnection: (id: string) => dispatch(setActiveConnection(id)),
dispatchInitCmd: (initCmd: any) => dispatch(executeSystemCommand(initCmd))
}
}
Expand All @@ -481,5 +487,9 @@ const mergeProps = (stateProps: any, dispatchProps: any, ownProps: any) => {
}

export default withBus(
connect(mapStateToProps, mapDispatchToProps, mergeProps)(ConnectionForm)
connect(
mapStateToProps,
mapDispatchToProps,
mergeProps
)(ConnectionFormController)
)
16 changes: 7 additions & 9 deletions src/browser/modules/Stream/Auth/ConnectionFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ import React, { Component } from 'react'

import FrameBodyTemplate from '../../Frame/FrameBodyTemplate'
import FrameError from '../../Frame/FrameError'
import ConnectionForm from './ConnectionForm'
import ConnectionForm from './ConnectionFormController'
import { StyledConnectionAside, StyledConnectionBodyContainer } from './styled'
import { Lead } from 'browser-components/Text'
import { H3 } from 'browser-components/headers'
import { BaseFrameProps } from '../Stream'
import { Neo4jError } from 'neo4j-driver'

type State = any

class ConnectionFrame extends Component<any, State> {
constructor(props: {}) {
super(props)
this.state = {
error: {}
}
type ConnectionFrameState = { error: Partial<Neo4jError>; success?: true }
class ConnectionFrame extends Component<BaseFrameProps, ConnectionFrameState> {
state: ConnectionFrameState = {
error: {}
}

error(e: any) {
Expand Down