From f0af2950542c1329cafa13342cf6b86bde3f2d03 Mon Sep 17 00:00:00 2001 From: Sascha Eggenberger <seggenberger@gitlab.com> Date: Fri, 22 Mar 2024 20:58:06 +0000 Subject: [PATCH] Reorganization project overview page Move information into a sidebar Changelog: changed --- .../stylesheets/page_bundles/project.scss | 2 +- app/helpers/stat_anchors_helper.rb | 18 +- app/presenters/project_presenter.rb | 36 +--- app/views/projects/_files.html.haml | 16 +- app/views/projects/_home_panel.html.haml | 33 --- .../_invite_members_empty_project.html.haml | 29 +-- app/views/projects/_sidebar.html.haml | 4 +- .../projects/_stat_anchor_list.html.haml | 9 +- app/views/projects/empty.html.haml | 200 ++++++------------ app/views/projects/show.html.haml | 32 +-- app/views/shared/projects/_topics.html.haml | 3 - .../development/project_overview_reorg.yml | 8 - ee/app/views/projects/_home_mirror.html.haml | 4 +- .../features/projects/show_project_spec.rb | 34 ++- qa/qa/page/project/show.rb | 3 - .../show/user_sees_git_instructions_spec.rb | 3 +- .../user_sees_setup_shortcut_buttons_spec.rb | 50 +++-- spec/features/projects_spec.rb | 105 ++++++--- spec/helpers/stat_anchors_helper_spec.rb | 10 +- spec/presenters/project_presenter_spec.rb | 8 +- spec/views/projects/_files.html.haml_spec.rb | 68 ------ .../projects/_home_panel.html.haml_spec.rb | 70 ------ 22 files changed, 227 insertions(+), 518 deletions(-) delete mode 100644 config/feature_flags/development/project_overview_reorg.yml delete mode 100644 spec/views/projects/_files.html.haml_spec.rb diff --git a/app/assets/stylesheets/page_bundles/project.scss b/app/assets/stylesheets/page_bundles/project.scss index bd24d991c8d36..fb9d11c0ff866 100644 --- a/app/assets/stylesheets/page_bundles/project.scss +++ b/app/assets/stylesheets/page_bundles/project.scss @@ -157,7 +157,6 @@ } } -// FF :project_overview_reorg enabled .project-page-indicator:not(.hidden) + .project-page-layout { @include media-breakpoint-up(lg) { display: grid; @@ -183,6 +182,7 @@ #{$calc-application-viewport-height} - #{$gl-spacing-scale-4} ); padding-inline: $gl-padding-4; + padding-block-end: $gl-spacing-scale-11; overflow-y: scroll; overflow-x: hidden; -webkit-overflow-scrolling: touch; diff --git a/app/helpers/stat_anchors_helper.rb b/app/helpers/stat_anchors_helper.rb index d2c452681f5f6..d4b687297e204 100644 --- a/app/helpers/stat_anchors_helper.rb +++ b/app/helpers/stat_anchors_helper.rb @@ -11,25 +11,15 @@ def stat_anchor_attrs(anchor) private - def new_button_attribute(anchor) - anchor.class_modifier || 'btn-link gl-text-blue-500!' - end - def button_attribute(anchor) - anchor.class_modifier || 'btn-dashed' + anchor.class_modifier || 'btn-link gl-text-blue-500!' end def extra_classes(anchor) - if Feature.enabled?(:project_overview_reorg) - if anchor.is_link - 'stat-link gl-px-0! gl-pb-2!' - else - "stat-link gl-px-0! gl-pb-2! #{new_button_attribute(anchor)}" - end - elsif anchor.is_link - 'stat-link' + if anchor.is_link + 'stat-link gl-px-0! gl-pb-2!' else - button_attribute(anchor) + "stat-link gl-px-0! gl-pb-2! #{button_attribute(anchor)}" end end end diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 19b1d5c315c5a..2d0acf2b262db 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -22,14 +22,10 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated MAX_TOPICS_TO_SHOW = 3 def statistic_default_class_list - Feature.enabled?(:project_overview_reorg) ? 'icon gl-mr-3 gl-text-gray-500' : 'icon gl-mr-2 gl-text-gray-500' + 'icon gl-mr-3 gl-text-gray-500' end - def statistic_default_icon - Feature.enabled?(:project_overview_reorg) ? 'plus' : 'plus-square-o' - end - - def statistic_icon(icon_name = statistic_default_icon, class_list = statistic_default_class_list) + def statistic_icon(icon_name = 'plus', class_list = statistic_default_class_list) sprite_icon(icon_name, css_class: class_list) end @@ -296,17 +292,13 @@ 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) - if Feature.enabled?(:project_overview_reorg) - AnchorData.new(false, statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') + _('New file'), new_file_path) - else - AnchorData.new(false, statistic_icon + _('New file'), new_file_path, 'btn-dashed') - end + AnchorData.new(false, statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') + _('New file'), new_file_path) end end def readme_anchor_data if can_current_user_push_to_default_branch? && readme_path.nil? - icon = Feature.enabled?(:project_overview_reorg) ? statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') : statistic_icon + icon = statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') label = icon + _('Add README') AnchorData.new(false, label, empty_repo? ? add_readme_ide_path : add_readme_path) elsif readme_path @@ -322,7 +314,7 @@ def readme_anchor_data def changelog_anchor_data if can_current_user_push_to_default_branch? && repository.changelog.blank? - icon = Feature.enabled?(:project_overview_reorg) ? statistic_icon('plus', 'gl-mr-3') : statistic_icon + icon = statistic_icon('plus', 'gl-mr-3') label = icon + _('Add CHANGELOG') AnchorData.new( false, @@ -352,7 +344,7 @@ def license_anchor_data 'license' ) elsif can_current_user_push_to_default_branch? - icon = Feature.enabled?(:project_overview_reorg) ? statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') : statistic_icon + icon = statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') label = icon + _('Add LICENSE') AnchorData.new( false, @@ -364,7 +356,7 @@ def license_anchor_data def contribution_guide_anchor_data if can_current_user_push_to_default_branch? && repository.contribution_guide.blank? - icon = Feature.enabled?(:project_overview_reorg) ? statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') : statistic_icon + icon = statistic_icon('plus', 'gl-text-blue-500! gl-mr-3') label = icon + _('Add CONTRIBUTING') AnchorData.new( false, @@ -407,11 +399,7 @@ def autodevops_anchor_data(show_auto_devops_callout: false) def kubernetes_cluster_anchor_data if can_instantiate_cluster? if clusters.empty? - if Feature.enabled?(:project_overview_reorg) - AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'gl-mr-3') + _('Add Kubernetes cluster')), project_clusters_path(project)) - else - AnchorData.new(false, content_tag(:span, statistic_icon + _('Add Kubernetes cluster')), project_clusters_path(project)) - end + AnchorData.new(false, content_tag(:span, statistic_icon('plus', 'gl-mr-3') + _('Add Kubernetes cluster')), project_clusters_path(project)) else cluster_link = clusters.count == 1 ? project_cluster_path(project, clusters.first) : project_clusters_path(project) @@ -436,7 +424,7 @@ def wiki_anchor_data if project.wiki.has_home_page? AnchorData.new(false, statistic_icon('book') + _('Wiki'), project_wiki_path, 'btn-default', nil, nil) elsif can_create_wiki? - icon = Feature.enabled?(:project_overview_reorg) ? statistic_icon('plus', 'gl-mr-3') : statistic_icon + icon = statistic_icon('plus', 'gl-mr-3') label = icon + _('Add Wiki') AnchorData.new(false, label, project_create_wiki_path, nil, nil, nil) end @@ -483,11 +471,7 @@ def all_clusters_empty? def integrations_anchor_data return unless can?(current_user, :admin_project, project) - if Feature.enabled?(:project_overview_reorg) - 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) - else - AnchorData.new(false, content_tag(:span, statistic_icon('settings') + _('Configure Integrations')), project_settings_integrations_path(project), nil, nil, nil) - end + 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) end def cicd_missing? diff --git a/app/views/projects/_files.html.haml b/app/views/projects/_files.html.haml index b6672e2f51739..1d3a3c208b0c2 100644 --- a/app/views/projects/_files.html.haml +++ b/app/views/projects/_files.html.haml @@ -1,17 +1,13 @@ -- show_auto_devops_callout = show_auto_devops_callout?(@project) -- is_project_overview = local_assigns.fetch(:is_project_overview, false) - ref = local_assigns.fetch(:ref) { current_ref } - project = local_assigns.fetch(:project) { @project } -- has_project_shortcut_buttons = !current_user || current_user.project_shortcut_buttons - add_page_startup_api_call logs_file_project_ref_path(@project, ref, @path, format: "json", offset: 0, ref_type: @ref_type) - if readme_path = @project.repository.readme_path - add_page_startup_api_call project_blob_path(@project, tree_join(@ref, readme_path), viewer: "rich", format: "json") - add_page_specific_style 'page_bundles/commit_description' #tree-holder.tree-holder.clearfix.js-per-page.gl-mt-5{ data: { blame_per_page: Gitlab::Git::BlamePagination::PAGINATION_PER_PAGE } } - - if Feature.enabled?(:project_overview_reorg) - .nav-block.gl-display-flex.gl-flex-direction-column.gl-sm-flex-direction-row.gl-align-items-stretch - = render 'projects/tree/tree_header', tree: @tree + .nav-block.gl-display-flex.gl-flex-direction-column.gl-sm-flex-direction-row.gl-align-items-stretch + = render 'projects/tree/tree_header', tree: @tree .info-well.gl-display-none.gl-sm-display-flex.project-last-commit.gl-flex-direction-column.gl-mt-5 #js-last-commit.gl-m-auto{ data: {ref_type: @ref_type.to_s} } @@ -19,15 +15,7 @@ - if project.licensed_feature_available?(:code_owners) #js-code-owners{ data: { branch: @ref, can_view_branch_rules: can_view_branch_rules?, branch_rules_path: branch_rules_path } } - - if Feature.disabled?(:project_overview_reorg) - .nav-block.gl-display-flex.gl-flex-direction-column.gl-sm-flex-direction-row.gl-align-items-stretch - = render 'projects/tree/tree_header', tree: @tree - - if project.forked? #js-fork-info{ data: vue_fork_divergence_data(project, ref) } - - if Feature.disabled?(:project_overview_reorg) && is_project_overview && has_project_shortcut_buttons - .project-buttons.gl-mb-5.js-show-on-project-root{ data: { testid: 'project-buttons' } } - = render 'stat_anchor_list', anchors: @project.statistics_buttons(show_auto_devops_callout: show_auto_devops_callout), project_buttons: true - #js-tree-list{ data: vue_file_list_data(project, ref) } diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index 018e61f5a330b..ec5439020aeae 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -1,5 +1,4 @@ - empty_repo = @project.empty_repo? -- ff_reorg_disabled = Feature.disabled?(:project_overview_reorg) %header.project-home-panel.js-show-on-project-root.gl-mt-5{ class: [("empty-project" if empty_repo)] } .gl-display-flex.gl-justify-content-space-between.gl-flex-wrap.gl-flex-direction-column.gl-md-flex-direction-row.gl-gap-5 @@ -22,36 +21,4 @@ #js-home-panel{ data: home_panel_data_attributes } - - if ff_reorg_disabled - - if can?(current_user, :read_code, @project) - - show_auto_devops_callout = show_auto_devops_callout?(@project) - - %nav.project-stats.gl-mt-3 - - if @project.empty_repo? - = render 'stat_anchor_list', anchors: @project.empty_repo_statistics_anchors - - else - = render 'stat_anchor_list', anchors: @project.statistics_anchors(show_auto_devops_callout: show_auto_devops_callout) - .gl-my-3 - = render "shared/projects/topics", project: @project - - .home-panel-home-desc.mt-1 - - if @project.description.present? - .home-panel-description.text-break - .home-panel-description-markdown.read-more-container{ itemprop: 'description' } - = markdown_field(@project, :description) - = render Pajamas::ButtonComponent.new(category: :tertiary, variant: :link, button_options: { class: 'js-read-more-trigger gl-lg-display-none' }) do - = _("Read more") - = render_if_exists "projects/home_mirror" - - - if ff_reorg_disabled && @project.badges.present? - .project-badges.mb-2{ data: { testid: 'project-badges-content' } } - - @project.badges.each do |badge| - - badge_link_url = badge.rendered_link_url(@project) - %a.gl-mr-3{ href: badge_link_url, - target: '_blank', - rel: 'noopener noreferrer', - data: { testid: 'badge-image-link', qa_link_url: badge_link_url } }> - %img.project-badge{ src: badge.rendered_image_url(@project), - 'aria-hidden': true, - alt: 'Project badge' }> diff --git a/app/views/projects/_invite_members_empty_project.html.haml b/app/views/projects/_invite_members_empty_project.html.haml index 730021f345a92..b0539d367aaaf 100644 --- a/app/views/projects/_invite_members_empty_project.html.haml +++ b/app/views/projects/_invite_members_empty_project.html.haml @@ -1,20 +1,9 @@ -- if Feature.enabled?(:project_overview_reorg) - %p.gl-font-weight-bold.gl-text-gray-900.gl-mt-0.gl-mt-n1.gl-mb-3{ data: { testid: 'invite-member-section', - track_label: 'invite_members_empty_project', - track_action: 'render' } } - = s_('InviteMember|Invite your team') - %p.gl-mb-3= s_('InviteMember|Add members to this project and start collaborating with your team.') - .js-invite-members-trigger{ data: { variant: 'confirm', - classes: 'gl-mb-3 gl-w-full gl-sm-w-auto', - display_text: s_('InviteMember|Invite members'), - trigger_source: 'project_empty_page' } } -- else - %h4.gl-mt-0.gl-mb-3{ data: { testid: 'invite-member-section', - track_label: 'invite_members_empty_project', - track_action: 'render' } } - = s_('InviteMember|Invite your team') - %p= s_('InviteMember|Add members to this project and start collaborating with your team.') - .js-invite-members-trigger{ data: { variant: 'confirm', - classes: 'gl-mb-8 gl-w-full gl-sm-w-auto', - display_text: s_('InviteMember|Invite members'), - trigger_source: 'project_empty_page' } } +%p.gl-font-weight-bold.gl-text-gray-900.gl-mt-0.gl-mt-n1.gl-mb-3{ data: { testid: 'invite-member-section', + track_label: 'invite_members_empty_project', + track_action: 'render' } } + = s_('InviteMember|Invite your team') +%p.gl-mb-3= s_('InviteMember|Add members to this project and start collaborating with your team.') +.js-invite-members-trigger{ data: { variant: 'confirm', + classes: 'gl-mb-3 gl-w-full gl-sm-w-auto', + display_text: s_('InviteMember|Invite members'), + trigger_source: 'project_empty_page' } } diff --git a/app/views/projects/_sidebar.html.haml b/app/views/projects/_sidebar.html.haml index 38a7f93e06fe7..06fb12c7214c6 100644 --- a/app/views/projects/_sidebar.html.haml +++ b/app/views/projects/_sidebar.html.haml @@ -4,7 +4,7 @@ - statistics_empty_buttons = @project.empty_repo_statistics_buttons - statistics_buttons = @project.statistics_buttons(show_auto_devops_callout: show_auto_devops_callout) -%aside.project-page-sidebar +%aside.project-page-sidebar{ data: { testid: 'project-page-sidebar' } } .project-page-sidebar-block.home-panel-home-desc.gl-py-4.gl-border-b.gl-border-gray-50{ class: 'gl-pt-2!' } %h2.gl-font-base.gl-font-weight-bold.gl-reset-line-height.gl-text-gray-900.gl-m-0.gl-mb-1= s_('ProjectPage|Project information') -# Project description @@ -53,7 +53,7 @@ = render 'stat_anchor_list', anchors: anchor_buttons -# Buttons - - if has_project_shortcut_buttons && (@project.empty_repo? ? statistics_empty_buttons.any? : statistics_buttons.any?) + - if can?(current_user, :read_code, @project) && has_project_shortcut_buttons && (@project.empty_repo? ? statistics_empty_buttons.any? : statistics_buttons.any?) .project-page-sidebar-block.gl-py-4.gl-border-b.gl-border-gray-50 .project-buttons.gl-mb-2.js-show-on-project-root{ data: { testid: 'project-buttons' } } - if @project.empty_repo? diff --git a/app/views/projects/_stat_anchor_list.html.haml b/app/views/projects/_stat_anchor_list.html.haml index 90e636bd1a623..164899793fec1 100644 --- a/app/views/projects/_stat_anchor_list.html.haml +++ b/app/views/projects/_stat_anchor_list.html.haml @@ -1,7 +1,6 @@ - anchors = local_assigns.fetch(:anchors, []) - project_buttons = local_assigns.fetch(:project_buttons, false) -- ff_reorg_enabled = Feature.enabled?(:project_overview_reorg) -- stat_text_classes = "stat-text d-flex gl-align-items-center #{'gl-px-0! gl-pb-2!' if ff_reorg_enabled}" +- stat_text_classes = "stat-text d-flex gl-align-items-center gl-px-0! gl-pb-2!" - return unless anchors.any? @@ -9,11 +8,7 @@ - anchors.each do |anchor| %li.nav-item - if anchor.link # render actionable link/button - - if anchor.is_link || ff_reorg_enabled - = link_to(anchor.label, anchor.link, stat_anchor_attrs(anchor)) - - else - = render Pajamas::ButtonComponent.new(href: anchor.link, button_options: stat_anchor_attrs(anchor)) do - = anchor.label + = link_to(anchor.label, anchor.link, stat_anchor_attrs(anchor)) - elsif project_buttons # render disabled button = render Pajamas::ButtonComponent.new(disabled: true, button_options: { classes: stat_text_classes }) do = anchor.label diff --git a/app/views/projects/empty.html.haml b/app/views/projects/empty.html.haml index 8c9da1ea9f995..20984ad45e91d 100644 --- a/app/views/projects/empty.html.haml +++ b/app/views/projects/empty.html.haml @@ -1,4 +1,6 @@ - add_page_specific_style 'page_bundles/projects' +- add_page_specific_style 'page_bundles/project' + - default_branch_name = @project.default_branch_or_main - escaped_default_branch_name = default_branch_name.shellescape - @skip_current_level_breadcrumb = true @@ -8,142 +10,72 @@ = render "home_panel" -- if Feature.enabled?(:project_overview_reorg) - - add_page_specific_style 'page_bundles/project' +.project-page-indicator.js-show-on-project-root - .project-page-indicator.js-show-on-project-root +#js-project-show-empty-page.project-page-layout + .project-page-layout-content.gl-mt-5 + .project-buttons.gl-mb-5{ data: { testid: 'quick-actions-container' } } + .project-clone-holder.d-block.d-sm-none + = render "shared/mobile_clone_panel" - #js-project-show-empty-page.project-page-layout - .project-page-layout-content.gl-mt-5 - .project-buttons.gl-mb-5{ data: { testid: 'quick-actions-container' } } - .project-clone-holder.d-block.d-sm-none - = render "shared/mobile_clone_panel" + .project-clone-holder.gl-display-none.gl-sm-display-flex.gl-justify-content-end.gl-w-full + = render "projects/buttons/code", ref: @ref - .project-clone-holder.gl-display-none.gl-sm-display-flex.gl-justify-content-end.gl-w-full - = render "projects/buttons/code", ref: @ref + = render Pajamas::CardComponent.new(card_options: { class: 'gl-mb-5' }, body_options: { class: 'gl-new-card-body gl-bg-gray-10 gl-p-5' }) do |c| + - c.with_body do + %h4.gl-font-lg.gl-my-0= _('The repository for this project is empty') + - if @project.can_current_user_push_code? + %p.gl-m-0.gl-mt-2.gl-text-secondary= _('You can get started by cloning the repository or start adding files to it with one of the following options.') - = render Pajamas::CardComponent.new(card_options: { class: 'gl-mb-5' }, body_options: { class: 'gl-new-card-body gl-bg-gray-10 gl-p-5' }) do |c| + - if can?(current_user, :push_code, @project) + = render Pajamas::CardComponent.new(header_options: { class: 'gl-py-4' }) do |c| + - c.with_header do + %h5.gl-font-lg.gl-m-0= _('Command line instructions') - c.with_body do - %h4.gl-font-lg.gl-mt-0.gl-mb-2= _('The repository for this project is empty') - - if @project.can_current_user_push_code? - %p.gl-m-0.gl-text-secondary= _('You can get started by cloning the repository or start adding files to it with one of the following options.') - - - if can?(current_user, :push_code, @project) - = render Pajamas::CardComponent.new(header_options: { class: 'gl-py-4' }) do |c| - - c.with_header do - %h5.gl-font-lg.gl-m-0= _('Command line instructions') - - c.with_body do - %p - = _('You can also upload existing files from your computer using the instructions below.') - .git-empty.js-git-empty - %h5= _('Git global setup') - %pre.gl-bg-gray-10 - :preserve - git config --global user.name "#{h git_user_name}" - git config --global user.email "#{h git_user_email}" - - %h5= _('Create a new repository') - %pre.gl-bg-gray-10 - :preserve - git clone #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - cd #{h @project.path} - git switch --create #{h escaped_default_branch_name} - touch README.md - git add README.md - git commit -m "add README" - - if @project.can_current_user_push_to_default_branch? - %span>< - git push --set-upstream origin #{h escaped_default_branch_name } - - %h5= _('Push an existing folder') - %pre.gl-bg-gray-10 - :preserve - cd existing_folder - git init --initial-branch=#{h escaped_default_branch_name} - git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - git add . - git commit -m "Initial commit" - - if @project.can_current_user_push_to_default_branch? - %span>< - git push --set-upstream origin #{h escaped_default_branch_name } - - %h5= _('Push an existing Git repository') - %pre.gl-bg-gray-10 - :preserve - cd existing_repo - git remote rename origin old-origin - git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - - if @project.can_current_user_push_to_default_branch? - %span>< - git push --set-upstream origin --all - git push --set-upstream origin --tags - - .project-page-layout-sidebar.js-show-on-project-root.gl-mt-5 - = render "sidebar" - -- else - = render "invite_members_empty_project" if can_admin_project_member?(@project) - - %h4.gl-mt-0.gl-mb-3 - = _('The repository for this project is empty') - - - if @project.can_current_user_push_code? - %p - = _('You can get started by cloning the repository or start adding files to it with one of the following options.') - - .project-buttons{ data: { testid: 'quick-actions-container' } } - .project-clone-holder.d-block.d-sm-none.gl-mt-3.gl-mr-3 - = render "shared/mobile_clone_panel" - - #js-project-show-empty-page.project-clone-holder.gl-display-none.gl-sm-display-inline-block.gl-mb-3.gl-mr-3.gl-float-left - = render "projects/buttons/code", ref: @ref - = render 'stat_anchor_list', anchors: @project.empty_repo_statistics_buttons, project_buttons: true - - - if can?(current_user, :push_code, @project) - .empty-wrapper.gl-mt-4 - %h3#repo-command-line-instructions.page-title-empty - = _('Command line instructions') - %p - = _('You can also upload existing files from your computer using the instructions below.') - .git-empty.js-git-empty - %h5= _('Git global setup') - %pre.bg-light - :preserve - git config --global user.name "#{h git_user_name}" - git config --global user.email "#{h git_user_email}" - - %h5= _('Create a new repository') - %pre.bg-light - :preserve - git clone #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - cd #{h @project.path} - git switch --create #{h escaped_default_branch_name} - touch README.md - git add README.md - git commit -m "add README" - - if @project.can_current_user_push_to_default_branch? - %span>< - git push --set-upstream origin #{h escaped_default_branch_name } - - %h5= _('Push an existing folder') - %pre.bg-light - :preserve - cd existing_folder - git init --initial-branch=#{h escaped_default_branch_name} - git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - git add . - git commit -m "Initial commit" - - if @project.can_current_user_push_to_default_branch? - %span>< - git push --set-upstream origin #{h escaped_default_branch_name } - - %h5= _('Push an existing Git repository') - %pre.bg-light - :preserve - cd existing_repo - git remote rename origin old-origin - git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - - if @project.can_current_user_push_to_default_branch? - %span>< - git push --set-upstream origin --all - git push --set-upstream origin --tags + %p + = _('You can also upload existing files from your computer using the instructions below.') + .git-empty.js-git-empty + %h5= _('Git global setup') + %pre.gl-bg-gray-10 + :preserve + git config --global user.name "#{h git_user_name}" + git config --global user.email "#{h git_user_email}" + + %h5= _('Create a new repository') + %pre.gl-bg-gray-10 + :preserve + git clone #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} + cd #{h @project.path} + git switch --create #{h escaped_default_branch_name} + touch README.md + git add README.md + git commit -m "add README" + - if @project.can_current_user_push_to_default_branch? + %span>< + git push --set-upstream origin #{h escaped_default_branch_name } + + %h5= _('Push an existing folder') + %pre.gl-bg-gray-10 + :preserve + cd existing_folder + git init --initial-branch=#{h escaped_default_branch_name} + git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} + git add . + git commit -m "Initial commit" + - if @project.can_current_user_push_to_default_branch? + %span>< + git push --set-upstream origin #{h escaped_default_branch_name } + + %h5= _('Push an existing Git repository') + %pre.gl-bg-gray-10 + :preserve + cd existing_repo + git remote rename origin old-origin + git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} + - if @project.can_current_user_push_to_default_branch? + %span>< + git push --set-upstream origin --all + git push --set-upstream origin --tags + + .project-page-layout-sidebar.js-show-on-project-root.gl-mt-5 + = render "sidebar" diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index ccf41f698f837..5a1f6bb193757 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -14,31 +14,19 @@ = render "home_panel" -- if Feature.enabled?(:project_overview_reorg) - .project-page-indicator.js-show-on-project-root +.project-page-indicator.js-show-on-project-root - .project-page-layout - .project-page-layout-sidebar.js-show-on-project-root.gl-mt-5 - = render "sidebar" +.project-page-layout + .project-page-layout-sidebar.js-show-on-project-root.gl-mt-5 + = render "sidebar" - .project-page-layout-content - - if can?(current_user, :read_code, @project) && @project.repository_languages.present? - - add_page_startup_graphql_call('repository/path_last_commit', { projectPath: @project.full_path, ref: current_ref, path: current_route_path || "" }) + .project-page-layout-content + - if can?(current_user, :read_code, @project) && @project.repository_languages.present? + - add_page_startup_graphql_call('repository/path_last_commit', { projectPath: @project.full_path, ref: current_ref, path: current_route_path || "" }) = render_if_exists "projects/ancestor_group_marked_for_deletion_notice", project: @project - - view_path = @project.default_view + - view_path = @project.default_view - %div{ class: project_child_container_class(view_path) } - = render view_path, is_project_overview: true -- else - - if can?(current_user, :read_code, @project) && @project.repository_languages.present? - - add_page_startup_graphql_call('repository/path_last_commit', { projectPath: @project.full_path, ref: current_ref, path: current_route_path || "" }) - = repository_languages_bar(@project.repository_languages) - - = render_if_exists "projects/ancestor_group_marked_for_deletion_notice", project: @project - - - view_path = @project.default_view - - %div{ class: project_child_container_class(view_path) } - = render view_path, is_project_overview: true + %div{ class: project_child_container_class(view_path) } + = render view_path, is_project_overview: true diff --git a/app/views/shared/projects/_topics.html.haml b/app/views/shared/projects/_topics.html.haml index 33e4ac58fa5a3..0f60c563f0505 100644 --- a/app/views/shared/projects/_topics.html.haml +++ b/app/views/shared/projects/_topics.html.haml @@ -2,9 +2,6 @@ - if project.topics.present? .gl-w-full.gl-display-inline-flex.gl-flex-wrap.gl-font-base.gl-font-weight-normal.gl-align-items-center.gl-mx-n2.gl-my-n2{ 'data-testid': 'project_topic_list' } - - if Feature.disabled?(:project_overview_reorg) - %span.gl-p-2.gl-text-gray-500 - = _('Topics') + ':' - project.topics_to_show.each do |topic| - explore_project_topic_path = topic_explore_projects_cleaned_path(topic_name: topic[:name]) - if topic[:title].length > max_project_topic_length diff --git a/config/feature_flags/development/project_overview_reorg.yml b/config/feature_flags/development/project_overview_reorg.yml deleted file mode 100644 index 994c17aada6c1..0000000000000 --- a/config/feature_flags/development/project_overview_reorg.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: project_overview_reorg -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/137025 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/432034 -milestone: '16.7' -type: development -group: group::ux paper cuts -default_enabled: false diff --git a/ee/app/views/projects/_home_mirror.html.haml b/ee/app/views/projects/_home_mirror.html.haml index 3b4dc1bf8d9c2..c873cfb08949f 100644 --- a/ee/app/views/projects/_home_mirror.html.haml +++ b/ee/app/views/projects/_home_mirror.html.haml @@ -1,7 +1,5 @@ -- ff_reorg_enabled_classes = Feature.enabled?(:project_overview_reorg) ? 'gl-text-secondary gl-mt-2 gl-mb-0' : '' - - if @project.mirror? && can?(current_user, :admin_project, @project) - %p{ class: ff_reorg_enabled_classes } + %p{ class: 'gl-text-secondary gl-mt-2 gl-mb-0' } - import_url = @project.safe_import_url = format(_('Mirrored from %{link}.'), link: link_to(import_url, import_url)).html_safe %br diff --git a/ee/spec/features/projects/show_project_spec.rb b/ee/spec/features/projects/show_project_spec.rb index d80d7115f5582..5060e1980e678 100644 --- a/ee/spec/features/projects/show_project_spec.rb +++ b/ee/spec/features/projects/show_project_spec.rb @@ -36,10 +36,6 @@ create(:project, :repository, mirror: true, mirror_user: user, import_url: 'http://user:pass@test.com') end - before do - stub_feature_flags(project_overview_reorg: false) - end - context 'for maintainer' do before do project.add_maintainer(user) @@ -99,31 +95,25 @@ end end - context 'with FF project_overview_reorg enabled' do + context "when user has no permissions" do let_it_be(:project) { create(:project, :public, :repository) } - before do - stub_feature_flags(project_overview_reorg: true) - end - - context "when user has no permissions" do - it 'does not render settings button if user has no permissions', :js do - visit project_path(project) + it 'does not render settings button if user has no permissions', :js do + visit project_path(project) - find_by_testid('groups-projects-more-actions-dropdown').click + find_by_testid('groups-projects-more-actions-dropdown').click - expect(page).not_to have_selector('[data-testid="settings-project-link"]') - end + expect(page).not_to have_selector('[data-testid="project-settings-link"]') + end - it 'renders settings button if user has permissions', :js do - project.add_maintainer(user) - sign_in(user) - visit project_path(project) + it 'renders settings button if user has permissions', :js do + project.add_maintainer(user) + sign_in(user) + visit project_path(project) - find_by_testid('groups-projects-more-actions-dropdown').click + find_by_testid('groups-projects-more-actions-dropdown').click - expect(page).to have_selector('[data-testid="settings-project-link"]') - end + expect(page).to have_selector('[data-testid="settings-project-link"]') end end end diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb index 4130b43e34a42..8c4cbf2ad4776 100644 --- a/qa/qa/page/project/show.rb +++ b/qa/qa/page/project/show.rb @@ -33,9 +33,6 @@ class Show < Page::Base view 'app/views/projects/_sidebar.html.haml' do element 'project-badges-content' element 'badge-image-link' - end - - view 'app/views/projects/_files.html.haml' do element 'project-buttons' end diff --git a/spec/features/projects/show/user_sees_git_instructions_spec.rb b/spec/features/projects/show/user_sees_git_instructions_spec.rb index 8d2f93ba3b719..7f8a4b81a56d4 100644 --- a/spec/features/projects/show/user_sees_git_instructions_spec.rb +++ b/spec/features/projects/show/user_sees_git_instructions_spec.rb @@ -10,7 +10,6 @@ # validation failure on NotificationSetting. # See https://gitlab.com/gitlab-org/gitlab/-/issues/299822#note_492817174 user.notification_settings.reset - stub_feature_flags(project_overview_reorg: false) end shared_examples_for 'redirects to the sign in page' do @@ -23,7 +22,7 @@ it 'shows Git command line instructions' do click_link 'Create empty repository' - page.within '.empty-wrapper' do + page.within '.project-page-layout-content' do expect(page).to have_content('Command line instructions') end diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb index 853584f8ab1ef..25f62476afa09 100644 --- a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb +++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb @@ -17,7 +17,6 @@ describe 'as a normal user' do before do - stub_feature_flags(project_overview_reorg: false) sign_in(user) visit project_path(project) end @@ -25,7 +24,7 @@ it 'project buttons are not visible' do visit project_path(project) - page.within('.project-buttons') do + within_testid('project-page-sidebar') do expect(page).not_to have_link('New file') expect(page).not_to have_link('Add README') expect(page).not_to have_link('Add CHANGELOG') @@ -40,7 +39,6 @@ describe 'as a maintainer' do before do - stub_feature_flags(project_overview_reorg: false) project.add_maintainer(user) sign_in(user) @@ -48,19 +46,19 @@ end it '"New file" button linked to IDE new file page' do - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('New file', href: presenter.ide_edit_path(project, project.default_branch || 'master')) end end it '"Add README" button linked to IDE new file populated for a README' do - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Add README', href: presenter.add_readme_ide_path) end end it '"Add license" button linked to IDE new file populated for a license' do - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Add LICENSE', href: presenter.add_license_ide_path) end end @@ -76,7 +74,7 @@ end it '"New file" button linked to IDE new file page' do - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('New file', href: presenter.ide_edit_path(project, 'example_branch')) end end @@ -99,7 +97,7 @@ it '"Auto DevOps enabled" button not linked' do visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_text('Auto DevOps enabled') end end @@ -109,14 +107,14 @@ let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) } it 'no Auto DevOps button if can not manage pipelines' do - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Enable Auto DevOps') expect(page).not_to have_link('Auto DevOps enabled') end end it 'no Kubernetes cluster button if can not manage clusters' do - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Add Kubernetes cluster') expect(page).not_to have_link('Kubernetes') end @@ -144,7 +142,7 @@ expect(project.repository.readme).not_to be_nil - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Add README', href: presenter.add_readme_ide_path) expect(page).to have_link('README', href: presenter.readme_path) end @@ -156,7 +154,7 @@ visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Add README', href: presenter.add_readme_path) expect(page).to have_link('README', href: presenter.readme_path) end @@ -170,7 +168,7 @@ visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Add README', href: presenter.add_readme_path) end end @@ -182,7 +180,7 @@ expect(project.repository.changelog).not_to be_nil - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Add CHANGELOG') end end @@ -192,7 +190,7 @@ expect(project.repository.license_blob).not_to be_nil - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Add LICENSE') end end @@ -202,7 +200,7 @@ expect(project.repository.contribution_guide).not_to be_nil - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Add CONTRIBUTING') end end @@ -212,7 +210,7 @@ it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Set up CI/CD') end end @@ -226,7 +224,7 @@ expect(project.has_ci_config_file?).to eq(false) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Set up CI/CD', href: project_ci_pipeline_editor_path(project)) end end @@ -246,7 +244,7 @@ visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Set up CI/CD') expect(page).to have_link('CI/CD configuration') end @@ -259,7 +257,7 @@ it '"Auto DevOps enabled" anchor linked to settings page' do visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) end end @@ -271,7 +269,7 @@ it '"Enable Auto DevOps" button linked to settings page' do visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) end end @@ -283,7 +281,7 @@ expect(page).to have_selector('.js-autodevops-banner') - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Enable Auto DevOps') expect(page).not_to have_link('Auto DevOps enabled') end @@ -294,7 +292,7 @@ visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Enable Auto DevOps') expect(page).not_to have_link('Auto DevOps enabled') end @@ -315,7 +313,7 @@ visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).not_to have_link('Enable Auto DevOps') expect(page).not_to have_link('Auto DevOps enabled') end @@ -327,7 +325,7 @@ it '"Add Kubernetes cluster" button linked to clusters page' do visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Add Kubernetes cluster', href: project_clusters_path(project)) end end @@ -337,7 +335,7 @@ visit project_path(project) - page.within('.project-buttons') do + within_testid('project-buttons') do expect(page).to have_link('Kubernetes', href: project_cluster_path(project, cluster)) end end diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 1fb1e21ac67fb..cc3cbc64cb3b8 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -12,7 +12,6 @@ before do sign_in user visit new_project_path - stub_feature_flags(project_overview_reorg: false) end shared_examples 'creates from template' do |template, sub_template_tab = nil| @@ -100,19 +99,18 @@ before do sign_in(project.first_owner) - stub_feature_flags(project_overview_reorg: false) end it 'parses Markdown' do project.update_attribute(:description, 'This is **my** project') visit path - expect(page).to have_css('.home-panel-description > .home-panel-description-markdown > p > strong') + expect(page).to have_css('.home-panel-description .home-panel-description-markdown p > strong') end it 'passes through html-pipeline' do project.update_attribute(:description, 'This project is the :poop:') visit path - expect(page).to have_css('.home-panel-description > .home-panel-description-markdown > p > gl-emoji') + expect(page).to have_css('.home-panel-description .home-panel-description-markdown p > gl-emoji') end it 'sanitizes unwanted tags' do @@ -128,24 +126,11 @@ end context 'read more', :js do - let(:read_more_selector) { '.read-more-container' } - let(:read_more_trigger_selector) { '.home-panel-home-desc .js-read-more-trigger' } - - it 'does not display "read more" link on desktop breakpoint' do - project.update_attribute(:description, 'This is **my** project') + it 'displays "read more" link', :js do + project.update_attribute(:description, "This is **my** project\n\nA\n\nB\n\nC\n\nD\n\nE\n\nF\n\nG\n\nH\n\nI\n\nJ\nK\n\nL\n\nM\n\nN\n\nEnd test.") visit path - expect(find(read_more_trigger_selector, visible: false)).not_to be_visible - end - - it 'displays "read more" link on mobile breakpoint' do - project.update_attribute(:description, 'This is **my** project') - visit path - resize_screen_xs - - find(read_more_trigger_selector).click - - expect(page).to have_css('.home-panel-description .is-expanded') + expect(page).to have_css('.home-panel-description .js-read-more-trigger') end end @@ -166,7 +151,6 @@ before do sign_in(project.first_owner) visit path - stub_feature_flags(project_overview_reorg: false) end it 'shows project topics' do @@ -198,7 +182,6 @@ before do sign_in(project.first_owner) visit path - stub_feature_flags(project_overview_reorg: false) end context 'desktop component' do @@ -431,10 +414,6 @@ let(:project) { create(:project, :repository) } let(:user) { create(:user) } - before do - stub_feature_flags(project_overview_reorg: false) - end - it 'does not contain default branch information in its content', :js do default_branch = 'merge-commit-analyze-side-branch' @@ -451,6 +430,80 @@ end end + context 'badges' do + shared_examples 'show badges' do + it 'renders the all badges' do + expect(page).to have_selector('.project-badges a') + + badges.each do |badge| + expect(page).to have_link(href: badge.rendered_link_url) + end + end + end + + let(:user) { create(:user) } + let(:badges) { project.badges } + + context 'has no badges' do + let(:project) { create(:project, :repository) } + + before do + sign_in(user) + project.add_maintainer(user) + visit project_path(project) + end + + it 'does not render any badge' do + expect(page).not_to have_selector('.project-badges') + end + end + + context 'only has group badges' do + let(:group) { create(:group) } + let(:project) { create(:project, :repository, namespace: group) } + + before do + create(:group_badge, group: project.group) + + sign_in(user) + project.add_maintainer(user) + visit project_path(project) + end + + it_behaves_like 'show badges' + end + + context 'only has project badges' do + let(:project) { create(:project, :repository) } + + before do + create(:project_badge, project: project) + + sign_in(user) + project.add_maintainer(user) + visit project_path(project) + end + + it_behaves_like 'show badges' + end + + context 'has both group and project badges' do + let(:group) { create(:group) } + let(:project) { create(:project, :repository, namespace: group) } + + before do + create(:project_badge, project: project) + create(:group_badge, group: project.group) + + sign_in(user) + project.add_maintainer(user) + visit project_path(project) + end + + it_behaves_like 'show badges' + end + end + def remove_with_confirm(button_text, confirm_with, confirm_button_text = 'Confirm') click_button button_text fill_in 'confirm_name_input', with: confirm_with diff --git a/spec/helpers/stat_anchors_helper_spec.rb b/spec/helpers/stat_anchors_helper_spec.rb index 929a6e7b8dc09..660db4a5dc26b 100644 --- a/spec/helpers/stat_anchors_helper_spec.rb +++ b/spec/helpers/stat_anchors_helper_spec.rb @@ -8,15 +8,11 @@ describe '#stat_anchor_attrs' do subject { helper.stat_anchor_attrs(anchor) } - before do - stub_feature_flags(project_overview_reorg: false) - end - context 'when anchor is a link' do let(:anchor) { anchor_klass.new(true) } it 'returns the proper attributes' do - expect(subject[:class]).to include('stat-link') + expect(subject[:class]).to include('stat-link gl-px-0! gl-pb-2!') end end @@ -25,7 +21,7 @@ let(:anchor) { anchor_klass.new(false, nil, nil, 'btn-default') } it 'returns the proper attributes' do - expect(subject[:class]).to include('btn-default') + expect(subject[:class]).to include('stat-link gl-px-0! gl-pb-2! btn-default') end end @@ -33,7 +29,7 @@ let(:anchor) { anchor_klass.new(false) } it 'returns the proper attributes' do - expect(subject[:class]).to include('btn-dashed') + expect(subject[:class]).to include('stat-link gl-px-0! gl-pb-2! btn-link gl-text-blue-500!') end end end diff --git a/spec/presenters/project_presenter_spec.rb b/spec/presenters/project_presenter_spec.rb index 45cf86b480052..1a76a4bc93d39 100644 --- a/spec/presenters/project_presenter_spec.rb +++ b/spec/presenters/project_presenter_spec.rb @@ -420,18 +420,13 @@ end describe '#new_file_anchor_data' do - before do - stub_feature_flags(project_overview_reorg: false) - end - it 'returns new file data if user can push' do project.add_developer(user) expect(presenter.new_file_anchor_data).to have_attributes( is_link: false, label: a_string_including("New file"), - link: presenter.project_new_blob_path(project, 'master'), - class_modifier: 'btn-dashed' + link: presenter.project_new_blob_path(project, 'master') ) end @@ -747,7 +742,6 @@ subject(:empty_repo_statistics_buttons) { presenter.empty_repo_statistics_buttons } before do - stub_feature_flags(project_overview_reorg: false) allow(project).to receive(:auto_devops_enabled?).and_return(false) end diff --git a/spec/views/projects/_files.html.haml_spec.rb b/spec/views/projects/_files.html.haml_spec.rb deleted file mode 100644 index 870d436ca8884..0000000000000 --- a/spec/views/projects/_files.html.haml_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'projects/_files', feature_category: :groups_and_projects do - let_it_be(:template) { 'projects/files' } - let_it_be(:namespace) { build_stubbed(:namespace) } - let_it_be(:user) { build_stubbed(:user, namespace: namespace) } - let_it_be(:project) { build_stubbed(:project, namespace: namespace) } - - before do - assign(:project, project) - assign(:path, '/job_path') - assign(:ref, 'main') - # used by project_new_blob_path - assign(:id, '1') - - allow(project).to receive(:statistics_buttons).and_return([]) - end - - context 'when the user disabled project shortcut buttons' do - before do - allow(view).to receive(:current_user).and_return(user) - allow(user).to receive(:project_shortcut_buttons).and_return(false) - end - - it 'does not render buttons' do - render(template, is_project_overview: true) - - expect(rendered).not_to have_selector('.js-show-on-project-root') - end - end - - context 'when the user has project shortcut buttons enabled' do - before do - allow(view).to receive(:current_user).and_return(user) - allow(user).to receive(:project_shortcut_buttons).and_return(true) - - stub_feature_flags(project_overview_reorg: false) - end - - it 'renders buttons' do - render(template, is_project_overview: true) - - expect(rendered).to have_selector('.js-show-on-project-root') - end - end - - context 'when rendered in the project overview page and there is no current user' do - before do - stub_feature_flags(project_overview_reorg: false) - end - - it 'renders buttons' do - render(template, is_project_overview: true) - - expect(rendered).to have_selector('.js-show-on-project-root') - end - end - - context 'when rendered in a page other than project overview' do - it 'does not render buttons' do - render(template, is_project_overview: false) - - expect(rendered).not_to have_selector('.js-show-on-project-root') - end - end -end diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb index 2f80eab613e3e..e058a23a605e4 100644 --- a/spec/views/projects/_home_panel.html.haml_spec.rb +++ b/spec/views/projects/_home_panel.html.haml_spec.rb @@ -51,76 +51,6 @@ end end - context 'badges' do - shared_examples 'show badges' do - it 'renders the all badges' do - render - - expect(rendered).to have_selector('.project-badges a') - - badges.each do |badge| - expect(rendered).to have_link(href: badge.rendered_link_url) - end - end - end - - let(:user) { create(:user) } - let(:badges) { project.badges } - - before do - assign(:project, project) - - allow(view).to receive(:current_user).and_return(user) - allow(view).to receive(:can?).with(user, :read_project, project).and_return(false) - allow(project).to receive(:license_anchor_data).and_return(false) - - stub_feature_flags(project_overview_reorg: false) - end - - context 'has no badges' do - let(:project) { create(:project) } - - it 'does not render any badge' do - render - - expect(rendered).not_to have_selector('.project-badges') - end - end - - context 'only has group badges' do - let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } - - before do - create(:group_badge, group: project.group) - end - - it_behaves_like 'show badges' - end - - context 'only has project badges' do - let(:project) { create(:project) } - - before do - create(:project_badge, project: project) - end - - it_behaves_like 'show badges' - end - - context 'has both group and project badges' do - let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } - - before do - create(:project_badge, project: project) - create(:group_badge, group: project.group) - end - - it_behaves_like 'show badges' - end - end - context 'forks' do let(:source_project) { create(:project, :repository) } let(:project) { fork_project(source_project) } -- GitLab