Merge pull request #8044 from aignatov-bio/ai-sci-11284-fix-archived-items

Fix permission for archived rows and download link [SCI-11284][SCI-11285]
This commit is contained in:
aignatov-bio 2024-11-15 10:06:45 +01:00 committed by GitHub
commit 8e91284e29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View file

@ -40,7 +40,7 @@
<div class="basis-1/4 flex justify-end">
<a class="btn btn-icon p-0 px-2 hover:bg-sn-light-grey"
v-if="enabled || index === 0"
:href="fileVersion.attributes.url"
:href="fileVersion.attributes.download_url"
target="_blank"
data-render-tooltip="true"
:title="i18n.t('assets.file_versions_modal.download')"

View file

@ -27,6 +27,7 @@ Canaid::Permissions.register_for(Asset) do
if object.repository_column.repository.is_a?(RepositorySnapshot)
false
else
object.repository_row.active? &&
can_manage_repository_assets?(user, object.repository_column.repository)
end
end

View file

@ -4,7 +4,7 @@ module ActiveStorage
class BlobSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes :filename, :extension, :basename, :url, :created_at, :byte_size, :version, :restored_from_version, :created_by
attributes :filename, :extension, :basename, :url, :created_at, :byte_size, :version, :restored_from_version, :created_by, :download_url
def basename
object.filename.base
@ -14,6 +14,10 @@ module ActiveStorage
object.filename.extension_without_delimiter
end
def download_url
rails_blob_url(object, disposition: 'attachment')
end
def version
object.metadata['version'] || 1
end