Merge branch '18874-merge-wb2'
[arvados.git] / services / workbench2 / src / store / process-logs-panel / process-logs-panel.ts
diff --git a/services/workbench2/src/store/process-logs-panel/process-logs-panel.ts b/services/workbench2/src/store/process-logs-panel/process-logs-panel.ts
new file mode 100644 (file)
index 0000000..531d372
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { matchProcessRoute } from 'routes/routes';
+import { RouterState } from 'react-router-redux';
+
+export interface ProcessLogsPanel {
+    filters: string[];
+    selectedFilter: string;
+    logs: ProcessLogs;
+}
+
+export interface ProcessLogs {
+    [logType: string]: {lastByte: number | undefined, contents: string[]};
+}
+
+export const getProcessPanelLogs = ({ selectedFilter, logs }: ProcessLogsPanel): string[] => {
+    return logs[selectedFilter]?.contents || [];
+};
+
+export const getProcessLogsPanelCurrentUuid = (router: RouterState) => {
+    const pathname = router.location ? router.location.pathname : '';
+    const match = matchProcessRoute(pathname);
+    return match ? match.params.id : undefined;
+};