debian-mirror-gitlab/app/assets/javascripts/behaviors/markdown/render_metrics.js

25 lines
618 B
JavaScript
Raw Normal View History

2019-10-12 21:52:04 +05:30
import Vue from 'vue';
import Metrics from '~/monitoring/components/embed.vue';
import { createStore } from '~/monitoring/stores';
// TODO: Handle copy-pasting - https://gitlab.com/gitlab-org/gitlab-ce/issues/64369.
export default function renderMetrics(elements) {
if (!elements.length) {
return;
}
elements.forEach(element => {
const { dashboardUrl } = element.dataset;
const MetricsComponent = Vue.extend(Metrics);
// eslint-disable-next-line no-new
new MetricsComponent({
el: element,
store: createStore(),
propsData: {
dashboardUrl,
},
});
});
}