Commit 451f206d authored by Paul Slaughter's avatar Paul Slaughter Committed by Frédéric Caplette

Use path_with_namespace for delete confirmation phrase

- Display names are not unique and can include
  special characters

Changelog: changed
parent a61c457d
<script>
import { GlModal, GlModalDirective, GlFormTextarea, GlButton } from '@gitlab/ui';
import { GlModal, GlModalDirective, GlFormInput, 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,
GlFormTextarea,
GlFormInput,
GlButton,
},
directives: {
......@@ -88,7 +88,12 @@ export default {
<p>
<code class="gl-white-space-pre-wrap">{{ confirmPhrase }}</code>
</p>
<gl-form-textarea id="confirm_name_input" v-model="userInput" name="confirm_name_input" />
<gl-form-input
id="confirm_name_input"
v-model="userInput"
name="confirm_name_input"
type="text"
/>
<slot name="modal-footer"></slot>
</div>
</gl-modal>
......
......@@ -384,12 +384,11 @@ module ProjectsHelper
# 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.
# Thus the phrase should include the namespace to make it very clear to the
# user which project is subject to deletion.
# Relevant issue: https://gitlab.com/gitlab-org/gitlab/-/issues/343591
def delete_confirm_phrase(project)
s_('DeleteProject|Delete %{name}') % { name: project.full_name }
project.path_with_namespace
end
private
......
......@@ -11,7 +11,7 @@
%strong= s_('Delayed Project Deletion (%{adjourned_deletion})') % { adjourned_deletion: adjourned_deletion ? 'Enabled' : 'Disabled' }
- if adjourned_deletion
= render 'projects/settings/marked_for_removal'
#js-project-adjourned-delete-button{ data: { recovery_help_path: recovery_help_path, adjourned_removal_date: adjourned_date, form_path: project_path(project), confirm_phrase: project.path } }
#js-project-adjourned-delete-button{ data: { recovery_help_path: recovery_help_path, adjourned_removal_date: adjourned_date, form_path: project_path(project), confirm_phrase: delete_confirm_phrase(project) } }
- else
%p
%span.gl-text-gray-500= _('Projects will be permanently deleted immediately.')
......
......@@ -5,4 +5,4 @@
%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, permanently_delete: true), confirm_phrase: project.path } }
#js-project-delete-button{ data: { form_path: project_path(project, permanently_delete: true), confirm_phrase: delete_confirm_phrase(project) } }
......@@ -48,7 +48,7 @@ RSpec.describe 'Project', :js do
end
it 'deletes the project immediately', :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', project.path_with_namespace, '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
......
......@@ -60,10 +60,10 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
</code>
</p>
<gl-form-textarea-stub
<gl-form-input-stub
id="confirm_name_input"
name="confirm_name_input"
noresize="true"
type="text"
/>
<p
......
......@@ -11125,9 +11125,6 @@ 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', "Delete #{project.full_name}", 'Yes, delete project') }.to change { Project.count }.by(-1)
expect { remove_with_confirm('Delete project', project.path_with_namespace, '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-textarea-stub
<gl-form-input-stub
id="confirm_name_input"
name="confirm_name_input"
noresize="true"
type="text"
/>
</div>
......
......@@ -51,10 +51,10 @@ exports[`Project remove modal intialized matches the snapshot 1`] = `
</code>
</p>
<gl-form-textarea-stub
<gl-form-input-stub
id="confirm_name_input"
name="confirm_name_input"
noresize="true"
type="text"
/>
</div>
......
......@@ -987,8 +987,8 @@ RSpec.describe ProjectsHelper do
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}")
it 'includes the project path with namespace' do
expect(subject).to eq(project.path_with_namespace)
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