diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index b50b00f14..92367b755 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b20313b4f..ea7b80302 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/views/assets/wopi/_create_wopi_file_button.html.erb b/app/views/assets/wopi/_create_wopi_file_button.html.erb index 50b2e59b9..01d6c83e2 100644 --- a/app/views/assets/wopi/_create_wopi_file_button.html.erb +++ b/app/views/assets/wopi/_create_wopi_file_button.html.erb @@ -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 %> - - - - <%=t 'assets.create_wopi_file.button_text' %> - + + + <%=t 'assets.create_wopi_file.button_text' %> + <% end %> +<% end %>