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 initLegacyConfirmDangerModal from '~/confirm_danger_modal';
import initConfirmDanger from '~/init_confirm_danger';
import dirtySubmitFactory from '~/dirty_submit/dirty_submit_factory';
import initFilePickers from '~/file_pickers';
import mountBadgeSettings from '~/pages/shared/mount_badge_settings';
......@@ -15,6 +16,7 @@ import initProjectLoadingSpinner from '../shared/save_project_loader';
initFilePickers();
initLegacyConfirmDangerModal();
initConfirmDanger();
initSettingsPanels();
initProjectDeleteButton();
mountBadgeSettings(PROJECT_BADGE);
......
......@@ -326,10 +326,6 @@
}
}
.transfer-project .select2-container {
min-width: 200px;
}
.right-sidebar {
.block {
.select2-container span {
......
......@@ -126,6 +126,8 @@ class ProjectsController < Projects::ApplicationController
if ::Projects::UnlinkForkService.new(@project, current_user).execute
flash[:notice] = _('The fork relationship has been removed.')
end
redirect_to edit_project_path(@project)
end
def activity
......
......@@ -120,6 +120,15 @@ module ProjectsHelper
{ project_full_name: project.full_name }
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)
project.fork_source if project.fork_source && can?(current_user, :read_project, project.fork_source)
end
......
- return unless @project.forked? && can?(current_user, :remove_fork_project, @project)
- remove_form_id = "js-remove-project-fork-form"
.sub-section
%h4.danger-title= _('Remove fork relationship')
%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
%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'
= 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
expect(forked_project.reload.forked?).to be_falsey
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
......@@ -1108,7 +1108,7 @@ RSpec.describe ProjectsController do
format: :js)
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
......
......@@ -15,7 +15,7 @@ RSpec.describe 'Projects > Settings > For a forked project', :js do
end
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)
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