mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Fix: Use basepath from state for socket path (#24369)
Closes https://github.com/elastic/kibana/issues/23168 This PR uses the `basePath` constant from Angular to mount the client socket instance, allowing it to connect correctly even in when using a Space. ### Workpad correctly loading in a Space  ### List of workpads restricted to a space  ### List of workpads restricted to default space 
This commit is contained in:
parent
9b78cfd4b9
commit
f894f0ea62
2 changed files with 17 additions and 7 deletions
|
@ -8,7 +8,7 @@ import { connect } from 'react-redux';
|
|||
import { compose, withProps } from 'recompose';
|
||||
import { createSocket } from '../../socket';
|
||||
import { initialize as initializeInterpreter } from '../../lib/interpreter';
|
||||
import { getAppReady } from '../../state/selectors/app';
|
||||
import { getAppReady, getBasePath } from '../../state/selectors/app';
|
||||
import { appReady, appError } from '../../state/actions/app';
|
||||
import { trackRouteChange } from './track_route_change';
|
||||
import { App as Component } from './app';
|
||||
|
@ -19,13 +19,15 @@ const mapStateToProps = state => {
|
|||
|
||||
return {
|
||||
appState: typeof appState === 'object' ? appState : { ready: appState },
|
||||
basePath: getBasePath(state),
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setAppReady: async () => {
|
||||
// TODO: the correct socket path should come from upstream, using the constant here is not ideal
|
||||
setAppReady: basePath => async () => {
|
||||
// initialize the socket and interpreter
|
||||
createSocket();
|
||||
createSocket(basePath);
|
||||
await initializeInterpreter();
|
||||
|
||||
// set app state to ready
|
||||
|
@ -34,10 +36,20 @@ const mapDispatchToProps = dispatch => ({
|
|||
setAppError: payload => dispatch(appError(payload)),
|
||||
});
|
||||
|
||||
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||||
return {
|
||||
...ownProps,
|
||||
...stateProps,
|
||||
...dispatchProps,
|
||||
setAppReady: dispatchProps.setAppReady(stateProps.basePath),
|
||||
};
|
||||
};
|
||||
|
||||
export const App = compose(
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
mapDispatchToProps,
|
||||
mergeProps
|
||||
),
|
||||
withProps(() => ({
|
||||
onRouteChange: trackRouteChange,
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import io from 'socket.io-client';
|
||||
import { functionsRegistry } from '../common/lib/functions_registry';
|
||||
import { loadBrowserPlugins } from './lib/load_browser_plugins';
|
||||
|
||||
let socket;
|
||||
|
||||
export function createSocket() {
|
||||
const basePath = chrome.getBasePath();
|
||||
export function createSocket(basePath) {
|
||||
socket = io(undefined, { path: `${basePath}/socket.io` });
|
||||
|
||||
socket.on('getFunctionList', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue