mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Added changeInstance action; exported actions to public API
This commit is contained in:
@@ -681,3 +681,15 @@ export function toggleTroubleshootingMenu(ev) {
|
||||
type: ActionTypes.TOGGLE_TROUBLESHOOTING_MENU
|
||||
};
|
||||
}
|
||||
|
||||
export function changeInstance() {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
getNodesDelta(
|
||||
getCurrentTopologyUrl(state),
|
||||
getActiveTopologyOptions(state),
|
||||
dispatch,
|
||||
true // forces websocket teardown and reconnect to new instance
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
exports.reducer = require('./reducers/root').default;
|
||||
exports.Scope = require('./components/app').default;
|
||||
exports.ActionTypes = require('./constants/action-types').default;
|
||||
exports.actions = require('./actions/app-actions');
|
||||
|
||||
@@ -166,11 +166,12 @@ export function getTopologies(options, dispatch) {
|
||||
});
|
||||
}
|
||||
|
||||
export function getNodesDelta(topologyUrl, options, dispatch) {
|
||||
export function getNodesDelta(topologyUrl, options, dispatch, forceReload) {
|
||||
const optionsQuery = buildOptionsQuery(options);
|
||||
// only recreate websocket if url changed or if forced (weave cloud instance reload);
|
||||
const isNewUrl = topologyUrl && (topologyUrl !== currentUrl || currentOptions !== optionsQuery);
|
||||
|
||||
// only recreate websocket if url changed
|
||||
if (topologyUrl && (topologyUrl !== currentUrl || currentOptions !== optionsQuery)) {
|
||||
if (forceReload || isNewUrl) {
|
||||
createWebsocket(topologyUrl, optionsQuery, dispatch);
|
||||
currentUrl = topologyUrl;
|
||||
currentOptions = optionsQuery;
|
||||
|
||||
Reference in New Issue
Block a user