Module: WebIdeButtonHelper
- Included in:
- TreeHelper
- Defined in:
- app/helpers/web_ide_button_helper.rb
Instance Method Summary collapse
- #can_collaborate? ⇒ Boolean
- #can_create_mr_from_fork? ⇒ Boolean
- #edit_url(options = {}) ⇒ Object
- #fork? ⇒ Boolean
- #gitpod_url ⇒ Object
- #needs_to_fork? ⇒ Boolean
- #project_fork ⇒ Object
- #project_to_use ⇒ Object
- #readable_blob?(options = {}) ⇒ Boolean
- #show_edit_button?(options = {}) ⇒ Boolean
- #show_gitpod_button? ⇒ Boolean
- #show_pipeline_editor_button?(project, path) ⇒ Boolean
- #show_web_ide_button? ⇒ Boolean
- #web_ide_url ⇒ Object
Instance Method Details
#can_collaborate? ⇒ Boolean
12 13 14 |
# File 'app/helpers/web_ide_button_helper.rb', line 12 def can_collaborate? can_collaborate_with_project?(@project) end |
#can_create_mr_from_fork? ⇒ Boolean
16 17 18 |
# File 'app/helpers/web_ide_button_helper.rb', line 16 def can_create_mr_from_fork? can?(current_user, :fork_project, @project) && can?(current_user, :create_merge_request_in, @project) end |
#edit_url(options = {}) ⇒ Object
52 53 54 |
# File 'app/helpers/web_ide_button_helper.rb', line 52 def edit_url( = {}) readable_blob?() ? edit_blob_path(@project, @ref, @path || '') : '' end |
#fork? ⇒ Boolean
36 37 38 |
# File 'app/helpers/web_ide_button_helper.rb', line 36 def fork? !project_fork.nil? && !can_push_code? end |
#gitpod_url ⇒ Object
56 57 58 59 60 |
# File 'app/helpers/web_ide_button_helper.rb', line 56 def gitpod_url return "" unless Gitlab::CurrentSettings.gitpod_enabled && @ref "#{Gitlab::CurrentSettings.gitpod_url}##{project_tree_url(@project, tree_join(@ref, @path || ''))}" end |
#needs_to_fork? ⇒ Boolean
44 45 46 |
# File 'app/helpers/web_ide_button_helper.rb', line 44 def needs_to_fork? !can_collaborate? && !current_user&.already_forked?(@project) end |
#project_fork ⇒ Object
4 5 6 |
# File 'app/helpers/web_ide_button_helper.rb', line 4 def project_fork current_user&.fork_of(@project) end |
#project_to_use ⇒ Object
8 9 10 |
# File 'app/helpers/web_ide_button_helper.rb', line 8 def project_to_use fork? ? project_fork : @project end |
#readable_blob?(options = {}) ⇒ Boolean
40 41 42 |
# File 'app/helpers/web_ide_button_helper.rb', line 40 def readable_blob?( = {}) !readable_blob(, @path, @project, @ref).nil? end |
#show_edit_button?(options = {}) ⇒ Boolean
24 25 26 |
# File 'app/helpers/web_ide_button_helper.rb', line 24 def ( = {}) readable_blob?() && end |
#show_gitpod_button? ⇒ Boolean
28 29 30 |
# File 'app/helpers/web_ide_button_helper.rb', line 28 def && Gitlab::CurrentSettings.gitpod_enabled end |
#show_pipeline_editor_button?(project, path) ⇒ Boolean
32 33 34 |
# File 'app/helpers/web_ide_button_helper.rb', line 32 def (project, path) can_view_pipeline_editor?(project) && path == project.ci_config_path_or_default end |
#show_web_ide_button? ⇒ Boolean
20 21 22 |
# File 'app/helpers/web_ide_button_helper.rb', line 20 def can_collaborate? || can_create_mr_from_fork? end |
#web_ide_url ⇒ Object
48 49 50 |
# File 'app/helpers/web_ide_button_helper.rb', line 48 def web_ide_url ide_edit_path(project_to_use, @ref, @path || '') end |