Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « under_topbar « search « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e50c6655dd4aa5fe4935b1452b6496ef118f03e (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 Translate from '~/vue_shared/translate';
import RefSelector from '~/ref/components/ref_selector.vue';
import { setUrlParams, visitUrl } from '~/lib/utils/url_utility';

Vue.use(Translate);

export const initBlobRefSwitcher = () => {
  const el = document.getElementById('js-blob-ref-switcher');

  if (!el) return false;

  const { projectId, ref, fieldName } = el.dataset;

  return new Vue({
    el,
    render(createElement) {
      return createElement(RefSelector, {
        props: {
          projectId,
          value: ref,
        },
        on: {
          input(selected) {
            visitUrl(setUrlParams({ [fieldName]: selected }));
          },
        },
      });
    },
  });
};