Commit ecd0c175 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'dz-nested-groups-title-ui' into 'master'

UI improvements for nested group feature

See merge request !8062
parents 49a70d1e 82f9957d
...@@ -12,11 +12,18 @@ module GroupsHelper ...@@ -12,11 +12,18 @@ module GroupsHelper
end end
def group_title(group, name = nil, url = nil) def group_title(group, name = nil, url = nil)
full_title = link_to(simple_sanitize(group.name), group_path(group)) full_title = ''
group.parents.each do |parent|
full_title += link_to(simple_sanitize(parent.name), group_path(parent))
full_title += ' / '.html_safe
end
full_title += link_to(simple_sanitize(group.name), group_path(group))
full_title += ' · '.html_safe + link_to(simple_sanitize(name), url) if name full_title += ' · '.html_safe + link_to(simple_sanitize(name), url) if name
content_tag :span do content_tag :span do
full_title full_title.html_safe
end end
end end
......
...@@ -52,7 +52,7 @@ module ProjectsHelper ...@@ -52,7 +52,7 @@ module ProjectsHelper
def project_title(project) def project_title(project)
namespace_link = namespace_link =
if project.group if project.group
link_to(simple_sanitize(project.group.name), group_path(project.group)) group_title(project.group)
else else
owner = project.namespace.owner owner = project.namespace.owner
link_to(simple_sanitize(owner.name), user_path(owner)) link_to(simple_sanitize(owner.name), user_path(owner))
...@@ -390,7 +390,7 @@ module ProjectsHelper ...@@ -390,7 +390,7 @@ module ProjectsHelper
"success" "success"
end end
end end
def readme_cache_key def readme_cache_key
sha = @project.commit.try(:sha) || 'nil' sha = @project.commit.try(:sha) || 'nil'
[@project.path_with_namespace, sha, "readme"].join('-') [@project.path_with_namespace, sha, "readme"].join('-')
......
...@@ -83,7 +83,7 @@ class Group < Namespace ...@@ -83,7 +83,7 @@ class Group < Namespace
end end
def human_name def human_name
name full_name
end end
def visibility_level_field def visibility_level_field
......
...@@ -161,6 +161,19 @@ class Namespace < ActiveRecord::Base ...@@ -161,6 +161,19 @@ class Namespace < ActiveRecord::Base
end end
end end
def full_name
@full_name ||=
if parent
parent.full_name + ' / ' + name
else
name
end
end
def parents
@parents ||= parent ? parent.parents + [parent] : []
end
private private
def repository_storage_paths def repository_storage_paths
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
= image_tag group_icon(group), class: "avatar s40 hidden-xs" = image_tag group_icon(group), class: "avatar s40 hidden-xs"
.title .title
= link_to [:admin, group], class: 'group-name' do = link_to [:admin, group], class: 'group-name' do
= group.name = group.full_name
- if group.description.present? - if group.description.present?
.description .description
......
- page_title @group.name, "Groups" - page_title @group.name, "Groups"
%h3.page-title %h3.page-title
Group: #{@group.name} Group: #{@group.full_name}
= link_to admin_group_edit_path(@group), class: "btn pull-right" do = link_to admin_group_edit_path(@group), class: "btn pull-right" do
%i.fa.fa-pencil-square-o %i.fa.fa-pencil-square-o
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
= image_tag group_icon(group), class: "avatar s40 hidden-xs" = image_tag group_icon(group), class: "avatar s40 hidden-xs"
.title .title
= link_to group, class: 'group-name' do = link_to group, class: 'group-name' do
= group.name = group.full_name
- if group_member - if group_member
as as
......
...@@ -128,4 +128,26 @@ describe Namespace, models: true do ...@@ -128,4 +128,26 @@ describe Namespace, models: true do
it { expect(group.full_path).to eq(group.path) } it { expect(group.full_path).to eq(group.path) }
it { expect(nested_group.full_path).to eq("#{group.path}/#{nested_group.path}") } it { expect(nested_group.full_path).to eq("#{group.path}/#{nested_group.path}") }
end end
describe '#full_name' do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
it { expect(group.full_name).to eq(group.name) }
it { expect(nested_group.full_name).to eq("#{group.name} / #{nested_group.name}") }
end
describe '#parents' do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let(:deep_nested_group) { create(:group, parent: nested_group) }
let(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
it 'returns the correct parents' do
expect(very_deep_nested_group.parents).to eq([group, nested_group, deep_nested_group])
expect(deep_nested_group.parents).to eq([group, nested_group])
expect(nested_group.parents).to eq([group])
expect(group.parents).to eq([])
end
end
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