Commit 178ec5fe authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Rémy Coutable

Replace confirm danger modal in remove project fork form

- Adds the shared confirm danger modal trigger
  button to the remove project fork form
- Wire the new modal button to the edit project form 
- Reinstates the remove fork project feature
  spec in `forked_project_settings_spec.rb`
parent 39af8313
import { PROJECT_BADGE } from '~/badges/constants'; import { PROJECT_BADGE } from '~/badges/constants';
import initLegacyConfirmDangerModal from '~/confirm_danger_modal'; import initLegacyConfirmDangerModal from '~/confirm_danger_modal';
import initConfirmDanger from '~/init_confirm_danger';
import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory'; import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory';
import initFilePickers from '~/file_pickers'; import initFilePickers from '~/file_pickers';
import mountBadgeSettings from '~/pages/shared/mount_badge_settings'; import mountBadgeSettings from '~/pages/shared/mount_badge_settings';
...@@ -15,6 +16,7 @@ import initProjectLoadingSpinner from '../shared/save_project_loader'; ...@@ -15,6 +16,7 @@ import initProjectLoadingSpinner from '../shared/save_project_loader';
initFilePickers(); initFilePickers();
initLegacyConfirmDangerModal(); initLegacyConfirmDangerModal();
initConfirmDanger();
initSettingsPanels(); initSettingsPanels();
initProjectDeleteButton(); initProjectDeleteButton();
mountBadgeSettings(PROJECT_BADGE); mountBadgeSettings(PROJECT_BADGE);
......
...@@ -326,10 +326,6 @@ ...@@ -326,10 +326,6 @@
} }
} }
.transfer-project .select2-container {
min-width: 200px;
}
.right-sidebar { .right-sidebar {
.block { .block {
.select2-container span { .select2-container span {
......
...@@ -126,6 +126,8 @@ class ProjectsController < Projects::ApplicationController ...@@ -126,6 +126,8 @@ class ProjectsController < Projects::ApplicationController
if ::Projects::UnlinkForkService.new(@project, current_user).execute if ::Projects::UnlinkForkService.new(@project, current_user).execute
flash[:notice] = _('The fork relationship has been removed.') flash[:notice] = _('The fork relationship has been removed.')
end end
redirect_to edit_project_path(@project)
end end
def activity def activity
......
...@@ -120,6 +120,15 @@ module ProjectsHelper ...@@ -120,6 +120,15 @@ module ProjectsHelper
{ project_full_name: project.full_name } { project_full_name: project.full_name }
end end
def remove_fork_project_confirm_json(project, remove_form_id)
{
remove_form_id: remove_form_id,
button_text: _('Remove fork relationship'),
confirm_danger_message: remove_fork_project_warning_message(project),
phrase: @project.path
}
end
def visible_fork_source(project) def visible_fork_source(project)
project.fork_source if project.fork_source && can?(current_user, :read_project, project.fork_source) project.fork_source if project.fork_source && can?(current_user, :read_project, project.fork_source)
end end
......
- return unless @project.forked? && can?(current_user, :remove_fork_project, @project) - return unless @project.forked? && can?(current_user, :remove_fork_project, @project)
- remove_form_id = "js-remove-project-fork-form"
.sub-section .sub-section
%h4.danger-title= _('Remove fork relationship') %h4.danger-title= _('Remove fork relationship')
%p= remove_fork_project_description_message(@project) %p= remove_fork_project_description_message(@project)
= form_for @project, url: remove_fork_project_path(@project), method: :delete, remote: true, html: { class: 'transfer-project' } do |f| = form_for @project, url: remove_fork_project_path(@project), method: :delete, html: { id: remove_form_id } do |f|
%p %p
%strong= _('Once removed, the fork relationship cannot be restored. This project will no longer be able to receive or send merge requests to the source project or other forks.') %strong= _('Once removed, the fork relationship cannot be restored. This project will no longer be able to receive or send merge requests to the source project or other forks.')
= link_to _('Learn more.'), help_page_path('user/project/settings/index', anchor: 'removing-a-fork-relationship'), target: '_blank', rel: 'noopener noreferrer' = link_to _('Learn more.'), help_page_path('user/project/settings/index', anchor: 'removing-a-fork-relationship'), target: '_blank', rel: 'noopener noreferrer'
= button_to _('Remove fork relationship'), '#', class: "gl-button btn btn-danger js-legacy-confirm-danger", data: { "confirm-danger-message" => remove_fork_project_warning_message(@project) } .js-confirm-danger{ data: remove_fork_project_confirm_json(@project, remove_form_id) }
:plain
location.href = "#{edit_project_path(@project)}";
...@@ -1092,7 +1092,7 @@ RSpec.describe ProjectsController do ...@@ -1092,7 +1092,7 @@ RSpec.describe ProjectsController do
expect(forked_project.reload.forked?).to be_falsey expect(forked_project.reload.forked?).to be_falsey
expect(flash[:notice]).to eq(s_('The fork relationship has been removed.')) expect(flash[:notice]).to eq(s_('The fork relationship has been removed.'))
expect(response).to render_template(:remove_fork) expect(response).to redirect_to(edit_project_path(forked_project))
end end
end end
...@@ -1108,7 +1108,7 @@ RSpec.describe ProjectsController do ...@@ -1108,7 +1108,7 @@ RSpec.describe ProjectsController do
format: :js) format: :js)
expect(flash[:notice]).to be_nil expect(flash[:notice]).to be_nil
expect(response).to render_template(:remove_fork) expect(response).to redirect_to(edit_project_path(unforked_project))
end end
end end
end end
......
...@@ -15,7 +15,7 @@ RSpec.describe 'Projects > Settings > For a forked project', :js do ...@@ -15,7 +15,7 @@ RSpec.describe 'Projects > Settings > For a forked project', :js do
end end
shared_examples 'project settings for a forked projects' do shared_examples 'project settings for a forked projects' do
it 'allows deleting the link to the forked project', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/327817' do it 'allows deleting the link to the forked project' do
visit edit_project_path(forked_project) visit edit_project_path(forked_project)
click_button 'Remove fork relationship' click_button 'Remove fork relationship'
......
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