Commit 27f68edd authored by Douwe Maan's avatar Douwe Maan

Merge branch '23603-add-extra-functionality-for-the-top-right-plus-button' into 'master'

Resolve "Add extra functionality for the top right Plus Button"

Closes #23603

See merge request !11632
parents dd80b629 39d976cf
...@@ -266,7 +266,14 @@ ...@@ -266,7 +266,14 @@
text-transform: capitalize; text-transform: capitalize;
} }
.separator + .dropdown-header { .dropdown-bold-header {
font-weight: 600;
line-height: 22px;
padding: 0 16px;
}
.separator + .dropdown-header,
.separator + .dropdown-bold-header {
padding-top: 2px; padding-top: 2px;
} }
......
...@@ -36,10 +36,7 @@ ...@@ -36,10 +36,7 @@
%li %li
= link_to admin_root_path, title: 'Admin area', aria: { label: "Admin area" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to admin_root_path, title: 'Admin area', aria: { label: "Admin area" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('wrench fw') = icon('wrench fw')
- if current_user.can_create_project? = render 'layouts/header/new_dropdown'
%li
= link_to new_project_path, title: 'New project', aria: { label: "New project" }, data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('plus fw')
- if Gitlab::Sherlock.enabled? - if Gitlab::Sherlock.enabled?
%li %li
= link_to sherlock_transactions_path, title: 'Sherlock Transactions', = link_to sherlock_transactions_path, title: 'Sherlock Transactions',
...@@ -74,12 +71,12 @@ ...@@ -74,12 +71,12 @@
@#{current_user.username} @#{current_user.username}
%li.divider %li.divider
%li %li
= link_to "Profile", current_user, class: 'profile-link', aria: { label: "Profile" }, data: { user: current_user.username } = link_to "Profile", current_user, class: 'profile-link', data: { user: current_user.username }
%li %li
= link_to "Settings", profile_path, aria: { label: "Settings" } = link_to "Settings", profile_path
%li.divider %li.divider
%li %li
= link_to "Sign out", destroy_user_session_path, method: :delete, class: "sign-out-link", aria: { label: "Sign out" } = link_to "Sign out", destroy_user_session_path, method: :delete, class: "sign-out-link"
- else - else
%li %li
%div %div
......
%li.header-new.dropdown
= link_to new_project_path, class: "header-new-dropdown-toggle has-tooltip", title: "New...", ref: 'tooltip', aria: { label: "New..." }, data: { toggle: 'dropdown', placement: 'bottom', container: 'body' } do
= icon('plus fw')
= icon('caret-down')
.dropdown-menu-nav.dropdown-menu-align-right
%ul
- if @group
- 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.header-new-group-project
= link_to 'New project', new_project_path(namespace_id: @group.id)
- if create_group_subgroup
%li
= link_to 'New subgroup', new_group_path(parent_id: @group.id)
%li.divider
%li.dropdown-bold-header GitLab
- if @project && @project.persisted?
- create_project_issue = can?(current_user, :create_issue, @project)
- merge_project = can?(current_user, :create_merge_request, @project) ? @project : (current_user && current_user.fork_of(@project))
- create_project_snippet = can?(current_user, :create_project_snippet, @project)
- if create_project_issue || merge_project || create_project_snippet
%li.dropdown-bold-header This project
- if create_project_issue
%li
= link_to 'New issue', new_namespace_project_issue_path(@project.namespace, @project)
- if merge_project
%li
= link_to 'New merge request', new_namespace_project_merge_request_path(merge_project.namespace, merge_project)
- if create_project_snippet
%li.header-new-project-snippet
= link_to 'New snippet', new_namespace_project_snippet_path(@project.namespace, @project)
%li.divider
%li.dropdown-bold-header GitLab
- if current_user.can_create_project?
%li
= link_to 'New project', new_project_path
- if current_user.can_create_group?
%li
= link_to 'New group', new_group_path
%li
= link_to 'New snippet', new_snippet_path
---
title: Add extra context-sensitive functionality for the top right menu button
merge_request: 11632
author:
...@@ -4,7 +4,13 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps ...@@ -4,7 +4,13 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
include SharedProject include SharedProject
step 'I click "New project" link' do step 'I click "New project" link' do
page.within('.content') do page.within '#content-body' do
click_link "New project"
end
end
step 'I click "New project" in top right menu' do
page.within '.header-content' do
click_link "New project" click_link "New project"
end end
end end
......
...@@ -5,7 +5,9 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps ...@@ -5,7 +5,9 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
step 'fill project form with valid data' do step 'fill project form with valid data' do
fill_in 'project_path', with: 'Empty' fill_in 'project_path', with: 'Empty'
click_button "Create project" page.within '#content-body' do
click_button "Create project"
end
end end
step 'I should see project page' do step 'I should see project page' do
......
...@@ -42,7 +42,9 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps ...@@ -42,7 +42,9 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps
end end
step 'I click link "New merge request"' do step 'I click link "New merge request"' do
page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request') page.within '#content-body' do
page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request')
end
end end
step 'I should see the new merge request page for my namespace' do step 'I should see the new merge request page for my namespace' do
......
...@@ -17,7 +17,9 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -17,7 +17,9 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
end end
step 'I click link "New Merge Request"' do step 'I click link "New Merge Request"' do
page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request') page.within '#content-body' do
page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request')
end
end end
step 'I should see merge request "Merge Request On Forked Project"' do step 'I should see merge request "Merge Request On Forked Project"' do
......
...@@ -62,7 +62,9 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps ...@@ -62,7 +62,9 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
end end
step 'I click link "New issue"' do step 'I click link "New issue"' do
page.has_link?('New Issue') ? click_link('New Issue') : click_link('New issue') page.within '#content-body' do
page.has_link?('New Issue') ? click_link('New Issue') : click_link('New issue')
end
end end
step 'I click "author" dropdown' do step 'I click "author" dropdown' do
......
...@@ -14,7 +14,9 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps ...@@ -14,7 +14,9 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end end
step 'I click link "New Merge Request"' do step 'I click link "New Merge Request"' do
page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request') page.within '#content-body' do
page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request')
end
end end
step 'I click link "Bug NS-04"' do step 'I click link "Bug NS-04"' do
......
...@@ -23,7 +23,9 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps ...@@ -23,7 +23,9 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
end end
step 'I click link "New snippet"' do step 'I click link "New snippet"' do
first(:link, "New snippet").click page.within '#content-body' do
first(:link, "New snippet").click
end
end end
step 'I click link "Snippet one"' do step 'I click link "Snippet one"' do
......
...@@ -24,7 +24,9 @@ feature 'Admin Groups', feature: true do ...@@ -24,7 +24,9 @@ feature 'Admin Groups', feature: true do
it 'creates new group' do it 'creates new group' do
visit admin_groups_path visit admin_groups_path
click_link "New group" page.within '#content-body' do
click_link "New group"
end
path_component = 'gitlab' path_component = 'gitlab'
group_name = 'GitLab group name' group_name = 'GitLab group name'
group_description = 'Description of group for GitLab' group_description = 'Description of group for GitLab'
......
require 'spec_helper'
feature 'Top Plus Menu', feature: true, js: true do
let(:user) { create :user }
let(:guest_user) { create :user}
let(:group) { create(:group) }
let(:project) { create(:project, :repository, creator: user, namespace: user.namespace) }
let(:public_project) { create(:project, :public) }
before do
group.add_owner(user)
group.add_guest(guest_user)
project.add_guest(guest_user)
end
context 'used by full user' do
before do
login_as(user)
end
scenario 'click on New project shows new project page' do
visit root_dashboard_path
click_topmenuitem("New project")
expect(page).to have_content('Project path')
expect(page).to have_content('Project name')
end
scenario 'click on New group shows new group page' do
visit root_dashboard_path
click_topmenuitem("New group")
expect(page).to have_content('Group path')
expect(page).to have_content('Group name')
end
scenario 'click on New snippet shows new snippet page' do
visit root_dashboard_path
click_topmenuitem("New snippet")
expect(page).to have_content('New Snippet')
expect(page).to have_content('Title')
end
scenario 'click on New issue shows new issue page' do
visit namespace_project_path(project.namespace, project)
click_topmenuitem("New issue")
expect(page).to have_content('New Issue')
expect(page).to have_content('Title')
end
scenario 'click on New merge request shows new merge request page' do
visit namespace_project_path(project.namespace, project)
click_topmenuitem("New merge request")
expect(page).to have_content('New Merge Request')
expect(page).to have_content('Source branch')
expect(page).to have_content('Target branch')
end
scenario 'click on New project snippet shows new snippet page' do
visit namespace_project_path(project.namespace, project)
page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click')
expect(page).to have_selector('.header-new.dropdown.open', count: 1)
find('.header-new-project-snippet a').trigger('click')
end
expect(page).to have_content('New Snippet')
expect(page).to have_content('Title')
end
scenario 'Click on New subgroup shows new group page' do
visit group_path(group)
click_topmenuitem("New subgroup")
expect(page).to have_content('Group path')
expect(page).to have_content('Group name')
end
scenario 'Click on New project in group shows new project page' do
visit group_path(group)
page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click')
expect(page).to have_selector('.header-new.dropdown.open', count: 1)
find('.header-new-group-project a').trigger('click')
end
expect(page).to have_content('Project path')
expect(page).to have_content('Project name')
end
end
context 'used by guest user' do
before do
login_as(guest_user)
end
scenario 'click on New issue shows new issue page' do
visit namespace_project_path(project.namespace, project)
click_topmenuitem("New issue")
expect(page).to have_content('New Issue')
expect(page).to have_content('Title')
end
scenario 'has no New merge request menu item' do
visit namespace_project_path(project.namespace, project)
hasnot_topmenuitem("New merge request")
end
scenario 'has no New project snippet menu item' do
visit namespace_project_path(project.namespace, project)
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-project-snippet')
end
scenario 'public project has no New Issue Button' do
visit namespace_project_path(public_project.namespace, public_project)
hasnot_topmenuitem("New issue")
end
scenario 'public project has no New merge request menu item' do
visit namespace_project_path(public_project.namespace, public_project)
hasnot_topmenuitem("New merge request")
end
scenario 'public project has no New project snippet menu item' do
visit namespace_project_path(public_project.namespace, public_project)
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-project-snippet')
end
scenario 'has no New subgroup menu item' do
visit group_path(group)
hasnot_topmenuitem("New subgroup")
end
scenario 'has no New project for group menu item' do
visit group_path(group)
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-group-project')
end
end
def click_topmenuitem(item_name)
page.within '.header-content' do
find('.header-new-dropdown-toggle').trigger('click')
expect(page).to have_selector('.header-new.dropdown.open', count: 1)
click_link item_name
end
end
def hasnot_topmenuitem(item_name)
expect(find('.header-new.dropdown')).not_to have_content(item_name)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment