Merge branch '12377-workbench-composer-link' refs #12377
[arvados.git] / apps / workbench / app / controllers / work_unit_templates_controller.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class WorkUnitTemplatesController < ApplicationController
6   def find_objects_for_index
7     return if !params[:partial]
8
9     @limit = 40
10     @filters = @filters || []
11
12     # get next page of pipeline_templates
13     if PipelineTemplate.api_exists?(:index)
14       filters = @filters + [["uuid", "is_a", ["arvados#pipelineTemplate"]]]
15       pipelines = PipelineTemplate.limit(@limit).order(["created_at desc"]).filter(filters)
16     end
17
18     # get next page of workflows
19     filters = @filters + [["uuid", "is_a", ["arvados#workflow"]]]
20     workflows = Workflow.limit(@limit).order(["created_at desc"]).filter(filters)
21
22     @objects = (pipelines.to_a + workflows.to_a).sort_by(&:created_at).reverse.first(@limit)
23
24     if @objects.any?
25       @next_page_filters = next_page_filters('<=')
26       @next_page_href = url_for(partial: :choose_rows,
27                                 filters: @next_page_filters.to_json)
28     else
29       @next_page_href = nil
30     end
31   end
32
33   def next_page_href with_params={}
34     @next_page_href
35   end
36 end