Commit c9b5c42b authored by Constance Okoghenun's avatar Constance Okoghenun

Added commit form fields for delete page confirmation

parent 86b8fd3b
<script>
import _ from 'underscore';
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { s__} from '~/locale';
import { s__, sprintf } from '~/locale';
export default {
components: {
......@@ -12,6 +13,11 @@ export default {
required: false,
default: '',
},
pageTitle: {
type: String,
required: false,
default: '',
},
csrfToken: {
type: String,
required: false,
......@@ -19,8 +25,22 @@ export default {
},
},
computed: {
text() {
return s__('WikiPageConfirmDelete|Are you sure you want to delete this page?')
message() {
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: {
......@@ -34,17 +54,16 @@ export default {
<template>
<gl-modal
id="delete-wiki-modal"
:header-title-text="s__('WikiPageConfirmDelete|Delete Wiki?')"
:header-title-text="title"
footer-primary-button-variant="danger"
:footer-primary-button-text="s__('WikiPageConfirmDelete|Delete')"
:footer-primary-button-text="s__('WikiPageConfirmDelete|Delete Page')"
@submit="onSubmit"
>
{{ text }}
<form
ref="form"
:action="deleteWikiUrl"
method="post"
class="form-horizontal js-requires-input"
>
<input
ref="method"
......@@ -57,6 +76,31 @@ export default {
name="authenticity_token"
: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>
</gl-modal>
</template>
......
......@@ -15,9 +15,9 @@ document.addEventListener('DOMContentLoaded', () => {
new GLForm($('.wiki-form'), true); // eslint-disable-line no-new
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 deleteModal = new Vue({
const deleteModal = new Vue({ // eslint-disable-line
el: deleteWikiModalEl,
data: {
deleteWikiUrl: '',
......@@ -25,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => {
render(createElement) {
return createElement(deleteWikiModal, {
props: {
pageTitle,
deleteWikiUrl,
csrfToken: csrf.token,
},
......
......@@ -28,11 +28,10 @@
= link_to project_wiki_history_path(@project, @page), class: "btn" do
= s_("Wiki|Page history")
- 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',
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',
type: 'button' }
= _('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