diff options
Diffstat (limited to 'app/helpers/blob_helper.rb')
-rw-r--r-- | app/helpers/blob_helper.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 0c5823894c5..bca53dfb88a 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -106,11 +106,12 @@ module BlobHelper return unless blob common_classes = "btn btn-#{btn_class}" + base_button = button_tag(label, class: "#{common_classes} disabled", disabled: true) if !on_top_of_branch?(project, ref) - button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' } + modify_file_button_tooltip(base_button, _("You can only %{action} files when you are on a branch") % { action: action }) elsif blob.stored_externally? - button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' } + modify_file_button_tooltip(base_button, _("It is not possible to %{action} files that are stored in LFS using the web interface") % { action: action }) elsif can_modify_blob?(blob, project, ref) button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' elsif can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project) @@ -217,6 +218,10 @@ module BlobHelper @gitlab_ci_ymls ||= template_dropdown_names(TemplateFinder.build(:gitlab_ci_ymls, project).execute) end + def gitlab_ci_syntax_ymls(project) + @gitlab_ci_syntax_ymls ||= template_dropdown_names(TemplateFinder.build(:gitlab_ci_syntax_ymls, project).execute) + end + def metrics_dashboard_ymls(project) @metrics_dashboard_ymls ||= template_dropdown_names(TemplateFinder.build(:metrics_dashboard_ymls, project).execute) end @@ -360,7 +365,11 @@ module BlobHelper end def edit_disabled_button_tag(button_text, common_classes) - button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _('You can only edit files when you are on a branch'), data: { container: 'body' }) + button = button_tag(button_text, class: "#{common_classes} disabled", disabled: true) + + # Disabled buttons with tooltips should have the tooltip attached + # to a wrapper element https://bootstrap-vue.org/docs/components/tooltip#disabled-elements + content_tag(:span, button, class: 'has-tooltip', title: _('You can only edit files when you are on a branch'), data: { container: 'body' }) end def edit_link_tag(link_text, edit_path, common_classes, data) @@ -397,4 +406,12 @@ module BlobHelper @path.to_s.end_with?(Ci::Pipeline::CONFIG_EXTENSION) || @path.to_s == @project.ci_config_path_or_default end + + private + + def modify_file_button_tooltip(button, tooltip_message) + # Disabled buttons with tooltips should have the tooltip attached + # to a wrapper element https://bootstrap-vue.org/docs/components/tooltip#disabled-elements + content_tag(:span, button, class: 'btn-group has-tooltip', title: tooltip_message, data: { container: 'body' }) + end end |