summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 12:08:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 12:08:48 +0000
commitf7dae0cdcb70ecb71c1d65f099e9d96b27a4548c (patch)
treee53baffa847c4fd37c8e335e4d93d603c75f9f02 /app/assets/javascripts/vue_shared
parentb98fa9ef3d5bead417ae2f325cb64637883264e9 (diff)
downloadgitlab-ce-f7dae0cdcb70ecb71c1d65f099e9d96b27a4548c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared')
-rw-r--r--app/assets/javascripts/vue_shared/components/confirm_modal.vue63
1 files changed, 63 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/confirm_modal.vue b/app/assets/javascripts/vue_shared/components/confirm_modal.vue
new file mode 100644
index 00000000000..21722f62133
--- /dev/null
+++ b/app/assets/javascripts/vue_shared/components/confirm_modal.vue
@@ -0,0 +1,63 @@
+<script>
+import { GlModal } from '@gitlab/ui';
+import csrf from '~/lib/utils/csrf';
+
+export default {
+ components: {
+ GlModal,
+ },
+ props: {
+ modalAttributes: {
+ type: Object,
+ required: true,
+ },
+ path: {
+ type: String,
+ required: true,
+ },
+ method: {
+ type: String,
+ required: true,
+ },
+ },
+ data() {
+ return {
+ isDismissed: false,
+ };
+ },
+ mounted() {
+ this.openModal();
+ },
+ methods: {
+ openModal() {
+ this.$refs.modal.show();
+ },
+ submitModal() {
+ this.$refs.form.requestSubmit();
+ },
+ dismiss() {
+ this.isDismissed = true;
+ },
+ },
+ csrf,
+};
+</script>
+
+<template>
+ <gl-modal
+ v-if="!isDismissed"
+ ref="modal"
+ v-bind="modalAttributes"
+ @primary="submitModal"
+ @canceled="dismiss"
+ >
+ <form ref="form" :action="path" method="post">
+ <!-- Rails workaround for <form method="delete" />
+ https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts/rails-ujs/features/method.coffee
+ -->
+ <input type="hidden" name="_method" :value="method" />
+ <input type="hidden" name="authenticity_token" :value="$options.csrf.token" />
+ <div>{{ modalAttributes.message }}</div>
+ </form>
+ </gl-modal>
+</template>