X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/695a100d4bd3bf4f5534c7e489c118c2917bf35a..9a4c456560f0b78660c2bfc9a7aa4030de74c741:/apps/workbench/app/controllers/trash_items_controller.rb?ds=sidebyside diff --git a/apps/workbench/app/controllers/trash_items_controller.rb b/apps/workbench/app/controllers/trash_items_controller.rb index 5190474e90..b957798459 100644 --- a/apps/workbench/app/controllers/trash_items_controller.rb +++ b/apps/workbench/app/controllers/trash_items_controller.rb @@ -1,8 +1,16 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class TrashItemsController < ApplicationController def model_class Collection end + def index_pane_list + %w(Trashed_collections Trashed_projects) + end + def find_objects_for_index # If it's not the index rows partial display, just return # The /index request will again be invoked to display the @@ -12,10 +20,10 @@ class TrashItemsController < ApplicationController trashed_items if @objects.any? + @objects = @objects.sort_by { |obj| obj.trash_at }.reverse @next_page_filters = next_page_filters('<=') @next_page_href = url_for(partial: :trash_rows, filters: @next_page_filters.to_json) - preload_links_for_objects(@objects.to_a) else @next_page_href = nil end @@ -25,6 +33,27 @@ class TrashItemsController < ApplicationController @next_page_href end + def next_page_filters nextpage_operator + next_page_filters = @filters.reject do |attr, op, val| + (attr == 'trash_at' and op == nextpage_operator) or + (attr == 'uuid' and op == 'not in') + end + + if @objects.any? + last_trash_at = @objects.last.trash_at + + last_uuids = [] + @objects.each do |obj| + last_uuids << obj.uuid if obj.trash_at.eql?(last_trash_at) + end + + next_page_filters += [['trash_at', nextpage_operator, last_trash_at]] + next_page_filters += [['uuid', 'not in', last_uuids]] + end + + next_page_filters + end + def trashed_items # API server index doesn't return manifest_text by default, but our # callers want it unless otherwise specified. @@ -37,39 +66,13 @@ class TrashItemsController < ApplicationController if params[:search].andand.length.andand > 0 tags = Link.where(any: ['contains', params[:search]]) - @objects = (base_search.limit(limit).offset(offset).where(uuid: tags.collect(&:head_uuid)) | - base_search.where(any: ['contains', params[:search]])). - uniq { |c| c.uuid } + base_search = base_search.limit(limit).offset(offset) + @objects = (base_search.where(uuid: tags.collect(&:head_uuid)) | + base_search.where(any: ['contains', params[:search]])). + uniq { |c| c.uuid } else @objects = base_search.limit(limit).offset(offset) end - - @links = Link.where(head_uuid: @objects.collect(&:uuid)) - @collection_info = {} - @objects.each do |c| - @collection_info[c.uuid] = { - tag_links: [], - wanted: false, - wanted_by_me: false, - provenance: [], - links: [] - } - end - @links.each do |link| - @collection_info[link.head_uuid] ||= {} - info = @collection_info[link.head_uuid] - case link.link_class - when 'tag' - info[:tag_links] << link - when 'resources' - info[:wanted] = true - info[:wanted_by_me] ||= link.tail_uuid == current_user.uuid - when 'provenance' - info[:provenance] << link.name - end - info[:links] << link - end - @request_url = request.url end def untrash_items @@ -77,9 +80,9 @@ class TrashItemsController < ApplicationController updates = {trash_at: nil} - params[:selection].collect { |uuid| ArvadosBase.find uuid }.each do |item| - item.update_attributes updates - @untrashed_uuids << item.uuid + Collection.include_trash(1).where(uuid: params[:selection]).each do |c| + c.untrash + @untrashed_uuids << c.uuid end respond_to do |format|