Commit 86b8fd3b authored by Constance Okoghenun's avatar Constance Okoghenun

Changed delete wiki prompt from 'confirm' for 'gl_modal'

parent b8a84830
<script>
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { s__} from '~/locale';
export default {
components: {
GlModal
},
props: {
deleteWikiUrl: {
type: String,
required: false,
default: '',
},
csrfToken: {
type: String,
required: false,
default: '',
},
},
computed: {
text() {
return s__('WikiPageConfirmDelete|Are you sure you want to delete this page?')
}
},
methods: {
onSubmit() {
this.$refs.form.submit();
}
}
}
</script>
<template>
<gl-modal
id="delete-wiki-modal"
:header-title-text="s__('WikiPageConfirmDelete|Delete Wiki?')"
footer-primary-button-variant="danger"
:footer-primary-button-text="s__('WikiPageConfirmDelete|Delete')"
@submit="onSubmit"
>
{{ text }}
<form
ref="form"
:action="deleteWikiUrl"
method="post"
>
<input
ref="method"
type="hidden"
name="_method"
value="delete"
/>
<input
type="hidden"
name="authenticity_token"
:value="csrfToken"
/>
</form>
</gl-modal>
</template>
import $ from 'jquery';
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import csrf from '~/lib/utils/csrf';
import Wikis from './wikis';
import ShortcutsWiki from '../../../shortcuts_wiki';
import ZenMode from '../../../zen_mode';
import GLForm from '../../../gl_form';
import deleteWikiModal from './components/delete_wiki_modal.vue';
document.addEventListener('DOMContentLoaded', () => {
new Wikis(); // eslint-disable-line no-new
new ShortcutsWiki(); // eslint-disable-line no-new
new ZenMode(); // eslint-disable-line no-new
new GLForm($('.wiki-form'), true); // eslint-disable-line no-new
Vue.use(Translate);
const { deleteWikiUrl } = document.getElementById('delete-wiki-button').dataset;
const deleteWikiModalEl = document.getElementById('delete-wiki-modal');
const deleteModal = new Vue({
el: deleteWikiModalEl,
data: {
deleteWikiUrl: '',
},
render(createElement) {
return createElement(deleteWikiModal, {
props: {
deleteWikiUrl,
csrfToken: csrf.token,
},
});
},
});
});
......@@ -28,9 +28,17 @@
= 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")
-# = 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) },
id: 'delete-wiki-button',
type: 'button' }
= _('Delete')
= render 'form'
= render 'sidebar'
#delete-wiki-modal.modal.fade
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