summaryrefslogtreecommitdiff
path: root/app/helpers/blob_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/blob_helper.rb')
-rw-r--r--app/helpers/blob_helper.rb36
1 files changed, 28 insertions, 8 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index f4238e7711a..615c834c529 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -48,24 +48,40 @@ module BlobHelper
return unless blob = readable_blob(options, path, project, ref)
common_classes = "btn btn-primary js-edit-blob ml-2 #{options[:extra_class]}"
+ data = { track_event: 'click_edit', track_label: 'Edit' }
+
+ if Feature.enabled?(:web_ide_primary_edit, project.group)
+ common_classes += " btn-inverted"
+ data[:track_property] = 'secondary'
+ end
edit_button_tag(blob,
common_classes,
_('Edit'),
edit_blob_path(project, ref, path, options),
project,
- ref)
+ ref,
+ data)
end
def ide_edit_button(project = @project, ref = @ref, path = @path, blob:)
return unless blob
+ common_classes = 'btn btn-primary ide-edit-button ml-2'
+ data = { track_event: 'click_edit_ide', track_label: 'Web IDE' }
+
+ unless Feature.enabled?(:web_ide_primary_edit, project.group)
+ common_classes += " btn-inverted"
+ data[:track_property] = 'secondary'
+ end
+
edit_button_tag(blob,
- 'btn btn-inverted btn-primary ide-edit-button ml-2',
+ common_classes,
_('Web IDE'),
ide_edit_path(project, ref, path),
project,
- ref)
+ ref,
+ data)
end
def modify_file_button(project = @project, ref = @ref, path = @path, blob:, label:, action:, btn_class:, modal_type:)
@@ -184,6 +200,10 @@ module BlobHelper
@gitlab_ci_ymls ||= template_dropdown_names(TemplateFinder.build(:gitlab_ci_ymls, project).execute)
end
+ def metrics_dashboard_ymls(project)
+ @metrics_dashboard_ymls ||= template_dropdown_names(TemplateFinder.build(:metrics_dashboard_ymls, project).execute)
+ end
+
def dockerfile_names(project)
@dockerfile_names ||= template_dropdown_names(TemplateFinder.build(:dockerfiles, project).execute)
end
@@ -325,16 +345,16 @@ module BlobHelper
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' })
end
- def edit_link_tag(link_text, edit_path, common_classes)
- link_to link_text, edit_path, class: "#{common_classes} btn-sm"
+ def edit_link_tag(link_text, edit_path, common_classes, data)
+ link_to link_text, edit_path, class: "#{common_classes} btn-sm", data: data
end
- def edit_button_tag(blob, common_classes, text, edit_path, project, ref)
+ def edit_button_tag(blob, common_classes, text, edit_path, project, ref, data)
if !on_top_of_branch?(project, ref)
edit_disabled_button_tag(text, common_classes)
# This condition only applies to users who are logged in
elsif !current_user || (current_user && can_modify_blob?(blob, project, ref))
- edit_link_tag(text, edit_path, common_classes)
+ edit_link_tag(text, edit_path, common_classes, data)
elsif can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project)
edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path))
end
@@ -343,7 +363,7 @@ module BlobHelper
def show_suggest_pipeline_creation_celebration?
experiment_enabled?(:suggest_pipeline) &&
@blob.path == Gitlab::FileDetector::PATTERNS[:gitlab_ci] &&
- @blob.auxiliary_viewer.valid?(project: @project, sha: @commit.sha, user: current_user) &&
+ @blob.auxiliary_viewer&.valid?(project: @project, sha: @commit.sha, user: current_user) &&
@project.uses_default_ci_config? &&
cookies[suggest_pipeline_commit_cookie_name].present?
end