Commit 5c2bdf2a authored by Jannik Lehmann's avatar Jannik Lehmann Committed by David O'Regan

Replace window.confirm with GlModal for repository index

This commit replaces window.confirm dialog with
a GlModal when locking a path.

Changelog: changed
parent 46099516
......@@ -2,6 +2,7 @@ import Vue from 'vue';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal';
import initTree from '~/repository';
import CodeOwners from './components/code_owners.vue';
......@@ -13,7 +14,7 @@ export default () => {
if (!toggleBtn) return;
toggleBtn.addEventListener('click', (e) => {
toggleBtn.addEventListener('click', async (e) => {
e.preventDefault();
const { dataset } = e.target;
......@@ -22,8 +23,9 @@ export default () => {
? __('Are you sure you want to lock this directory?')
: __('Are you sure you want to unlock this directory?');
// eslint-disable-next-line no-alert
if (!window.confirm(message)) {
const confirmed = await confirmAction(message);
if (!confirmed) {
return;
}
......
......@@ -23,7 +23,15 @@ RSpec.describe 'Path Locks', :js do
click_link "encoding"
end
accept_confirm(text: 'Are you sure you want to lock this directory?') { find('.js-path-lock').click }
find('.js-path-lock').click
wait_for_requests
page.within '.modal' do
expect(page).to have_selector('.modal-body', visible: true)
expect(page).to have_css('.modal-body', text: 'Are you sure you want to lock this directory?')
click_button "OK"
end
expect(page).to have_link('Unlock')
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