Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSytse Sijbrandij <sytse@gitlab.com>2015-07-10 19:43:39 +0300
committerSytse Sijbrandij <sytse@gitlab.com>2015-07-10 19:43:39 +0300
commita69855fc90cec7e8e079c8bd9d2127858d03d006 (patch)
treee3723dba2066e473d6cef0ec401eeb232fc7f0b0
parent1ea0db475f399c3d1a841bbcfe8e19518e88506f (diff)
parent77025ad8e33cc99c645febe9b51fbf9931a62bcf (diff)
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
-rw-r--r--CHANGELOG2
-rw-r--r--app/assets/stylesheets/generic/sidebar.scss9
-rw-r--r--app/helpers/gitlab_markdown_helper.rb2
-rw-r--r--app/helpers/projects_helper.rb10
-rw-r--r--app/helpers/visibility_level_helper.rb6
-rw-r--r--app/views/events/_event.html.haml1
-rw-r--r--app/views/layouts/nav/_group.html.haml10
-rw-r--r--app/views/layouts/nav/_profile.html.haml8
-rw-r--r--app/views/layouts/nav/_project.html.haml15
-rw-r--r--app/views/projects/_zen.html.haml2
-rw-r--r--app/views/projects/edit.html.haml2
-rw-r--r--app/views/projects/labels/_label.html.haml4
-rw-r--r--app/views/projects/notes/_edit_form.html.haml4
-rw-r--r--app/views/projects/notes/_form.html.haml10
-rw-r--r--app/views/shared/_visibility_radios.html.haml1
-rw-r--r--features/groups.feature4
-rw-r--r--features/project/project.feature9
-rw-r--r--features/steps/groups.rb4
-rw-r--r--features/steps/project/project.rb14
-rw-r--r--lib/gitlab/visibility_level.rb4
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb2
-rw-r--r--spec/helpers/projects_helper_spec.rb44
-rw-r--r--spec/helpers/visibility_level_helper_spec.rb39
23 files changed, 189 insertions, 17 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 5daee9830ed..a964a192216 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -41,6 +41,8 @@ v 7.13.0 (unreleased)
- Allow users to be blocked and unblocked via the API
- Use native Postgres database cleaning during backup restore
- Redesign project page. Show README as default instead of activity. Move project activity to separate page
+ - Make left menu more hierarchical and less contextual by adding back item at top
+ - A fork can’t have a visibility level that is greater than the original project.
v 7.12.2
- Correctly show anonymous authorized applications under Profile > Applications.
diff --git a/app/assets/stylesheets/generic/sidebar.scss b/app/assets/stylesheets/generic/sidebar.scss
index 00e0534b81e..cb8ecba8dee 100644
--- a/app/assets/stylesheets/generic/sidebar.scss
+++ b/app/assets/stylesheets/generic/sidebar.scss
@@ -39,12 +39,12 @@
}
a {
+ padding: 7px 15px;
+ font-size: 13px;
+ line-height: 18px;
color: $gray;
display: block;
text-decoration: none;
- padding: 8px 15px;
- font-size: 14px;
- line-height: 20px;
padding-left: 16px;
&:hover {
@@ -114,9 +114,6 @@
width: $sidebar_collapsed_width;
li a {
- font-size: 14px;
- padding: 8px 15px;
- text-align: left;
padding-left: 16px;
}
}
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index a801d3b10aa..eb3f72a307d 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -118,7 +118,7 @@ module GitlabMarkdownHelper
# Returns a random markdown tip for use as a textarea placeholder
def random_markdown_tip
- "Tip: #{MARKDOWN_TIPS.sample}"
+ MARKDOWN_TIPS.sample
end
private
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index cef23a52e34..aa15398cbed 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -92,6 +92,16 @@ module ProjectsHelper
end
end
+ def can_change_visibility_level?(project, current_user)
+ return false unless can?(current_user, :change_visibility_level, project)
+
+ if project.forked?
+ project.forked_from_project.visibility_level > Gitlab::VisibilityLevel::PRIVATE
+ else
+ true
+ end
+ end
+
private
def get_project_nav_tabs(project, current_user)
diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb
index 00d4c7f1051..b52cd23aba2 100644
--- a/app/helpers/visibility_level_helper.rb
+++ b/app/helpers/visibility_level_helper.rb
@@ -86,4 +86,10 @@ module VisibilityLevelHelper
def default_snippet_visibility
current_application_settings.default_snippet_visibility
end
+
+ def skip_level?(form_model, level)
+ form_model.is_a?(Project) &&
+ form_model.forked? &&
+ !Gitlab::VisibilityLevel.allowed_fork_levels(form_model.forked_from_project.visibility_level).include?(level)
+ end
end
diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml
index b2e5d11279b..b8409f64665 100644
--- a/app/views/events/_event.html.haml
+++ b/app/views/events/_event.html.haml
@@ -5,6 +5,7 @@
- if event.created_project?
= cache [event, current_user] do
+ = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:''
= render "events/event/created_project", event: event
- else
= cache event do
diff --git a/app/views/layouts/nav/_group.html.haml b/app/views/layouts/nav/_group.html.haml
index 9d216be151a..fc74d0205c6 100644
--- a/app/views/layouts/nav/_group.html.haml
+++ b/app/views/layouts/nav/_group.html.haml
@@ -1,9 +1,17 @@
%ul.nav.nav-sidebar
+ = nav_link do
+ = link_to root_path, title: 'Back to dashboard', data: {placement: 'right'} do
+ = icon('caret-square-o-left fw')
+ %span
+ Back to Dashboard
+
+ %li.separate-item
+
= nav_link(path: 'groups#show', html_options: {class: 'home'}) do
= link_to group_path(@group), title: 'Home', data: {placement: 'right'} do
= icon('dashboard fw')
%span
- Activity
+ Group
- if current_user
= nav_link(controller: [:group, :milestones]) do
= link_to group_milestones_path(@group), title: 'Milestones', data: {placement: 'right'} do
diff --git a/app/views/layouts/nav/_profile.html.haml b/app/views/layouts/nav/_profile.html.haml
index de5544268a1..00d3cb300d4 100644
--- a/app/views/layouts/nav/_profile.html.haml
+++ b/app/views/layouts/nav/_profile.html.haml
@@ -1,4 +1,12 @@
%ul.nav.nav-sidebar
+ = nav_link do
+ = link_to root_path, title: 'Back to dashboard', data: {placement: 'right'} do
+ = icon('caret-square-o-left fw')
+ %span
+ Back to Dashboard
+
+ %li.separate-item
+
= nav_link(path: 'profiles#show', html_options: {class: 'home'}) do
= link_to profile_path, title: 'Profile', data: {placement: 'right'} do
= icon('user fw')
diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml
index 2012478eba9..a92d618284d 100644
--- a/app/views/layouts/nav/_project.html.haml
+++ b/app/views/layouts/nav/_project.html.haml
@@ -1,4 +1,19 @@
%ul.nav.nav-sidebar
+ - if @project.group
+ = nav_link do
+ = link_to group_path(@project.group), title: 'Back to group', data: {placement: 'right'} do
+ = icon('caret-square-o-left fw')
+ %span
+ Back to Group
+ - else
+ = nav_link do
+ = link_to root_path, title: 'Back to dashboard', data: {placement: 'right'} do
+ = icon('caret-square-o-left fw')
+ %span
+ Back to Dashboard
+
+ %li.separate-item
+
= nav_link(path: 'projects#show', html_options: {class: 'home'}) do
= link_to project_path(@project), title: 'Project', class: 'shortcuts-project', data: {placement: 'right'} do
= icon('home fw')
diff --git a/app/views/projects/_zen.html.haml b/app/views/projects/_zen.html.haml
index a4e41eeb363..6a41cdbc907 100644
--- a/app/views/projects/_zen.html.haml
+++ b/app/views/projects/_zen.html.haml
@@ -2,7 +2,7 @@
%input#zen-toggle-comment.zen-toggle-comment{ tabindex: '-1', type: 'checkbox' }
.zen-backdrop
- classes << ' js-gfm-input markdown-area'
- = f.text_area attr, class: classes, placeholder: random_markdown_tip
+ = f.text_area attr, class: classes, placeholder: ''
= link_to nil, class: 'zen-enter-link', tabindex: '-1' do
%i.fa.fa-expand
Edit in fullscreen
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index 7ef42ac0f8c..e8e65d87f47 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -29,7 +29,7 @@
.col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'select2 select-wide'})
- = render 'shared/visibility_level', f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can?(current_user, :change_visibility_level, @project), form_model: @project
+ = render 'shared/visibility_level', f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can_change_visibility_level?(@project, current_user), form_model: @project
.form-group
= f.label :tag_list, "Tags", class: 'control-label'
diff --git a/app/views/projects/labels/_label.html.haml b/app/views/projects/labels/_label.html.haml
index 7fa1ee53f76..c6ebfa281a1 100644
--- a/app/views/projects/labels/_label.html.haml
+++ b/app/views/projects/labels/_label.html.haml
@@ -6,5 +6,5 @@
= pluralize label.open_issues_count, 'open issue'
- if can? current_user, :admin_label, @project
- = link_to 'Edit', edit_namespace_project_label_path(@project.namespace, @project, label), class: 'btn'
- = link_to 'Remove', namespace_project_label_path(@project.namespace, @project, label), class: 'btn btn-remove remove-row', method: :delete, remote: true, data: {confirm: "Remove this label? Are you sure?"}
+ = link_to 'Edit', edit_namespace_project_label_path(@project.namespace, @project, label), class: 'btn btn-sm'
+ = link_to 'Remove', namespace_project_label_path(@project.namespace, @project, label), class: 'btn btn-sm btn-remove remove-row', method: :delete, remote: true, data: {confirm: "Remove this label? Are you sure?"}
diff --git a/app/views/projects/notes/_edit_form.html.haml b/app/views/projects/notes/_edit_form.html.haml
index a663950f031..7472b33bb53 100644
--- a/app/views/projects/notes/_edit_form.html.haml
+++ b/app/views/projects/notes/_edit_form.html.haml
@@ -5,8 +5,8 @@
= render 'projects/zen', f: f, attr: :note, classes: 'note_text js-note-text js-task-list-field'
.comment-hints.clearfix
- .pull-left Comments are parsed with #{link_to 'GitLab Flavored Markdown', help_page_path('markdown', 'markdown'),{ target: '_blank', tabindex: -1 }}
- .pull-right Attach files by dragging &amp; dropping or #{link_to 'selecting them', '#', class: 'markdown-selector', tabindex: -1 }.
+ .pull-left #{link_to 'Markdown ', help_page_path('markdown', 'markdown'),{ target: '_blank', tabindex: -1 }}
+ .pull-right #{link_to 'Attach a file', '#', class: 'markdown-selector', tabindex: -1 }
.note-form-actions
.buttons
diff --git a/app/views/projects/notes/_form.html.haml b/app/views/projects/notes/_form.html.haml
index 3fb044d736e..64f98741d45 100644
--- a/app/views/projects/notes/_form.html.haml
+++ b/app/views/projects/notes/_form.html.haml
@@ -12,8 +12,14 @@
classes: 'note_text js-note-text'
.comment-hints.clearfix
- .pull-left Comments are parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"),{ target: '_blank', tabindex: -1 }}
- .pull-right Attach files by dragging &amp; dropping or #{link_to "selecting them", '#', class: 'markdown-selector', tabindex: -1 }.
+ .pull-left
+ = link_to "Markdown ", help_page_path("markdown", "markdown"),{ target: '_blank', tabindex: -1 }
+ tip:
+ = random_markdown_tip
+ .pull-right
+ = link_to '#', class: 'markdown-selector', tabindex: -1 do
+ Attach a file
+ = icon('paperclip')
.error-alert
.note-form-actions
diff --git a/app/views/shared/_visibility_radios.html.haml b/app/views/shared/_visibility_radios.html.haml
index 02416125a72..ebe2eb0433d 100644
--- a/app/views/shared/_visibility_radios.html.haml
+++ b/app/views/shared/_visibility_radios.html.haml
@@ -1,4 +1,5 @@
- Gitlab::VisibilityLevel.values.each do |level|
+ - next if skip_level?(form_model, level)
.radio
- restricted = restricted_visibility_levels.include?(level)
= form.label "#{model_method}_#{level}" do
diff --git a/features/groups.feature b/features/groups.feature
index 415e43d6ae7..299e846edb0 100644
--- a/features/groups.feature
+++ b/features/groups.feature
@@ -4,6 +4,10 @@ Feature: Groups
And "John Doe" is owner of group "Owned"
And "John Doe" is guest of group "Guest"
+ Scenario: I should have back to group button
+ When I visit group "Owned" page
+ Then I should see back to dashboard button
+
@javascript
Scenario: I should see group "Owned" dashboard list
When I visit group "Owned" page
diff --git a/features/project/project.feature b/features/project/project.feature
index 5fb2c67401e..089ffcba14a 100644
--- a/features/project/project.feature
+++ b/features/project/project.feature
@@ -18,6 +18,15 @@ Feature: Project
Then I should see the default project avatar
And I should not see the "Remove avatar" button
+ Scenario: I should have back to group button
+ And project "Shop" belongs to group
+ And I visit project "Shop" page
+ Then I should see back to group button
+
+ Scenario: I should have back to group button
+ And I visit project "Shop" page
+ Then I should see back to dashboard button
+
Scenario: I should have readme on page
And I visit project "Shop" page
Then I should see project "Shop" README
diff --git a/features/steps/groups.rb b/features/steps/groups.rb
index 2812c5473e9..46e1f4d0990 100644
--- a/features/steps/groups.rb
+++ b/features/steps/groups.rb
@@ -5,6 +5,10 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
include SharedUser
include Select2Helper
+ step 'I should see back to dashboard button' do
+ expect(page).to have_content 'Back to Dashboard'
+ end
+
step 'gitlab user "Mike"' do
create(:user, name: "Mike")
end
diff --git a/features/steps/project/project.rb b/features/steps/project/project.rb
index e8f9a80737f..0404fd5e594 100644
--- a/features/steps/project/project.rb
+++ b/features/steps/project/project.rb
@@ -116,4 +116,18 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step 'I should not see "Snippets" button' do
expect(page).not_to have_link 'Snippets'
end
+
+ step 'project "Shop" belongs to group' do
+ group = create(:group)
+ @project.namespace = group
+ @project.save!
+ end
+
+ step 'I should see back to dashboard button' do
+ expect(page).to have_content 'Back to Dashboard'
+ end
+
+ step 'I should see back to group button' do
+ expect(page).to have_content 'Back to Group'
+ end
end
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index 582fc759efd..335dc44be19 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -47,6 +47,10 @@ module Gitlab
def valid_level?(level)
options.has_value?(level)
end
+
+ def allowed_fork_levels(origin_level)
+ [PRIVATE, INTERNAL, PUBLIC].select{ |level| level <= origin_level }
+ end
end
def private?
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 14c8c29d008..a42ccb9b501 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -137,7 +137,7 @@ describe GitlabMarkdownHelper do
describe 'random_markdown_tip' do
it 'returns a random Markdown tip' do
stub_const("#{described_class}::MARKDOWN_TIPS", ['Random tip'])
- expect(random_markdown_tip).to eq 'Tip: Random tip'
+ expect(random_markdown_tip).to eq 'Random tip'
end
end
end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 0f78725e3d9..beb9b4e438e 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -8,4 +8,48 @@ describe ProjectsHelper do
expect(project_status_css_class("finished")).to eq("success")
end
end
+
+ describe "can_change_visibility_level?" do
+ let(:project) { create(:project) }
+
+ let(:fork_project) do
+ fork_project = create(:forked_project_with_submodules)
+ fork_project.build_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id)
+ fork_project.save
+
+ fork_project
+ end
+
+ let(:user) { create(:user) }
+
+ it "returns false if there are no approipriate permissions" do
+ allow(helper).to receive(:can?) { false }
+
+ expect(helper.can_change_visibility_level?(project, user)).to be_falsey
+ end
+
+ it "returns true if there are permissions and it is not fork" do
+ allow(helper).to receive(:can?) { true }
+
+ expect(helper.can_change_visibility_level?(project, user)).to be_truthy
+ end
+
+ context "forks" do
+ it "returns false if there are permissions and origin project is PRIVATE" do
+ allow(helper).to receive(:can?) { true }
+
+ project.update visibility_level: Gitlab::VisibilityLevel::PRIVATE
+
+ expect(helper.can_change_visibility_level?(fork_project, user)).to be_falsey
+ end
+
+ it "returns true if there are permissions and origin project is INTERNAL" do
+ allow(helper).to receive(:can?) { true }
+
+ project.update visibility_level: Gitlab::VisibilityLevel::INTERNAL
+
+ expect(helper.can_change_visibility_level?(fork_project, user)).to be_truthy
+ end
+ end
+ end
end
diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb
index 3840e64981f..c4f7693329c 100644
--- a/spec/helpers/visibility_level_helper_spec.rb
+++ b/spec/helpers/visibility_level_helper_spec.rb
@@ -72,4 +72,43 @@ describe VisibilityLevelHelper do
end
end
end
+
+ describe "skip_level?" do
+ describe "forks" do
+ let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
+ let(:fork_project) { create(:forked_project_with_submodules) }
+
+ before do
+ fork_project.build_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id)
+ fork_project.save
+ end
+
+ it "skips levels" do
+ expect(skip_level?(fork_project, Gitlab::VisibilityLevel::PUBLIC)).to be_truthy
+ expect(skip_level?(fork_project, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey
+ expect(skip_level?(fork_project, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey
+ end
+ end
+
+ describe "non-forked project" do
+ let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
+
+ it "skips levels" do
+ expect(skip_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey
+ expect(skip_level?(project, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey
+ expect(skip_level?(project, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey
+ end
+ end
+
+ describe "Snippet" do
+ let(:snippet) { create(:snippet, visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
+
+ it "skips levels" do
+ expect(skip_level?(snippet, Gitlab::VisibilityLevel::PUBLIC)).to be_falsey
+ expect(skip_level?(snippet, Gitlab::VisibilityLevel::INTERNAL)).to be_falsey
+ expect(skip_level?(snippet, Gitlab::VisibilityLevel::PRIVATE)).to be_falsey
+ end
+ end
+
+ end
end