18315: Adds websocket collection event handling. Updates test.
[arvados-workbench2.git] / src / websocket / websocket.ts
index 3e740256c3f06f40cbc852b3ed8c4000962839b2..7c8e0171e6d38bb48286b3d23a341c5c881986f8 100644 (file)
@@ -2,20 +2,20 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { RootStore } from '~/store/store';
-import { AuthService } from '~/services/auth-service/auth-service';
-import { Config } from '~/common/config';
+import { RootStore } from 'store/store';
+import { AuthService } from 'services/auth-service/auth-service';
+import { Config } from 'common/config';
 import { WebSocketService } from './websocket-service';
 import { ResourceEventMessage } from './resource-event-message';
-import { ResourceKind } from '~/models/resource';
-import { loadProcess } from '~/store/processes/processes-actions';
-// import { loadContainers } from '~/store/processes/processes-actions';
-import { LogEventType } from '~/models/log';
-import { addProcessLogsPanelItem } from '../store/process-logs-panel/process-logs-panel-actions';
-// import { FilterBuilder } from "~/services/api/filter-builder";
-import { subprocessPanelActions } from "~/store/subprocess-panel/subprocess-panel-actions";
-import { projectPanelActions } from "~/store/project-panel/project-panel-action";
-import { getProjectPanelCurrentUuid } from '~/store/project-panel/project-panel-action';
+import { ResourceKind } from 'models/resource';
+import { loadProcess } from 'store/processes/processes-actions';
+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";
+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';
 
 export const initWebSocket = (config: Config, authService: AuthService, store: RootStore) => {
     if (config.websocketUrl) {
@@ -30,6 +30,12 @@ export const initWebSocket = (config: Config, authService: AuthService, store: R
 const messageListener = (store: RootStore) => (message: ResourceEventMessage) => {
     if (message.eventType === LogEventType.CREATE || message.eventType === LogEventType.UPDATE) {
         switch (message.objectKind) {
+            case ResourceKind.COLLECTION:
+                const currentCollection = store.getState().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));
@@ -37,6 +43,7 @@ const messageListener = (store: RootStore) => (message: ResourceEventMessage) =>
             // 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())) {
                     store.dispatch(projectPanelActions.REQUEST_ITEMS());
                 }