Commit 20f01509 authored by Doug Stull's avatar Doug Stull Committed by Miguel Rincon

Clean up import and other invite members modal rollout pieces

- no longer need these routes or javascript items

Changelog: removed
parent 894ad5e3
import $ from 'jquery';
import Pikaday from 'pikaday';
import { parsePikadayDate, pikadayToString } from './lib/utils/datetime_utility';
// Add datepickers to all `js-access-expiration-date` elements. If those elements are
// children of an element with the `clearable-input` class, and have a sibling
// `js-clear-input` element, then show that element when there is a value in the
// datepicker, and make clicking on that element clear the field.
//
export default function memberExpirationDate(selector = '.js-access-expiration-date') {
function toggleClearInput() {
$(this)
.closest('.clearable-input')
.toggleClass('has-value', $(this).val() !== '');
}
const inputs = $(selector);
inputs.each((i, el) => {
const $input = $(el);
const calendar = new Pikaday({
field: $input.get(0),
theme: 'gitlab-theme animate-picker',
format: 'yyyy-mm-dd',
minDate: new Date(),
container: $input.parent().get(0),
parse: (dateString) => parsePikadayDate(dateString),
toString: (date) => pikadayToString(date),
onSelect(dateText) {
$input.val(calendar.toString(dateText));
toggleClearInput.call($input);
},
firstDay: gon.first_day_of_week,
});
calendar.setDate(parsePikadayDate($input.val()));
$input.data('pikaday', calendar);
});
inputs.next('.js-clear-input').on('click', function clicked(event) {
event.preventDefault();
const input = $(this).closest('.clearable-input').find(selector);
const calendar = input.data('pikaday');
calendar.setDate(null);
toggleClearInput.call(input);
});
inputs.on('blur', toggleClearInput);
inputs.each(toggleClearInput);
}
import { groupMemberRequestFormatter } from '~/groups/members/utils'; import { groupMemberRequestFormatter } from '~/groups/members/utils';
import groupsSelect from '~/groups_select';
import initInviteGroupTrigger from '~/invite_members/init_invite_group_trigger'; import initInviteGroupTrigger from '~/invite_members/init_invite_group_trigger';
import initInviteGroupsModal from '~/invite_members/init_invite_groups_modal'; import initInviteGroupsModal from '~/invite_members/init_invite_groups_modal';
import initInviteMembersModal from '~/invite_members/init_invite_members_modal'; import initInviteMembersModal from '~/invite_members/init_invite_members_modal';
import initInviteMembersTrigger from '~/invite_members/init_invite_members_trigger'; import initInviteMembersTrigger from '~/invite_members/init_invite_members_trigger';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import memberExpirationDate from '~/member_expiration_date';
import { initMembersApp } from '~/members'; import { initMembersApp } from '~/members';
import { MEMBER_TYPES } from '~/members/constants'; import { MEMBER_TYPES } from '~/members/constants';
import { groupLinkRequestFormatter } from '~/members/utils'; import { groupLinkRequestFormatter } from '~/members/utils';
import UsersSelect from '~/users_select';
const SHARED_FIELDS = ['account', 'maxRole', 'expiration', 'actions']; const SHARED_FIELDS = ['account', 'maxRole', 'expiration', 'actions'];
...@@ -52,12 +49,7 @@ initMembersApp(document.querySelector('.js-group-members-list-app'), { ...@@ -52,12 +49,7 @@ initMembersApp(document.querySelector('.js-group-members-list-app'), {
}, },
}); });
groupsSelect();
memberExpirationDate();
memberExpirationDate('.js-access-expiration-date-groups');
initInviteMembersModal(); initInviteMembersModal();
initInviteGroupsModal(); initInviteGroupsModal();
initInviteMembersTrigger(); initInviteMembersTrigger();
initInviteGroupTrigger(); initInviteGroupTrigger();
new UsersSelect(); // eslint-disable-line no-new
import groupsSelect from '~/groups_select';
import initImportAProjectModal from '~/invite_members/init_import_a_project_modal'; import initImportAProjectModal from '~/invite_members/init_import_a_project_modal';
import initInviteGroupTrigger from '~/invite_members/init_invite_group_trigger'; import initInviteGroupTrigger from '~/invite_members/init_invite_group_trigger';
import initInviteMembersModal from '~/invite_members/init_invite_members_modal'; import initInviteMembersModal from '~/invite_members/init_invite_members_modal';
import initInviteGroupsModal from '~/invite_members/init_invite_groups_modal'; import initInviteGroupsModal from '~/invite_members/init_invite_groups_modal';
import initInviteMembersTrigger from '~/invite_members/init_invite_members_trigger'; import initInviteMembersTrigger from '~/invite_members/init_invite_members_trigger';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import memberExpirationDate from '~/member_expiration_date';
import { initMembersApp } from '~/members'; import { initMembersApp } from '~/members';
import { MEMBER_TYPES } from '~/members/constants'; import { MEMBER_TYPES } from '~/members/constants';
import { groupLinkRequestFormatter } from '~/members/utils'; import { groupLinkRequestFormatter } from '~/members/utils';
import { projectMemberRequestFormatter } from '~/projects/members/utils'; import { projectMemberRequestFormatter } from '~/projects/members/utils';
import UsersSelect from '~/users_select';
groupsSelect();
memberExpirationDate();
memberExpirationDate('.js-access-expiration-date-groups');
initImportAProjectModal(); initImportAProjectModal();
initInviteMembersModal(); initInviteMembersModal();
initInviteGroupsModal(); initInviteGroupsModal();
initInviteMembersTrigger(); initInviteMembersTrigger();
initInviteGroupTrigger(); initInviteGroupTrigger();
new UsersSelect(); // eslint-disable-line no-new
const SHARED_FIELDS = ['account', 'maxRole', 'expiration', 'actions']; const SHARED_FIELDS = ['account', 'maxRole', 'expiration', 'actions'];
initMembersApp(document.querySelector('.js-project-members-list-app'), { initMembersApp(document.querySelector('.js-project-members-list-app'), {
[MEMBER_TYPES.user]: { [MEMBER_TYPES.user]: {
......
...@@ -24,23 +24,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController ...@@ -24,23 +24,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@project_members = present_members(non_invited_members.page(params[:page])) @project_members = present_members(non_invited_members.page(params[:page]))
end end
def import
@projects = Project.visible_to_user_and_access_level(current_user, Gitlab::Access::MAINTAINER).order_id_desc
end
def apply_import
source_project = Project.find(params[:source_project_id])
if can?(current_user, :admin_project_member, source_project)
status = @project.team.import(source_project, current_user)
notice = status ? "Successfully imported" : "Import failed"
else
return render_404
end
redirect_to(project_project_members_path(project), notice: notice)
end
# MembershipActions concern # MembershipActions concern
alias_method :membershipable, :project alias_method :membershipable, :project
......
- page_title _("Import members")
%h3.page-title
= _("Import members from another project")
%p.light
= _("Only project members will be imported. Group members will be skipped.")
%hr
= form_tag apply_import_project_project_members_path(@project), method: 'post' do
.form-group.row
= label_tag :source_project_id, _("Project"), class: 'col-form-label col-sm-2'
.col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(@projects, :id, :name_with_namespace), prompt: "Select project", class: "select2 lg", required: true)
.form-actions
= button_tag _('Import project members'), class: "btn gl-button btn-success"
= link_to _("Cancel"), project_project_members_path(@project), class: "btn gl-button btn-cancel"
...@@ -166,11 +166,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -166,11 +166,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :project_members, except: [:show, :new, :create, :edit], constraints: { id: %r{[a-zA-Z./0-9_\-#%+:]+} }, concerns: :access_requestable do resources :project_members, except: [:show, :new, :create, :edit], constraints: { id: %r{[a-zA-Z./0-9_\-#%+:]+} }, concerns: :access_requestable do
collection do collection do
delete :leave delete :leave
# Used for import team
# from another project
get :import
post :apply_import
end end
member do member do
......
...@@ -122,11 +122,11 @@ To import users: ...@@ -122,11 +122,11 @@ To import users:
1. On the top bar, select **Menu > Projects** and find your project. 1. On the top bar, select **Menu > Projects** and find your project.
1. On the left sidebar, select **Project information > Members**. 1. On the left sidebar, select **Project information > Members**.
1. On the **Invite member** tab, at the bottom of the panel, select **Import**. 1. Select **Import from a project**.
1. Select the project. You can view only the projects for which you're a maintainer. 1. Select the project. You can view only the projects for which you're a maintainer.
1. Select **Import project members**. 1. Select **Import project members**.
A success message is displayed and the new members are now displayed in the list. After the success message displays, refresh the page to view the new members.
## Inherited membership ## Inherited membership
......
# frozen_string_literal: true
require('spec_helper')
RSpec.describe Projects::ProjectMembersController do
let(:user) { create(:user) }
let(:project) { create(:project, :public, namespace: namespace) }
let(:namespace) { create :group }
describe 'POST apply_import' do
subject(:apply_import) do
post(:apply_import, params: {
namespace_id: project.namespace,
project_id: project,
source_project_id: another_project.id
})
end
let(:another_project) { create(:project, :private) }
let(:member) { create(:user) }
before do
project.add_maintainer(user)
another_project.add_guest(member)
sign_in(user)
end
context 'when user can access source project members' do
before do
another_project.add_guest(user)
end
context 'and the project group has membership lock enabled' do
before do
project.namespace.update!(membership_lock: true)
end
it 'responds with 403' do
apply_import
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
end
describe 'GET import' do
subject(:import) do
get :import, params: {
namespace_id: project.namespace,
project_id: project
}
end
before do
project.add_maintainer(user)
sign_in(user)
end
context 'when project group has membership lock enabled' do
before do
project.namespace.update!(membership_lock: true)
end
it 'responds with 403' do
import
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
end
...@@ -18607,12 +18607,6 @@ msgstr "" ...@@ -18607,12 +18607,6 @@ msgstr ""
msgid "Import issues" msgid "Import issues"
msgstr "" msgstr ""
msgid "Import members"
msgstr ""
msgid "Import members from another project"
msgstr ""
msgid "Import multiple repositories by uploading a manifest file." msgid "Import multiple repositories by uploading a manifest file."
msgstr "" msgstr ""
...@@ -18622,9 +18616,6 @@ msgstr "" ...@@ -18622,9 +18616,6 @@ msgstr ""
msgid "Import project from" msgid "Import project from"
msgstr "" msgstr ""
msgid "Import project members"
msgstr ""
msgid "Import projects from Bitbucket" msgid "Import projects from Bitbucket"
msgstr "" msgstr ""
...@@ -25765,9 +25756,6 @@ msgstr "" ...@@ -25765,9 +25756,6 @@ msgstr ""
msgid "Only project members can comment." msgid "Only project members can comment."
msgstr "" msgstr ""
msgid "Only project members will be imported. Group members will be skipped."
msgstr ""
msgid "Only projects created under a Ultimate license are available in Security Dashboards." msgid "Only projects created under a Ultimate license are available in Security Dashboards."
msgstr "" msgstr ""
......
...@@ -472,59 +472,6 @@ RSpec.describe Projects::ProjectMembersController do ...@@ -472,59 +472,6 @@ RSpec.describe Projects::ProjectMembersController do
end end
end end
describe 'POST apply_import' do
let_it_be(:another_project) { create(:project, :private) }
let_it_be(:member) { create(:user) }
before do
project.add_maintainer(user)
another_project.add_guest(member)
sign_in(user)
end
shared_context 'import applied' do
before do
post(:apply_import, params: {
namespace_id: project.namespace,
project_id: project,
source_project_id: another_project.id
})
end
end
context 'when user can admin source project members' do
before do
another_project.add_maintainer(user)
end
include_context 'import applied'
it 'imports source project members', :aggregate_failures do
expect(project.team_members).to include member
expect(controller).to set_flash.to 'Successfully imported'
expect(response).to redirect_to(
project_project_members_path(project)
)
end
end
context "when user can't admin source project members" do
before do
another_project.add_developer(user)
end
include_context 'import applied'
it 'does not import team members' do
expect(project.team_members).not_to include member
end
it 'responds with not found' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
describe 'POST resend_invite' do describe 'POST resend_invite' do
let_it_be(:member) { create(:project_member, project: project) } let_it_be(:member) { create(:project_member, project: project) }
......
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