Merge branch '15672-subprocess-list-v2'
[arvados-workbench2.git] / src / store / processes / process.ts
index c9e62f943455a2ebaae9b8d8b45c16ff8084a62f..400d77cfc88ee38942e46a5a1a6692e5a9ee82a2 100644 (file)
@@ -56,12 +56,22 @@ export const getSubprocesses = (uuid: string) => (resources: ResourcesState) =>
     return [];
 };
 
-export const getProcessRuntime = ({ container }: Process) =>
-    container
-        ? getTimeDiff(container.finishedAt || '', container.startedAt || '')
-        : 0;
+export const getProcessRuntime = ({ container }: Process) => {
+    if (container) {
+        if (container.startedAt === null) {
+            return 0;
+        }
+        if (container.finishedAt === null) {
+            // Count it from now
+            return new Date().getTime() - new Date(container.startedAt).getTime();
+        }
+        return getTimeDiff(container.finishedAt, container.startedAt);
+    } else {
+        return 0;
+    }
+};
 
-export const getProcessStatusColor = (status: string, { customs }: ArvadosTheme) => {
+export const getProcessStatusColor = (status: string, { customs, palette }: ArvadosTheme) => {
     switch (status) {
         case ProcessStatus.RUNNING:
             return customs.colors.blue500;
@@ -71,7 +81,7 @@ export const getProcessStatusColor = (status: string, { customs }: ArvadosTheme)
         case ProcessStatus.FAILED:
             return customs.colors.red900;
         default:
-            return customs.colors.grey500;
+            return palette.grey["500"];
     }
 };