Class: ProjectPresenter

Inherits:
Gitlab::View::Presenter::Delegated show all
Includes:
ActionView::Helpers::NumberHelper, BlobHelper, ChecksCollaboration, Ci::PipelineEditorHelper, Gitlab::Experiment::Dsl, Gitlab::Utils::StrongMemoize, GitlabRoutingHelper, IconsHelper, StorageHelper, TreeHelper
Defined in:
app/presenters/project_presenter.rb

Defined Under Namespace

Classes: AnchorData

Constant Summary collapse

MAX_TOPICS_TO_SHOW =
3

Constants included from IconsHelper

IconsHelper::DEFAULT_ICON_SIZE

Instance Method Summary collapse

Methods included from ChecksCollaboration

#can_collaborate_with_project?, #user_access

Methods included from BlobHelper

#blob_editor_paths, #blob_icon, #blob_raw_path, #blob_raw_url, #blob_render_error_options, #blob_render_error_reason, #can_modify_blob?, #contribution_options, #copy_blob_source_button, #copy_file_path_button, #dockerfile_names, #download_blob_button, #edit_blob_button, #edit_blob_fork_params, #edit_blob_path, #edit_button_tag, #edit_disabled_button_tag, #edit_fork_button_tag, #edit_link_tag, #editing_preview_title, #encode_ide_path, #fork_and_edit_path, #fork_path_for_current_user, #gitignore_names, #gitlab_ci_ymls, #human_access, #ide_edit_path, #ide_fork_and_edit_path, #ide_merge_request_path, #leave_edit_message, #licenses_for_select, #open_raw_blob_button, #parent_dir_raw_path, #readable_blob, #ref_project, #sanitize_svg_data, #show_suggest_pipeline_creation_celebration?, #suggest_pipeline_commit_cookie_name, #vue_blob_app_data

Methods included from IconsHelper

#audit_icon, #boolean_to_icon, #custom_icon, #external_snippet_icon, #file_type_icon_class, #gl_loading_icon, #sprite_file_icons_path, #sprite_icon, #sprite_icon_path, #visibility_level_icon

Methods included from Ci::PipelineEditorHelper

#can_view_pipeline_editor?, #js_pipeline_editor_data

Methods included from TreeHelper

#breadcrumb_data_attributes, #can_edit_tree?, #commit_in_fork_help, #commit_in_single_accessible_branch, #directory_download_links, #edit_in_new_fork_notice, #edit_in_new_fork_notice_action, #edit_in_new_fork_notice_now, #fork_modal_options, #on_top_of_branch?, #patch_branch_name, #path_breadcrumbs, #relative_url_root, #selected_branch, #tree_edit_branch, #tree_icon, #tree_join, #vue_file_list_data, #web_ide_button_data

Methods included from WebIdeButtonHelper

#can_collaborate?, #can_create_mr_from_fork?, #edit_url, #fork?, #gitpod_url, #needs_to_fork?, #project_fork, #project_to_use, #readable_blob?, #show_edit_button?, #show_gitpod_button?, #show_pipeline_editor_button?, #show_web_ide_button?, #web_ide_url

Methods included from StorageHelper

#storage_counter, #storage_counters_details

Methods included from Routing::PackagesHelper

#package_path

Methods included from Routing::PseudonymizationHelper

#masked_page_url

Methods included from Routing::GraphqlHelper

#graphql_etag_pipeline_path, #graphql_etag_pipeline_sha_path, #graphql_etag_project_on_demand_scan_counts_path

Methods included from Routing::WikiHelper

#wiki_page_path, #wiki_path

Methods included from Routing::SnippetsHelper

#gitlab_dashboard_snippets_path, #gitlab_raw_snippet_blob_path, #gitlab_raw_snippet_blob_url, #gitlab_raw_snippet_path, #gitlab_raw_snippet_url, #gitlab_snippet_note_path, #gitlab_snippet_note_url, #gitlab_snippet_notes_path, #gitlab_snippet_notes_url, #gitlab_snippet_path, #gitlab_snippet_url, #gitlab_toggle_award_emoji_snippet_note_path, #gitlab_toggle_award_emoji_snippet_note_url, #gitlab_toggle_award_emoji_snippet_path, #gitlab_toggle_award_emoji_snippet_url, #preview_markdown_path, #toggle_award_emoji_personal_snippet_path, #toggle_award_emoji_project_project_snippet_path, #toggle_award_emoji_project_project_snippet_url

Methods included from Routing::PipelineSchedulesHelper

#edit_pipeline_schedule_path, #pipeline_schedule_path, #pipeline_schedules_path, #play_pipeline_schedule_path, #take_ownership_pipeline_schedule_path

Methods included from Routing::ArtifactsHelper

#artifacts_action_path, #expose_fast_artifacts_path, #fast_browse_project_job_artifacts_path, #fast_download_project_job_artifacts_path, #fast_keep_project_job_artifacts_path

Methods included from Routing::MembersHelper

#source_members_url

Methods included from Routing::Groups::MembersHelper

#approve_access_request_group_member_path, #group_member_path, #group_members_url, #leave_group_members_path, #request_access_group_members_path, #resend_invite_group_member_path

Methods included from Routing::Projects::MembersHelper

#approve_access_request_project_member_path, #leave_project_members_path, #project_member_path, #project_members_url, #request_access_project_members_path, #resend_invite_project_member_path

Methods included from Routing::ProjectsHelper

#commit_url, #commits_url, #edit_milestone_path, #environment_delete_path, #environment_path, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #pipeline_job_url, #pipeline_path, #pipeline_url, #project_commits_path, #project_ref_path, #project_tree_path, #release_url, #toggle_subscription_path, #work_item_url

Methods included from API::Helpers::RelatedResourcesHelpers

#expose_path, #expose_url, #issues_available?, #mrs_available?, #project_feature_string_access_level

Methods included from ApplicationSettingsHelper

#all_protocols_enabled?, #allowed_protocols_present?, #anti_spam_service_enabled?, #deprecated_attributes, #enabled_protocol, #enabled_protocol_button, #expanded_by_default?, #external_authorization_allow_token_help_text, #external_authorization_client_certificate_help_text, #external_authorization_client_key_help_text, #external_authorization_client_pass_help_text, #external_authorization_client_url_help_text, #external_authorization_description, #external_authorization_service_attributes, #external_authorization_timeout_help_text, #external_authorization_url_help_text, #http_enabled?, #import_sources_checkboxes, #instance_clusters_enabled?, #integration_expanded?, #key_restriction_options_for_select, #kroki_available_formats, #oauth_providers_checkboxes, #omnibus_protected_paths_throttle?, #pending_user_count, #registration_features_can_be_prompted?, #repository_storages_options_json, #restricted_level_checkboxes, #runner_token_expiration_interval_attributes, #sidekiq_job_limiter_mode_help_text, #sidekiq_job_limiter_modes_for_select, #signup_enabled?, #signup_form_data, #ssh_enabled?, #storage_weights, #user_oauth_applications?, #valid_runner_registrars, #visible_attributes

Methods included from ProjectsHelper

#able_to_see_forks_count?, #able_to_see_issues?, #able_to_see_merge_requests?, #any_projects?, #author_content_tag, #autodeploy_flash_notice, #badge_count, #branch_rules_path, #can_admin_associated_clusters?, #can_admin_project_member?, #can_change_visibility_level?, #can_disable_emails?, #can_push_code?, #can_view_branch_rules?, #clusters_deprecation_alert_message, #delete_confirm_phrase, #directory?, #error_tracking_setting_project_json, #explore_projects_tab?, #external_classification_label_help_message, #fork_button_data_attributes, #grafana_integration_enabled?, #grafana_integration_masked_token, #grafana_integration_url, #http_clone_url_to_repo, #import_from_bitbucket_message, #import_from_gitlab_message, #inactive_project_deletion_date, #last_pipeline_from_status_cache, #last_push_event, #link_to_autodeploy_doc, #link_to_member, #link_to_member_avatar, #link_to_project, #load_pipeline_status, #localized_project_human_access, #membership_locked?, #no_password_message, #project_can_be_shared?, #project_classes, #project_coverage_chart_data_attributes, #project_incident_management_setting, #project_license_name, #project_list_cache_key, #project_permissions_panel_data, #project_title, #push_to_create_project_command, #remote_mirror_setting_enabled?, #remove_fork_project_confirm_json, #remove_fork_project_description_message, #remove_fork_project_warning_message, #remove_project_message, #show_auto_devops_implicitly_enabled_banner?, #show_clusters_alert?, #show_count?, #show_inactive_project_deletion_banner?, #show_mobile_devops_project_promo?, #show_no_password_message?, #show_no_ssh_key_message?, #show_projects?, #show_terraform_banner?, #show_xcode_link?, #ssh_clone_url_to_repo, #transfer_project_message, #visibility_level_content, #visible_fork_source, #vue_fork_divergence_data, #xcode_uri_to_repo

Methods included from Gitlab::Allowable

#can?

Methods included from CompareHelper

#create_mr_button?, #create_mr_path, #project_compare_selector_data, #target_projects

Methods inherited from Gitlab::View::Presenter::Delegated

#initialize

Methods included from Gitlab::Utils::DelegatorOverride

#delegator_override, #delegator_override_with, #delegator_target, validator, validators, verify!

Methods included from Gitlab::View::Presenter::Base

#__subject__, #can?, #declarative_policy_delegate, #is_a?, #path_with_line_numbers, #present, #url_builder, #web_path, #web_url

Methods included from Gitlab::Routing

includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

This class inherits a constructor from Gitlab::View::Presenter::Delegated

Instance Method Details

#add_changelog_ide_pathObject



119
120
121
# File 'app/presenters/project_presenter.rb', line 119

def add_changelog_ide_path
  ide_edit_path(project, default_branch_or_main, 'CHANGELOG')
end

#add_changelog_pathObject



115
116
117
# File 'app/presenters/project_presenter.rb', line 115

def add_changelog_path
  add_special_file_path(file_name: 'CHANGELOG')
end

#add_contribution_guide_ide_pathObject



127
128
129
# File 'app/presenters/project_presenter.rb', line 127

def add_contribution_guide_ide_path
  ide_edit_path(project, default_branch_or_main, 'CONTRIBUTING.md')
end

#add_contribution_guide_pathObject



123
124
125
# File 'app/presenters/project_presenter.rb', line 123

def add_contribution_guide_path
  add_special_file_path(file_name: 'CONTRIBUTING.md', commit_message: 'Add CONTRIBUTING')
end

#add_license_ide_pathObject



111
112
113
# File 'app/presenters/project_presenter.rb', line 111

def add_license_ide_path
  ide_edit_path(project, default_branch_or_main, 'LICENSE')
end

#add_license_pathObject



107
108
109
# File 'app/presenters/project_presenter.rb', line 107

def add_license_path
  add_special_file_path(file_name: 'LICENSE')
end

#add_readme_ide_pathObject



135
136
137
# File 'app/presenters/project_presenter.rb', line 135

def add_readme_ide_path
  ide_edit_path(project, default_branch_or_main, 'README.md')
end

#add_readme_pathObject



131
132
133
# File 'app/presenters/project_presenter.rb', line 131

def add_readme_path
  add_special_file_path(file_name: 'README.md')
end

#all_clusters_empty?Boolean

Returns:

  • (Boolean)


448
449
450
451
452
# File 'app/presenters/project_presenter.rb', line 448

def all_clusters_empty?
  strong_memoize(:all_clusters_empty) do
    project.all_clusters.empty?
  end
end

#autodevops_anchor_data(show_auto_devops_callout: false) ⇒ Object



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'app/presenters/project_presenter.rb', line 367

def autodevops_anchor_data(show_auto_devops_callout: false)
  return unless project.feature_available?(:builds, current_user)

  if current_user && can?(current_user, :admin_pipeline, project) && repository.gitlab_ci_yml.blank? && !show_auto_devops_callout
    if auto_devops_enabled?
      AnchorData.new(
        false,
        statistic_icon('settings') + _('Auto DevOps enabled'),
        project_settings_ci_cd_path(project, anchor: 'autodevops-settings'),
        'btn-default'
      )
    else
      AnchorData.new(
        false,
        statistic_icon + _('Enable Auto DevOps'),
        project_settings_ci_cd_path(project, anchor: 'autodevops-settings')
      )
    end
  elsif auto_devops_enabled?
    AnchorData.new(false, _('Auto DevOps enabled'), nil)
  end
end

#branches_anchor_dataObject



227
228
229
230
231
232
233
234
235
236
237
238
# File 'app/presenters/project_presenter.rb', line 227

def branches_anchor_data
  AnchorData.new(
    true,
    statistic_icon('branch') +
    n_('%{strong_start}%{branch_count}%{strong_end} Branch', '%{strong_start}%{branch_count}%{strong_end} Branches', repository.branch_count).html_safe % {
      branch_count: number_with_delimiter(repository.branch_count),
      strong_start: '<strong class="project-stat-value">'.html_safe,
      strong_end: '</strong>'.html_safe
    },
    empty_repo? ? nil : project_branches_path(project)
  )
end

#can_current_user_push_code?Boolean

Returns:

  • (Boolean)


144
145
146
147
148
149
150
151
152
# File 'app/presenters/project_presenter.rb', line 144

def can_current_user_push_code?
  strong_memoize(:can_current_user_push_code) do
    if empty_repo?
      can?(current_user, :push_code, project)
    else
      can_current_user_push_to_branch?(default_branch)
    end
  end
end

#can_current_user_push_to_branch?(branch) ⇒ Boolean

Returns:

  • (Boolean)


154
155
156
157
158
# File 'app/presenters/project_presenter.rb', line 154

def can_current_user_push_to_branch?(branch)
  return false unless current_user

  user_access(project).can_push_to_branch?(branch)
end

#can_current_user_push_to_default_branch?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'app/presenters/project_presenter.rb', line 160

def can_current_user_push_to_default_branch?
  can_current_user_push_to_branch?(default_branch)
end

#can_setup_review_app?Boolean

Returns:

  • (Boolean)


442
443
444
445
446
# File 'app/presenters/project_presenter.rb', line 442

def can_setup_review_app?
  strong_memoize(:can_setup_review_app) do
    (can_instantiate_cluster? && all_clusters_empty?) || cicd_missing?
  end
end

#changelog_anchor_dataObject



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'app/presenters/project_presenter.rb', line 312

def changelog_anchor_data
  if can_current_user_push_to_default_branch? && repository.changelog.blank?
    AnchorData.new(
      false,
      statistic_icon + _('Add CHANGELOG'),
      empty_repo? ? add_changelog_ide_path : add_changelog_path
    )
  elsif repository.changelog.present?
    AnchorData.new(
      false,
      statistic_icon('doc-text') + _('CHANGELOG'),
      changelog_path,
      'btn-default'
    )
  end
end

#changelog_pathObject



93
94
95
# File 'app/presenters/project_presenter.rb', line 93

def changelog_path
  filename_path(repository.changelog&.name)
end

#commits_anchor_dataObject



214
215
216
217
218
219
220
221
222
223
224
225
# File 'app/presenters/project_presenter.rb', line 214

def commits_anchor_data
  AnchorData.new(
    true,
    statistic_icon('commit') +
    n_('%{strong_start}%{commit_count}%{strong_end} Commit', '%{strong_start}%{commit_count}%{strong_end} Commits', statistics.commit_count).html_safe % {
      commit_count: number_with_delimiter(statistics.commit_count),
      strong_start: '<strong class="project-stat-value">'.html_safe,
      strong_end: '</strong>'.html_safe
    },
    empty_repo? ? nil : project_commits_path(project, default_branch_or_main)
  )
end

#contribution_guide_anchor_dataObject



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'app/presenters/project_presenter.rb', line 350

def contribution_guide_anchor_data
  if can_current_user_push_to_default_branch? && repository.contribution_guide.blank?
    AnchorData.new(
      false,
      statistic_icon + _('Add CONTRIBUTING'),
      empty_repo? ? add_contribution_guide_ide_path : add_contribution_guide_path
    )
  elsif repository.contribution_guide.present?
    AnchorData.new(
      false,
      statistic_icon('doc-text') + _('CONTRIBUTING'),
      contribution_guide_path,
      'btn-default'
    )
  end
end

#contribution_guide_pathObject



101
102
103
104
105
# File 'app/presenters/project_presenter.rb', line 101

def contribution_guide_path
  if project && contribution_guide = repository.contribution_guide
    project_blob_path(project, tree_join(project.default_branch, contribution_guide.name))
  end
end

#count_of_extra_topics_not_shownObject



430
431
432
433
434
435
436
# File 'app/presenters/project_presenter.rb', line 430

def count_of_extra_topics_not_shown
  if project_topic_list.count > MAX_TOPICS_TO_SHOW
    project_topic_list.count - MAX_TOPICS_TO_SHOW
  else
    0
  end
end

#default_viewObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/presenters/project_presenter.rb', line 71

def default_view
  return anonymous_project_view unless current_user

  user_view = current_user.project_view

  if can?(current_user, :read_code, project)
    user_view
  elsif user_view == 'activity'
    'activity'
  elsif project.wiki_repository_exists? && can?(current_user, :read_wiki, project)
    'wiki'
  elsif can?(current_user, :read_issue, project)
    'projects/issues/issues'
  else
    'activity'
  end
end

#empty_repo_statistics_anchorsObject



53
54
55
# File 'app/presenters/project_presenter.rb', line 53

def empty_repo_statistics_anchors
  []
end

#empty_repo_statistics_buttonsObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/presenters/project_presenter.rb', line 57

def empty_repo_statistics_buttons
  [
    upload_anchor_data,
    new_file_anchor_data,
    readme_anchor_data,
    license_anchor_data,
    changelog_anchor_data,
    contribution_guide_anchor_data,
    gitlab_ci_anchor_data,
    wiki_anchor_data,
    integrations_anchor_data
  ].compact.reject { |item| item.is_link }
end

#environments_anchor_dataObject



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'app/presenters/project_presenter.rb', line 196

def environments_anchor_data
  return unless can?(current_user, :read_environment, project)

  environments_count = project.environments.available.count
  return if environments_count == 0

  AnchorData.new(
    true,
    statistic_icon('environment') +
    n_('%{strong_start}%{count}%{strong_end} Environment', '%{strong_start}%{count}%{strong_end} Environments', environments_count).html_safe % {
      count: number_with_delimiter(environments_count),
      strong_start: '<strong class="project-stat-value">'.html_safe,
      strong_end: '</strong>'.html_safe
    },
    project_environments_path(project)
  )
end

#gitlab_ci_anchor_dataObject



402
403
404
405
406
407
408
409
410
# File 'app/presenters/project_presenter.rb', line 402

def gitlab_ci_anchor_data
  return unless can_view_pipeline_editor?(project)

  if cicd_missing?
    AnchorData.new(false, statistic_icon + _('Set up CI/CD'), project_ci_pipeline_editor_path(project))
  elsif repository.gitlab_ci_yml.present?
    AnchorData.new(false, statistic_icon('doc-text') + _('CI/CD configuration'), project_ci_pipeline_editor_path(project), 'btn-default')
  end
end

#has_extra_topics?Boolean

Returns:

  • (Boolean)


438
439
440
# File 'app/presenters/project_presenter.rb', line 438

def has_extra_topics?
  count_of_extra_topics_not_shown > 0
end

#kubernetes_cluster_anchor_dataObject



390
391
392
393
394
395
396
397
398
399
400
# File 'app/presenters/project_presenter.rb', line 390

def kubernetes_cluster_anchor_data
  if can_instantiate_cluster?
    if clusters.empty?
      AnchorData.new(false, statistic_icon + _('Add Kubernetes cluster'), project_clusters_path(project))
    else
      cluster_link = clusters.count == 1 ? project_cluster_path(project, clusters.first) : project_clusters_path(project)

      AnchorData.new(false, _('Kubernetes'), cluster_link, 'btn-default')
    end
  end
end

#license_anchor_dataObject



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'app/presenters/project_presenter.rb', line 329

def license_anchor_data
  icon = statistic_icon('scale')

  if repository.license_blob.present?
    AnchorData.new(
      false,
      icon + (:span, license_short_name, class: 'project-stat-value'),
      license_path,
      'btn-default',
      nil,
      'license'
    )
  elsif can_current_user_push_to_default_branch?
    AnchorData.new(
      false,
      (:span, statistic_icon + _('Add LICENSE'), class: 'add-license-link d-flex'),
      empty_repo? ? add_license_ide_path : add_license_path
    )
  end
end

#license_pathObject



97
98
99
# File 'app/presenters/project_presenter.rb', line 97

def license_path
  filename_path(repository.license_blob&.name)
end

#license_short_nameObject



139
140
141
142
# File 'app/presenters/project_presenter.rb', line 139

def license_short_name
  license = repository.license
  license&.nickname || license&.name || 'LICENSE'
end

#new_file_anchor_dataObject



290
291
292
293
294
295
296
# File 'app/presenters/project_presenter.rb', line 290

def new_file_anchor_data
  if can_current_user_push_to_default_branch?
    new_file_path = empty_repo? ? ide_edit_path(project, default_branch_or_main) : project_new_blob_path(project, default_branch_or_main)

    AnchorData.new(false, statistic_icon + _('New file'), new_file_path, 'btn-dashed')
  end
end

#readme_anchor_dataObject



298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'app/presenters/project_presenter.rb', line 298

def readme_anchor_data
  if can_current_user_push_to_default_branch? && readme_path.nil?
    AnchorData.new(false, statistic_icon + _('Add README'), empty_repo? ? add_readme_ide_path : add_readme_path)
  elsif readme_path
    AnchorData.new(
      false,
      statistic_icon('doc-text') + _('README'),
      default_view != 'readme' ? readme_path : '#readme',
      'btn-default',
      'doc-text'
    )
  end
end

#readme_pathObject



89
90
91
# File 'app/presenters/project_presenter.rb', line 89

def readme_path
  filename_path(repository.readme_path)
end

#releases_anchor_dataObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'app/presenters/project_presenter.rb', line 178

def releases_anchor_data
  return unless can?(current_user, :read_release, project)

  releases_count = project.releases.count
  return if releases_count < 1

  AnchorData.new(
    true,
    statistic_icon('rocket-launch') +
    n_('%{strong_start}%{release_count}%{strong_end} Release', '%{strong_start}%{release_count}%{strong_end} Releases', releases_count).html_safe % {
      release_count: number_with_delimiter(releases_count),
      strong_start: '<strong class="project-stat-value">'.html_safe,
      strong_end: '</strong>'.html_safe
    },
    project_releases_path(project)
  )
end

#statistic_icon(icon_name = 'plus-square-o') ⇒ Object



23
24
25
# File 'app/presenters/project_presenter.rb', line 23

def statistic_icon(icon_name = 'plus-square-o')
  sprite_icon(icon_name, css_class: 'icon gl-mr-2 gl-text-gray-500')
end

#statistics_anchors(show_auto_devops_callout:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'app/presenters/project_presenter.rb', line 27

def statistics_anchors(show_auto_devops_callout:)
  [
    commits_anchor_data,
    branches_anchor_data,
    terraform_states_anchor_data,
    tags_anchor_data,
    storage_anchor_data,
    releases_anchor_data,
    environments_anchor_data
  ].compact.select(&:is_link)
end

#statistics_buttons(show_auto_devops_callout:) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/presenters/project_presenter.rb', line 39

def statistics_buttons(show_auto_devops_callout:)
  [
    readme_anchor_data,
    license_anchor_data,
    changelog_anchor_data,
    contribution_guide_anchor_data,
    autodevops_anchor_data(show_auto_devops_callout: show_auto_devops_callout),
    kubernetes_cluster_anchor_data,
    gitlab_ci_anchor_data,
    wiki_anchor_data,
    integrations_anchor_data
  ].compact.reject(&:is_link).sort_by.with_index { |item, idx| [item.class_modifier ? 0 : 1, idx] }
end

#storage_anchor_dataObject



164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'app/presenters/project_presenter.rb', line 164

def storage_anchor_data
  can_show_quota = can?(current_user, :admin_project, project) && !empty_repo?
  AnchorData.new(
    true,
    statistic_icon('disk') +
    _('%{strong_start}%{human_size}%{strong_end} Project Storage').html_safe % {
      human_size: storage_counter(statistics.storage_size),
      strong_start: '<strong class="project-stat-value">'.html_safe,
      strong_end: '</strong>'.html_safe
    },
    can_show_quota ? project_usage_quotas_path(project) : nil
  )
end

#tags_anchor_dataObject



255
256
257
258
259
260
261
262
263
264
265
266
# File 'app/presenters/project_presenter.rb', line 255

def tags_anchor_data
  AnchorData.new(
    true,
    statistic_icon('label') +
    n_('%{strong_start}%{tag_count}%{strong_end} Tag', '%{strong_start}%{tag_count}%{strong_end} Tags', repository.tag_count).html_safe % {
      tag_count: number_with_delimiter(repository.tag_count),
      strong_start: '<strong class="project-stat-value">'.html_safe,
      strong_end: '</strong>'.html_safe
    },
    empty_repo? ? nil : project_tags_path(project)
  )
end

#terraform_states_anchor_dataObject



240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'app/presenters/project_presenter.rb', line 240

def terraform_states_anchor_data
  if project.terraform_states.exists? && can_read_terraform_state?
    AnchorData.new(
      true,
      statistic_icon('terraform') +
      n_('%{strong_start}%{terraform_states_count}%{strong_end} Terraform State', '%{strong_start}%{terraform_states_count}%{strong_end} Terraform States', project.terraform_states.count).html_safe % {
        terraform_states_count: number_with_delimiter(project.terraform_states.count),
        strong_start: '<strong class="project-stat-value">'.html_safe,
        strong_end: '</strong>'.html_safe
      },
      project_terraform_index_path(project)
    )
  end
end

#topics_not_shownObject



426
427
428
# File 'app/presenters/project_presenter.rb', line 426

def topics_not_shown
  project_topic_list - topics_to_show
end

#topics_to_showObject



422
423
424
# File 'app/presenters/project_presenter.rb', line 422

def topics_to_show
  project_topic_list.take(MAX_TOPICS_TO_SHOW) # rubocop: disable CodeReuse/ActiveRecord
end

#upload_anchor_dataObject



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'app/presenters/project_presenter.rb', line 268

def upload_anchor_data
  strong_memoize(:upload_anchor_data) do
    next unless can_current_user_push_to_default_branch?

    AnchorData.new(
      false,
      statistic_icon('upload') + _('Upload file'),
      '#modal-upload-blob',
      'js-upload-file-trigger',
      nil,
      nil,
      {
        'target_branch' => default_branch_or_main,
        'original_branch' => default_branch_or_main,
        'can_push_code' => 'true',
        'path' => project_create_blob_path(project, default_branch_or_main),
        'project_path' => project.full_path
      }
    )
  end
end

#wiki_anchor_dataObject



412
413
414
415
416
417
418
419
420
# File 'app/presenters/project_presenter.rb', line 412

def wiki_anchor_data
  return unless project.wiki_enabled? && can_read_wiki?

  if project.wiki.has_home_page?
    AnchorData.new(false, statistic_icon('book') + _('Wiki'), project_wiki_path, 'btn-default', nil, nil)
  elsif can_create_wiki?
    AnchorData.new(false, statistic_icon + _('Add Wiki'), project_create_wiki_path, nil, nil, nil)
  end
end