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

index.js « topbar « search « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d6e16085c280609ca7bcd6426af20a3eef9b9921 (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
39
40
41
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import GlobalSearchTopbar from './components/app.vue';

Vue.use(Translate);

export const initTopbar = (store) => {
  const el = document.getElementById('js-search-topbar');

  if (!el) {
    return false;
  }

  const {
    groupInitialJson,
    projectInitialJson,
    elasticsearchEnabled,
    defaultBranchName,
  } = el.dataset;

  const groupInitialJsonParsed = JSON.parse(groupInitialJson);
  const projectInitialJsonParsed = JSON.parse(projectInitialJson);
  const elasticsearchEnabledParsed = elasticsearchEnabled
    ? JSON.parse(elasticsearchEnabled)
    : false;

  return new Vue({
    el,
    store,
    render(createElement) {
      return createElement(GlobalSearchTopbar, {
        props: {
          groupInitialJson: groupInitialJsonParsed,
          projectInitialJson: projectInitialJsonParsed,
          elasticsearchEnabled: elasticsearchEnabledParsed,
          defaultBranchName,
        },
      });
    },
  });
};