diff options
Diffstat (limited to 'app/views/layouts/header')
7 files changed, 53 insertions, 78 deletions
diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index ae333cffb84..87580e57e75 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -1,11 +1,12 @@ - has_impersonation_link = header_link?(:admin_impersonation) - user_status_data = user_status_properties(current_user) +- use_top_nav_redesign = Feature.enabled?(:combined_menu, current_user, default_enabled: :yaml) %header.navbar.navbar-gitlab.navbar-expand-sm.js-navbar{ data: { qa_selector: 'navbar' } } %a.gl-sr-only.gl-accessibility{ href: "#content-body" } Skip to content .container-fluid .header-content - .title-container + .title-container.hide-when-menu-expanded %h1.title %span.gl-sr-only GitLab = link_to root_path, title: _('Dashboard'), id: 'logo', **tracking_attrs('main_navigation', 'click_gitlab_logo_link', 'navigation') do @@ -19,8 +20,9 @@ %span.gl-badge.gl-bg-green-500.gl-text-white.gl-rounded-pill.gl-font-weight-bold.gl-py-1 = _('Next') - - if Feature.enabled?(:combined_menu, current_user, default_enabled: :yaml) - = render "layouts/nav/top_nav" + - if use_top_nav_redesign + .gl-display-none.gl-sm-display-block + = render "layouts/nav/top_nav" - else - if current_user = render "layouts/nav/dashboard" @@ -30,13 +32,14 @@ .navbar-collapse.collapse %ul.nav.navbar-nav - if current_user - = render 'layouts/header/new_dropdown' - - if header_link?(:search) + = render 'layouts/header/new_dropdown', class: ('gl-display-none gl-sm-display-block' if use_top_nav_redesign) + - if top_nav_show_search + - search_menu_item = top_nav_search_menu_item_attrs %li.nav-item.d-none.d-lg-block.m-auto = render 'layouts/search' unless current_controller?(:search) - %li.nav-item.d-inline-block.d-lg-none - = link_to search_context.search_url, title: _('Search'), aria: { label: _('Search') }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do - = sprite_icon('search') + %li.nav-item{ class: use_top_nav_redesign ? 'd-none d-sm-inline-block d-lg-none' : 'd-inline-block d-lg-none' } + = link_to search_menu_item.fetch(:href), title: search_menu_item.fetch(:title), aria: { label: search_menu_item.fetch(:title) }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do + = sprite_icon(search_menu_item.fetch(:icon)) - if header_link?(:issues) = nav_link(path: 'dashboard#issues', html_options: { class: "user-counter" }) do = link_to assigned_issues_dashboard_path, title: _('Issues'), class: 'dashboard-shortcuts-issues', aria: { label: _('Issues') }, @@ -115,10 +118,15 @@ - sign_in_text = allow_signup? ? _('Sign in / Register') : _('Sign in') = link_to sign_in_text, new_session_path(:user, redirect_to_referer: 'yes'), class: 'gl-button btn btn-default btn-sign-in' - %button.navbar-toggler.d-block.d-sm-none{ type: 'button' } + %button.navbar-toggler.d-block.d-sm-none{ type: 'button', class: ('gl-border-none!' if use_top_nav_redesign) } %span.sr-only= _('Toggle navigation') - = sprite_icon('ellipsis_h', size: 12, css_class: 'more-icon js-navbar-toggle-right') - = sprite_icon('close', size: 12, css_class: 'close-icon js-navbar-toggle-left') + - if use_top_nav_redesign + %span.more-icon.gl-px-3.gl-font-sm.gl-font-weight-bold + %span.gl-pr-2= _('Menu') + = sprite_icon('hamburger', size: 16) + - else + = sprite_icon('ellipsis_h', size: 12, css_class: 'more-icon') + = sprite_icon('close', size: 12, css_class: 'close-icon') - if display_whats_new? #whats-new-app{ data: { version_digest: whats_new_version_digest } } diff --git a/app/views/layouts/header/_group_invite_members_new_dropdown_item.html.haml b/app/views/layouts/header/_group_invite_members_new_dropdown_item.html.haml deleted file mode 100644 index cb74c77dff8..00000000000 --- a/app/views/layouts/header/_group_invite_members_new_dropdown_item.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- return unless Gitlab::Experimentation.active?(:invite_members_new_dropdown) && can?(current_user, :admin_group_member, @group) - -%li= dropdown_invite_members_link(@group) diff --git a/app/views/layouts/header/_help_dropdown.html.haml b/app/views/layouts/header/_help_dropdown.html.haml index c3769dd2993..01e59b8e2ef 100644 --- a/app/views/layouts/header/_help_dropdown.html.haml +++ b/app/views/layouts/header/_help_dropdown.html.haml @@ -10,7 +10,7 @@ %li %button.js-shortcuts-modal-trigger{ type: "button" } = _("Keyboard shortcuts") - %span.text-secondary.float-right{ "aria-hidden": true }= '?'.html_safe + %span.text-secondary.float-right{ "aria-hidden": "true" }= '?'.html_safe %li.divider %li = link_to _("Submit feedback"), "https://about.gitlab.com/submit-feedback" diff --git a/app/views/layouts/header/_new_dropdown.html.haml b/app/views/layouts/header/_new_dropdown.html.haml index ca90d2e02fa..c5f43fb2c16 100644 --- a/app/views/layouts/header/_new_dropdown.html.haml +++ b/app/views/layouts/header/_new_dropdown.html.haml @@ -1,47 +1,27 @@ -- new_repo_experiment_text = content_for(:new_repo_experiment) -%li.header-new.dropdown{ data: { track_label: "new_dropdown", track_event: "click_dropdown", track_experiment: "new_repo" } } - = link_to new_project_path, class: "header-new-dropdown-toggle has-tooltip qa-new-menu-toggle", id: "js-onboarding-new-project-link", title: _("New..."), ref: 'tooltip', aria: { label: _("New...") }, data: { toggle: 'dropdown', placement: 'bottom', container: 'body', display: 'static' } do +- view_model = new_dropdown_view_model(project: @project, group: @group) +- menu_sections = view_model.fetch(:menu_sections) +- title = view_model.fetch(:title) +- show_headers = menu_sections.length > 1 +- top_class = local_assigns.fetch(:class, nil) + +- return if menu_sections.empty? + +%li.header-new.dropdown{ class: top_class, data: { track_label: "new_dropdown", track_event: "click_dropdown", track_experiment: "new_repo" } } + = link_to new_project_path, class: "header-new-dropdown-toggle has-tooltip", id: "js-onboarding-new-project-link", title: title, ref: 'tooltip', aria: { label: title }, data: { toggle: 'dropdown', placement: 'bottom', container: 'body', display: 'static', qa_selector: 'new_menu_toggle' } do = sprite_icon('plus-square') = sprite_icon('chevron-down', css_class: 'caret-down') .dropdown-menu.dropdown-menu-right.dropdown-extended-height %ul - - if @group&.persisted? - - create_group_project = can?(current_user, :create_projects, @group) - - create_group_subgroup = can?(current_user, :create_subgroup, @group) - - - if create_group_project || create_group_subgroup - %li.dropdown-bold-header - = _('This group') - - if create_group_project - %li= link_to new_repo_experiment_text, new_project_path(namespace_id: @group.id), data: { track_experiment: 'new_repo', track_event: 'click_link_new_project_group', track_label: 'plus_menu_dropdown' } - - if create_group_subgroup - %li= link_to _('New subgroup'), new_group_path(parent_id: @group.id), data: { track_event: 'click_link_new_subgroup', track_label: 'plus_menu_dropdown' } - = render_if_exists 'layouts/header/create_epic_new_dropdown_item' - = render 'layouts/header/group_invite_members_new_dropdown_item' + - menu_sections.each_with_index do |section, index| + - if index > 0 %li.divider - %li.dropdown-bold-header GitLab - - - if @project&.persisted? - - create_project_issue = show_new_issue_link?(@project) - - merge_project = merge_request_source_project_for_project(@project) - - create_project_snippet = can?(current_user, :create_snippet, @project) - - - if create_project_issue || merge_project || create_project_snippet + - if show_headers %li.dropdown-bold-header - = _('This project') - - if create_project_issue - %li= link_to _('New issue'), new_project_issue_path(@project), data: { track_event: 'click_link_new_issue', track_label: 'plus_menu_dropdown' } - - if merge_project - %li= link_to _('New merge request'), project_new_merge_request_path(merge_project), data: { track_event: 'click_link_new_mr', track_label: 'plus_menu_dropdown' } - - - if create_project_snippet - %li= link_to _('New snippet'), new_project_snippet_path(@project), data: { track_event: 'click_link_new_snippet_project', track_label: 'plus_menu_dropdown' } - = render 'layouts/header/project_invite_members_new_dropdown_item' - %li.divider - %li.dropdown-bold-header GitLab - - if current_user.can_create_project? - %li= link_to new_repo_experiment_text, new_project_path, class: 'qa-global-new-project-link', data: { track_experiment: 'new_repo', track_event: 'click_link_new_project', track_label: 'plus_menu_dropdown' } - - if current_user.can_create_group? - %li= link_to _('New group'), new_group_path, data: { track_event: 'click_link_new_group', track_label: 'plus_menu_dropdown' } - - if current_user.can?(:create_snippet) - %li= link_to _('New snippet'), new_snippet_path, data: { track_event: 'click_link_new_snippet_parent', track_label: 'plus_menu_dropdown' }, class: 'qa-global-new-snippet-link' + = section.fetch(:title) + - section.fetch(:menu_items).each do |menu_item| + %li< + = link_to menu_item.fetch(:href), class: menu_item.fetch(:css_class), data: menu_item.fetch(:data) do + = menu_item.fetch(:title) + - if menu_item.fetch(:emoji) + -# We need to insert a space between the title and emoji + = " #{emoji_icon(menu_item.fetch(:emoji), 'aria-hidden': true, class: "gl-font-base gl-vertical-align-baseline")}".html_safe diff --git a/app/views/layouts/header/_new_repo_experiment.html.haml b/app/views/layouts/header/_new_repo_experiment.html.haml deleted file mode 100644 index aaa13d593cd..00000000000 --- a/app/views/layouts/header/_new_repo_experiment.html.haml +++ /dev/null @@ -1,6 +0,0 @@ -- content_for :new_repo_experiment do - - experiment(:new_repo, user: current_user) do |e| - - e.use do - = _('New project') - - e.try do - = _('New project/repository') diff --git a/app/views/layouts/header/_project_invite_members_new_dropdown_item.html.haml b/app/views/layouts/header/_project_invite_members_new_dropdown_item.html.haml deleted file mode 100644 index 2cb67e857e3..00000000000 --- a/app/views/layouts/header/_project_invite_members_new_dropdown_item.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- return unless Gitlab::Experimentation.active?(:invite_members_new_dropdown) && can_import_members? - -%li= dropdown_invite_members_link(@project) diff --git a/app/views/layouts/header/_registration_enabled_callout.html.haml b/app/views/layouts/header/_registration_enabled_callout.html.haml index 1b1804edcc7..9266702e44e 100644 --- a/app/views/layouts/header/_registration_enabled_callout.html.haml +++ b/app/views/layouts/header/_registration_enabled_callout.html.haml @@ -1,15 +1,14 @@ - return unless show_registration_enabled_user_callout? -%div{ class: [container_class, @content_class, 'gl-pt-5!'] } - .gl-alert.gl-alert-warning.js-registration-enabled-callout{ role: 'alert', data: { feature_id: UserCalloutsHelper::REGISTRATION_ENABLED_CALLOUT, dismiss_endpoint: user_callouts_path } } - = sprite_icon('warning', size: 16, css_class: 'gl-alert-icon') - %button.gl-alert-dismiss.js-close{ type: 'button', aria: { label: _('Close') }, data: { testid: 'close-registration-enabled-callout' } } - = sprite_icon('close', size: 16) - .gl-alert-title - = _('Open registration is enabled on your instance.') - .gl-alert-body - = html_escape(_('%{anchorOpen}Learn more%{anchorClose} about how you can customize / disable registration on your instance.')) % { anchorOpen: "<a href=\"#{help_page_path('user/admin_area/settings/sign_up_restrictions')}\">".html_safe, anchorClose: '</a>'.html_safe } - .gl-alert-actions - = link_to general_admin_application_settings_path(anchor: 'js-signup-settings'), class: 'btn gl-alert-action btn-info btn-md gl-button' do - %span.gl-button-text - = _('View setting') += render 'shared/global_alert', + title: _('Open registration is enabled on your instance.'), + variant: :warning, + alert_class: 'js-registration-enabled-callout', + alert_data: { feature_id: UserCalloutsHelper::REGISTRATION_ENABLED_CALLOUT, dismiss_endpoint: user_callouts_path }, + close_button_data: { testid: 'close-registration-enabled-callout' } do + .gl-alert-body + = html_escape(_('%{anchorOpen}Learn more%{anchorClose} about how you can customize / disable registration on your instance.')) % { anchorOpen: "<a href=\"#{help_page_path('user/admin_area/settings/sign_up_restrictions')}\">".html_safe, anchorClose: '</a>'.html_safe } + .gl-alert-actions + = link_to general_admin_application_settings_path(anchor: 'js-signup-settings'), class: 'btn gl-alert-action btn-info btn-md gl-button' do + %span.gl-button-text + = _('View setting') |