18995: Merge branch 'main' into 18995-code-cleanup-5
[arvados.git] / apps / workbench / app / models / job_work_unit.rb
index 80dea192d1c3b8b3b2383ff7d74048fa00062c17..83825a533849fea023482d12bafeac8c88db76d8 100644 (file)
@@ -1,6 +1,10 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class JobWorkUnit < ProxyWorkUnit
   def children
-    return self.my_children if self.my_children
+    return @my_children if @my_children
 
     # Jobs components
     items = []
@@ -20,7 +24,15 @@ class JobWorkUnit < ProxyWorkUnit
       end
     end
 
-    self.my_children = items
+    @my_children = items
+  end
+
+  def child_summary
+    if children.any?
+      super
+    else
+      get(:tasks_summary)
+    end
   end
 
   def parameters
@@ -51,16 +63,30 @@ class JobWorkUnit < ProxyWorkUnit
     get(:nondeterministic)
   end
 
-  def child_summary
-    if children.any?
-      super
-    else
-      get(:tasks_summary)
-    end
+  def runtime_constraints
+    get(:runtime_constraints)
+  end
+
+  def priority
+    get(:priority)
+  end
+
+  def log_collection
+    get(:log)
+  end
+
+  def outputs
+    items = []
+    items << get(:output) if get(:output)
+    items
   end
 
   def can_cancel?
-    true
+    state_label.in? ["Queued", "Running"]
+  end
+
+  def confirm_cancellation
+    "All unfinished child jobs and pipelines will also be canceled, even if they are being used in another job or pipeline. Are you sure you want to cancel this job?"
   end
 
   def uri