summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_alerts.js
blob: 6550eb314911badfc63d50046ce4616210fafefe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import DismissibleAlert from '~/vue_shared/components/dismissible_alert.vue';

const mountVueAlert = el => {
  const props = {
    html: el.innerHTML,
  };
  const attrs = {
    ...el.dataset,
    dismissible: parseBoolean(el.dataset.dismissible),
  };

  return new Vue({
    el,
    render(h) {
      return h(DismissibleAlert, { props, attrs });
    },
  });
};

export default () => [...document.querySelectorAll('.js-vue-alert')].map(mountVueAlert);