Commit d20ed309 authored by Jiaan Louw's avatar Jiaan Louw Committed by Paul Slaughter

Restore namespace requirement for project deletion confirmation

This updates the project deletion modal to include the project's
namespace as well as the project name and changes the input to a
multi-line text input.

Changelog: changed
parent 8e24a20c
<script>
import { GlModal, GlModalDirective, GlFormInput, GlButton } from '@gitlab/ui';
import { GlModal, GlModalDirective, GlFormTextarea, GlButton } from '@gitlab/ui';
import { uniqueId } from 'lodash';
import csrf from '~/lib/utils/csrf';
import { __ } from '~/locale';
......@@ -7,7 +7,7 @@ import { __ } from '~/locale';
export default {
components: {
GlModal,
GlFormInput,
GlFormTextarea,
GlButton,
},
directives: {
......@@ -88,12 +88,7 @@ export default {
<p>
<code class="gl-white-space-pre-wrap">{{ confirmPhrase }}</code>
</p>
<gl-form-input
id="confirm_name_input"
v-model="userInput"
name="confirm_name_input"
type="text"
/>
<gl-form-textarea id="confirm_name_input" v-model="userInput" name="confirm_name_input" />
<slot name="modal-footer"></slot>
</div>
</gl-modal>
......
......@@ -382,6 +382,16 @@ module ProjectsHelper
""
end
# Returns the confirm phrase the user needs to type in order to delete the project
#
# Occasionally a user will delete one project, believing it is a different (similar) one.
# Specifically, a user might delete an original project, believing it is a fork.
# Thus the phrase should be the project full name to include the namespace.
# Relevant issue: https://gitlab.com/gitlab-org/gitlab/-/issues/343591
def delete_confirm_phrase(project)
s_('DeleteProject|Delete %{name}') % { name: project.full_name }
end
private
def tab_ability_map
......
......@@ -7,4 +7,4 @@
= link_to _('Learn more.'), help_page_path('user/project/settings/index', anchor: 'removing-a-fork-relationship'), target: '_blank', rel: 'noopener noreferrer'
%p
%strong= _('Deleted projects cannot be restored!')
#js-project-delete-button{ data: { form_path: project_path(project), confirm_phrase: project.path } }
#js-project-delete-button{ data: { form_path: project_path(project), confirm_phrase: delete_confirm_phrase(project) } }
......@@ -19,7 +19,7 @@
%p= permanent_delete_message(project)
%p
%strong= _('Are you ABSOLUTELY SURE you wish to delete this project?')
#js-project-delete-button{ data: { form_path: project_path(project), confirm_phrase: project.path } }
#js-project-delete-button{ data: { form_path: project_path(project), confirm_phrase: delete_confirm_phrase(project) } }
- else
= render 'projects/settings/restore', project: project
= render 'projects/settings/permanently_delete', project: project
......
......@@ -60,10 +60,10 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
</code>
</p>
<gl-form-input-stub
<gl-form-textarea-stub
id="confirm_name_input"
name="confirm_name_input"
type="text"
noresize="true"
/>
<p
......
......@@ -11101,6 +11101,9 @@ msgstr ""
msgid "Delete variable"
msgstr ""
msgid "DeleteProject|Delete %{name}"
msgstr ""
msgid "DeleteProject|Failed to remove project repository. Please try again or contact administrator."
msgstr ""
......
......@@ -257,7 +257,7 @@ RSpec.describe 'Project' do
end
it 'deletes a project', :sidekiq_inline do
expect { remove_with_confirm('Delete project', project.path, 'Yes, delete project') }.to change { Project.count }.by(-1)
expect { remove_with_confirm('Delete project', "Delete #{project.full_name}", 'Yes, delete project') }.to change { Project.count }.by(-1)
expect(page).to have_content "Project '#{project.full_name}' is in the process of being deleted."
expect(Project.all.count).to be_zero
expect(project.issues).to be_empty
......
......@@ -71,10 +71,10 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
</code>
</p>
<gl-form-input-stub
<gl-form-textarea-stub
id="confirm_name_input"
name="confirm_name_input"
type="text"
noresize="true"
/>
</div>
......
......@@ -51,10 +51,10 @@ exports[`Project remove modal intialized matches the snapshot 1`] = `
</code>
</p>
<gl-form-input-stub
<gl-form-textarea-stub
id="confirm_name_input"
name="confirm_name_input"
type="text"
noresize="true"
/>
</div>
......
......@@ -983,4 +983,12 @@ RSpec.describe ProjectsHelper do
it { is_expected.not_to include('project-highlight-puc') }
end
end
describe "#delete_confirm_phrase" do
subject { helper.delete_confirm_phrase(project) }
it 'includes the project full name' do
expect(subject).to eq("Delete #{project.full_name}")
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