Fix the file preview modal so it supports WOPI_ENABLED == false

This commit is contained in:
Luka Murn 2019-05-10 16:25:18 +02:00
parent bbf54de9c7
commit b78caef915
3 changed files with 16 additions and 9 deletions

View file

@ -5,6 +5,7 @@ class AssetsController < ApplicationController
include ActionView::Helpers::TextHelper
include ActionView::Helpers::UrlHelper
include ActionView::Context
include ApplicationHelper
include InputSanitizeHelper
include FileIconsHelper
@ -81,7 +82,7 @@ class AssetsController < ApplicationController
)
end
if wopi_file?(@asset)
if wopi_enabled? && wopi_file?(@asset)
edit_supported, title = wopi_file_edit_button_status
response_json['wopi-controls'] = render_to_string(
partial: 'shared/file_wopi_controlls.html.erb',
@ -293,6 +294,7 @@ class AssetsController < ApplicationController
def asset_data_type(asset)
return 'wopi' if wopi_file?(asset)
return 'image' if asset.is_image?
'file'
end
end

View file

@ -221,4 +221,8 @@ module ApplicationHelper
user.avatar(style) == '/images/icon_small/missing.png' ||
user.avatar(style) == '/images/thumb/missing.png'
end
def wopi_enabled?
ENV['WOPI_ENABLED'] == 'true'
end
end

View file

@ -1,11 +1,12 @@
<%= link_to create_wopi_file_path,
class: 'btn btn-default create-wopi-file-btn',
target: '_blank',
<% if wopi_enabled? %>
<%= link_to create_wopi_file_path,
class: 'btn btn-default create-wopi-file-btn',
target: '_blank',
title: 'Create_new_file',
data: { 'id': element_id, 'type': element_type, } do %>
<span class="btn btn-default new-asset-upload-button">
<span class="fas fa-file-medical new-asset-upload-icon"></span>
<%=t 'assets.create_wopi_file.button_text' %>
</span>
<span class="btn btn-default new-asset-upload-button">
<span class="fas fa-file-medical new-asset-upload-icon"></span>
<%=t 'assets.create_wopi_file.button_text' %>
</span>
<% end %>
<% end %>