20219: Adjust logFileToLogType argument type to only CollectionFile and adjust
authorStephen Smith <stephen@curii.com>
Wed, 2 Aug 2023 01:19:09 +0000 (21:19 -0400)
committerStephen Smith <stephen@curii.com>
Wed, 2 Aug 2023 01:46:59 +0000 (21:46 -0400)
loadContainerLogFileList filter type hint to satisfy type

Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/services/log-service/log-service.ts
src/store/process-logs-panel/process-logs-panel-actions.ts

index b96d8223ffd96ae1bd536c61bde147a3bfc783b1..f2424715f1c3a575166c9e95ce88c669f5609df1 100644 (file)
@@ -8,7 +8,7 @@ import { CommonResourceService } from "services/common-service/common-resource-s
 import { ApiActions } from "services/api/api-actions";
 import { WebDAV } from "common/webdav";
 import { extractFilesData } from "services/collection-service/collection-service-files-response";
-import { CollectionDirectory, CollectionFile } from "models/collection-file";
+import { CollectionFile } from "models/collection-file";
 
 export type LogFragment = {
     logType: LogEventType;
@@ -50,4 +50,4 @@ export class LogService extends CommonResourceService<LogResource> {
     }
 }
 
-export const logFileToLogType = (file: CollectionFile | CollectionDirectory) => (file.name.replace(/\.(txt|json)$/, '') as LogEventType);
+export const logFileToLogType = (file: CollectionFile) => (file.name.replace(/\.(txt|json)$/, '') as LogEventType);
index 328ca4da25b889dc358386e5ba68dc8ef5f6aa08..ea082cd9b8c672040ea5a77e19ed2a6fa9d42e2f 100644 (file)
@@ -102,12 +102,12 @@ const loadContainerLogFileList = async (containerUuid: string, logService: LogSe
     const logCollectionContents = await logService.listLogFiles(containerUuid);
 
     // Filter only root directory files matching log event types which have bytes
-    return logCollectionContents.filter((file) => (
+    return logCollectionContents.filter((file): file is CollectionFile => (
+        file.type === CollectionFileType.FILE &&
         file.path === `/arvados/v1/container_requests/${containerUuid}/log` &&
         PROCESS_PANEL_LOG_EVENT_TYPES.indexOf(logFileToLogType(file)) > -1 &&
-        file.type === CollectionFileType.FILE &&
         file.size > 0
-    )) as CollectionFile[];
+    ));
 };
 
 /**