From 0c66771d25e4a81eca06ac4bede100710c07271a Mon Sep 17 00:00:00 2001 From: David Russell Date: Thu, 12 Dec 2024 15:28:21 +0000 Subject: [PATCH] rename feature flag, change to hidden config, remove protocol version, change to server version --- .../CypherFrame/ErrorsView/ErrorsView.tsx | 19 ++++++++----------- .../Stream/CypherFrame/WarningsView.tsx | 14 +++++++++----- .../modules/connections/connectionsDuck.ts | 16 ---------------- .../experimentalFeaturesDuck.ts | 6 ------ .../modules/features/versionedFeatures.ts | 3 +++ src/shared/modules/settings/settingsDuck.ts | 2 ++ src/shared/services/bolt/bolt.ts | 1 - src/shared/services/bolt/boltConnection.ts | 13 ------------- 8 files changed, 22 insertions(+), 52 deletions(-) diff --git a/src/browser/modules/Stream/CypherFrame/ErrorsView/ErrorsView.tsx b/src/browser/modules/Stream/CypherFrame/ErrorsView/ErrorsView.tsx index a2f13b60aaa..465bba3b2c3 100644 --- a/src/browser/modules/Stream/CypherFrame/ErrorsView/ErrorsView.tsx +++ b/src/browser/modules/Stream/CypherFrame/ErrorsView/ErrorsView.tsx @@ -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 @@ -180,11 +177,11 @@ class ErrorsViewComponent extends Component { } 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) => ({ diff --git a/src/browser/modules/Stream/CypherFrame/WarningsView.tsx b/src/browser/modules/Stream/CypherFrame/WarningsView.tsx index 554c1613bb4..5c554e44272 100644 --- a/src/browser/modules/Stream/CypherFrame/WarningsView.tsx +++ b/src/browser/modules/Stream/CypherFrame/WarningsView.tsx @@ -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') { @@ -128,10 +131,11 @@ class WarningsViewComponent extends Component { } 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) => ({ diff --git a/src/shared/modules/connections/connectionsDuck.ts b/src/shared/modules/connections/connectionsDuck.ts index ed674899878..eea15721b66 100644 --- a/src/shared/modules/connections/connectionsDuck.ts +++ b/src/shared/modules/connections/connectionsDuck.ts @@ -102,7 +102,6 @@ export type Connection = { SSOError?: string SSOProviders?: SSOProvider[] attemptSSOLogin?: boolean - protocolVersion?: number | null } export const initialState: ConnectionReduxState = { @@ -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 => { @@ -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({ diff --git a/src/shared/modules/experimentalFeatures/experimentalFeaturesDuck.ts b/src/shared/modules/experimentalFeatures/experimentalFeaturesDuck.ts index 5ed0c3c4388..f883296bb3c 100644 --- a/src/shared/modules/experimentalFeatures/experimentalFeaturesDuck.ts +++ b/src/shared/modules/experimentalFeatures/experimentalFeaturesDuck.ts @@ -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' } } diff --git a/src/shared/modules/features/versionedFeatures.ts b/src/shared/modules/features/versionedFeatures.ts index dac355f84a6..1813b38b46a 100644 --- a/src/shared/modules/features/versionedFeatures.ts +++ b/src/shared/modules/features/versionedFeatures.ts @@ -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) diff --git a/src/shared/modules/settings/settingsDuck.ts b/src/shared/modules/settings/settingsDuck.ts index 2b2eaaa4fc3..d9fd71e2641 100644 --- a/src/shared/modules/settings/settingsDuck.ts +++ b/src/shared/modules/settings/settingsDuck.ts @@ -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 diff --git a/src/shared/services/bolt/bolt.ts b/src/shared/services/bolt/bolt.ts index fa0ab2def74..71f692b1bd2 100644 --- a/src/shared/services/bolt/bolt.ts +++ b/src/shared/services/bolt/bolt.ts @@ -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, diff --git a/src/shared/services/bolt/boltConnection.ts b/src/shared/services/bolt/boltConnection.ts index c0ac1d90e93..4e86be1956b 100644 --- a/src/shared/services/bolt/boltConnection.ts +++ b/src/shared/services/bolt/boltConnection.ts @@ -47,19 +47,6 @@ export const hasMultiDbSupport = async (): Promise => { return supportsMultiDb } -export const protocolVersion = async (): Promise => { - 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 => { if (!getGlobalDrivers()) { throw BoltConnectionError()