summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/header_search/index.js
blob: 4af8513ecdbb7e57e5d7dac336b04fe6f492611e (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
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import HeaderSearchApp from './components/app.vue';
import createStore from './store';

Vue.use(Translate);

export const initHeaderSearchApp = (search = '') => {
  const el = document.getElementById('js-header-search');

  if (!el) {
    return false;
  }

  const { searchPath, issuesPath, mrPath, autocompletePath } = el.dataset;
  let { searchContext } = el.dataset;
  searchContext = JSON.parse(searchContext);

  return new Vue({
    el,
    store: createStore({ searchPath, issuesPath, mrPath, autocompletePath, searchContext, search }),
    render(createElement) {
      return createElement(HeaderSearchApp);
    },
  });
};