summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pages/projects/shared/web_ide_link/index.js
blob: 5f08943d2110ebe7c0b6f57e1de88a0982c81e97 (plain)
1
2
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
import Vue from 'vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { joinPaths, webIDEUrl } from '~/lib/utils/url_utility';
import WebIdeButton from '~/vue_shared/components/web_ide_link.vue';

export default ({ el, router }) => {
  if (!el) return;

  const { projectPath, ref, isBlob, webIdeUrl, ...options } = convertObjectPropsToCamelCase(
    JSON.parse(el.dataset.options),
  );

  // eslint-disable-next-line no-new
  new Vue({
    el,
    router,
    render(h) {
      return h(WebIdeButton, {
        props: {
          isBlob,
          webIdeUrl: isBlob
            ? webIdeUrl
            : webIDEUrl(
                joinPaths('/', projectPath, 'edit', ref, '-', this.$route?.params.path || '', '/'),
              ),
          ...options,
        },
      });
    },
  });
};