Commit 83a59b9c authored by Matthias Käppler's avatar Matthias Käppler

Merge branch...

Merge branch '330902-ldap-synchronization-should-warn-before-it-kills-direct-member-list' into 'master'

Add confirmation modal to "Sync now" LDAP button

See merge request gitlab-org/gitlab!64555
parents d29f4674 9c316cc3
import '~/pages/groups/group_members';
import initConfirmModal from '~/confirm_modal';
const LDAP_SYNC_NOW_BUTTON_SELECTOR = '.js-ldap-sync-now-button';
if (document.querySelector(LDAP_SYNC_NOW_BUTTON_SELECTOR)) {
initConfirmModal({ selector: LDAP_SYNC_NOW_BUTTON_SELECTOR });
}
# frozen_string_literal: true
module GroupMembersHelper
def clear_ldap_permission_cache_message
markdown(
<<-EOT.strip_heredoc
Be careful, all members of this group (except you) will have their
**access level temporarily downgraded** to `Guest`. The next time that a group member
signs in to GitLab (or after one hour, whichever occurs first) their access level will
be updated to the one specified on the Group settings page.
EOT
)
end
end
# frozen_string_literal: true
module Groups::LdapSyncHelper
def ldap_sync_now_button_data(group)
{
method: :put,
path: sync_group_ldap_path(group),
modal_attributes: {
message: _("Warning: Synchronizing LDAP removes direct members' access."),
title: _('Synchronize LDAP'),
size: 'sm',
actionPrimary: {
text: _('Sync LDAP'),
attributes: [{ variant: 'danger', 'data-qa-selector': 'sync_ldap_confirm_button' }]
},
actionSecondary: {
text: _('Cancel'),
attributes: [{ variant: 'default' }]
}
}.to_json
}
end
end
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= sprite_icon("retry", css_class: 'spin gl-mr-2') = sprite_icon("retry", css_class: 'spin gl-mr-2')
= _('Pending sync…') = _('Pending sync…')
- else - else
= link_to sync_group_ldap_path(@group), method: :put, class: 'btn btn-default gl-button qa-sync-now-button' do %button.js-ldap-sync-now-button.btn.btn-default.gl-button.qa-sync-now-button{ data: ldap_sync_now_button_data(@group) }
= sprite_icon("retry", css_class: "gl-mr-2") = sprite_icon("retry", css_class: "gl-mr-2")
= _('Sync now') = _('Sync now')
- if @group.ldap_sync_ready? && @group.ldap_sync_last_successful_update_at - if @group.ldap_sync_ready? && @group.ldap_sync_last_successful_update_at
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::LdapSyncHelper do
let_it_be(:group) { build(:group) }
describe '#ldap_sync_now_button_data' do
sync_group_ldap_path = '/groups/foo-bar/-/ldap/sync'
before do
allow(helper).to receive(:sync_group_ldap_path).with(group).and_return(sync_group_ldap_path)
end
subject { helper.ldap_sync_now_button_data(group) }
it 'sets `path` key correctly' do
expect(subject[:path]).to eq(sync_group_ldap_path)
end
it 'sets `modal_attributes` key to valid json' do
expect(subject[:modal_attributes]).to be_valid_json
end
end
end
...@@ -31554,6 +31554,9 @@ msgstr "" ...@@ -31554,6 +31554,9 @@ msgstr ""
msgid "Symbolic link" msgid "Symbolic link"
msgstr "" msgstr ""
msgid "Sync LDAP"
msgstr ""
msgid "Sync now" msgid "Sync now"
msgstr "" msgstr ""
...@@ -31563,6 +31566,9 @@ msgstr "" ...@@ -31563,6 +31566,9 @@ msgstr ""
msgid "Synchronization settings" msgid "Synchronization settings"
msgstr "" msgstr ""
msgid "Synchronize LDAP"
msgstr ""
msgid "Syncing…" msgid "Syncing…"
msgstr "" msgstr ""
...@@ -36217,6 +36223,9 @@ msgstr "" ...@@ -36217,6 +36223,9 @@ msgstr ""
msgid "Warning: Displaying this diagram might cause performance issues on this page." msgid "Warning: Displaying this diagram might cause performance issues on this page."
msgstr "" msgstr ""
msgid "Warning: Synchronizing LDAP removes direct members' access."
msgstr ""
msgid "We are currently unable to fetch data for the pipeline header." msgid "We are currently unable to fetch data for the pipeline header."
msgstr "" msgstr ""
......
...@@ -9,8 +9,13 @@ module QA ...@@ -9,8 +9,13 @@ module QA
element :sync_now_button element :sync_now_button
end end
view 'ee/app/helpers/groups/ldap_sync_helper.rb' do
element :sync_ldap_confirm_button
end
def click_sync_now def click_sync_now
click_element :sync_now_button click_element :sync_now_button
click_element :sync_ldap_confirm_button
end end
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