Commit aa7e0513 authored by Annabel Dunstone Gray's avatar Annabel Dunstone Gray

Merge branch 'ce#31853-projects-shared-groups' into 'master'

31853 Remove duplication for sharing projects with groups in project settings

Closes #31853

See merge request !11951
parents 7bd5b8c1 59b0f3e5
...@@ -3,6 +3,41 @@ ...@@ -3,6 +3,41 @@
border-bottom: 1px solid $border-color; border-bottom: 1px solid $border-color;
} }
.project-member-tabs {
background: $gray-light;
border: 1px solid $border-color;
li {
width: 50%;
&.active {
background: $white-light;
}
&:first-child {
border-right: 1px solid $border-color;
}
a {
width: 100%;
text-align: center;
}
}
}
.users-project-form {
.btn-create {
margin-right: 10px;
}
}
.project-member-tab-content {
padding: $gl-padding;
border: 1px solid $border-color;
border-top: 0;
margin-bottom: $gl-padding;
}
.member { .member {
.list-item-name { .list-item-name {
@media (min-width: $screen-sm-min) { @media (min-width: $screen-sm-min) {
......
.row.prepend-top-default .row.prepend-top-default
.col-lg-3.settings-sidebar .col-lg-3.settings-sidebar
%h4.prepend-top-0 %h4.prepend-top-0
Members Project members
- if can?(current_user, :admin_project_member, @project) - if can?(current_user, :admin_project_member, @project)
%p %p
Add a new member to You can add a new member to
%strong= @project.name %strong= @project.name
or share it with another group.
- else - else
%p %p
Members can be added by project Members can be added by project
...@@ -13,9 +14,20 @@ ...@@ -13,9 +14,20 @@
or or
%i Owners %i Owners
.col-lg-9 .col-lg-9
.light.prepend-top-default .light
- if can?(current_user, :admin_project_member, @project) - if can?(current_user, :admin_project_member, @project)
= render "projects/project_members/new_project_member" %ul.nav-links.project-member-tabs{ role: 'tablist' }
%li.active{ role: 'presentation' }
%a{ href: '#add-member-pane', id: 'add-member-tab', data: { toggle: 'tab' }, role: 'tab' } Add member
- if @project.allowed_to_share_with_group?
%li{ role: 'presentation' }
%a{ href: '#share-with-group-pane', id: 'share-with-group-tab', data: { toggle: 'tab' }, role: 'tab' } Share with group
.tab-content.project-member-tab-content
.tab-pane.active{ id: 'add-member-pane', role: 'tabpanel' }
= render 'projects/project_members/new_project_member', tab_title: 'Add member'
.tab-pane{ id: 'share-with-group-pane', role: 'tabpanel' }
= render 'projects/project_members/new_shared_group', tab_title: 'Share with group'
= render 'shared/members/requests', membership_source: @project, requesters: @requesters = render 'shared/members/requests', membership_source: @project, requesters: @requesters
.clearfix .clearfix
......
= form_for @project_member, as: :project_member, url: namespace_project_project_members_path(@project.namespace, @project), html: { class: 'users-project-form' } do |f| .row
.col-sm-12
= form_for @project_member, as: :project_member, url: namespace_project_project_members_path(@project.namespace, @project), html: { class: 'users-project-form' } do |f|
.form-group .form-group
= label_tag :user_ids, "Select members to invite", class: "label-light"
= users_select_tag(:user_ids, multiple: true, class: "input-clamp", scope: :all, email_user: true, placeholder: "Search for members to update or invite") = users_select_tag(:user_ids, multiple: true, class: "input-clamp", scope: :all, email_user: true, placeholder: "Search for members to update or invite")
.help-block.append-bottom-10
Search for members by name, username, or email, or invite new ones using their email address.
.form-group .form-group
= label_tag :access_level, "Choose a role permission", class: "label-light"
= select_tag :access_level, options_for_select(ProjectMember.access_level_roles, @project_member.access_level), class: "form-control project-access-select" = select_tag :access_level, options_for_select(ProjectMember.access_level_roles, @project_member.access_level), class: "form-control project-access-select"
.help-block.append-bottom-10 .help-block.append-bottom-10
= link_to "Read more", help_page_path("user/permissions"), class: "vlink" = link_to "Read more", help_page_path("user/permissions"), class: "vlink"
about role permissions about role permissions
.form-group .form-group
.clearable-input .clearable-input
= label_tag :expires_at, 'Access expiration date', class: 'label-light'
= text_field_tag :expires_at, nil, class: 'form-control js-access-expiration-date', placeholder: 'Expiration date' = text_field_tag :expires_at, nil, class: 'form-control js-access-expiration-date', placeholder: 'Expiration date'
%i.clear-icon.js-clear-input %i.clear-icon.js-clear-input
.help-block.append-bottom-10
On this date, the member(s) will automatically lose access to this project.
= f.submit "Add to project", class: "btn btn-create" = f.submit "Add to project", class: "btn btn-create"
= link_to "Import", import_namespace_project_project_members_path(@project.namespace, @project), class: "btn btn-default", title: "Import members from another project" = link_to "Import", import_namespace_project_project_members_path(@project.namespace, @project), class: "btn btn-default", title: "Import members from another project"
- page_title "Groups" .row
.row.prepend-top-default .col-sm-12
.col-lg-3.settings-sidebar
%h4.prepend-top-0
Share project with other groups
%p
Projects can be stored in only one group at once. However you can share a project with other groups here.
.col-lg-9
= form_tag namespace_project_group_links_path(@project.namespace, @project), class: 'js-requires-input', method: :post do = form_tag namespace_project_group_links_path(@project.namespace, @project), class: 'js-requires-input', method: :post do
.form-group .form-group
= label_tag :link_group_id, "Select a group to share with", class: "label-light" = label_tag :link_group_id, "Select a group to share with", class: "label-light"
= groups_select_tag(:link_group_id, data: { skip_groups: @skip_groups }, required: true) = groups_select_tag(:link_group_id, data: { skip_groups: @skip_groups }, class: "input-clamp", required: true)
.form-group .form-group
= label_tag :link_group_access, "Max access level", class: "label-light" = label_tag :link_group_access, "Max access level", class: "label-light"
.select-wrapper .select-wrapper
= select_tag :link_group_access, options_for_select(ProjectGroupLink.access_options, ProjectGroupLink.default_access), class: "form-control select-control" = select_tag :link_group_access, options_for_select(ProjectGroupLink.access_options, ProjectGroupLink.default_access), class: "form-control select-control"
= icon('caret-down') = icon('caret-down')
.help-block.append-bottom-10
= link_to "Read more", help_page_path("user/permissions"), class: "vlink"
about role permissions
.form-group .form-group
= label_tag :expires_at, 'Access expiration date', class: 'label-light' = label_tag :expires_at, 'Access expiration date', class: 'label-light'
.clearable-input .clearable-input
= text_field_tag :expires_at, nil, class: 'form-control js-access-expiration-date-groups', placeholder: 'Select access expiration date', id: 'expires_at_groups' = text_field_tag :expires_at, nil, class: 'form-control js-access-expiration-date-groups', placeholder: 'Expiration date', id: 'expires_at_groups'
%i.clear-icon.js-clear-input %i.clear-icon.js-clear-input
.help-block
On this date, all members in the group will automatically lose access to this project.
= submit_tag "Share", class: "btn btn-create" = submit_tag "Share", class: "btn btn-create"
.col-lg-9.col-lg-offset-3
%hr
.col-lg-9.col-lg-offset-3.append-bottom-default.enabled-groups
%h5.prepend-top-0
Groups you share with (#{@group_links.size})
- if @group_links.present?
%ul.well-list
- @group_links.each do |group_link|
- group = group_link.group
%li
.pull-left.append-right-10.hidden-xs
= icon("folder-open-o", class: "settings-list-icon")
.pull-left
= link_to group do
= group.full_name
%br
up to #{group_link.human_access}
- if group_link.expires?
·
%span{ class: ('text-warning' if group_link.expires_soon?) }
expires in #{distance_of_time_in_words_to_now(group_link.expires_at)}
.pull-right
= link_to namespace_project_group_link_path(@project.namespace, @project, group_link), method: :delete, class: "btn btn-transparent" do
%span.sr-only disable sharing
= icon("trash")
- else
.settings-message.text-center
There are no groups with access to your project, add one in the form above
...@@ -2,6 +2,3 @@ ...@@ -2,6 +2,3 @@
= render "projects/settings/head" = render "projects/settings/head"
= render "projects/project_members/index" = render "projects/project_members/index"
- if can?(current_user, :admin_project, @project)
- if @project.allowed_to_share_with_group?
= render "projects/group_links/index"
---
title: Remove duplication for sharing projects with groups in project settings
merge_request:
author:
...@@ -5,18 +5,19 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps ...@@ -5,18 +5,19 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
include Select2Helper include Select2Helper
step 'I should see project already shared with group "Ops"' do step 'I should see project already shared with group "Ops"' do
page.within '.enabled-groups' do page.within '.project-members-groups' do
expect(page).to have_content "Ops" expect(page).to have_content "Ops"
end end
end end
step 'I should see project is not shared with group "Market"' do step 'I should see project is not shared with group "Market"' do
page.within '.enabled-groups' do page.within '.project-members-groups' do
expect(page).not_to have_content "Market" expect(page).not_to have_content "Market"
end end
end end
step 'I select group "Market" for share' do step 'I select group "Market" for share' do
click_link 'Share with group'
group = Group.find_by(path: 'market') group = Group.find_by(path: 'market')
select2(group.id, from: "#link_group_id") select2(group.id, from: "#link_group_id")
select "Master", from: 'link_group_access' select "Master", from: 'link_group_access'
...@@ -24,7 +25,7 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps ...@@ -24,7 +25,7 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
end end
step 'I should see project is shared with group "Market"' do step 'I should see project is shared with group "Market"' do
page.within '.enabled-groups' do page.within '.project-members-groups' do
expect(page).to have_content "Market" expect(page).to have_content "Market"
end end
end end
......
...@@ -16,15 +16,17 @@ feature 'Project group links', :feature, :js do ...@@ -16,15 +16,17 @@ feature 'Project group links', :feature, :js do
before do before do
visit namespace_project_settings_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
click_on 'share-with-group-tab'
select2 group.id, from: '#link_group_id' select2 group.id, from: '#link_group_id'
fill_in 'expires_at_groups', with: (Time.current + 4.5.days).strftime('%Y-%m-%d') fill_in 'expires_at_groups', with: (Time.current + 4.5.days).strftime('%Y-%m-%d')
page.find('body').click page.find('body').click
click_on 'Share' find('.btn-create').trigger('click')
end end
it 'shows the expiration time with a warning class' do it 'shows the expiration time with a warning class' do
page.within('.enabled-groups') do page.within('.project-members-groups') do
expect(page).to have_content('expires in 4 days') expect(page).to have_content('Expires in 4 days')
expect(page).to have_selector('.text-warning') expect(page).to have_selector('.text-warning')
end end
end end
...@@ -43,6 +45,7 @@ feature 'Project group links', :feature, :js do ...@@ -43,6 +45,7 @@ feature 'Project group links', :feature, :js do
it 'does not show ancestors', :nested_groups do it 'does not show ancestors', :nested_groups do
visit namespace_project_settings_members_path(project.namespace, project) visit namespace_project_settings_members_path(project.namespace, project)
click_on 'share-with-group-tab'
click_link 'Search for a group' click_link 'Search for a group'
page.within '.select2-drop' do page.within '.select2-drop' do
......
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