Commit f77caca4 authored by Frédéric Caplette's avatar Frédéric Caplette

Merge branch '343591-follow-up' into 'master'

Use path_with_namespace for delete confirmation phrase

See merge request gitlab-org/gitlab!73506
parents 1d655748 451f206d
<script> <script>
import { GlModal, GlModalDirective, GlFormTextarea, GlButton } from '@gitlab/ui'; import { GlModal, GlModalDirective, GlFormInput, GlButton } from '@gitlab/ui';
import { uniqueId } from 'lodash'; import { uniqueId } from 'lodash';
import csrf from '~/lib/utils/csrf'; import csrf from '~/lib/utils/csrf';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -7,7 +7,7 @@ import { __ } from '~/locale'; ...@@ -7,7 +7,7 @@ import { __ } from '~/locale';
export default { export default {
components: { components: {
GlModal, GlModal,
GlFormTextarea, GlFormInput,
GlButton, GlButton,
}, },
directives: { directives: {
...@@ -88,7 +88,12 @@ export default { ...@@ -88,7 +88,12 @@ export default {
<p> <p>
<code class="gl-white-space-pre-wrap">{{ confirmPhrase }}</code> <code class="gl-white-space-pre-wrap">{{ confirmPhrase }}</code>
</p> </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> <slot name="modal-footer"></slot>
</div> </div>
</gl-modal> </gl-modal>
......
...@@ -384,12 +384,11 @@ module ProjectsHelper ...@@ -384,12 +384,11 @@ module ProjectsHelper
# Returns the confirm phrase the user needs to type in order to delete the project # 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. # Thus the phrase should include the namespace to make it very clear to the
# Specifically, a user might delete an original project, believing it is a fork. # user which project is subject to deletion.
# Thus the phrase should be the project full name to include the namespace.
# Relevant issue: https://gitlab.com/gitlab-org/gitlab/-/issues/343591 # Relevant issue: https://gitlab.com/gitlab-org/gitlab/-/issues/343591
def delete_confirm_phrase(project) def delete_confirm_phrase(project)
s_('DeleteProject|Delete %{name}') % { name: project.full_name } project.path_with_namespace
end end
private private
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
%strong= s_('Delayed Project Deletion (%{adjourned_deletion})') % { adjourned_deletion: adjourned_deletion ? 'Enabled' : 'Disabled' } %strong= s_('Delayed Project Deletion (%{adjourned_deletion})') % { adjourned_deletion: adjourned_deletion ? 'Enabled' : 'Disabled' }
- if adjourned_deletion - if adjourned_deletion
= render 'projects/settings/marked_for_removal' = 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 - else
%p %p
%span.gl-text-gray-500= _('Projects will be permanently deleted immediately.') %span.gl-text-gray-500= _('Projects will be permanently deleted immediately.')
......
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
%p= permanent_delete_message(project) %p= permanent_delete_message(project)
%p %p
%strong= _('Are you ABSOLUTELY SURE you wish to delete this project?') %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 ...@@ -48,7 +48,7 @@ RSpec.describe 'Project', :js do
end end
it 'deletes the project immediately', :sidekiq_inline do 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(page).to have_content "Project '#{project.full_name}' is in the process of being deleted."
expect(Project.all.count).to be_zero expect(Project.all.count).to be_zero
......
...@@ -60,10 +60,10 @@ exports[`Project remove modal initialized matches the snapshot 1`] = ` ...@@ -60,10 +60,10 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
</code> </code>
</p> </p>
<gl-form-textarea-stub <gl-form-input-stub
id="confirm_name_input" id="confirm_name_input"
name="confirm_name_input" name="confirm_name_input"
noresize="true" type="text"
/> />
<p <p
......
...@@ -11113,9 +11113,6 @@ msgstr "" ...@@ -11113,9 +11113,6 @@ msgstr ""
msgid "Delete variable" msgid "Delete variable"
msgstr "" msgstr ""
msgid "DeleteProject|Delete %{name}"
msgstr ""
msgid "DeleteProject|Failed to remove project repository. Please try again or contact administrator." msgid "DeleteProject|Failed to remove project repository. Please try again or contact administrator."
msgstr "" msgstr ""
......
...@@ -257,7 +257,7 @@ RSpec.describe 'Project' do ...@@ -257,7 +257,7 @@ RSpec.describe 'Project' do
end end
it 'deletes a project', :sidekiq_inline do 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(page).to have_content "Project '#{project.full_name}' is in the process of being deleted."
expect(Project.all.count).to be_zero expect(Project.all.count).to be_zero
expect(project.issues).to be_empty expect(project.issues).to be_empty
......
...@@ -71,10 +71,10 @@ exports[`Project remove modal initialized matches the snapshot 1`] = ` ...@@ -71,10 +71,10 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
</code> </code>
</p> </p>
<gl-form-textarea-stub <gl-form-input-stub
id="confirm_name_input" id="confirm_name_input"
name="confirm_name_input" name="confirm_name_input"
noresize="true" type="text"
/> />
</div> </div>
......
...@@ -51,10 +51,10 @@ exports[`Project remove modal intialized matches the snapshot 1`] = ` ...@@ -51,10 +51,10 @@ exports[`Project remove modal intialized matches the snapshot 1`] = `
</code> </code>
</p> </p>
<gl-form-textarea-stub <gl-form-input-stub
id="confirm_name_input" id="confirm_name_input"
name="confirm_name_input" name="confirm_name_input"
noresize="true" type="text"
/> />
</div> </div>
......
...@@ -987,8 +987,8 @@ RSpec.describe ProjectsHelper do ...@@ -987,8 +987,8 @@ RSpec.describe ProjectsHelper do
describe "#delete_confirm_phrase" do describe "#delete_confirm_phrase" do
subject { helper.delete_confirm_phrase(project) } subject { helper.delete_confirm_phrase(project) }
it 'includes the project full name' do it 'includes the project path with namespace' do
expect(subject).to eq("Delete #{project.full_name}") expect(subject).to eq(project.path_with_namespace)
end end
end 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