Merge branch '19295-reused' refs #19295
authorPeter Amstutz <peter.amstutz@curii.com>
Wed, 29 Mar 2023 18:17:13 +0000 (14:17 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Wed, 29 Mar 2023 18:17:13 +0000 (14:17 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/store/processes/process.ts
src/store/resource-type-filters/resource-type-filters.ts
src/views/process-panel/process-details-card.tsx

index ad0a14c72ec172b887cc6be0bf0df3b14443b114..e621949887a4307bd8477df2667d485bbbe8e2cb 100644 (file)
@@ -26,6 +26,8 @@ export enum ProcessStatus {
     RUNNING = 'Running',
     WARNING = 'Warning',
     UNKNOWN = 'Unknown',
+    REUSED = 'Reused',
+    CANCELLING = 'Cancelling',
 }
 
 export const getProcess = (uuid: string) => (resources: ResourcesState): Process | undefined => {
@@ -83,6 +85,7 @@ export const getProcessStatusStyles = (status: string, theme: ArvadosTheme): Rea
             running = true;
             break;
         case ProcessStatus.COMPLETED:
+        case ProcessStatus.REUSED:
             color = theme.customs.colors.green800;
             break;
         case ProcessStatus.WARNING:
@@ -93,6 +96,10 @@ export const getProcessStatusStyles = (status: string, theme: ArvadosTheme): Rea
             color = theme.customs.colors.red900;
             running = true;
             break;
+        case ProcessStatus.CANCELLING:
+            color = theme.customs.colors.red900;
+            running = true;
+            break;
         case ProcessStatus.CANCELLED:
         case ProcessStatus.FAILED:
             color = theme.customs.colors.red900;
@@ -113,7 +120,7 @@ export const getProcessStatusStyles = (status: string, theme: ArvadosTheme): Rea
         // Set text color to status color when running, else use white text for solid button
         color: running ? color : theme.palette.common.white,
         // Set border color when running, else omit the style entirely
-        ...(running ? {border: `2px solid ${color}`} : {}),
+        ...(running ? { border: `2px solid ${color}` } : {}),
     };
 };
 
@@ -131,8 +138,22 @@ export const getProcessStatus = ({ containerRequest, container }: Process): Proc
         case containerRequest.state === ContainerRequestState.UNCOMMITTED:
             return ProcessStatus.DRAFT;
 
-        case container?.state === ContainerState.COMPLETE:
+        case container && container.state === ContainerState.COMPLETE:
             if (container?.exitCode === 0) {
+                if (containerRequest && container.finishedAt) {
+                    // don't compare on createdAt because the container can
+                    // have a slightly earlier creation time when it is created
+                    // in the same transaction as the container request.
+                    // use finishedAt because most people will assume "reused" means
+                    // no additional work needed to be done, it's possible
+                    // to share a running container but calling it "reused" in that case
+                    // is more likely to just be confusing.
+                    const finishedAt = new Date(container.finishedAt).getTime();
+                    const createdAt = new Date(containerRequest.createdAt).getTime();
+                    if (finishedAt < createdAt) {
+                        return ProcessStatus.REUSED;
+                    }
+                }
                 return ProcessStatus.COMPLETED;
             }
             return ProcessStatus.FAILED;
@@ -148,6 +169,9 @@ export const getProcessStatus = ({ containerRequest, container }: Process): Proc
             return ProcessStatus.QUEUED;
 
         case container?.state === ContainerState.RUNNING:
+            if (container?.priority === 0) {
+                return ProcessStatus.CANCELLING;
+            }
             if (!!container?.runtimeStatus.error) {
                 return ProcessStatus.FAILING;
             }
@@ -170,15 +194,15 @@ export const isProcessResumable = ({ containerRequest, container }: Process): bo
     containerRequest.priority === 0 &&
     // Don't show run button when container is present & running or cancelled
     !(container && (container.state === ContainerState.RUNNING ||
-                            container.state === ContainerState.CANCELLED ||
-                            container.state === ContainerState.COMPLETE))
+        container.state === ContainerState.CANCELLED ||
+        container.state === ContainerState.COMPLETE))
 );
 
 export const isProcessCancelable = ({ containerRequest, container }: Process): boolean => (
     containerRequest.priority !== null &&
     containerRequest.priority > 0 &&
     container !== undefined &&
-        (container.state === ContainerState.QUEUED ||
+    (container.state === ContainerState.QUEUED ||
         container.state === ContainerState.LOCKED ||
         container.state === ContainerState.RUNNING)
 );
index 361b52a6ae47f1449dcd99ffbb6f0028f52df01a..397442a154edfd67b5bef74e125682d7c24ee05c 100644 (file)
@@ -79,16 +79,16 @@ export const getInitialResourceTypeFilters = pipe(
     ),
     pipe(
         initFilter(ObjectTypeFilter.WORKFLOW, '', false, true),
-        initFilter(ObjectTypeFilter.DEFINITION, ObjectTypeFilter.WORKFLOW),
         initFilter(ProcessTypeFilter.MAIN_PROCESS, ObjectTypeFilter.WORKFLOW),
         initFilter(ProcessTypeFilter.CHILD_PROCESS, ObjectTypeFilter.WORKFLOW, false),
+        initFilter(ObjectTypeFilter.DEFINITION, ObjectTypeFilter.WORKFLOW),
     ),
     pipe(
         initFilter(ObjectTypeFilter.COLLECTION, '', true, true),
         initFilter(CollectionTypeFilter.GENERAL_COLLECTION, ObjectTypeFilter.COLLECTION),
         initFilter(CollectionTypeFilter.OUTPUT_COLLECTION, ObjectTypeFilter.COLLECTION),
-        initFilter(CollectionTypeFilter.INTERMEDIATE_COLLECTION, ObjectTypeFilter.COLLECTION),
-        initFilter(CollectionTypeFilter.LOG_COLLECTION, ObjectTypeFilter.COLLECTION),
+        initFilter(CollectionTypeFilter.INTERMEDIATE_COLLECTION, ObjectTypeFilter.COLLECTION, false),
+        initFilter(CollectionTypeFilter.LOG_COLLECTION, ObjectTypeFilter.COLLECTION, false),
     ),
 
 );
index f339d1b3dfab65cc22dc091eb6db2fb68a5257e3..abcbcdb4c3a6d30129da50c0e490b02c46cb1901 100644 (file)
@@ -59,10 +59,10 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         fontSize: '0.78rem',
     },
     cancelButton: {
-        color: theme.customs.colors.red900,
-        borderColor: theme.customs.colors.red900,
+        color: theme.palette.common.white,
+        backgroundColor: theme.customs.colors.red900,
         '&:hover': {
-            borderColor: theme.customs.colors.red900,
+            backgroundColor: theme.customs.colors.red900,
         },
         '& svg': {
             fontSize: '22px',
@@ -126,7 +126,7 @@ export const ProcessDetailsCard = withStyles(styles)(
                         {isProcessCancelable(process) &&
                             <Button
                                 data-cy="process-cancel-button"
-                                variant="outlined"
+                                variant="contained"
                                 size="small"
                                 color="primary"
                                 className={classNames(classes.actionButton, classes.cancelButton)}