Skip to content

Commit

Permalink
rename feature flag, change to hidden config, remove protocol version…
Browse files Browse the repository at this point in the history
…, change to server version
  • Loading branch information
daveajrussell committed Dec 12, 2024
1 parent be28b5d commit 0c66771
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 52 deletions.
19 changes: 8 additions & 11 deletions src/browser/modules/Stream/CypherFrame/ErrorsView/ErrorsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,14 @@ import {
import { BrowserError } from 'services/exceptions'
import { deepEquals } from 'neo4j-arc/common'
import { getSemanticVersion } from 'shared/modules/dbMeta/dbMetaDuck'
import { SemVer } from 'semver'
import { getProtocolVersion } from 'shared/modules/connections/connectionsDuck'
import { gte, SemVer } from 'semver'
import {
formatError,
formatErrorGqlStatusObject,
hasPopulatedGqlFields
} from '../errorUtils'
import {
enableGqlErrors,
showFeature
} from 'shared/modules/experimentalFeatures/experimentalFeaturesDuck'
import { FIRST_GQL_ERRORS_SUPPORT } from 'shared/modules/features/versionedFeatures'
import { shouldShowGqlErrorsAndNotifications } from 'shared/modules/settings/settingsDuck'

export type ErrorsViewProps = {
result: BrowserRequestResult
Expand Down Expand Up @@ -180,11 +177,11 @@ class ErrorsViewComponent extends Component<ErrorsViewProps> {
}

const gqlErrorsEnabled = (state: GlobalState): boolean => {
const featureEnabled = showFeature(state, enableGqlErrors)
const protocolVersion = getProtocolVersion(state)
const protocolVersionSupported =
protocolVersion !== null && protocolVersion >= 5.7
return featureEnabled && protocolVersionSupported
const featureEnabled = shouldShowGqlErrorsAndNotifications(state)
const version = getSemanticVersion(state)
return version
? featureEnabled && gte(version, FIRST_GQL_ERRORS_SUPPORT)
: false
}

const mapStateToProps = (state: GlobalState) => ({
Expand Down
14 changes: 9 additions & 5 deletions src/browser/modules/Stream/CypherFrame/WarningsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ import { NotificationSeverityLevel, QueryResult } from 'neo4j-driver-core'
import { connect } from 'react-redux'
import { withBus } from 'react-suber'
import { GlobalState } from 'shared/globalState'
import { getProtocolVersion } from 'shared/modules/connections/connectionsDuck'
import { Bus } from 'suber'
import { getSemanticVersion } from 'shared/modules/dbMeta/dbMetaDuck'
import { gte } from 'semver'
import { FIRST_GQL_NOTIFICATIONS_SUPPORT } from 'shared/modules/features/versionedFeatures'
import { shouldShowGqlErrorsAndNotifications } from 'shared/modules/settings/settingsDuck'

const getWarningComponent = (severity?: string | NotificationSeverityLevel) => {
if (severity === 'ERROR') {
Expand Down Expand Up @@ -128,10 +131,11 @@ class WarningsViewComponent extends Component<WarningsViewProps> {
}

const gqlWarningsEnabled = (state: GlobalState): boolean => {
const protocolVersion = getProtocolVersion(state)
const protocolVersionSupported =
protocolVersion !== null && protocolVersion >= 5.6
return protocolVersionSupported
const featureEnabled = shouldShowGqlErrorsAndNotifications(state)
const version = getSemanticVersion(state)
return version
? featureEnabled && gte(version, FIRST_GQL_NOTIFICATIONS_SUPPORT)
: false
}

const mapStateToProps = (state: GlobalState) => ({
Expand Down
16 changes: 0 additions & 16 deletions src/shared/modules/connections/connectionsDuck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export type Connection = {
SSOError?: string
SSOProviders?: SSOProvider[]
attemptSSOLogin?: boolean
protocolVersion?: number | null
}

export const initialState: ConnectionReduxState = {
Expand Down Expand Up @@ -197,11 +196,6 @@ export function getConnectionData(
return { ...data, username: data.username ? data.username : memoryUsername }
}

export function getProtocolVersion(state: GlobalState): number | null {
const currentConnection = getActiveConnectionData(state)
return currentConnection?.protocolVersion ?? null
}

const removeConnectionHelper = (
state: ConnectionReduxState
): ConnectionReduxState => {
Expand Down Expand Up @@ -418,16 +412,6 @@ export const connectEpic = (action$: any, store: any) =>
}
}

const protocolVersion = await bolt.protocolVersion()
if (protocolVersion) {
store.dispatch(
updateConnection({
id: action.id,
protocolVersion
})
)
}

if (action.requestedUseDb) {
store.dispatch(
updateConnection({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ export const initialState = {
on: true,
displayName: 'Show experimental features',
tooltip: 'Show feature section in settings drawer'
},
[enableGqlErrors]: {
name: enableGqlErrors,
on: false,
displayName: 'Enable GQL errors',
tooltip: 'Enables GQL compliant errors for servers that support them'
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/shared/modules/features/versionedFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const FIRST_MULTI_DB_SUPPORT = NEO4J_4_0
// compatible bolt server.
export const FIRST_NO_MULTI_DB_SUPPORT = '3.4.0'

export const FIRST_GQL_NOTIFICATIONS_SUPPORT = '5.23.0'
export const FIRST_GQL_ERRORS_SUPPORT = '5.26.0'

export const getShowCurrentUserProcedure = (serverVersion: string) => {
const serverVersionGuessed = guessSemverVersion(serverVersion)

Expand Down
2 changes: 2 additions & 0 deletions src/shared/modules/settings/settingsDuck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export const getAllowUserStats = (state: GlobalState): boolean =>
state[NAME].allowUserStats ?? initialState.allowUserStats
export const shouldShowWheelZoomInfo = (state: GlobalState) =>
state[NAME].showWheelZoomInfo
export const shouldShowGqlErrorsAndNotifications = (state: any) =>
state[NAME].enableGqlErrorsAndNotifications

// Ideally the string | number types would be only numbers
// but they're saved as strings in the settings component
Expand Down
1 change: 0 additions & 1 deletion src/shared/services/bolt/bolt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ export default {
backgroundWorkerlessRoutedRead,
quickVerifyConnectivity: boltConnection.quickVerifyConnectivity,
hasMultiDbSupport: boltConnection.hasMultiDbSupport,
protocolVersion: boltConnection.protocolVersion,
useDb: (db: any) => (_useDb = db),
directConnect: boltConnection.directConnect,
openConnection,
Expand Down
13 changes: 0 additions & 13 deletions src/shared/services/bolt/boltConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ export const hasMultiDbSupport = async (): Promise<boolean> => {
return supportsMultiDb
}

export const protocolVersion = async (): Promise<number> => {
if (!getGlobalDrivers()) {
throw BoltConnectionError()
}
const drivers = getGlobalDrivers()
const tmpDriver = drivers && drivers.getRoutedDriver()
if (!tmpDriver) {
throw BoltConnectionError()
}
const serverInfo = await tmpDriver.getServerInfo()
return serverInfo?.protocolVersion ?? -1
}

export const quickVerifyConnectivity = async (): Promise<void> => {
if (!getGlobalDrivers()) {
throw BoltConnectionError()
Expand Down

0 comments on commit 0c66771

Please sign in to comment.