diff --git a/src/browser/components/buttons/__snapshots__/ConfirmationButton.test.js.snap b/src/browser/components/buttons/__snapshots__/ConfirmationButton.test.js.snap index 91ccf5760e7..91588d37d02 100644 --- a/src/browser/components/buttons/__snapshots__/ConfirmationButton.test.js.snap +++ b/src/browser/components/buttons/__snapshots__/ConfirmationButton.test.js.snap @@ -7,7 +7,7 @@ exports[`ConfirmationButton renders changes state on clicks and finally calls th data-testid="confirmation-button-initial" > @@ -21,7 +21,7 @@ exports[`ConfirmationButton renders changes state on clicks and finally calls th data-testid="confirmation-button-confirm" > @@ -43,7 +43,7 @@ exports[`ConfirmationButton renders changes state on clicks and finally calls th data-testid="confirmation-button-initial" > @@ -56,7 +56,7 @@ exports[`ConfirmationButton renders changes state on clicks and finally calls th data-testid="confirmation-button-initial" > diff --git a/src/browser/modules/App/App.jsx b/src/browser/modules/App/App.jsx index 8d986ba1599..b217f60a36b 100644 --- a/src/browser/modules/App/App.jsx +++ b/src/browser/modules/App/App.jsx @@ -32,26 +32,17 @@ import { import { FOCUS, EXPAND } from 'shared/modules/editor/editorDuck' import { useBrowserSync } from 'shared/modules/features/featuresDuck' import { getErrorMessage } from 'shared/modules/commands/commandsDuck' -import { - allowOutgoingConnections, - getVersion -} from 'shared/modules/dbMeta/dbMetaDuck' +import { allowOutgoingConnections } from 'shared/modules/dbMeta/dbMetaDuck' import { getActiveConnection, getConnectionState, getLastConnectionUpdate, getActiveConnectionData, isConnected, - getConnectionData, - SILENT_DISCONNECT, - SWITCH_CONNECTION, - SWITCH_CONNECTION_FAILED + getConnectionData } from 'shared/modules/connections/connectionsDuck' import { toggle } from 'shared/modules/sidebar/sidebarDuck' -import { - CONNECTION_ID, - INJECTED_DISCOVERY -} from 'shared/modules/discovery/discoveryDuck' +import { CONNECTION_ID } from 'shared/modules/discovery/discoveryDuck' import { StyledWrapper, StyledApp, @@ -66,24 +57,21 @@ import asTitleString from '../DocTitle/titleStringBuilder' import Intercom from '../Intercom' import Render from 'browser-components/Render' import BrowserSyncInit from '../Sync/BrowserSyncInit' -import DesktopIntegration from 'browser-components/DesktopIntegration' -import { - getActiveGraph, - buildConnectionCredentialsObject -} from 'browser-components/DesktopIntegration/helpers' import { getMetadata, getUserAuthStatus } from 'shared/modules/sync/syncDuck' import ErrorBoundary from 'browser-components/ErrorBoundary' import { getExperimentalFeatures } from 'shared/modules/experimentalFeatures/experimentalFeaturesDuck' import FeatureToggleProvider from '../FeatureToggle/FeatureToggleProvider' -import { inWebEnv, URL_ARGUMENTS_CHANGE } from 'shared/modules/app/appDuck' +import { inWebEnv } from 'shared/modules/app/appDuck' import useDerivedTheme from 'browser-hooks/useDerivedTheme' import FileDrop from 'browser-components/FileDrop/FileDrop' +import RelateApi from 'browser-components/relate-api/relate-api' export function App(props) { const [derivedTheme, setEnvironmentTheme] = useDerivedTheme( props.theme, LIGHT_THEME ) + const themeData = themes[derivedTheme] || themes[LIGHT_THEME] useEffect(() => { document.addEventListener('keyup', focusEditorOnSlash) @@ -95,15 +83,6 @@ export function App(props) { } }, []) - const detectDesktopThemeChanges = (_, newContext) => { - if (newContext.global.prefersColorScheme) { - setEnvironmentTheme(newContext.global.prefersColorScheme) - } else { - setEnvironmentTheme(null) - } - } - const themeData = themes[derivedTheme] || themes[LIGHT_THEME] - const focusEditorOnSlash = e => { if (['INPUT', 'TEXTAREA'].indexOf(e.target.tagName) > -1) return if (e.key !== '/') return @@ -113,6 +92,7 @@ export function App(props) { if (e.keyCode !== 27) return props.bus && props.bus.send(EXPAND) } + const { drawer, cmdchar, @@ -129,7 +109,8 @@ export function App(props) { browserSyncAuthStatus, experimentalFeatures, store, - codeFontLigatures + codeFontLigatures, + defaultConnectionData } = props const wrapperClassNames = [] @@ -139,33 +120,16 @@ export function App(props) { return ( + - { - props.setInitialConnectionData( - activeGraph, - connectionsCredentials, - context, - getKerberosTicket - ) - detectDesktopThemeChanges(null, context) - }} - onGraphActive={props.switchConnection} - onGraphInactive={props.closeConnectionMaybe} - onColorSchemeUpdated={detectDesktopThemeChanges} - /> @@ -222,8 +186,7 @@ const mapStateToProps = state => { browserSyncConfig: getBrowserSyncConfig(state), browserSyncAuthStatus: getUserAuthStatus(state), loadSync: useBrowserSync(state), - isWebEnv: inWebEnv(state), - neo4jVersion: getVersion(state) + isWebEnv: inWebEnv(state) } } @@ -235,59 +198,4 @@ const mapDispatchToProps = dispatch => { } } -const mergeProps = (stateProps, dispatchProps, ownProps) => { - const switchConnection = async ( - event, - newContext, - oldContext, - getKerberosTicket - ) => { - const connectionCreds = await buildConnectionCredentialsObject( - newContext, - stateProps.defaultConnectionData, - getKerberosTicket, - stateProps.neo4jVersion - ) - ownProps.bus.send(SWITCH_CONNECTION, connectionCreds) - } - const setInitialConnectionData = async ( - graph, - credentials, - context, - getKerberosTicket - ) => { - const connectionCreds = await buildConnectionCredentialsObject( - context, - stateProps.defaultConnectionData, - getKerberosTicket, - stateProps.neo4jVersion - ) - // No connection. Probably no graph active. - if (!connectionCreds) { - ownProps.bus.send(SWITCH_CONNECTION_FAILED) - return - } - ownProps.bus.send(INJECTED_DISCOVERY, connectionCreds) - } - const closeConnectionMaybe = (event, newContext, oldContext) => { - const activeGraph = getActiveGraph(newContext) - if (activeGraph) return // We still got an active graph, do nothing - ownProps.bus.send(SILENT_DISCONNECT, {}) - } - const onArgumentsChange = argsString => { - ownProps.bus.send(URL_ARGUMENTS_CHANGE, { url: `?${argsString}` }) - } - return { - ...stateProps, - ...ownProps, - ...dispatchProps, - switchConnection, - setInitialConnectionData, - closeConnectionMaybe, - onArgumentsChange - } -} - -export default withBus( - connect(mapStateToProps, mapDispatchToProps, mergeProps)(App) -) +export default withBus(connect(mapStateToProps, mapDispatchToProps)(App)) diff --git a/src/browser/modules/App/App.test.js b/src/browser/modules/App/App.test.js index 9f6800cd056..3c56b3e2a30 100644 --- a/src/browser/modules/App/App.test.js +++ b/src/browser/modules/App/App.test.js @@ -18,108 +18,37 @@ * along with this program. If not, see . */ +/* global jest, test, expect */ import React from 'react' import { render } from '@testing-library/react' import configureMockStore from 'redux-mock-store' import { App } from './App' -import { buildConnectionCredentialsObject } from 'browser-components/DesktopIntegration/helpers' -import { flushPromises } from 'services/utils' const mockStore = configureMockStore() const store = mockStore({}) jest.mock('../FeatureToggle/FeatureToggleProvider', () => { - const FT = ({ children }) =>
{children}
- FT.displayName = 'FTMock' - return FT + return ({ children }) =>
{children}
}) jest.mock('./styled', () => { const orig = require.requireActual('./styled') return { ...orig, - StyledApp: () => null + StyledApp: () =>
Loaded
} }) describe('App', () => { test('App loads', async () => { // Given - const getKerberosTicket = jest.fn(() => Promise.resolve('xxx')) - const desktopIntegrationPoint = getIntegrationPoint(true, getKerberosTicket) - let connectionCreds = null const props = { - store, - desktopIntegrationPoint, - setInitialConnectionData: async ( - graph, - credentials, - context, - getKerberosTicket - ) => { - connectionCreds = await buildConnectionCredentialsObject( - context, - {}, - getKerberosTicket - ) - } + store } // When - render() + const { getByText } = render() // Then - await flushPromises() - expect(connectionCreds).toMatchObject({ - authenticationMethod: 'KERBEROS', - password: 'xxx' - }) - expect(getKerberosTicket).toHaveBeenCalledTimes(1) + expect(getByText('Loaded')) }) }) - -const getIntegrationPoint = (kerberosEnabled, getKerberosTicket) => { - const context = Promise.resolve(getDesktopContext(kerberosEnabled)) - return { - getKerberosTicket: getKerberosTicket, - getContext: () => context - } -} - -const getDesktopContext = (kerberosEnabled = false) => ({ - projects: [ - { - graphs: [ - { - status: 'ACTIVE', - connection: { - type: 'REMOTE', - configuration: { - authenticationMethods: { - kerberos: { - enabled: kerberosEnabled, - servicePrincipal: 'KERBEROS' - } - }, - protocols: { - bolt: { - enabled: true, - username: 'neo4j', - password: 'password', - tlsLevel: 'REQUIRED', - url: 'bolt://localhost:7687' - }, - http: { - enabled: true, - username: 'neo4j', - password: 'password', - host: 'localhost', - port: '7474' - } - } - } - } - } - ] - } - ] -}) diff --git a/src/browser/modules/DBMSInfo/__snapshots__/MetaItems.test.js.snap b/src/browser/modules/DBMSInfo/__snapshots__/MetaItems.test.js.snap index e3fd460a0ac..d5c5dff188a 100644 --- a/src/browser/modules/DBMSInfo/__snapshots__/MetaItems.test.js.snap +++ b/src/browser/modules/DBMSInfo/__snapshots__/MetaItems.test.js.snap @@ -11,7 +11,7 @@ exports[`LabelItems renders empty 1`] = ` Node Labels

There are no labels in database @@ -32,7 +32,7 @@ exports[`LabelItems renders labels 1`] = ` Node Labels

There are no properties in database @@ -89,7 +89,7 @@ exports[`PropertyItems renders properties 1`] = ` Property Keys

No relationships in database @@ -140,7 +140,7 @@ exports[`RelationshipItems renders relationshipTypes 1`] = ` Relationship Types

diff --git a/src/browser/modules/Stream/CypherFrame/__snapshots__/CodeView.test.js.snap b/src/browser/modules/Stream/CypherFrame/__snapshots__/CodeView.test.js.snap index ccee9f210a8..e508ceb60ff 100644 --- a/src/browser/modules/Stream/CypherFrame/__snapshots__/CodeView.test.js.snap +++ b/src/browser/modules/Stream/CypherFrame/__snapshots__/CodeView.test.js.snap @@ -89,7 +89,7 @@ exports[`CodeViews CodeView displays request and response info if successful que > Summary
@@ -107,7 +107,7 @@ exports[`CodeViews CodeView displays request and response info if successful que > Response
diff --git a/src/browser/modules/Stream/CypherFrame/__snapshots__/ErrorsView.test.js.snap b/src/browser/modules/Stream/CypherFrame/__snapshots__/ErrorsView.test.js.snap index bce9af884a3..72a4128bf93 100644 --- a/src/browser/modules/Stream/CypherFrame/__snapshots__/ErrorsView.test.js.snap +++ b/src/browser/modules/Stream/CypherFrame/__snapshots__/ErrorsView.test.js.snap @@ -10,7 +10,7 @@ exports[`ErrorsViews ErrorsStatusbar displays error 1`] = ` title="Test.Error: Test error description" > Test.Error: Test error description @@ -61,7 +61,7 @@ exports[`ErrorsViews ErrorsView displays procedure link if unknown procedure 1`] class="styled__StyledLink-sc-1dtvgs1-8 fPQgTq" >  List available procedures diff --git a/src/browser/modules/Stream/CypherFrame/__snapshots__/TableView.test.js.snap b/src/browser/modules/Stream/CypherFrame/__snapshots__/TableView.test.js.snap index 31f75b06fb9..d40695c6da2 100644 --- a/src/browser/modules/Stream/CypherFrame/__snapshots__/TableView.test.js.snap +++ b/src/browser/modules/Stream/CypherFrame/__snapshots__/TableView.test.js.snap @@ -51,7 +51,7 @@ exports[`TableViews TableView does not display bodyMessage if rows 1`] = ` x @@ -59,10 +59,10 @@ exports[`TableViews TableView does not display bodyMessage if rows 1`] = ` "y" diff --git a/src/browser/modules/Stream/CypherFrame/__snapshots__/VisualizationView.test.js.snap b/src/browser/modules/Stream/CypherFrame/__snapshots__/VisualizationView.test.js.snap index 5bd5044f9d8..cb033d109ee 100644 --- a/src/browser/modules/Stream/CypherFrame/__snapshots__/VisualizationView.test.js.snap +++ b/src/browser/modules/Stream/CypherFrame/__snapshots__/VisualizationView.test.js.snap @@ -8,32 +8,32 @@ exports[`Visualization renders with result 1`] = ` class="VisualizationViewstyled__StyledVisContainer-sc-1b47q51-0 dFbJTz" >
    • * (1) @@ -45,15 +45,15 @@ exports[`Visualization renders with result 1`] = ` data-testid="viz-legend-labels" >
      • Person (1) @@ -131,26 +131,26 @@ exports[`Visualization renders with result 1`] = `