user_operation_confirmation_modal.vue 1.3 KB
Newer Older
1
<script>
2
/* eslint-disable vue/no-v-html */
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
import { GlModal } from '@gitlab/ui';
import { sprintf } from '~/locale';

export default {
  components: {
    GlModal,
  },
  props: {
    title: {
      type: String,
      required: true,
    },
    content: {
      type: String,
      required: true,
    },
    action: {
      type: String,
      required: true,
    },
    url: {
      type: String,
      required: true,
    },
    username: {
      type: String,
      required: true,
    },
    csrfToken: {
      type: String,
      required: true,
    },
    method: {
      type: String,
      required: false,
      default: 'put',
    },
  },
  computed: {
    modalTitle() {
      return sprintf(this.title, { username: this.username });
    },
  },
  methods: {
    show() {
      this.$refs.modal.show();
    },
    submit() {
      this.$refs.form.submit();
    },
  },
};
</script>
<template>
  <gl-modal
    ref="modal"
    modal-id="user-operation-modal"
    :title="modalTitle"
    ok-variant="warning"
    :ok-title="action"
    @ok="submit"
  >
    <form ref="form" :action="url" method="post">
      <span v-html="content"></span>
      <input ref="method" type="hidden" name="_method" :value="method" />
      <input :value="csrfToken" type="hidden" name="authenticity_token" />
    </form>
  </gl-modal>
</template>