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

index.js « ref_switcher « find_file « projects « pages « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9a3bb25de705f56aaf533ea206709ad0d05cd6bb (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
32
33
34
35
36
37
38
import Vue from 'vue';
import { s__ } from '~/locale';
import Translate from '~/vue_shared/translate';
import RefSelector from '~/ref/components/ref_selector.vue';
import { visitUrl } from '~/lib/utils/url_utility';
import { generateRefDestinationPath } from './ref_switcher_utils';

Vue.use(Translate);

const REF_SWITCH_HEADER = s__('FindFile|Switch branch/tag');

export default () => {
  const el = document.getElementById('js-blob-ref-switcher');
  if (!el) return false;

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

  return new Vue({
    el,
    render(createElement) {
      return createElement(RefSelector, {
        props: {
          projectId,
          value: ref,
          translations: {
            dropdownHeader: REF_SWITCH_HEADER,
            searchPlaceholder: REF_SWITCH_HEADER,
          },
        },
        on: {
          input(selected) {
            visitUrl(generateRefDestinationPath(selected, namespace));
          },
        },
      });
    },
  });
};