diff --git a/app/assets/stylesheets/page_bundles/project.scss b/app/assets/stylesheets/page_bundles/project.scss index de38f3469d110e5f4abd618f13e8466308fd2ccb..0e11e74155af9e0dd69c512b098319ef2dca1ca1 100644 --- a/app/assets/stylesheets/page_bundles/project.scss +++ b/app/assets/stylesheets/page_bundles/project.scss @@ -122,14 +122,6 @@ &:focus { text-decoration: underline; } - - .project-stat-value { - @apply gl-text-default; - } - - .icon { - @apply gl-fill-icon-subtle; - } } .btn { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b365cf0319919fa909d47359f8ba5e507159a689..7a8e2979a9e49db62eab45fdfd85566043a6cab3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -500,7 +500,7 @@ def gitlab_ui_form_with(**args, &block) form_with(**args.merge({ builder: ::Gitlab::FormBuilders::GitlabUiFormBuilder }), &block) end - def hidden_resource_icon(resource, css_class: nil) + def hidden_resource_icon(resource, css_class: nil, variant: nil) issuable_title = _('This %{issuable} is hidden because its author has been banned.') case resource @@ -515,7 +515,7 @@ def hidden_resource_icon(resource, css_class: nil) return unless title content_tag(:span, class: 'has-tooltip', title: title) do - sprite_icon('spam', css_class: ['gl-align-text-bottom', css_class].compact_blank.join(' ')) + sprite_icon('spam', css_class: ['gl-align-text-bottom', css_class].compact_blank.join(' '), variant: variant) end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 583f477a0adb9bff2abd653cdee9f324a83d73bb..a8cc4fe2aa1329b991806e9da31a72d8d2ff0d17 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -137,8 +137,9 @@ def visibility_level_icon(level, options: {}) end css_class = options.delete(:class) + variant = options.delete(:variant) - sprite_icon(name, size: DEFAULT_ICON_SIZE, css_class: css_class) + sprite_icon(name, size: DEFAULT_ICON_SIZE, css_class: css_class, variant: variant) end def file_type_icon_class(type, mode, name) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index e9f1c4f004df5f8ebe6eace55aef93f854009476..73e0c2b472c17b7bf796e0d66fc0b3a74ee591f1 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -671,9 +671,9 @@ def branch_rules_path project_settings_repository_path(@project, anchor: 'js-branch-rules') end - def visibility_level_content(project, css_class: nil, icon_css_class: nil) + def visibility_level_content(project, css_class: nil, icon_css_class: nil, icon_variant: nil) if project.created_and_owned_by_banned_user? && Feature.enabled?(:hide_projects_of_banned_users) - return hidden_resource_icon(project, css_class: css_class) + return hidden_resource_icon(project, css_class: css_class, variant: icon_variant) end title = visibility_icon_description(project) @@ -690,7 +690,7 @@ def visibility_level_content(project, css_class: nil, icon_css_class: nil) title: title, type: 'button', aria: { label: title }) do - visibility_level_icon(project.visibility_level, options: { class: icon_css_class }) + visibility_level_icon(project.visibility_level, options: { class: icon_css_class, variant: icon_variant }) end end diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index a89cb2e1071e4ceb6629c5d071631b5eb1b103d8..665d0fb47214ee9885807f5e14fb8bdcd00308af 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -22,12 +22,8 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated AnchorData = Struct.new(:is_link, :label, :link, :class_modifier, :icon, :itemprop, :data) MAX_TOPICS_TO_SHOW = 3 - def statistic_default_class_list - 'icon gl-mr-3 gl-text-subtle' - end - - def statistic_icon(icon_name = 'plus', class_list = statistic_default_class_list) - sprite_icon(icon_name, css_class: class_list) + def statistic_icon(icon_name = 'plus', variant = 'info') + sprite_icon(icon_name, css_class: 'gl-mr-3', variant: variant) end def statistics_anchors(show_auto_devops_callout:) @@ -173,7 +169,7 @@ def storage_anchor_data AnchorData.new( true, - statistic_icon('disk') + storage_anchor_text, + statistic_icon('disk', 'subtle') + storage_anchor_text, project_usage_quotas_path(project) ) end @@ -186,7 +182,7 @@ def releases_anchor_data AnchorData.new( true, - statistic_icon('rocket-launch') + + statistic_icon('rocket-launch', 'subtle') + safe_format(n_('%{strong_start}%{release_count}%{strong_end} Release', '%{strong_start}%{release_count}%{strong_end} Releases', releases_count), 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) ) @@ -200,7 +196,7 @@ def environments_anchor_data AnchorData.new( true, - statistic_icon('environment') + + statistic_icon('environment', 'subtle') + safe_format(n_('%{strong_start}%{count}%{strong_end} Environment', '%{strong_start}%{count}%{strong_end} Environments', environments_count), count: number_with_delimiter(environments_count), strong_start: '<strong class="project-stat-value">'.html_safe, strong_end: '</strong>'.html_safe), project_environments_path(project) ) @@ -209,7 +205,7 @@ def environments_anchor_data def commits_anchor_data AnchorData.new( true, - statistic_icon('commit') + + statistic_icon('commit', 'subtle') + safe_format(n_('%{strong_start}%{commit_count}%{strong_end} Commit', '%{strong_start}%{commit_count}%{strong_end} Commits', statistics.commit_count), 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) ) @@ -218,7 +214,7 @@ def commits_anchor_data def branches_anchor_data AnchorData.new( true, - statistic_icon('branch') + + statistic_icon('branch', 'subtle') + safe_format(n_('%{strong_start}%{branch_count}%{strong_end} Branch', '%{strong_start}%{branch_count}%{strong_end} Branches', repository.branch_count), 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) ) @@ -235,7 +231,7 @@ def terraform_states_anchor_data AnchorData.new( true, - statistic_icon('terraform') + + statistic_icon('terraform', 'subtle') + safe_format(n_('%{strong_start}%{terraform_states_count}%{strong_end} Terraform State', '%{strong_start}%{terraform_states_count}%{strong_end} Terraform States', project.terraform_states.count), terraform_states_count: number_with_delimiter(project.terraform_states.count), strong_start: '<strong class="project-stat-value">'.html_safe, strong_end: '</strong>'.html_safe) + terraform_warn_icon, project_terraform_index_path(project) ) @@ -245,7 +241,7 @@ def terraform_states_anchor_data def tags_anchor_data AnchorData.new( true, - statistic_icon('label') + + statistic_icon('label', 'subtle') + safe_format(n_('%{strong_start}%{tag_count}%{strong_end} Tag', '%{strong_start}%{tag_count}%{strong_end} Tags', repository.tag_count), 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) ) @@ -257,7 +253,7 @@ def upload_anchor_data AnchorData.new( false, - statistic_icon('upload') + _('Upload file'), + statistic_icon('upload', 'subtle') + _('Upload file'), '#modal-upload-blob', 'js-upload-file-trigger', nil, @@ -278,19 +274,19 @@ 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('plus', 'gl-mr-3') + _('New file'), new_file_path) + AnchorData.new(false, statistic_icon('plus', 'info') + _('New file'), new_file_path) end end def readme_anchor_data if can_current_user_push_to_default_branch? && readme_path.nil? - icon = statistic_icon('plus', 'gl-mr-3') + icon = statistic_icon('plus', 'info') label = icon + _('Add README') AnchorData.new(false, label, empty_repo? ? add_readme_ide_path : add_readme_path) elsif readme_path AnchorData.new( false, - statistic_icon('doc-text') + _('README'), + statistic_icon('doc-text', 'subtle') + _('README'), default_view != 'readme' ? readme_path : '#readme', 'btn-default', 'doc-text' @@ -300,7 +296,7 @@ def readme_anchor_data def changelog_anchor_data if can_current_user_push_to_default_branch? && repository.changelog.blank? - icon = statistic_icon('plus', 'gl-mr-3') + icon = statistic_icon('plus', 'info') label = icon + _('Add CHANGELOG') AnchorData.new( false, @@ -310,7 +306,7 @@ def changelog_anchor_data elsif repository.changelog.present? AnchorData.new( false, - statistic_icon('doc-text') + _('CHANGELOG'), + statistic_icon('doc-text', 'subtle') + _('CHANGELOG'), changelog_path, 'btn-default' ) @@ -318,7 +314,7 @@ def changelog_anchor_data end def license_anchor_data - icon = statistic_icon('scale') + icon = statistic_icon('scale', 'subtle') if repository.license_blob.present? AnchorData.new( @@ -330,7 +326,7 @@ def license_anchor_data 'license' ) elsif can_current_user_push_to_default_branch? - icon = statistic_icon('plus', 'gl-mr-3') + icon = statistic_icon('plus', 'info') label = icon + _('Add LICENSE') AnchorData.new( false, @@ -342,7 +338,7 @@ def license_anchor_data def contribution_guide_anchor_data if can_current_user_push_to_default_branch? && repository.contribution_guide.blank? - icon = statistic_icon('plus', 'gl-mr-3') + icon = statistic_icon('plus', 'info') label = icon + _('Add CONTRIBUTING') AnchorData.new( false, @@ -352,7 +348,7 @@ def contribution_guide_anchor_data elsif repository.contribution_guide.present? AnchorData.new( false, - statistic_icon('doc-text') + _('CONTRIBUTING'), + statistic_icon('doc-text', 'subtle') + _('CONTRIBUTING'), contribution_guide_path, 'btn-default' ) @@ -366,14 +362,14 @@ def autodevops_anchor_data(show_auto_devops_callout: false) if auto_devops_enabled? AnchorData.new( false, - statistic_icon('settings') + _('Auto DevOps enabled'), + statistic_icon('settings', 'subtle') + _('Auto DevOps enabled'), project_settings_ci_cd_path(project, anchor: 'autodevops-settings'), 'btn-default' ) else AnchorData.new( false, - content_tag(:span, statistic_icon('plus', 'gl-mr-3') + _('Enable Auto DevOps')), + content_tag(:span, statistic_icon('plus', 'info') + _('Enable Auto DevOps')), project_settings_ci_cd_path(project, anchor: 'autodevops-settings') ) end @@ -385,7 +381,7 @@ def autodevops_anchor_data(show_auto_devops_callout: false) def kubernetes_cluster_anchor_data if can_instantiate_cluster? if clusters.empty? - AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'gl-mr-3') + _('Add Kubernetes cluster')), project_clusters_path(project)) + AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'info') + _('Add Kubernetes cluster')), project_clusters_path(project)) else cluster_link = clusters.count == 1 ? project_cluster_path(project, clusters.first) : project_clusters_path(project) @@ -398,9 +394,9 @@ def gitlab_ci_anchor_data return unless can_view_pipeline_editor?(project) if cicd_missing? - AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'gl-mr-3') + _('Set up CI/CD')), project_ci_pipeline_editor_path(project)) + AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'info') + _('Set up CI/CD')), project_ci_pipeline_editor_path(project)) elsif project.has_ci_config_file? - AnchorData.new(false, statistic_icon('rocket') + _('CI/CD configuration'), project_ci_pipeline_editor_path(project), 'btn-default') + AnchorData.new(false, statistic_icon('rocket', 'subtle') + _('CI/CD configuration'), project_ci_pipeline_editor_path(project), 'btn-default') end end @@ -408,9 +404,9 @@ 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) + AnchorData.new(false, statistic_icon('book', 'subtle') + _('Wiki'), project_wiki_path, 'btn-default', nil, nil) elsif can_create_wiki? - icon = statistic_icon('plus', 'gl-mr-3') + icon = statistic_icon('plus', 'info') label = icon + _('Add Wiki') AnchorData.new(false, label, project_create_wiki_path, nil, nil, nil) end @@ -456,7 +452,7 @@ def pages_anchor_data return unless project.pages_deployed? && can?(current_user, :read_pages_content, project) pages_url = build_pages_url(project) - AnchorData.new(false, statistic_icon('external-link') + _('GitLab Pages'), pages_url, 'btn-default', nil) + AnchorData.new(false, statistic_icon('external-link', 'subtle') + _('GitLab Pages'), pages_url, 'btn-default', nil) end private @@ -464,7 +460,7 @@ def pages_anchor_data def integrations_anchor_data return unless can?(current_user, :admin_project, project) - AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'gl-blue-500! gl-mr-3') + _('Configure Integrations')), project_settings_integrations_path(project), nil, nil, nil) + AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'info') + _('Configure Integrations')), project_settings_integrations_path(project), nil, nil, nil) end def cicd_missing? diff --git a/app/views/groups/projects.html.haml b/app/views/groups/projects.html.haml index ea8f48f63f7c47a3c21d68a203d7914520dcfc99..69d1aab98993bbef7ca9b4b60e4c8e63e26c5392 100644 --- a/app/views/groups/projects.html.haml +++ b/app/views/groups/projects.html.haml @@ -26,7 +26,7 @@ \/ %span.project-name = project.name - = visibility_level_content(project, css_class: 'visibility-icon gl-fill-icon-subtle gl-ml-2', icon_css_class: 'icon') + = visibility_level_content(project, css_class: 'visibility-icon gl-ml-2', icon_css_class: 'icon', icon_variant: 'subtle') - if project.description.present? .description diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index debfeea86d0295a72daf848a9fade1a5e3d380cd..764e2ba12c8a9233e1024c1c555259c4a318fd1b 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -6,7 +6,7 @@ = render Pajamas::AvatarComponent.new(@project, alt: @project.name, class: 'gl-self-start gl-shrink-0 gl-mr-4', size: 48, avatar_options: { itemprop: 'image' }) %h1.home-panel-title.gl-heading-1.gl-flex.gl-items-center.gl-flex-wrap.gl-gap-3.gl-break-anywhere.gl-mb-0{ data: { testid: 'project-name-content' }, itemprop: 'name' } = @project.name - = visibility_level_content(@project, css_class: 'visibility-icon gl-inline-flex gl-fill-icon-subtle', icon_css_class: 'icon') + = visibility_level_content(@project, css_class: 'visibility-icon gl-inline-flex', icon_variant: 'subtle') - if @project.catalog_resource = render partial: 'shared/ci_catalog_badge', locals: { href: explore_catalog_path(@project.catalog_resource), css_class: 'gl-mx-0' } - if @project.group diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 481c8303d53d3defc6196ecd3915ca2d642281b0..0cb3ac377bf771b23ec0aaefad6690c48e9172fd 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -915,7 +915,7 @@ def stub_controller_method(method_name, value) shared_examples 'returns icon with tooltip' do before do - allow(helper).to receive(:sprite_icon).with('spam', css_class: 'gl-align-text-bottom').and_return(mock_svg) + allow(helper).to receive(:sprite_icon).with('spam', css_class: 'gl-align-text-bottom', variant: nil).and_return(mock_svg) end it 'returns icon with tooltip' do @@ -949,10 +949,19 @@ def stub_controller_method(method_name, value) let_it_be(:resource) { build(:issue) } it 'passes the value to sprite_icon' do - expect(helper).to receive(:sprite_icon).with('spam', css_class: 'gl-align-text-bottom extra-class').and_return(mock_svg) + expect(helper).to receive(:sprite_icon).with('spam', css_class: 'gl-align-text-bottom extra-class', variant: nil).and_return(mock_svg) helper.hidden_resource_icon(resource, css_class: 'extra-class') end end + + context 'when variant is provided' do + let_it_be(:resource) { build(:issue) } + + it 'passes the value to sprite_icon' do + expect(helper).to receive(:sprite_icon).with('spam', css_class: 'gl-align-text-bottom', variant: 'subtle').and_return(mock_svg) + helper.hidden_resource_icon(resource, variant: 'subtle') + end + end end end diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index b663372328d1645c4256916a330a9a9c61ea1814..0dbc3941bd2ca579f795bf8c64c0ca97eeedca0f 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -1827,7 +1827,7 @@ def license_name expected_result = "<button class=\"has-tooltip gl-border-0 gl-bg-transparent gl-p-0 gl-leading-0 gl-text-inherit extra-class\" data-container=\"body\" data-placement=\"top\" title=\"#{description}\" type=\"button\" aria-label=\"#{description}\">#{icon}</button>" expect(helper).to receive(:visibility_level_icon) - .with(anything, options: { class: 'extra-icon-class' }) + .with(anything, options: { class: 'extra-icon-class', variant: nil }) .and_return(icon) result = helper.visibility_level_content(project, css_class: 'extra-class', icon_css_class: 'extra-icon-class') expect(result).to eq(expected_result)