Commit c9b5c42b authored by Constance Okoghenun's avatar Constance Okoghenun

Added commit form fields for delete page confirmation

parent 86b8fd3b
<script> <script>
import _ from 'underscore';
import GlModal from '~/vue_shared/components/gl_modal.vue'; import GlModal from '~/vue_shared/components/gl_modal.vue';
import { s__} from '~/locale'; import { s__, sprintf } from '~/locale';
export default { export default {
components: { components: {
...@@ -12,6 +13,11 @@ export default { ...@@ -12,6 +13,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
pageTitle: {
type: String,
required: false,
default: '',
},
csrfToken: { csrfToken: {
type: String, type: String,
required: false, required: false,
...@@ -19,8 +25,22 @@ export default { ...@@ -19,8 +25,22 @@ export default {
}, },
}, },
computed: { computed: {
text() { message() {
return s__('WikiPageConfirmDelete|Are you sure you want to delete this page?') return sprintf(s__('WikiPageConfirmDelete|Delete %{pageTitle}'),
{
pageTitle: _.escape(this.pageTitle),
},
false,
);
},
title() {
return sprintf(s__('WikiPageConfirmDelete|Delete Page %{pageTitle}?'),
{
pageTitle: `'${_.escape(this.pageTitle)}'`,
},
false,
);
} }
}, },
methods: { methods: {
...@@ -34,17 +54,16 @@ export default { ...@@ -34,17 +54,16 @@ export default {
<template> <template>
<gl-modal <gl-modal
id="delete-wiki-modal" id="delete-wiki-modal"
:header-title-text="s__('WikiPageConfirmDelete|Delete Wiki?')" :header-title-text="title"
footer-primary-button-variant="danger" footer-primary-button-variant="danger"
:footer-primary-button-text="s__('WikiPageConfirmDelete|Delete')" :footer-primary-button-text="s__('WikiPageConfirmDelete|Delete Page')"
@submit="onSubmit" @submit="onSubmit"
> >
{{ text }}
<form <form
ref="form" ref="form"
:action="deleteWikiUrl" :action="deleteWikiUrl"
method="post" method="post"
class="form-horizontal js-requires-input"
> >
<input <input
ref="method" ref="method"
...@@ -57,6 +76,31 @@ export default { ...@@ -57,6 +76,31 @@ export default {
name="authenticity_token" name="authenticity_token"
:value="csrfToken" :value="csrfToken"
/> />
<div class="form-group">
<div class="col-sm-12">
<label for="commit_message" class="control-label-full-width">Commit Message</label>
</div>
<div class="col-sm-12">
<div class="commit-message-container">
<textarea
id="commit_message"
rows="3"
name="commit_message"
:value="message"
class="form-control js-commit-message" required></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label for="branch_name" class="control-label-full-width">Target Branch</label>
</div>
<div class="col-sm-12">
<input type="text" name="branch_name" class="form-control js-commit-message ref-name" required />
</div>
</div>
</form> </form>
</gl-modal> </gl-modal>
</template> </template>
......
...@@ -15,9 +15,9 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -15,9 +15,9 @@ document.addEventListener('DOMContentLoaded', () => {
new GLForm($('.wiki-form'), true); // eslint-disable-line no-new new GLForm($('.wiki-form'), true); // eslint-disable-line no-new
Vue.use(Translate); Vue.use(Translate);
const { deleteWikiUrl } = document.getElementById('delete-wiki-button').dataset; const { deleteWikiUrl, pageTitle } = document.getElementById('delete-wiki-button').dataset;
const deleteWikiModalEl = document.getElementById('delete-wiki-modal'); const deleteWikiModalEl = document.getElementById('delete-wiki-modal');
const deleteModal = new Vue({ const deleteModal = new Vue({ // eslint-disable-line
el: deleteWikiModalEl, el: deleteWikiModalEl,
data: { data: {
deleteWikiUrl: '', deleteWikiUrl: '',
...@@ -25,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -25,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => {
render(createElement) { render(createElement) {
return createElement(deleteWikiModal, { return createElement(deleteWikiModal, {
props: { props: {
pageTitle,
deleteWikiUrl, deleteWikiUrl,
csrfToken: csrf.token, csrfToken: csrf.token,
}, },
......
...@@ -28,11 +28,10 @@ ...@@ -28,11 +28,10 @@
= link_to project_wiki_history_path(@project, @page), class: "btn" do = link_to project_wiki_history_path(@project, @page), class: "btn" do
= s_("Wiki|Page history") = s_("Wiki|Page history")
- if can?(current_user, :admin_wiki, @project) - if can?(current_user, :admin_wiki, @project)
-# = link_to project_wiki_path(@project, @page), data: { confirm: s_("WikiPageConfirmDelete|Are you sure you want to delete this page?")}, method: :delete, class: "btn btn-danger" do
-# = _("Delete")
%button.btn.btn-danger{ data: { toggle: 'modal', %button.btn.btn-danger{ data: { toggle: 'modal',
target: '#delete-wiki-modal', target: '#delete-wiki-modal',
delete_wiki_url: project_wiki_path(@project, @page) }, delete_wiki_url: project_wiki_path(@project, @page),
page_title: @page.title.capitalize },
id: 'delete-wiki-button', id: 'delete-wiki-button',
type: 'button' } type: 'button' }
= _('Delete') = _('Delete')
......
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