[arvados-workbench2] created: 2.6.2-1-g3a9f6442
git repository hosting
git at public.arvados.org
Thu Jun 1 21:23:22 UTC 2023
at 3a9f6442080843c97737aae74608cb2d188be1da (commit)
commit 3a9f6442080843c97737aae74608cb2d188be1da
Author: Peter Amstutz <peter.amstutz at curii.com>
Date: Thu Jun 1 17:22:51 2023 -0400
20449: Examine websocket messages before reloading process pages
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>
diff --git a/src/websocket/websocket.ts b/src/websocket/websocket.ts
index 7c8e0171..6bb505b3 100644
--- a/src/websocket/websocket.ts
+++ b/src/websocket/websocket.ts
@@ -9,6 +9,7 @@ import { WebSocketService } from './websocket-service';
import { ResourceEventMessage } from './resource-event-message';
import { ResourceKind } from 'models/resource';
import { loadProcess } from 'store/processes/processes-actions';
+import { getProcess, getSubprocesses } from 'store/processes/process';
import { LogEventType } from 'models/log';
import { addProcessLogsPanelItem } from 'store/process-logs-panel/process-logs-panel-actions';
import { subprocessPanelActions } from "store/subprocess-panel/subprocess-panel-actions";
@@ -16,6 +17,7 @@ import { projectPanelActions } from "store/project-panel/project-panel-action";
import { getProjectPanelCurrentUuid } from 'store/project-panel/project-panel-action';
import { allProcessesPanelActions } from 'store/all-processes-panel/all-processes-panel-action';
import { loadCollection } from 'store/workbench/workbench-actions';
+import { matchAllProcessesRoute, matchProjectRoute, matchProcessRoute } from 'routes/routes';
export const initWebSocket = (config: Config, authService: AuthService, store: RootStore) => {
if (config.websocketUrl) {
@@ -29,22 +31,42 @@ export const initWebSocket = (config: Config, authService: AuthService, store: R
const messageListener = (store: RootStore) => (message: ResourceEventMessage) => {
if (message.eventType === LogEventType.CREATE || message.eventType === LogEventType.UPDATE) {
+ const state = store.getState();
+ const location = state.router.location ? state.router.location.pathname : '';
switch (message.objectKind) {
case ResourceKind.COLLECTION:
- const currentCollection = store.getState().collectionPanel.item;
+ const currentCollection = state.collectionPanel.item;
if (currentCollection && currentCollection.uuid === message.objectUuid) {
store.dispatch(loadCollection(message.objectUuid));
}
return;
case ResourceKind.CONTAINER_REQUEST:
- if (store.getState().processPanel.containerRequestUuid === message.objectUuid) {
- store.dispatch(loadProcess(message.objectUuid));
+ if (matchProcessRoute(location)) {
+ if (state.processPanel.containerRequestUuid === message.objectUuid) {
+ store.dispatch(loadProcess(message.objectUuid));
+ }
+ const proc = getProcess(state.processPanel.containerRequestUuid)(state.resources);
+ if (proc && proc.container && proc.container.uuid === message.properties["new_attributes"]["requesting_container_uuid"]) {
+ store.dispatch(subprocessPanelActions.REQUEST_ITEMS());
+ return;
+ }
}
// fall through, this will happen for container requests as well.
case ResourceKind.CONTAINER:
- store.dispatch(subprocessPanelActions.REQUEST_ITEMS());
- store.dispatch(allProcessesPanelActions.REQUEST_ITEMS());
- if (message.objectOwnerUuid === getProjectPanelCurrentUuid(store.getState())) {
+ if (matchProcessRoute(location)) {
+ // refresh only if this is a subprocess of the currently displayed process.
+ const subproc = getSubprocesses(state.processPanel.containerRequestUuid)(state.resources);
+ for (const sb of subproc) {
+ if (sb.containerRequest.uuid === message.objectUuid || (sb.container && sb.container.uuid === message.objectUuid)) {
+ store.dispatch(subprocessPanelActions.REQUEST_ITEMS());
+ break;
+ }
+ }
+ }
+ if (matchAllProcessesRoute(location)) {
+ store.dispatch(allProcessesPanelActions.REQUEST_ITEMS());
+ }
+ if (matchProjectRoute(location) && message.objectOwnerUuid === getProjectPanelCurrentUuid(state)) {
store.dispatch(projectPanelActions.REQUEST_ITEMS());
}
return;
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list